mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-13 15:03:20 +03:00
fix(mxl-compile): внятный отказ на объектную форму columnSet
Раскладка адресуется именем из columnSets. Инлайновой формы в этом DSL нет ни у
чего: style у ячейки и font внутри стиля тоже только имена — именованные сущности
объявляются один раз и всюду адресуются по имени. Объектная форма стала бы второй
формой одного и создала бы асимметрию «раскладку инлайнить можно, а стиль нельзя».
Объект в columnSet и раньше не портил вывод — навык падал с «Unknown 'columnSet'»,
подставляя сериализованный объект. Но сериализация у портов разная (@{columns=5}
против {'columns': 5}), то есть сообщения расходились. Теперь это отдельная проверка
с текстом, одинаковым в обоих портах и прямо называющим правило.
Кейсы: column-sets (позитивный, ссылка и объявление доезжают до XML) и
error-columnset-inline.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
26b38e2ee3
commit
8302b17814
@@ -1,4 +1,4 @@
|
||||
# mxl-compile v1.19 — Compile 1C spreadsheet from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# mxl-compile v1.20 — Compile 1C spreadsheet from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -789,6 +789,14 @@ foreach ($area in $def.areas) {
|
||||
$activeRowspans = @() # @{ColStart=1-based; ColEnd=1-based; EndLocalRow=int}
|
||||
$localRow = 0
|
||||
# Ссылка области на колоночную раскладку — её получают все строки области.
|
||||
# Раскладка адресуется ИМЕНЕМ из columnSets — инлайновой формы в этом DSL нет ни у чего
|
||||
# (стиль и шрифт тоже только по имени). Иначе сообщение включало бы сериализованный
|
||||
# объект, а он у портов выглядит по-разному.
|
||||
if ($area.PSObject.Properties['columnSet'] -and
|
||||
($area.columnSet -is [System.Management.Automation.PSCustomObject] -or $area.columnSet -is [System.Collections.IDictionary])) {
|
||||
[Console]::Error.WriteLine("'columnSet' must be a name declared in columnSets, got an object: area `"$($area.name)`"")
|
||||
exit 1
|
||||
}
|
||||
$areaColumnSet = if ($area.PSObject.Properties['columnSet']) { "$($area.columnSet)" } else { '' }
|
||||
$areaLayout = $columnLayouts[0]
|
||||
if ($areaColumnSet) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# mxl-compile v1.19 — Compile 1C spreadsheet from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# mxl-compile v1.20 — Compile 1C spreadsheet from JSON (+write_xml_file/write_utf8_bom: общий эталон записи)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -814,6 +814,13 @@ def main():
|
||||
active_rowspans = []
|
||||
local_row = 0
|
||||
# Ссылка области на колоночную раскладку — её получают все строки области.
|
||||
# Раскладка адресуется ИМЕНЕМ из columnSets — инлайновой формы в этом DSL нет ни у чего
|
||||
# (стиль и шрифт тоже только по имени). Иначе сообщение включало бы сериализованный
|
||||
# объект, а он у портов выглядит по-разному.
|
||||
if isinstance(area.get('columnSet'), (dict, list)):
|
||||
print(f'\'columnSet\' must be a name declared in columnSets, got an object:'
|
||||
f' area "{area.get("name", "")}"', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
area_column_set = str(area.get('columnSet') or '')
|
||||
area_layout = column_layouts[0]
|
||||
if area_column_set:
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "Колоночные раскладки: своя ширина колонок у группы строк",
|
||||
"input": {
|
||||
"columns": 3,
|
||||
"columnWidths": { "1-3": 20 },
|
||||
"columnSets": {
|
||||
"узкая": { "columns": 3, "columnWidths": { "1-3": 8 } }
|
||||
},
|
||||
"areas": [
|
||||
{ "name": "Шапка", "rows": [["Наименование", "Количество", "Сумма"]] },
|
||||
{ "name": "ТабличнаяЧасть", "columnSet": "узкая", "rows": [["{Товар}", "{Кол}", "{Сумма}"]] }
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"outputPath": "Template.xml"
|
||||
},
|
||||
"validatePath": "Template.xml",
|
||||
"expect": {
|
||||
"files": ["Template.xml"],
|
||||
"fileContains": {
|
||||
"file": "Template.xml",
|
||||
"text": ["<id>узкая</id>", "<columnsID>узкая</columnsID>"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Ошибка: columnSet задан объектом вместо имени",
|
||||
"input": {
|
||||
"columns": 3,
|
||||
"areas": [
|
||||
{ "name": "Шапка", "columnSet": { "columns": 5 }, "rows": [["А", "Б", "В"]] }
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"outputPath": "Template.xml"
|
||||
},
|
||||
"expectError": "'columnSet' must be a name declared in columnSets, got an object: area \"Шапка\""
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document xmlns="http://v8.1c.ru/8.2/data/spreadsheet" xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:v8="http://v8.1c.ru/8.1/data/core" xmlns:v8ui="http://v8.1c.ru/8.1/data/ui" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<languageSettings>
|
||||
<currentLanguage>ru</currentLanguage>
|
||||
<defaultLanguage>ru</defaultLanguage>
|
||||
<languageInfo>
|
||||
<id>ru</id>
|
||||
<code>Русский</code>
|
||||
<description>Русский</description>
|
||||
</languageInfo>
|
||||
</languageSettings>
|
||||
<columns>
|
||||
<size>3</size>
|
||||
<columnsItem>
|
||||
<index>0</index>
|
||||
<column>
|
||||
<formatIndex>2</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
<columnsItem>
|
||||
<index>1</index>
|
||||
<column>
|
||||
<formatIndex>2</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
<columnsItem>
|
||||
<index>2</index>
|
||||
<column>
|
||||
<formatIndex>2</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
</columns>
|
||||
<columns>
|
||||
<id>узкая</id>
|
||||
<size>3</size>
|
||||
<columnsItem>
|
||||
<index>0</index>
|
||||
<column>
|
||||
<formatIndex>3</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
<columnsItem>
|
||||
<index>1</index>
|
||||
<column>
|
||||
<formatIndex>3</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
<columnsItem>
|
||||
<index>2</index>
|
||||
<column>
|
||||
<formatIndex>3</formatIndex>
|
||||
</column>
|
||||
</columnsItem>
|
||||
</columns>
|
||||
<rowsItem>
|
||||
<index>0</index>
|
||||
<row>
|
||||
<c>
|
||||
<i>0</i>
|
||||
<c>
|
||||
<f>4</f>
|
||||
<tl>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Наименование</v8:content>
|
||||
</v8:item>
|
||||
</tl>
|
||||
</c>
|
||||
</c>
|
||||
<c>
|
||||
<i>1</i>
|
||||
<c>
|
||||
<f>4</f>
|
||||
<tl>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Количество</v8:content>
|
||||
</v8:item>
|
||||
</tl>
|
||||
</c>
|
||||
</c>
|
||||
<c>
|
||||
<i>2</i>
|
||||
<c>
|
||||
<f>4</f>
|
||||
<tl>
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Сумма</v8:content>
|
||||
</v8:item>
|
||||
</tl>
|
||||
</c>
|
||||
</c>
|
||||
</row>
|
||||
</rowsItem>
|
||||
<rowsItem>
|
||||
<index>1</index>
|
||||
<row>
|
||||
<columnsID>узкая</columnsID>
|
||||
<c>
|
||||
<i>0</i>
|
||||
<c>
|
||||
<f>5</f>
|
||||
<parameter>Товар</parameter>
|
||||
</c>
|
||||
</c>
|
||||
<c>
|
||||
<i>1</i>
|
||||
<c>
|
||||
<f>5</f>
|
||||
<parameter>Кол</parameter>
|
||||
</c>
|
||||
</c>
|
||||
<c>
|
||||
<i>2</i>
|
||||
<c>
|
||||
<f>5</f>
|
||||
<parameter>Сумма</parameter>
|
||||
</c>
|
||||
</c>
|
||||
</row>
|
||||
</rowsItem>
|
||||
<templateMode>true</templateMode>
|
||||
<defaultFormatIndex>1</defaultFormatIndex>
|
||||
<height>2</height>
|
||||
<vgRows>2</vgRows>
|
||||
<namedItem xsi:type="NamedItemCells">
|
||||
<name>ТабличнаяЧасть</name>
|
||||
<area>
|
||||
<type>Rows</type>
|
||||
<beginRow>1</beginRow>
|
||||
<endRow>1</endRow>
|
||||
<beginColumn>-1</beginColumn>
|
||||
<endColumn>-1</endColumn>
|
||||
</area>
|
||||
</namedItem>
|
||||
<namedItem xsi:type="NamedItemCells">
|
||||
<name>Шапка</name>
|
||||
<area>
|
||||
<type>Rows</type>
|
||||
<beginRow>0</beginRow>
|
||||
<endRow>0</endRow>
|
||||
<beginColumn>-1</beginColumn>
|
||||
<endColumn>-1</endColumn>
|
||||
</area>
|
||||
</namedItem>
|
||||
<font faceName="Arial" height="10" bold="false" italic="false" underline="false" strikeout="false" kind="Absolute" scale="100"/>
|
||||
<format>
|
||||
<width>10</width>
|
||||
</format>
|
||||
<format>
|
||||
<width>20</width>
|
||||
</format>
|
||||
<format>
|
||||
<width>8</width>
|
||||
</format>
|
||||
<format>
|
||||
<font>0</font>
|
||||
<fillType>Text</fillType>
|
||||
</format>
|
||||
<format>
|
||||
<font>0</font>
|
||||
<fillType>Parameter</fillType>
|
||||
</format>
|
||||
</document>
|
||||
Reference in New Issue
Block a user