diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index ff745829..2668c83b 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.ps1 +++ b/.claude/skills/skd-compile/scripts/skd-compile.ps1 @@ -1,4 +1,4 @@ -# skd-compile v1.31 — Compile 1C DCS from JSON +# skd-compile v1.32 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -1412,6 +1412,12 @@ function Emit-ParamValue { # Built-in style presets $script:areaStylePresets = @{ + none = @{ + font = $null; fontSize = $null; bold = $false; italic = $false + hAlign = $null; vAlign = $null; wrap = $false + bgColor = $null; textColor = $null + borderColor = $null; borders = $false + } data = @{ font = 'Arial'; fontSize = 10; bold = $false; italic = $false hAlign = $null; vAlign = $null; wrap = $false @@ -1530,13 +1536,15 @@ function Emit-CellAppearance { } X "$ind" } - # Font - $boldStr = if ($style.bold) { "true" } else { "false" } - $italicStr = if ($style.italic) { "true" } else { "false" } - X "$ind" - X "$ind`tШрифт" - X "$ind`t" - X "$ind" + # Font (skip if style has no font configured — for "none" preset) + if ($style.font) { + $boldStr = if ($style.bold) { "true" } else { "false" } + $italicStr = if ($style.italic) { "true" } else { "false" } + X "$ind" + X "$ind`tШрифт" + X "$ind`t" + X "$ind" + } # Horizontal alignment if ($style.hAlign) { X "$ind" diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index 667600be..c97fc6f1 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.py +++ b/.claude/skills/skd-compile/scripts/skd-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-compile v1.31 — Compile 1C DCS from JSON +# skd-compile v1.32 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -1163,6 +1163,12 @@ def emit_parameters(lines, defn): # === AreaTemplate DSL === AREA_STYLE_PRESETS = { + 'none': { + 'font': None, 'fontSize': None, 'bold': False, 'italic': False, + 'hAlign': None, 'vAlign': None, 'wrap': False, + 'bgColor': None, 'textColor': None, + 'borderColor': None, 'borders': False, + }, 'data': { 'font': 'Arial', 'fontSize': 10, 'bold': False, 'italic': False, 'hAlign': None, 'vAlign': None, 'wrap': False, @@ -1258,13 +1264,14 @@ def _emit_cell_appearance(lines, style, width=0, v_merge=False, h_merge=False, m lines.append(f'{ind}\t\t') lines.append(f'{ind}\t') lines.append(f'{ind}') - # Font - bold_str = 'true' if style.get('bold') else 'false' - italic_str = 'true' if style.get('italic') else 'false' - lines.append(f'{ind}') - lines.append(f'{ind}\t\u0428\u0440\u0438\u0444\u0442') - lines.append(f'{ind}\t') - lines.append(f'{ind}') + # Font (skip if style has no font configured \u2014 for "none" preset) + if style.get('font'): + bold_str = 'true' if style.get('bold') else 'false' + italic_str = 'true' if style.get('italic') else 'false' + lines.append(f'{ind}') + lines.append(f'{ind}\t\u0428\u0440\u0438\u0444\u0442') + lines.append(f'{ind}\t') + lines.append(f'{ind}') # Horizontal alignment if style.get('hAlign'): lines.append(f'{ind}') diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index 099d8610..e86f7516 100644 --- a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 +++ b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 @@ -1,4 +1,4 @@ -# skd-decompile v0.13 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.14 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -858,6 +858,7 @@ function Build-Template { $minHeight = $null $detectedStyle = $null $styleMismatch = $false + $hasAnyNonEmptyFp = $false # true если хоть одна ячейка имеет стилевые атрибуты $drilldownByParam = @{} # param name → field name (X from Расшифровка_X) $rowIdx = 0 @@ -875,12 +876,17 @@ function Build-Template { # Style detection (skip empty cells with no appearance, and merge cells) if ($appNode -and -not $perCell.mergeV -and -not $perCell.mergeH) { $fp = Get-AppearanceFingerprint $appNode - $matched = Match-BuiltinStyle $fp - if ($null -eq $detectedStyle) { - $detectedStyle = $matched - } elseif ($matched -ne $detectedStyle) { - $styleMismatch = $true + if ($fp.Count -gt 0) { + # Ячейка имеет стилевые атрибуты — пробуем match с built-in + $hasAnyNonEmptyFp = $true + $matched = Match-BuiltinStyle $fp + if ($null -eq $detectedStyle) { + $detectedStyle = $matched + } elseif ($matched -ne $detectedStyle) { + $styleMismatch = $true + } } + # Пустой fp (только per-cell width/merge) — ячейка без стиля, не контрибутирует. } # Drilldown attachment @@ -930,7 +936,10 @@ function Build-Template { # Decide output form if ($detectedStyle -and -not $styleMismatch) { $tmplObj['style'] = $detectedStyle - } elseif ($styleMismatch -or ($null -eq $detectedStyle -and $rows.Count -gt 0)) { + } elseif (-not $hasAnyNonEmptyFp -and $rows.Count -gt 0) { + # Все ячейки без стилевых атрибутов — это шаблон "без стиля" + $tmplObj['style'] = 'none' + } elseif ($styleMismatch -or ($null -eq $detectedStyle -and $hasAnyNonEmptyFp)) { # Couldn't unify style — emit sentinel $tmplObj['__unsupported__'] = (New-Sentinel -kind 'TemplateStyleMismatch' -loc $loc -detail 'Шаблон содержит ячейки с непокрытым/неоднородным оформлением (Кольцо 2)')['__unsupported__'] } diff --git a/tests/skills/cases/skd-decompile/snapshots/template-no-style/Template.xml b/tests/skills/cases/skd-decompile/snapshots/template-no-style/Template.xml new file mode 100644 index 00000000..93975050 --- /dev/null +++ b/tests/skills/cases/skd-decompile/snapshots/template-no-style/Template.xml @@ -0,0 +1,109 @@ + + + + ИсточникДанных1 + Local + + + Тест + + Поле1 + Поле1 + + xs:string + + 0 + Variable + + + + + Поле2 + Поле2 + + xs:string + + 0 + Variable + + + + ИсточникДанных1 + ВЫБРАТЬ * ИЗ Справочник.Сотрудники + + + + Основной + + + ru + Основной + + + + + + + + + + + + + + + + diff --git a/tests/skills/cases/skd-decompile/snapshots/template-no-style/decompiled.json b/tests/skills/cases/skd-decompile/snapshots/template-no-style/decompiled.json new file mode 100644 index 00000000..621c8bcf --- /dev/null +++ b/tests/skills/cases/skd-decompile/snapshots/template-no-style/decompiled.json @@ -0,0 +1,28 @@ +{ + "dataSets": [ + { + "name": "Тест", + "query": "ВЫБРАТЬ * ИЗ Справочник.Сотрудники", + "fields": [ + "Поле1: string", + "Поле2: string" + ] + } + ], + "templates": [ + { + "name": "БезСтиля", + "style": "none", + "widths": [ + "7", + "7" + ], + "rows": [ + [ + "A", + "B" + ] + ] + } + ] +} \ No newline at end of file diff --git a/tests/skills/cases/skd-decompile/template-no-style.json b/tests/skills/cases/skd-decompile/template-no-style.json new file mode 100644 index 00000000..806aa64b --- /dev/null +++ b/tests/skills/cases/skd-decompile/template-no-style.json @@ -0,0 +1,27 @@ +{ + "name": "Шаблон без стилевых атрибутов (style=none) — только per-cell width", + "preRun": [ + { + "script": "skd-compile/scripts/skd-compile", + "input": { + "dataSets": [{ + "name": "Тест", + "query": "ВЫБРАТЬ * ИЗ Справочник.Сотрудники", + "fields": ["Поле1: string", "Поле2: string"] + }], + "templates": [ + { + "name": "БезСтиля", + "style": "none", + "widths": [7, 7], + "rows": [["A", "B"]] + } + ] + }, + "args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "Template.xml" }, + "cwd": "{workDir}" + } + ], + "params": { "templatePath": "Template.xml" }, + "outputPath": "decompiled.json" +}