From 20bb45fb9e098ee6c6f0f07b8ed12690fea611be Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 15 Aug 2026 20:30:15 +0300 Subject: [PATCH] =?UTF-8?q?fix(mxl-compile,mxl-decompile):=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B7=D1=80=D0=B0=D1=87=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D1=83=20=D1=81=D1=81=D1=8B=D0=BB=D0=BE=D1=87=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Атрибут прозрачности живёт не только у картинки с данными: платформа пишет , причём t перед ref. Компилятор в этой ветке его терял, декомпилятор не читал — в «Бухгалтерии предприятия» на 8.3.27 таких записей 67. Заодно уточнена картина по конфигурациям: t="false" стоит у 11 135 картинок БП, значения true не бывает нигде — включённую прозрачность платформа выражает координатами пикселя, и вместе с t они не встречаются. --- .../mxl-compile/scripts/mxl-compile.ps1 | 12 ++++++----- .../skills/mxl-compile/scripts/mxl-compile.py | 14 +++++++------ .../mxl-decompile/scripts/mxl-decompile.ps1 | 20 ++++++++++--------- .../mxl-decompile/scripts/mxl-decompile.py | 16 +++++++-------- docs/1c-spreadsheet-spec.md | 5 +++++ ...rror-picture-transparent-without-data.json | 2 +- .../pictures-empty-and-transparent.json | 2 +- .../Template.xml | 8 ++++++-- 8 files changed, 47 insertions(+), 32 deletions(-) diff --git a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 index 5d79c36f..5d19937b 100644 --- a/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 +++ b/.claude/skills/mxl-compile/scripts/mxl-compile.ps1 @@ -1,4 +1,4 @@ -# mxl-compile v1.48 — Compile 1C spreadsheet from JSON +# mxl-compile v1.49 — Compile 1C spreadsheet from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -1612,7 +1612,7 @@ if ($def.pictures) { } if (-not $entry.Ref -and -not $entry.Data -and ($entry.Transparent -or $entry.PixelX)) { - [Console]::Error.WriteLine("pictures[$($pr.Name)]: 'transparent' and 'transparentPixel' require 'data'") + [Console]::Error.WriteLine("pictures[$($pr.Name)]: 'transparent' and 'transparentPixel' require 'ref' or 'data'") exit 1 } $pictureEntries += $entry @@ -2572,13 +2572,15 @@ $picIdx = 0 foreach ($pic in $pictureEntries) { X "`t" X "`t`t$picIdx" + # Прозрачность записывается перед ссылкой и не зависит от того, где лежит картинка: + # в БП 8.3.27 таких ссылочных записей 67. + $attr = if ($pic.Transparent) { " t=`"$($pic.Transparent)`"" } else { '' } + if ($pic.PixelX) { $attr += " tx=`"$($pic.PixelX)`" ty=`"$($pic.PixelY)`"" } if ($pic.Ref) { - X "`t`t" + X "`t`t" } elseif (-not $pic.Data) { X "`t`t" } else { - $attr = if ($pic.Transparent) { " t=`"$($pic.Transparent)`"" } else { '' } - if ($pic.PixelX) { $attr += " tx=`"$($pic.PixelX)`" ty=`"$($pic.PixelY)`"" } # Данные платформа переносит по строкам тем же переводом, что и весь файл, — # в отличие от блоба настроек элемента управления, где перенос голый LF. $parts = @("$($pic.Data)" -split "`r?`n") diff --git a/.claude/skills/mxl-compile/scripts/mxl-compile.py b/.claude/skills/mxl-compile/scripts/mxl-compile.py index 5bc3feea..8f0b8973 100644 --- a/.claude/skills/mxl-compile/scripts/mxl-compile.py +++ b/.claude/skills/mxl-compile/scripts/mxl-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# mxl-compile v1.48 — Compile 1C spreadsheet from JSON +# mxl-compile v1.49 — Compile 1C spreadsheet from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import hashlib @@ -1567,7 +1567,7 @@ def main(): entry['PixelX'] = str(int(pic_def['transparentPixel'].get('x', 0))) entry['PixelY'] = str(int(pic_def['transparentPixel'].get('y', 0))) if not entry['Ref'] and not entry['Data'] and (entry['Transparent'] or entry['PixelX']): - print(f"pictures[{pic_name}]: 'transparent' and 'transparentPixel' require 'data'", file=sys.stderr) + print(f"pictures[{pic_name}]: 'transparent' and 'transparentPixel' require 'ref' or 'data'", file=sys.stderr) sys.exit(1) picture_entries.append(entry) picture_names[pic_name] = len(picture_entries) @@ -2424,14 +2424,16 @@ def main(): for pic_i, pic in enumerate(picture_entries): lines.append('\t') lines.append(f'\t\t{pic_i}') + # Прозрачность записывается перед ссылкой и не зависит от того, где лежит картинка: + # в БП 8.3.27 таких ссылочных записей 67. + attr = f' t="{pic["Transparent"]}"' if pic['Transparent'] else '' + if pic['PixelX']: + attr += f' tx="{pic["PixelX"]}" ty="{pic["PixelY"]}"' if pic['Ref']: - lines.append(f'\t\t') + lines.append(f'\t\t') elif not pic['Data']: lines.append('\t\t') else: - attr = f' t="{pic["Transparent"]}"' if pic['Transparent'] else '' - if pic['PixelX']: - attr += f' tx="{pic["PixelX"]}" ty="{pic["PixelY"]}"' # Данные платформа переносит по строкам тем же переводом, что и весь файл, — # в отличие от блоба настроек элемента управления, где перенос голый LF. parts = str(pic['Data']).replace('\r\n', '\n').split('\n') diff --git a/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 b/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 index 6db6495f..f67f4e70 100644 --- a/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 +++ b/.claude/skills/mxl-decompile/scripts/mxl-decompile.ps1 @@ -1,4 +1,4 @@ -# mxl-decompile v1.27 — Decompile 1C spreadsheet to JSON +# mxl-decompile v1.28 — Decompile 1C spreadsheet to JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -283,14 +283,16 @@ foreach ($picNode in $root.SelectNodes("d:picture", $ns)) { # System.Xml переводы строк в тексте не нормализует, а lxml нормализует: без этой # замены порты дали бы разный JSON на одном и том же файле. $entry["data"] = ($inner.InnerText -replace "`r`n", "`n").Trim() - if ($inner.HasAttribute('t')) { $entry["transparent"] = ($inner.GetAttribute('t') -ceq 'true') } - # Пиксель прозрачного цвета: координата внутри самой картинки (проверено — - # это не её размеры). В корпусе встречается без атрибута t. - if ($inner.HasAttribute('tx')) { - $entry["transparentPixel"] = [ordered]@{ - x = [int]$inner.GetAttribute('tx') - y = [int]$inner.GetAttribute('ty') - } + } + # Прозрачность живёт и у ссылочной картинки (в БП 8.3.27 таких записей 67), поэтому + # читаем её вне ветвления. Пиксель прозрачного цвета — координата внутри картинки. + if ($entry.Count -gt 0 -and $inner.HasAttribute('t')) { + $entry["transparent"] = ($inner.GetAttribute('t') -ceq 'true') + } + if ($entry.Count -gt 0 -and $inner.HasAttribute('tx')) { + $entry["transparentPixel"] = [ordered]@{ + x = [int]$inner.GetAttribute('tx') + y = [int]$inner.GetAttribute('ty') } } $picturesOut[$name] = $entry diff --git a/.claude/skills/mxl-decompile/scripts/mxl-decompile.py b/.claude/skills/mxl-decompile/scripts/mxl-decompile.py index fb140715..ad680ba4 100644 --- a/.claude/skills/mxl-decompile/scripts/mxl-decompile.py +++ b/.claude/skills/mxl-decompile/scripts/mxl-decompile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# mxl-decompile v1.27 — Decompile 1C spreadsheet to JSON +# mxl-decompile v1.28 — Decompile 1C spreadsheet to JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse @@ -446,13 +446,13 @@ def main(): entry["ref"] = inner.get("ref") elif (inner.text or "").strip(): entry["data"] = (inner.text or "").strip() - if inner.get("t") is not None: - entry["transparent"] = inner.get("t") == "true" - # Пиксель прозрачного цвета: координата внутри самой картинки (проверено — - # это не её размеры). В корпусе встречается без атрибута t. - if inner.get("tx") is not None: - entry["transparentPixel"] = OrderedDict([("x", int(inner.get("tx"))), - ("y", int(inner.get("ty") or 0))]) + # Прозрачность живёт и у ссылочной картинки (в БП 8.3.27 таких записей 67), поэтому + # читаем её вне ветвления. Пиксель прозрачного цвета — координата внутри картинки. + if entry and inner.get("t") is not None: + entry["transparent"] = inner.get("t") == "true" + if entry and inner.get("tx") is not None: + entry["transparentPixel"] = OrderedDict([("x", int(inner.get("tx"))), + ("y", int(inner.get("ty") or 0))]) pictures_out[name] = entry picture_key[pic_i] = name diff --git a/docs/1c-spreadsheet-spec.md b/docs/1c-spreadsheet-spec.md index 7481b629..0fce1ddf 100644 --- a/docs/1c-spreadsheet-spec.md +++ b/docs/1c-spreadsheet-spec.md @@ -744,6 +744,11 @@ AARnQUlBAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAA в корпусе встречается `tx="97" ty="83"` при картинке 368×117, то есть Конфигуратор углом не ограничен. +Прозрачность не привязана к тому, где лежит картинка: `t` пишется и у ссылочной записи, причём +ПЕРЕД `ref` — ``. В «Бухгалтерии предприятия» на 8.3.27 таких +записей 67, а `t="false"` стоит у 11 135 картинок; значения `true` у этого атрибута не бывает +ни в одной проверенной конфигурации — включённую прозрачность выражают `tx`/`ty`. + ## Рисунки Рисунок — объект поверх сетки: картинка, фигура, надпись, диаграмма. Лежит в `` diff --git a/tests/skills/cases/mxl-compile/error-picture-transparent-without-data.json b/tests/skills/cases/mxl-compile/error-picture-transparent-without-data.json index a87ed7f0..b3524da5 100644 --- a/tests/skills/cases/mxl-compile/error-picture-transparent-without-data.json +++ b/tests/skills/cases/mxl-compile/error-picture-transparent-without-data.json @@ -6,5 +6,5 @@ "areas": [{ "rows": [["Бланк"]] }] }, "params": { "outputPath": "Template.xml" }, - "expectError": "pictures[пусто]: 'transparent' and 'transparentPixel' require 'data'" + "expectError": "pictures[пусто]: 'transparent' and 'transparentPixel' require 'ref' or 'data'" } diff --git a/tests/skills/cases/mxl-compile/pictures-empty-and-transparent.json b/tests/skills/cases/mxl-compile/pictures-empty-and-transparent.json index a58b4d42..b5c9a387 100644 --- a/tests/skills/cases/mxl-compile/pictures-empty-and-transparent.json +++ b/tests/skills/cases/mxl-compile/pictures-empty-and-transparent.json @@ -4,9 +4,9 @@ "columns": 2, "pictures": { "пусто": {}, + "значок": { "ref": "v8ui:Стоп48", "transparent": false }, "точка": { "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==", - "transparent": true, "transparentPixel": { "x": 3, "y": 5 } } }, diff --git a/tests/skills/cases/mxl-compile/snapshots/pictures-empty-and-transparent/Template.xml b/tests/skills/cases/mxl-compile/snapshots/pictures-empty-and-transparent/Template.xml index 472b1267..1b353608 100644 --- a/tests/skills/cases/mxl-compile/snapshots/pictures-empty-and-transparent/Template.xml +++ b/tests/skills/cases/mxl-compile/snapshots/pictures-empty-and-transparent/Template.xml @@ -43,7 +43,7 @@ false Stretch 1 - 2 + 3 true 1 @@ -58,6 +58,10 @@ 1 - iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg== + + + + 2 + iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg== \ No newline at end of file