mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 08:04:56 +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__']
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DataCompositionSchema xmlns="http://v8.1c.ru/8.1/data-composition-system/schema"
|
||||
xmlns:dcscom="http://v8.1c.ru/8.1/data-composition-system/common"
|
||||
xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core"
|
||||
xmlns:dcsset="http://v8.1c.ru/8.1/data-composition-system/settings"
|
||||
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">
|
||||
<dataSource>
|
||||
<name>ИсточникДанных1</name>
|
||||
<dataSourceType>Local</dataSourceType>
|
||||
</dataSource>
|
||||
<dataSet xsi:type="DataSetQuery">
|
||||
<name>Тест</name>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Поле1</dataPath>
|
||||
<field>Поле1</field>
|
||||
<valueType>
|
||||
<v8:Type>xs:string</v8:Type>
|
||||
<v8:StringQualifiers>
|
||||
<v8:Length>0</v8:Length>
|
||||
<v8:AllowedLength>Variable</v8:AllowedLength>
|
||||
</v8:StringQualifiers>
|
||||
</valueType>
|
||||
</field>
|
||||
<field xsi:type="DataSetFieldField">
|
||||
<dataPath>Поле2</dataPath>
|
||||
<field>Поле2</field>
|
||||
<valueType>
|
||||
<v8:Type>xs:string</v8:Type>
|
||||
<v8:StringQualifiers>
|
||||
<v8:Length>0</v8:Length>
|
||||
<v8:AllowedLength>Variable</v8:AllowedLength>
|
||||
</v8:StringQualifiers>
|
||||
</valueType>
|
||||
</field>
|
||||
<dataSource>ИсточникДанных1</dataSource>
|
||||
<query>ВЫБРАТЬ * ИЗ Справочник.Сотрудники</query>
|
||||
</dataSet>
|
||||
<template>
|
||||
<name>БезСтиля</name>
|
||||
<template xmlns:dcsat="http://v8.1c.ru/8.1/data-composition-system/area-template" xsi:type="dcsat:AreaTemplate">
|
||||
<dcsat:item xsi:type="dcsat:TableRow">
|
||||
<dcsat:tableCell>
|
||||
<dcsat:item xsi:type="dcsat:Field">
|
||||
<dcsat:value xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>A</v8:content>
|
||||
</v8:item>
|
||||
</dcsat:value>
|
||||
</dcsat:item>
|
||||
<dcsat:appearance>
|
||||
<dcscor:item>
|
||||
<dcscor:parameter>МинимальнаяШирина</dcscor:parameter>
|
||||
<dcscor:value xsi:type="xs:decimal">7</dcscor:value>
|
||||
</dcscor:item>
|
||||
<dcscor:item>
|
||||
<dcscor:parameter>МаксимальнаяШирина</dcscor:parameter>
|
||||
<dcscor:value xsi:type="xs:decimal">7</dcscor:value>
|
||||
</dcscor:item>
|
||||
</dcsat:appearance>
|
||||
</dcsat:tableCell>
|
||||
<dcsat:tableCell>
|
||||
<dcsat:item xsi:type="dcsat:Field">
|
||||
<dcsat:value xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>B</v8:content>
|
||||
</v8:item>
|
||||
</dcsat:value>
|
||||
</dcsat:item>
|
||||
<dcsat:appearance>
|
||||
<dcscor:item>
|
||||
<dcscor:parameter>МинимальнаяШирина</dcscor:parameter>
|
||||
<dcscor:value xsi:type="xs:decimal">7</dcscor:value>
|
||||
</dcscor:item>
|
||||
<dcscor:item>
|
||||
<dcscor:parameter>МаксимальнаяШирина</dcscor:parameter>
|
||||
<dcscor:value xsi:type="xs:decimal">7</dcscor:value>
|
||||
</dcscor:item>
|
||||
</dcsat:appearance>
|
||||
</dcsat:tableCell>
|
||||
</dcsat:item>
|
||||
</template>
|
||||
</template>
|
||||
<settingsVariant>
|
||||
<dcsset:name>Основной</dcsset:name>
|
||||
<dcsset:presentation xsi:type="v8:LocalStringType">
|
||||
<v8:item>
|
||||
<v8:lang>ru</v8:lang>
|
||||
<v8:content>Основной</v8:content>
|
||||
</v8:item>
|
||||
</dcsset:presentation>
|
||||
<dcsset:settings xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows">
|
||||
<dcsset:selection>
|
||||
</dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:StructureItemGroup">
|
||||
<dcsset:order>
|
||||
<dcsset:item xsi:type="dcsset:OrderItemAuto"/>
|
||||
</dcsset:order>
|
||||
<dcsset:selection>
|
||||
<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>
|
||||
</dcsset:selection>
|
||||
</dcsset:item>
|
||||
</dcsset:settings>
|
||||
</settingsVariant>
|
||||
</DataCompositionSchema>
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"dataSets": [
|
||||
{
|
||||
"name": "Тест",
|
||||
"query": "ВЫБРАТЬ * ИЗ Справочник.Сотрудники",
|
||||
"fields": [
|
||||
"Поле1: string",
|
||||
"Поле2: string"
|
||||
]
|
||||
}
|
||||
],
|
||||
"templates": [
|
||||
{
|
||||
"name": "БезСтиля",
|
||||
"style": "none",
|
||||
"widths": [
|
||||
"7",
|
||||
"7"
|
||||
],
|
||||
"rows": [
|
||||
[
|
||||
"A",
|
||||
"B"
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user