mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-15 22:35:23 +03:00
feat(skd): preset style=none + детект пустого fingerprint в decompile
Закрывает простую часть категории C: шаблоны где у ячеек appearance содержит только per-cell атрибуты (МинимальнаяШирина и др.) без font/ borders/colors. Раньше такие шаблоны попадали в TemplateStyleMismatch. - skd-compile (ps1+py): новый preset 'none' со всеми стилевыми полями null/false. Emit-CellAppearance / _emit_cell_appearance пропускают Font-элемент когда style.font=null. - skd-decompile: пустой fingerprint (после отсева per-cell ключей) не считается за стиль ячейки; если все non-merge ячейки шаблона имели пустой fp — эмитим style="none" вместо sentinel. - Новый тест template-no-style (round-trip bit-perfect). - Versions: compile v1.31→v1.32, decompile v0.13→v0.14. Метрики: - ERP-сэмпл 30: 32 → 24 sentinel'ов, clean 24→26/30 - Корпус из 40 отчётов целевого класса: 45 → 39 sentinel'ов, 19/40 clean Остаточные sentinel'ы — реальный custom appearance (нестандартный шрифт/ выравнивание/цвет вне built-in пресетов). Требует расширения DSL под hashtable-style — отдельная задача.
This commit is contained in:
@@ -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</dcscor:item>"
|
||||
}
|
||||
# Font
|
||||
$boldStr = if ($style.bold) { "true" } else { "false" }
|
||||
$italicStr = if ($style.italic) { "true" } else { "false" }
|
||||
X "$ind<dcscor:item>"
|
||||
X "$ind`t<dcscor:parameter>Шрифт</dcscor:parameter>"
|
||||
X "$ind`t<dcscor:value xsi:type=`"v8ui:Font`" faceName=`"$($style.font)`" height=`"$($style.fontSize)`" bold=`"$boldStr`" italic=`"$italicStr`" underline=`"false`" strikeout=`"false`" kind=`"Absolute`" scale=`"100`"/>"
|
||||
X "$ind</dcscor:item>"
|
||||
# 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<dcscor:item>"
|
||||
X "$ind`t<dcscor:parameter>Шрифт</dcscor:parameter>"
|
||||
X "$ind`t<dcscor:value xsi:type=`"v8ui:Font`" faceName=`"$($style.font)`" height=`"$($style.fontSize)`" bold=`"$boldStr`" italic=`"$italicStr`" underline=`"false`" strikeout=`"false`" kind=`"Absolute`" scale=`"100`"/>"
|
||||
X "$ind</dcscor:item>"
|
||||
}
|
||||
# Horizontal alignment
|
||||
if ($style.hAlign) {
|
||||
X "$ind<dcscor:item>"
|
||||
|
||||
@@ -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</dcscor:value>')
|
||||
lines.append(f'{ind}\t</dcscor:item>')
|
||||
lines.append(f'{ind}</dcscor:item>')
|
||||
# Font
|
||||
bold_str = 'true' if style.get('bold') else 'false'
|
||||
italic_str = 'true' if style.get('italic') else 'false'
|
||||
lines.append(f'{ind}<dcscor:item>')
|
||||
lines.append(f'{ind}\t<dcscor:parameter>\u0428\u0440\u0438\u0444\u0442</dcscor:parameter>')
|
||||
lines.append(f'{ind}\t<dcscor:value xsi:type="v8ui:Font" faceName="{style["font"]}" height="{style["fontSize"]}" bold="{bold_str}" italic="{italic_str}" underline="false" strikeout="false" kind="Absolute" scale="100"/>')
|
||||
lines.append(f'{ind}</dcscor:item>')
|
||||
# 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}<dcscor:item>')
|
||||
lines.append(f'{ind}\t<dcscor:parameter>\u0428\u0440\u0438\u0444\u0442</dcscor:parameter>')
|
||||
lines.append(f'{ind}\t<dcscor:value xsi:type="v8ui:Font" faceName="{style["font"]}" height="{style["fontSize"]}" bold="{bold_str}" italic="{italic_str}" underline="false" strikeout="false" kind="Absolute" scale="100"/>')
|
||||
lines.append(f'{ind}</dcscor:item>')
|
||||
# Horizontal alignment
|
||||
if style.get('hAlign'):
|
||||
lines.append(f'{ind}<dcscor:item>')
|
||||
|
||||
@@ -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__']
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user