mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-18 17:20:22 +03:00
fix(mxl-compile,mxl-decompile): прозрачность у ссылочной картинки
Атрибут прозрачности живёт не только у картинки с данными: платформа пишет <picture t="false" ref="v8ui:Имя"/>, причём t перед ref. Компилятор в этой ветке его терял, декомпилятор не читал — в «Бухгалтерии предприятия» на 8.3.27 таких записей 67. Заодно уточнена картина по конфигурациям: t="false" стоит у 11 135 картинок БП, значения true не бывает нигде — включённую прозрачность платформа выражает координатами пикселя, и вместе с t они не встречаются.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# mxl-compile v1.48 — Compile 1C spreadsheet from JSON
|
# mxl-compile v1.49 — Compile 1C spreadsheet from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -1612,7 +1612,7 @@ if ($def.pictures) {
|
|||||||
}
|
}
|
||||||
if (-not $entry.Ref -and -not $entry.Data -and
|
if (-not $entry.Ref -and -not $entry.Data -and
|
||||||
($entry.Transparent -or $entry.PixelX)) {
|
($entry.Transparent -or $entry.PixelX)) {
|
||||||
[Console]::Error.WriteLine("pictures[$($pr.Name)]: 'transparent' and 'transparentPixel' require 'data'")
|
[Console]::Error.WriteLine("pictures[$($pr.Name)]: 'transparent' and 'transparentPixel' require 'ref' or 'data'")
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
$pictureEntries += $entry
|
$pictureEntries += $entry
|
||||||
@@ -2572,13 +2572,15 @@ $picIdx = 0
|
|||||||
foreach ($pic in $pictureEntries) {
|
foreach ($pic in $pictureEntries) {
|
||||||
X "`t<picture>"
|
X "`t<picture>"
|
||||||
X "`t`t<index>$picIdx</index>"
|
X "`t`t<index>$picIdx</index>"
|
||||||
|
# Прозрачность записывается перед ссылкой и не зависит от того, где лежит картинка:
|
||||||
|
# в БП 8.3.27 таких ссылочных записей 67.
|
||||||
|
$attr = if ($pic.Transparent) { " t=`"$($pic.Transparent)`"" } else { '' }
|
||||||
|
if ($pic.PixelX) { $attr += " tx=`"$($pic.PixelX)`" ty=`"$($pic.PixelY)`"" }
|
||||||
if ($pic.Ref) {
|
if ($pic.Ref) {
|
||||||
X "`t`t<picture ref=`"$(Esc-Xml $pic.Ref)`"/>"
|
X "`t`t<picture$attr ref=`"$(Esc-Xml $pic.Ref)`"/>"
|
||||||
} elseif (-not $pic.Data) {
|
} elseif (-not $pic.Data) {
|
||||||
X "`t`t<picture/>"
|
X "`t`t<picture/>"
|
||||||
} else {
|
} else {
|
||||||
$attr = if ($pic.Transparent) { " t=`"$($pic.Transparent)`"" } else { '' }
|
|
||||||
if ($pic.PixelX) { $attr += " tx=`"$($pic.PixelX)`" ty=`"$($pic.PixelY)`"" }
|
|
||||||
# Данные платформа переносит по строкам тем же переводом, что и весь файл, —
|
# Данные платформа переносит по строкам тем же переводом, что и весь файл, —
|
||||||
# в отличие от блоба настроек элемента управления, где перенос голый LF.
|
# в отличие от блоба настроек элемента управления, где перенос голый LF.
|
||||||
$parts = @("$($pic.Data)" -split "`r?`n")
|
$parts = @("$($pic.Data)" -split "`r?`n")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# mxl-compile v1.48 — Compile 1C spreadsheet from JSON
|
# mxl-compile v1.49 — Compile 1C spreadsheet from JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
@@ -1567,7 +1567,7 @@ def main():
|
|||||||
entry['PixelX'] = str(int(pic_def['transparentPixel'].get('x', 0)))
|
entry['PixelX'] = str(int(pic_def['transparentPixel'].get('x', 0)))
|
||||||
entry['PixelY'] = str(int(pic_def['transparentPixel'].get('y', 0)))
|
entry['PixelY'] = str(int(pic_def['transparentPixel'].get('y', 0)))
|
||||||
if not entry['Ref'] and not entry['Data'] and (entry['Transparent'] or entry['PixelX']):
|
if not entry['Ref'] and not entry['Data'] and (entry['Transparent'] or entry['PixelX']):
|
||||||
print(f"pictures[{pic_name}]: 'transparent' and 'transparentPixel' require 'data'", file=sys.stderr)
|
print(f"pictures[{pic_name}]: 'transparent' and 'transparentPixel' require 'ref' or 'data'", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
picture_entries.append(entry)
|
picture_entries.append(entry)
|
||||||
picture_names[pic_name] = len(picture_entries)
|
picture_names[pic_name] = len(picture_entries)
|
||||||
@@ -2424,14 +2424,16 @@ def main():
|
|||||||
for pic_i, pic in enumerate(picture_entries):
|
for pic_i, pic in enumerate(picture_entries):
|
||||||
lines.append('\t<picture>')
|
lines.append('\t<picture>')
|
||||||
lines.append(f'\t\t<index>{pic_i}</index>')
|
lines.append(f'\t\t<index>{pic_i}</index>')
|
||||||
|
# Прозрачность записывается перед ссылкой и не зависит от того, где лежит картинка:
|
||||||
|
# в БП 8.3.27 таких ссылочных записей 67.
|
||||||
|
attr = f' t="{pic["Transparent"]}"' if pic['Transparent'] else ''
|
||||||
|
if pic['PixelX']:
|
||||||
|
attr += f' tx="{pic["PixelX"]}" ty="{pic["PixelY"]}"'
|
||||||
if pic['Ref']:
|
if pic['Ref']:
|
||||||
lines.append(f'\t\t<picture ref="{esc_xml(pic["Ref"])}"/>')
|
lines.append(f'\t\t<picture{attr} ref="{esc_xml(pic["Ref"])}"/>')
|
||||||
elif not pic['Data']:
|
elif not pic['Data']:
|
||||||
lines.append('\t\t<picture/>')
|
lines.append('\t\t<picture/>')
|
||||||
else:
|
else:
|
||||||
attr = f' t="{pic["Transparent"]}"' if pic['Transparent'] else ''
|
|
||||||
if pic['PixelX']:
|
|
||||||
attr += f' tx="{pic["PixelX"]}" ty="{pic["PixelY"]}"'
|
|
||||||
# Данные платформа переносит по строкам тем же переводом, что и весь файл, —
|
# Данные платформа переносит по строкам тем же переводом, что и весь файл, —
|
||||||
# в отличие от блоба настроек элемента управления, где перенос голый LF.
|
# в отличие от блоба настроек элемента управления, где перенос голый LF.
|
||||||
parts = str(pic['Data']).replace('\r\n', '\n').split('\n')
|
parts = str(pic['Data']).replace('\r\n', '\n').split('\n')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# mxl-decompile v1.27 — Decompile 1C spreadsheet to JSON
|
# mxl-decompile v1.28 — Decompile 1C spreadsheet to JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -283,14 +283,16 @@ foreach ($picNode in $root.SelectNodes("d:picture", $ns)) {
|
|||||||
# System.Xml переводы строк в тексте не нормализует, а lxml нормализует: без этой
|
# System.Xml переводы строк в тексте не нормализует, а lxml нормализует: без этой
|
||||||
# замены порты дали бы разный JSON на одном и том же файле.
|
# замены порты дали бы разный JSON на одном и том же файле.
|
||||||
$entry["data"] = ($inner.InnerText -replace "`r`n", "`n").Trim()
|
$entry["data"] = ($inner.InnerText -replace "`r`n", "`n").Trim()
|
||||||
if ($inner.HasAttribute('t')) { $entry["transparent"] = ($inner.GetAttribute('t') -ceq 'true') }
|
}
|
||||||
# Пиксель прозрачного цвета: координата внутри самой картинки (проверено —
|
# Прозрачность живёт и у ссылочной картинки (в БП 8.3.27 таких записей 67), поэтому
|
||||||
# это не её размеры). В корпусе встречается без атрибута t.
|
# читаем её вне ветвления. Пиксель прозрачного цвета — координата внутри картинки.
|
||||||
if ($inner.HasAttribute('tx')) {
|
if ($entry.Count -gt 0 -and $inner.HasAttribute('t')) {
|
||||||
$entry["transparentPixel"] = [ordered]@{
|
$entry["transparent"] = ($inner.GetAttribute('t') -ceq 'true')
|
||||||
x = [int]$inner.GetAttribute('tx')
|
}
|
||||||
y = [int]$inner.GetAttribute('ty')
|
if ($entry.Count -gt 0 -and $inner.HasAttribute('tx')) {
|
||||||
}
|
$entry["transparentPixel"] = [ordered]@{
|
||||||
|
x = [int]$inner.GetAttribute('tx')
|
||||||
|
y = [int]$inner.GetAttribute('ty')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$picturesOut[$name] = $entry
|
$picturesOut[$name] = $entry
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# mxl-decompile v1.27 — Decompile 1C spreadsheet to JSON
|
# mxl-decompile v1.28 — Decompile 1C spreadsheet to JSON
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
@@ -446,13 +446,13 @@ def main():
|
|||||||
entry["ref"] = inner.get("ref")
|
entry["ref"] = inner.get("ref")
|
||||||
elif (inner.text or "").strip():
|
elif (inner.text or "").strip():
|
||||||
entry["data"] = (inner.text or "").strip()
|
entry["data"] = (inner.text or "").strip()
|
||||||
if inner.get("t") is not None:
|
# Прозрачность живёт и у ссылочной картинки (в БП 8.3.27 таких записей 67), поэтому
|
||||||
entry["transparent"] = inner.get("t") == "true"
|
# читаем её вне ветвления. Пиксель прозрачного цвета — координата внутри картинки.
|
||||||
# Пиксель прозрачного цвета: координата внутри самой картинки (проверено —
|
if entry and inner.get("t") is not None:
|
||||||
# это не её размеры). В корпусе встречается без атрибута t.
|
entry["transparent"] = inner.get("t") == "true"
|
||||||
if inner.get("tx") is not None:
|
if entry and inner.get("tx") is not None:
|
||||||
entry["transparentPixel"] = OrderedDict([("x", int(inner.get("tx"))),
|
entry["transparentPixel"] = OrderedDict([("x", int(inner.get("tx"))),
|
||||||
("y", int(inner.get("ty") or 0))])
|
("y", int(inner.get("ty") or 0))])
|
||||||
pictures_out[name] = entry
|
pictures_out[name] = entry
|
||||||
picture_key[pic_i] = name
|
picture_key[pic_i] = name
|
||||||
|
|
||||||
|
|||||||
@@ -744,6 +744,11 @@ AARnQUlBAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAA</picture>
|
|||||||
в корпусе встречается `tx="97" ty="83"` при картинке 368×117, то есть Конфигуратор углом
|
в корпусе встречается `tx="97" ty="83"` при картинке 368×117, то есть Конфигуратор углом
|
||||||
не ограничен.
|
не ограничен.
|
||||||
|
|
||||||
|
Прозрачность не привязана к тому, где лежит картинка: `t` пишется и у ссылочной записи, причём
|
||||||
|
ПЕРЕД `ref` — `<picture t="false" ref="v8ui:Имя"/>`. В «Бухгалтерии предприятия» на 8.3.27 таких
|
||||||
|
записей 67, а `t="false"` стоит у 11 135 картинок; значения `true` у этого атрибута не бывает
|
||||||
|
ни в одной проверенной конфигурации — включённую прозрачность выражают `tx`/`ty`.
|
||||||
|
|
||||||
## Рисунки
|
## Рисунки
|
||||||
|
|
||||||
Рисунок — объект поверх сетки: картинка, фигура, надпись, диаграмма. Лежит в `<drawing>`
|
Рисунок — объект поверх сетки: картинка, фигура, надпись, диаграмма. Лежит в `<drawing>`
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
"areas": [{ "rows": [["Бланк"]] }]
|
"areas": [{ "rows": [["Бланк"]] }]
|
||||||
},
|
},
|
||||||
"params": { "outputPath": "Template.xml" },
|
"params": { "outputPath": "Template.xml" },
|
||||||
"expectError": "pictures[пусто]: 'transparent' and 'transparentPixel' require 'data'"
|
"expectError": "pictures[пусто]: 'transparent' and 'transparentPixel' require 'ref' or 'data'"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
"columns": 2,
|
"columns": 2,
|
||||||
"pictures": {
|
"pictures": {
|
||||||
"пусто": {},
|
"пусто": {},
|
||||||
|
"значок": { "ref": "v8ui:Стоп48", "transparent": false },
|
||||||
"точка": {
|
"точка": {
|
||||||
"data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==",
|
"data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==",
|
||||||
"transparent": true,
|
|
||||||
"transparentPixel": { "x": 3, "y": 5 }
|
"transparentPixel": { "x": 3, "y": 5 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+6
-2
@@ -43,7 +43,7 @@
|
|||||||
<autoSize>false</autoSize>
|
<autoSize>false</autoSize>
|
||||||
<pictureSize>Stretch</pictureSize>
|
<pictureSize>Stretch</pictureSize>
|
||||||
<zOrder>1</zOrder>
|
<zOrder>1</zOrder>
|
||||||
<pictureIndex>2</pictureIndex>
|
<pictureIndex>3</pictureIndex>
|
||||||
</drawing>
|
</drawing>
|
||||||
<templateMode>true</templateMode>
|
<templateMode>true</templateMode>
|
||||||
<defaultFormatIndex>1</defaultFormatIndex>
|
<defaultFormatIndex>1</defaultFormatIndex>
|
||||||
@@ -58,6 +58,10 @@
|
|||||||
</picture>
|
</picture>
|
||||||
<picture>
|
<picture>
|
||||||
<index>1</index>
|
<index>1</index>
|
||||||
<picture t="true" tx="3" ty="5">iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==</picture>
|
<picture t="false" ref="v8ui:Стоп48"/>
|
||||||
|
</picture>
|
||||||
|
<picture>
|
||||||
|
<index>2</index>
|
||||||
|
<picture tx="3" ty="5">iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/q842iQAAAABJRU5ErkJggg==</picture>
|
||||||
</picture>
|
</picture>
|
||||||
</document>
|
</document>
|
||||||
Reference in New Issue
Block a user