feat(form-decompile,form-compile): геометрия/layout единым хелпером (кластер E)

- compiler PS1+PY: общий Emit-Layout/emit_layout (width/height/stretch/maxWidth/
  maxHeight/autoMax*/skipOnInput/groupHorizontalAlign/groupVerticalAlign/
  horizontalAlign), вызывается во всех эмиттерах; inline-дубли убраны. Спец-квирки
  сохранены (input multiLine→autoMaxWidth, table height→HeightInTableRows).
- PictureDecoration LoadTransparent больше не захардкожен true — управляется
  loadTransparent (дефолт false).
- decompiler: Add-Layout (DRY, один вызов на элемент), table HeightInTableRows,
  picture loadTransparent.
- docs/form-dsl-spec: блок общих layout-свойств (4.1a), loadTransparent у picture.
- tests: groups расширен layout-свойствами (+snapshot, сертифицирован в 1С).

Churn снапшотов нулевой. АварийныйРежим: LOST полностью закрыт (остаток — над-генерация).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-04 17:51:13 +03:00
parent 67eaa1c3c8
commit e777ded8d2
6 changed files with 6705 additions and 6619 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
# form-decompile v0.3 — Decompile 1C managed Form.xml to JSON DSL (draft)
# form-decompile v0.4 — Decompile 1C managed Form.xml to JSON DSL (draft)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
# ВНИМАНИЕ: раундтрип не гарантируется. Навык исключён из авто-использования моделью.
param(
@@ -184,6 +184,25 @@ function Convert-TypedValue {
}
}
# Общие layout-свойства → в $obj (симметрично Emit-Layout компилятора).
# Вызывается один раз для любого элемента. Height тут — пиксельная высота
# (<Height>); Table хранит высоту в строках (<HeightInTableRows>) и ловит её сам.
function Add-Layout {
param($obj, $node)
if ((Get-Child $node 'SkipOnInput') -eq 'true') { $obj['skipOnInput'] = $true }
if ((Get-Child $node 'AutoMaxWidth') -eq 'false') { $obj['autoMaxWidth'] = $false }
$mw = Get-Child $node 'MaxWidth'; if ($mw) { $obj['maxWidth'] = [int]$mw }
if ((Get-Child $node 'AutoMaxHeight') -eq 'false') { $obj['autoMaxHeight'] = $false }
$mh = Get-Child $node 'MaxHeight'; if ($mh) { $obj['maxHeight'] = [int]$mh }
$w = Get-Child $node 'Width'; if ($w) { $obj['width'] = [int]$w }
$h = Get-Child $node 'Height'; if ($h) { $obj['height'] = [int]$h }
if ((Get-Child $node 'HorizontalStretch') -eq 'true') { $obj['horizontalStretch'] = $true }
if ((Get-Child $node 'VerticalStretch') -eq 'true') { $obj['verticalStretch'] = $true }
$gha = Get-Child $node 'GroupHorizontalAlign'; if ($gha) { $obj['groupHorizontalAlign'] = $gha }
$gva = Get-Child $node 'GroupVerticalAlign'; if ($gva) { $obj['groupVerticalAlign'] = $gva }
$ha = Get-Child $node 'HorizontalAlign'; if ($ha) { $obj['horizontalAlign'] = $ha }
}
# Суффиксы авто-имён обработчиков (инверсия компилятора)
$HANDLER_SUFFIX = @{
'OnChange'='ПриИзменении'; 'StartChoice'='НачалоВыбора'; 'ChoiceProcessing'='ОбработкаВыбора';
@@ -396,6 +415,7 @@ function Decompile-Element {
$obj[$key] = $name
Add-CommonProps $obj $node $name
$ref = $node.SelectSingleNode("lf:Picture/xr:Ref", $ns); if ($ref) { $obj['src'] = $ref.InnerText }
$lt = $node.SelectSingleNode("lf:Picture/xr:LoadTransparent", $ns); if ($lt -and $lt.InnerText -eq 'true') { $obj['loadTransparent'] = $true }
if ((Get-Child $node 'Hyperlink') -eq 'true') { $obj['hyperlink'] = $true }
}
'PictureField' {
@@ -418,6 +438,7 @@ function Decompile-Element {
if ((Get-Child $node 'ChangeRowOrder') -eq 'true') { $obj['changeRowOrder'] = $true }
if ((Get-Child $node 'Header') -eq 'false') { $obj['header'] = $false }
if ((Get-Child $node 'Footer') -eq 'true') { $obj['footer'] = $true }
$htr = Get-Child $node 'HeightInTableRows'; if ($htr) { $obj['height'] = [int]$htr }
$cbl = Get-Child $node 'CommandBarLocation'; if ($cbl) { $obj['commandBarLocation'] = $cbl }
$cols = Decompile-Children $node
if ($cols) { $obj['columns'] = $cols }
@@ -478,6 +499,7 @@ function Decompile-Element {
if ($kids) { $obj['children'] = $kids }
}
}
Add-Layout $obj $node
return $obj
}
+20
View File
@@ -117,6 +117,25 @@
| `on` | string[] | Массив имён событий |
| `handlers` | object | Явные имена обработчиков: `{"OnChange": "МойОбработчик"}` |
### 4.1a. Общие layout-свойства
Применимы к любому элементу (размеры, растягивание, выравнивание внутри родителя). Эмитятся только при указании.
| Свойство | XML | Значения |
|----------|-----|----------|
| `width` | `<Width>` | число |
| `height` | `<Height>` | число (у `table``<HeightInTableRows>`, высота в строках) |
| `horizontalStretch` | `<HorizontalStretch>` | `true` |
| `verticalStretch` | `<VerticalStretch>` | `true` |
| `autoMaxWidth` | `<AutoMaxWidth>` | `false` (у `input` при `multiLine` подставляется автоматически) |
| `autoMaxHeight` | `<AutoMaxHeight>` | `false` |
| `maxWidth` | `<MaxWidth>` | число |
| `maxHeight` | `<MaxHeight>` | число |
| `groupHorizontalAlign` | `<GroupHorizontalAlign>` | `Left`, `Center`, `Right` |
| `groupVerticalAlign` | `<GroupVerticalAlign>` | `Top`, `Center`, `Bottom` |
| `horizontalAlign` | `<HorizontalAlign>` | `Left`, `Center`, `Right` |
| `skipOnInput` | `<SkipOnInput>` | `true` |
### 4.2. Автоименование обработчиков
При указании `"on"` без `"handlers"` имя обработчика генерируется автоматически:
@@ -345,6 +364,7 @@ Pages поддерживает `pagesRepresentation`: `None`, `TabsOnTop`, `Tabs
| Свойство | Тип | Описание |
|----------|-----|----------|
| `src` или `picture` (как свойство) | string | Ссылка на картинку |
| `loadTransparent` | bool | `true` → загружать прозрачной. По умолчанию `false` |
| `hyperlink` | bool | Режим гиперссылки |
| `width` | int | Ширина |
| `height` | int | Высота |
+4 -3
View File
@@ -17,9 +17,10 @@
"title": "Группы",
"elements": [
{ "cmdBar": "КоманднаяПанель", "autofill": true },
{ "group": "horizontal", "name": "ГруппаШапка", "showTitle": true, "title": "Шапка", "children": [
{ "input": "Поле1", "path": "Поле1", "title": "Поле 1" },
{ "input": "Поле2", "path": "Поле2", "title": "Поле 2" }
{ "group": "horizontal", "name": "ГруппаШапка", "showTitle": true, "title": "Шапка", "horizontalStretch": true, "groupHorizontalAlign": "Right", "children": [
{ "input": "Поле1", "path": "Поле1", "title": "Поле 1", "width": 20, "skipOnInput": true },
{ "input": "Поле2", "path": "Поле2", "title": "Поле 2" },
{ "labelField": "Метка", "path": "Поле1", "groupVerticalAlign": "Center" }
]},
{ "group": "vertical", "name": "ГруппаПодвал", "children": [
{ "input": "Поле3", "path": "Поле3", "title": "Поле 3" }
@@ -22,6 +22,8 @@
</v8:item>
</Title>
<Group>Horizontal</Group>
<HorizontalStretch>true</HorizontalStretch>
<GroupHorizontalAlign>Right</GroupHorizontalAlign>
<ExtendedTooltip name="ГруппаШапкаРасширеннаяПодсказка" id="3"/>
<ChildItems>
<InputField name="Поле1" id="4">
@@ -32,6 +34,8 @@
<v8:content>Поле 1</v8:content>
</v8:item>
</Title>
<SkipOnInput>true</SkipOnInput>
<Width>20</Width>
<ContextMenu name="Поле1КонтекстноеМеню" id="5"/>
<ExtendedTooltip name="Поле1РасширеннаяПодсказка" id="6"/>
</InputField>
@@ -46,13 +50,19 @@
<ContextMenu name="Поле2КонтекстноеМеню" id="8"/>
<ExtendedTooltip name="Поле2РасширеннаяПодсказка" id="9"/>
</InputField>
<LabelField name="Метка" id="10">
<DataPath>Поле1</DataPath>
<GroupVerticalAlign>Center</GroupVerticalAlign>
<ContextMenu name="МеткаКонтекстноеМеню" id="11"/>
<ExtendedTooltip name="МеткаРасширеннаяПодсказка" id="12"/>
</LabelField>
</ChildItems>
</UsualGroup>
<UsualGroup name="ГруппаПодвал" id="10">
<UsualGroup name="ГруппаПодвал" id="13">
<Group>Vertical</Group>
<ExtendedTooltip name="ГруппаПодвалРасширеннаяПодсказка" id="11"/>
<ExtendedTooltip name="ГруппаПодвалРасширеннаяПодсказка" id="14"/>
<ChildItems>
<InputField name="Поле3" id="12">
<InputField name="Поле3" id="15">
<DataPath>Поле3</DataPath>
<Title>
<v8:item>
@@ -60,20 +70,20 @@
<v8:content>Поле 3</v8:content>
</v8:item>
</Title>
<ContextMenu name="Поле3КонтекстноеМеню" id="13"/>
<ExtendedTooltip name="Поле3РасширеннаяПодсказка" id="14"/>
<ContextMenu name="Поле3КонтекстноеМеню" id="16"/>
<ExtendedTooltip name="Поле3РасширеннаяПодсказка" id="17"/>
</InputField>
</ChildItems>
</UsualGroup>
</ChildItems>
<Attributes>
<Attribute name="Объект" id="15">
<Attribute name="Объект" id="18">
<Type>
<v8:Type>cfg:DataProcessorObject.СГруппами</v8:Type>
</Type>
<MainAttribute>true</MainAttribute>
</Attribute>
<Attribute name="Поле1" id="16">
<Attribute name="Поле1" id="19">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>
@@ -88,7 +98,7 @@
</v8:StringQualifiers>
</Type>
</Attribute>
<Attribute name="Поле2" id="17">
<Attribute name="Поле2" id="20">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>
@@ -104,7 +114,7 @@
</v8:NumberQualifiers>
</Type>
</Attribute>
<Attribute name="Поле3" id="18">
<Attribute name="Поле3" id="21">
<Title>
<v8:item>
<v8:lang>ru</v8:lang>