feat(form-decompile,form-compile): встроенные картинки (xr:Abs) + TransparentPixel + Page Picture (категория картинок)

Закрыты картиночные потери из ROOT-секции корпуса: Page>Picture (702),
PictureField>ValuesPicture (abs), Button>Picture (abs), а также RowsPicture
и командные/popup-картинки. ColumnGroup>HeaderPicture уже ловился (Add-CommonProps),
бэклог-числа были от старого прогона v0.62.

Две системные дыры + один полный пробел (по корпусу 36707 форм):
- xr:Abs (встроенная картинка) игнорировался везде, кроме PictureDecoration:
  Get-PictureRef и Button/Popup/Command picture брали только <xr:Ref>. Теперь
  src с префиксом "abs:" → <xr:Abs> (как у PictureDecoration). ~358 ValuesPicture
  + ~153 Button + хвост.
- xr:TransparentPixel ловился только у PictureDecoration. Теперь — в объектной
  форме картинки-ссылки {src, loadTransparent?, transparentPixel:{x,y}} у
  ValuesPicture/HeaderPicture/FooterPicture/RowsPicture/Page и у командных картинок.
- Page>Picture не поддерживался ни компилятором, ни декомпилятором. Новый ключ
  picture на Page (конвенция ValuesPicture: дефолт LoadTransparent=false, по корпусу
  416/286). Позиция XSD: после Title/ToolTip/флагов, перед Group/ShowTitle.

Компилятор: Emit-PictureRef + Emit-CommandPicture расширены abs/transparentPixel;
Emit-Page эмитит picture; RowsPicture переведён на Emit-PictureRef (был кастомный
блок без abs/TP). Декомпилятор: Get-PictureRef ловит xr:Abs/TransparentPixel;
новый хелпер Set-CommandPicture (Button/Popup/Command — abs + TP через объектную
форму при наличии TP, иначе скаляр); Page и RowsPicture через Get-PictureRef.
Зеркало py (байт-в-байт). abs валидируется раундтрипом на корпусе (нужен встроенный
бинарь — в синтет-кейсы не кладём); transparentPixel + Page picture сертифицированы
загрузкой в 1С (кейсы picture-field/pages/commands). Регресс 43/43 (ps1+py).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-11 13:35:13 +03:00
co-authored by Claude Opus 4.8
parent 73f1e6ec26
commit 606ac10fdb
10 changed files with 122 additions and 64 deletions
@@ -1,4 +1,4 @@
# form-compile v1.111 — Compile 1C managed form from JSON or object metadata
# form-compile v1.112 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -2822,19 +2822,23 @@ function Emit-CommonElementProps {
if ($el.headerHorizontalAlign) { X "$indent<HeaderHorizontalAlign>$($el.headerHorizontalAlign)</HeaderHorizontalAlign>" }
}
# Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture).
# Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture/Page Picture).
# Платформа ВСЕГДА эмитит <xr:LoadTransparent> → пишем всегда (false по умолчанию).
# Значение: скаляр (Ref) ИЛИ объект {src, loadTransparent}.
# Значение: скаляр (Ref) ИЛИ объект {src, loadTransparent, transparentPixel}.
# src с префиксом "abs:" → встроенная картинка <xr:Abs>; иначе именованная/стилевая <xr:Ref>.
function Emit-PictureRef {
param($val, [string]$picTag, [string]$indent)
if (-not $val) { return }
$src = $null; $lt = $false
$src = $null; $lt = $false; $tpx = $null
if ($val -is [string]) { $src = $val }
else { $src = $val.src; if ($val.loadTransparent -eq $true) { $lt = $true } }
else { $src = $val.src; if ($val.loadTransparent -eq $true) { $lt = $true }; $tpx = $val.transparentPixel }
if (-not $src) { return }
$srcStr = "$src"
X "$indent<$picTag>"
X "$indent`t<xr:Ref>$src</xr:Ref>"
if ($srcStr -match '^abs:(.*)$') { X "$indent`t<xr:Abs>$(Esc-Xml $matches[1])</xr:Abs>" }
else { X "$indent`t<xr:Ref>$(Esc-Xml $srcStr)</xr:Ref>" }
X "$indent`t<xr:LoadTransparent>$(if ($lt) { 'true' } else { 'false' })</xr:LoadTransparent>"
if ($tpx) { X "$indent`t<xr:TransparentPixel x=`"$($tpx.x)`" y=`"$($tpx.y)`"/>" }
X "$indent</$picTag>"
}
@@ -2854,14 +2858,17 @@ function Emit-ColumnPics {
function Emit-CommandPicture {
param($pic, $elemLt, [string]$indent)
if (-not $pic) { return }
$src = $null; $lt = $null
$src = $null; $lt = $null; $tpx = $null
if ($pic -is [string]) { $src = $pic }
else { $src = $pic.src; if ($null -ne $pic.loadTransparent) { $lt = [bool]$pic.loadTransparent } }
else { $src = $pic.src; if ($null -ne $pic.loadTransparent) { $lt = [bool]$pic.loadTransparent }; $tpx = $pic.transparentPixel }
if (-not $src) { return }
if ($null -eq $lt -and $null -ne $elemLt) { $lt = [bool]$elemLt }
$srcStr = "$src"
X "$indent<Picture>"
X "$indent`t<xr:Ref>$src</xr:Ref>"
if ($srcStr -match '^abs:(.*)$') { X "$indent`t<xr:Abs>$(Esc-Xml $matches[1])</xr:Abs>" }
else { X "$indent`t<xr:Ref>$(Esc-Xml $srcStr)</xr:Ref>" }
X "$indent`t<xr:LoadTransparent>$(if ($lt -eq $false) { 'false' } else { 'true' })</xr:LoadTransparent>"
if ($tpx) { X "$indent`t<xr:TransparentPixel x=`"$($tpx.x)`" y=`"$($tpx.y)`"/>" }
X "$indent</Picture>"
}
@@ -4228,15 +4235,8 @@ function Emit-Table {
if ($el.initialTreeView) { X "$inner<InitialTreeView>$($el.initialTreeView)</InitialTreeView>" }
if ($null -ne $el.enableDrag) { X "$inner<EnableDrag>$(if ($el.enableDrag){'true'}else{'false'})</EnableDrag>" }
if ($el.rowPictureDataPath) { X "$inner<RowPictureDataPath>$($el.rowPictureDataPath)</RowPictureDataPath>" }
if ($el.rowsPicture) {
# Строка = Ref (LoadTransparent дефолт false); объект {src, loadTransparent} → факт. значение
$rpSrc = if ($el.rowsPicture -is [string]) { $el.rowsPicture } else { $el.rowsPicture.src }
$rpLt = if ($el.rowsPicture -isnot [string] -and $el.rowsPicture.loadTransparent -eq $true) { 'true' } else { 'false' }
X "$inner<RowsPicture>"
X "$inner`t<xr:Ref>$rpSrc</xr:Ref>"
X "$inner`t<xr:LoadTransparent>$rpLt</xr:LoadTransparent>"
X "$inner</RowsPicture>"
}
# RowsPicture — та же конвенция, что ValuesPicture (дефолт LoadTransparent=false; abs/TransparentPixel)
Emit-PictureRef -val $el.rowsPicture -picTag 'RowsPicture' -indent $inner
# Блок свойств дин-список-таблицы (помечена эвристикой 11b.4)
if ($el.PSObject.Properties["_dynList"] -and $el._dynList) { Emit-DynListTableBlock -el $el -indent $inner }
if ($el.viewStatusLocation) { X "$inner<ViewStatusLocation>$($el.viewStatusLocation)</ViewStatusLocation>" }
@@ -4323,6 +4323,10 @@ function Emit-Page {
Emit-Title -el $el -name $name -indent $inner -auto
Emit-CommonFlags -el $el -indent $inner
# Картинка страницы (иконка вкладки): после Title/флагов, перед Group (порядок XSD).
# Конвенция как у ValuesPicture (дефолт LoadTransparent=false): скаляр-Ref/'abs:X' или объект.
Emit-PictureRef -val $el.picture -picTag 'Picture' -indent $inner
if ($el.group) {
# Доступные значения страницы/обычной группы: Vertical / HorizontalIfPossible / AlwaysHorizontal
# (InCell — только у columnGroup). Horizontal/AlwaysVertical оставлены forgiving (legacy).
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# form-compile v1.111 — Compile 1C managed form from JSON or object metadata
# form-compile v1.112 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import copy
@@ -2577,21 +2577,30 @@ def emit_common_element_props(lines, el, indent):
def emit_picture_ref(lines, val, pic_tag, indent):
"""Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture).
"""Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture/Page Picture).
Платформа ВСЕГДА эмитит <xr:LoadTransparent> пишем всегда (false по умолчанию).
Значение: скаляр (Ref) ИЛИ объект {src, loadTransparent}."""
Значение: скаляр (Ref) ИЛИ объект {src, loadTransparent, transparentPixel}.
src с префиксом "abs:" встроенная картинка <xr:Abs>; иначе <xr:Ref>."""
if not val:
return
tpx = None
if isinstance(val, str):
src, lt = val, False
else:
src = val.get('src')
lt = val.get('loadTransparent') is True
tpx = val.get('transparentPixel')
if not src:
return
src_str = str(src)
lines.append(f"{indent}<{pic_tag}>")
lines.append(f"{indent}\t<xr:Ref>{src}</xr:Ref>")
if src_str.startswith('abs:'):
lines.append(f"{indent}\t<xr:Abs>{esc_xml(src_str[4:])}</xr:Abs>")
else:
lines.append(f"{indent}\t<xr:Ref>{esc_xml(src_str)}</xr:Ref>")
lines.append(f'{indent}\t<xr:LoadTransparent>{"true" if lt else "false"}</xr:LoadTransparent>')
if tpx:
lines.append(f'{indent}\t<xr:TransparentPixel x="{tpx.get("x")}" y="{tpx.get("y")}"/>')
lines.append(f"{indent}</{pic_tag}>")
@@ -2611,19 +2620,27 @@ def emit_command_picture(lines, pic, elem_lt, indent):
if not pic:
return
lt = None
tpx = None
if isinstance(pic, str):
src = pic
else:
src = pic.get('src')
if pic.get('loadTransparent') is not None:
lt = bool(pic.get('loadTransparent'))
tpx = pic.get('transparentPixel')
if not src:
return
if lt is None and elem_lt is not None:
lt = bool(elem_lt)
src_str = str(src)
lines.append(f'{indent}<Picture>')
lines.append(f'{indent}\t<xr:Ref>{src}</xr:Ref>')
if src_str.startswith('abs:'):
lines.append(f'{indent}\t<xr:Abs>{esc_xml(src_str[4:])}</xr:Abs>')
else:
lines.append(f'{indent}\t<xr:Ref>{esc_xml(src_str)}</xr:Ref>')
lines.append(f'{indent}\t<xr:LoadTransparent>{"false" if lt is False else "true"}</xr:LoadTransparent>')
if tpx:
lines.append(f'{indent}\t<xr:TransparentPixel x="{tpx.get("x")}" y="{tpx.get("y")}"/>')
lines.append(f'{indent}</Picture>')
@@ -3954,15 +3971,8 @@ def emit_table(lines, el, name, eid, indent):
lines.append(f'{inner}<EnableDrag>{"true" if el["enableDrag"] else "false"}</EnableDrag>')
if el.get('rowPictureDataPath'):
lines.append(f'{inner}<RowPictureDataPath>{el["rowPictureDataPath"]}</RowPictureDataPath>')
if el.get('rowsPicture'):
# Строка = Ref (LoadTransparent дефолт false); объект {src, loadTransparent} → факт. значение
rp = el['rowsPicture']
rp_src = rp if isinstance(rp, str) else rp.get('src')
rp_lt = 'true' if (not isinstance(rp, str) and rp.get('loadTransparent') is True) else 'false'
lines.append(f'{inner}<RowsPicture>')
lines.append(f'{inner}\t<xr:Ref>{rp_src}</xr:Ref>')
lines.append(f'{inner}\t<xr:LoadTransparent>{rp_lt}</xr:LoadTransparent>')
lines.append(f'{inner}</RowsPicture>')
# RowsPicture — та же конвенция, что ValuesPicture (дефолт LoadTransparent=false; abs/TransparentPixel)
emit_picture_ref(lines, el.get('rowsPicture'), 'RowsPicture', inner)
# Блок свойств дин-список-таблицы (помечена эвристикой)
if el.get('_dynList'):
emit_dynlist_table_block(lines, el, inner)
@@ -4043,6 +4053,10 @@ def emit_page(lines, el, name, eid, indent):
emit_title(lines, el, name, inner, auto=True)
emit_common_flags(lines, el, inner)
# Картинка страницы (иконка вкладки): после Title/флагов, перед Group (порядок XSD).
# Конвенция как у ValuesPicture (дефолт LoadTransparent=false): скаляр-Ref/'abs:X' или объект.
emit_picture_ref(lines, el.get('picture'), 'Picture', inner)
if el.get('group'):
orientation_map = {
'horizontal': 'Horizontal',
@@ -1,4 +1,4 @@
# form-decompile v0.87 — Decompile 1C managed Form.xml to JSON DSL (draft)
# form-decompile v0.88 — Decompile 1C managed Form.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
param(
@@ -940,18 +940,49 @@ function Decompile-AttrColumn {
}
# Общие свойства элемента (visible/enabled/readonly/title/events) → в hash
# Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture).
# Картинка-ссылка с прозрачностью (HeaderPicture/FooterPicture/ValuesPicture/Page Picture).
# Платформа ВСЕГДА эмитит <xr:LoadTransparent> (и true, и false) → дефолт DSL = false.
# Скаляр (Ref) при loadTransparent=false; объект {src,loadTransparent:true} при true.
# Источник: <xr:Ref> (именованная/стилевая) ИЛИ <xr:Abs> (встроенная → префикс "abs:").
# Скаляр (src) при loadTransparent=false и без TransparentPixel; иначе объект
# {src, loadTransparent?, transparentPixel?}.
function Get-PictureRef {
param($node, [string]$picTag)
$ref = $node.SelectSingleNode("lf:$picTag/xr:Ref", $ns)
if (-not $ref) { return $null }
$abs = $node.SelectSingleNode("lf:$picTag/xr:Abs", $ns)
if (-not $ref -and -not $abs) { return $null }
$src = if ($ref) { $ref.InnerText } else { "abs:$($abs.InnerText)" }
$lt = $node.SelectSingleNode("lf:$picTag/xr:LoadTransparent", $ns)
if ($lt -and $lt.InnerText -eq 'true') {
return [ordered]@{ src = $ref.InnerText; loadTransparent = $true }
$ltTrue = ($lt -and $lt.InnerText -eq 'true')
$tpx = $node.SelectSingleNode("lf:$picTag/xr:TransparentPixel", $ns)
if (-not $ltTrue -and -not $tpx) { return $src }
$o = [ordered]@{ src = $src }
if ($ltTrue) { $o['loadTransparent'] = $true }
if ($tpx) { $o['transparentPixel'] = [ordered]@{ x = [int]$tpx.GetAttribute('x'); y = [int]$tpx.GetAttribute('y') } }
return $o
}
# <Picture> кнопки/попапа/команды. Дефолт LoadTransparent=true (обратная конвенция к header/values):
# фиксируем только отклонение false. Источник <xr:Ref> или <xr:Abs> (→ "abs:"). При наличии
# <xr:TransparentPixel> → объектная форма {src, loadTransparent?, transparentPixel}, иначе скаляр picture
# + отдельный loadTransparent:false.
function Set-CommandPicture {
param($obj, $node)
$ref = $node.SelectSingleNode("lf:Picture/xr:Ref", $ns)
$abs = $node.SelectSingleNode("lf:Picture/xr:Abs", $ns)
if (-not $ref -and -not $abs) { return }
$src = if ($ref) { $ref.InnerText } else { "abs:$($abs.InnerText)" }
$lt = $node.SelectSingleNode("lf:Picture/xr:LoadTransparent", $ns)
$ltFalse = ($lt -and $lt.InnerText -eq 'false')
$tpx = $node.SelectSingleNode("lf:Picture/xr:TransparentPixel", $ns)
if ($tpx) {
$o = [ordered]@{ src = $src }
if ($ltFalse) { $o['loadTransparent'] = $false }
$o['transparentPixel'] = [ordered]@{ x = [int]$tpx.GetAttribute('x'); y = [int]$tpx.GetAttribute('y') }
$obj['picture'] = $o
} else {
$obj['picture'] = $src
if ($ltFalse) { $obj['loadTransparent'] = $false }
}
return $ref.InnerText
}
# Шрифт <Font ...> → строка-ref (если только ref+kind=StyleItem) или объект-атрибуты.
@@ -1688,13 +1719,8 @@ function Decompile-Element {
$soin = Get-Child $node 'SearchOnInput'; if ($soin) { $obj['searchOnInput'] = $soin }
$mi = Get-Child $node 'AutoMarkIncomplete'; if ($null -ne $mi) { $obj['markIncomplete'] = ($mi -eq 'true') }
$itv = Get-Child $node 'InitialTreeView'; if ($itv) { $obj['initialTreeView'] = $itv }
# RowsPicture: src (xr:Ref) + LoadTransparent (дефолт false). При true → объектная форма.
$rpRef = $node.SelectSingleNode("lf:RowsPicture/xr:Ref", $ns)
if ($rpRef) {
$rpLt = $node.SelectSingleNode("lf:RowsPicture/xr:LoadTransparent", $ns)
if ($rpLt -and $rpLt.InnerText -eq 'true') { $obj['rowsPicture'] = [ordered]@{ src = $rpRef.InnerText; loadTransparent = $true } }
else { $obj['rowsPicture'] = $rpRef.InnerText }
}
# RowsPicture — конвенция ValuesPicture (Ref/Abs + LoadTransparent дефолт false + TransparentPixel)
$rp = Get-PictureRef $node 'RowsPicture'; if ($null -ne $rp) { $obj['rowsPicture'] = $rp }
$rpdp = Get-Child $node 'RowPictureDataPath'
# --- Блок дин-список-таблицы (признак: дочерний <UpdateOnDataChange>) ---
if (Has-Child $node 'UpdateOnDataChange') {
@@ -1736,6 +1762,8 @@ function Decompile-Element {
$g = Get-Child $node 'Group'
$gmap = @{ 'Horizontal'='horizontal'; 'Vertical'='vertical'; 'AlwaysHorizontal'='alwaysHorizontal'; 'AlwaysVertical'='alwaysVertical'; 'HorizontalIfPossible'='horizontalIfPossible' }
if ($g -and $gmap.ContainsKey($g)) { $obj['group'] = $gmap[$g] }
# Картинка страницы (иконка вкладки) — конвенция ValuesPicture (дефолт LoadTransparent=false)
$pp = Get-PictureRef $node 'Picture'; if ($null -ne $pp) { $obj['picture'] = $pp }
if ((Get-Child $node 'ShowTitle') -eq 'false') { $obj['showTitle'] = $false }
$kids = Decompile-Children $node
if ($kids) { $obj['children'] = $kids }
@@ -1755,9 +1783,7 @@ function Decompile-Element {
if ($type) { $tmap=@{'CommandBarButton'='commandBar';'UsualButton'='usual';'Hyperlink'='hyperlink';'CommandBarHyperlink'='hyperlink'}; if ($tmap.ContainsKey($type)) { $obj['type']=$tmap[$type] } else { $obj['type']=$type } }
if ((Get-Child $node 'DefaultButton') -eq 'true') { $obj['defaultButton'] = $true }
if ((Get-Child $node 'Check') -eq 'true') { $obj['checked'] = $true }
$ref = $node.SelectSingleNode("lf:Picture/xr:Ref", $ns); if ($ref) { $obj['picture'] = $ref.InnerText }
# Дефолт у picture кнопки/попапа = true → фиксируем только отклонение false (true опускаем)
$lt = $node.SelectSingleNode("lf:Picture/xr:LoadTransparent", $ns); if ($lt -and $lt.InnerText -eq 'false') { $obj['loadTransparent'] = $false }
Set-CommandPicture $obj $node
$rep = Get-Child $node 'Representation'; if ($rep) { $obj['representation'] = $rep }
$lic = Get-Child $node 'LocationInCommandBar'; if ($lic) { $obj['locationInCommandBar'] = $lic }
}
@@ -1781,9 +1807,7 @@ function Decompile-Element {
'Popup' {
$obj[$key] = $name
Add-CommonProps $obj $node $name
$ref = $node.SelectSingleNode("lf:Picture/xr:Ref", $ns); if ($ref) { $obj['picture'] = $ref.InnerText }
# Дефолт у picture кнопки/попапа = true → фиксируем только отклонение false (true опускаем)
$lt = $node.SelectSingleNode("lf:Picture/xr:LoadTransparent", $ns); if ($lt -and $lt.InnerText -eq 'false') { $obj['loadTransparent'] = $false }
Set-CommandPicture $obj $node
$rep = Get-Child $node 'Representation'; if ($rep) { $obj['representation'] = $rep }
$kids = Decompile-Children $node
if ($kids) { $obj['children'] = $kids }
@@ -2430,9 +2454,7 @@ if ($cmdsNode) {
# Используемая таблица — ссылка по имени элемента-таблицы (<AssociatedTableElementId xsi:type="xs:string">Имя</…>)
$ate = Get-Child $c 'AssociatedTableElementId'; if ($ate) { $co['table'] = $ate }
$sc = Get-Child $c 'Shortcut'; if ($sc) { $co['shortcut'] = $sc }
$ref = $c.SelectSingleNode("lf:Picture/xr:Ref", $ns); if ($ref) { $co['picture'] = $ref.InnerText }
# Дефолт у picture команды = true → фиксируем только отклонение false (true опускаем)
$lt = $c.SelectSingleNode("lf:Picture/xr:LoadTransparent", $ns); if ($lt -and $lt.InnerText -eq 'false') { $co['loadTransparent'] = $false }
Set-CommandPicture $co $c
$rep = Get-Child $c 'Representation'; if ($rep) { $co['representation'] = $rep }
[void]$cmds.Add($co)
}