ooxml-core 1.8.3 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PptxHandler-AT7FVG5Q.mjs +2 -0
- package/dist/{PptxHandler-BL4B7CZO.mjs → PptxHandler-EX4WBIQQ.mjs} +2 -2
- package/dist/PptxHandler-VFSCECPL.cjs +11 -0
- package/dist/automation/index.cjs +7380 -4682
- package/dist/automation/index.mjs +7380 -4682
- package/dist/chunk-AT66SA5M.cjs +44423 -0
- package/dist/{chunk-TTPZITQN.mjs → chunk-FIELY5PI.mjs} +1 -1
- package/dist/{chunk-ZAP5WLEN.mjs → chunk-IGOA57LE.mjs} +1 -1
- package/dist/chunk-LCS3J3QI.mjs +87604 -0
- package/dist/{chunk-NIHPA63A.mjs → chunk-M76PHYRR.mjs} +54 -37
- package/dist/chunk-OB277ZGE.mjs +44107 -0
- package/dist/{chunk-GAGSCAR3.mjs → chunk-OXHMZS7B.mjs} +552 -178
- package/dist/chunk-SWF7KVL5.cjs +87610 -0
- package/dist/{chunk-Z7IQR4S4.mjs → chunk-WSO4T2LJ.mjs} +246 -21
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/cell-blocks.d.ts +4 -0
- package/dist/docx/cell-blocks.d.ts.map +1 -0
- package/dist/docx/document-paragraphs.d.ts.map +1 -1
- package/dist/docx/document-parts.d.ts +2 -0
- package/dist/docx/document-parts.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +189 -20
- package/dist/docx/embedded.mjs +189 -20
- package/dist/docx/index.cjs +219 -24
- package/dist/docx/index.mjs +219 -24
- package/dist/docx/layout/adapt-table.d.ts.map +1 -1
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/flow-paragraph.d.ts +5 -0
- package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
- package/dist/docx/layout/flow-table.d.ts +2 -1
- package/dist/docx/layout/flow-table.d.ts.map +1 -1
- package/dist/docx/layout/footnote-columns.d.ts +22 -0
- package/dist/docx/layout/footnote-columns.d.ts.map +1 -0
- package/dist/docx/layout/footnote-flow.d.ts +27 -0
- package/dist/docx/layout/footnote-flow.d.ts.map +1 -0
- package/dist/docx/layout/footnote-split.d.ts +7 -0
- package/dist/docx/layout/footnote-split.d.ts.map +1 -0
- package/dist/docx/layout/index.cjs +1099 -92
- package/dist/docx/layout/index.mjs +1099 -92
- package/dist/docx/layout/input.d.ts +17 -1
- package/dist/docx/layout/input.d.ts.map +1 -1
- package/dist/docx/layout/legacy-footnote-flow.d.ts +18 -0
- package/dist/docx/layout/legacy-footnote-flow.d.ts.map +1 -0
- package/dist/docx/layout/line-metrics.d.ts.map +1 -1
- package/dist/docx/layout/page-cursor.d.ts +13 -8
- package/dist/docx/layout/page-cursor.d.ts.map +1 -1
- package/dist/docx/layout/page-flow.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
- package/dist/docx/layout/paragraph-tokens.d.ts +2 -0
- package/dist/docx/layout/paragraph-tokens.d.ts.map +1 -1
- package/dist/docx/layout/reference-footnotes.d.ts +7 -0
- package/dist/docx/layout/reference-footnotes.d.ts.map +1 -0
- package/dist/docx/layout/result.d.ts +31 -0
- package/dist/docx/layout/result.d.ts.map +1 -1
- package/dist/docx/layout/section-flow.d.ts +2 -0
- package/dist/docx/layout/section-flow.d.ts.map +1 -1
- package/dist/docx/layout/table-cell-layout.d.ts +11 -0
- package/dist/docx/layout/table-cell-layout.d.ts.map +1 -0
- package/dist/docx/layout/table-footnotes.d.ts +27 -0
- package/dist/docx/layout/table-footnotes.d.ts.map +1 -0
- package/dist/docx/layout/table-layout.d.ts +10 -4
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +194 -25
- package/dist/docx/load/index.mjs +194 -25
- package/dist/docx/model-run.d.ts +2 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/model.d.ts +7 -0
- package/dist/docx/model.d.ts.map +1 -1
- package/dist/docx/notes.d.ts +5 -0
- package/dist/docx/notes.d.ts.map +1 -1
- package/dist/docx/parse-table.d.ts.map +1 -1
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/save.d.ts.map +1 -1
- package/dist/docx/section-model.d.ts +2 -0
- package/dist/docx/section-model.d.ts.map +1 -1
- package/dist/docx/sections.d.ts.map +1 -1
- package/dist/docx/settings.d.ts +2 -0
- package/dist/docx/settings.d.ts.map +1 -1
- package/dist/docx/table-model.d.ts +3 -1
- package/dist/docx/table-model.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +55 -0
- package/dist/docx/ui/index.d.ts +1 -0
- package/dist/docx/ui/index.d.ts.map +1 -1
- package/dist/docx/ui/index.mjs +55 -1
- package/dist/docx/ui/table-structure-guard.d.ts +4 -0
- package/dist/docx/ui/table-structure-guard.d.ts.map +1 -0
- package/dist/docx/write-footnote-columns.d.ts +3 -0
- package/dist/docx/write-footnote-columns.d.ts.map +1 -0
- package/dist/docx/write-notes.d.ts.map +1 -1
- package/dist/docx/write-run.d.ts.map +1 -1
- package/dist/docx/write-sections.d.ts.map +1 -1
- package/dist/index.cjs +8 -5
- package/dist/index.mjs +8 -5
- package/dist/opc/clone-part-graph.d.ts +4 -0
- package/dist/opc/clone-part-graph.d.ts.map +1 -1
- package/dist/opc/index.cjs +8 -5
- package/dist/opc/index.mjs +8 -5
- package/dist/pptx/automation/index.cjs +621 -207
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-Cn-GzYGp.d.ts → index-B4cnSPNz.d.ts} +33 -4
- package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-CKIUurnd.d.ts → index-BZh-IMkN.d.ts} +14 -9
- package/dist/pptx/chunks/{index-CKIUurnd.d.ts.map → index-BZh-IMkN.d.ts.map} +1 -1
- package/dist/pptx/chunks/{text-operations-BHfAm5K9.d.ts → text-operations-BLodkuXE.d.ts} +29 -12
- package/dist/pptx/chunks/text-operations-BLodkuXE.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +622 -213
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +53 -36
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/find-replace.cjs +416 -45
- package/dist/pptx/editor/render/find-replace.d.ts +35 -4
- package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +416 -46
- package/dist/pptx/editor/render/slide-operations.cjs +87 -0
- package/dist/pptx/editor/render/slide-operations.d.ts +17 -1
- package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-operations.mjs +83 -1
- package/dist/pptx/editor/render/slide-search.cjs +6 -10
- package/dist/pptx/editor/render/slide-search.d.ts +1 -1
- package/dist/pptx/editor/render/slide-search.mjs +6 -10
- package/dist/pptx/editor/render/template-editing.d.ts +1 -1
- package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
- package/dist/pptx/index.cjs +889 -237
- package/dist/pptx/index.d.ts +4 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +672 -37
- package/dist/teams/index.mjs +672 -37
- package/dist/visio/accessibility.d.ts +10 -0
- package/dist/visio/accessibility.d.ts.map +1 -0
- package/dist/visio/cell-formula.d.ts +2 -0
- package/dist/visio/cell-formula.d.ts.map +1 -1
- package/dist/visio/connector-curve-aligned.d.ts +5 -0
- package/dist/visio/connector-curve-aligned.d.ts.map +1 -0
- package/dist/visio/connector-curve-spans.d.ts +14 -0
- package/dist/visio/connector-curve-spans.d.ts.map +1 -0
- package/dist/visio/connector-jumps.d.ts +5 -0
- package/dist/visio/connector-jumps.d.ts.map +1 -0
- package/dist/visio/connector-route-walk.d.ts +2 -1
- package/dist/visio/connector-route-walk.d.ts.map +1 -1
- package/dist/visio/edit-alt-text-scope.d.ts +5 -0
- package/dist/visio/edit-alt-text-scope.d.ts.map +1 -0
- package/dist/visio/edit-alt-text.d.ts +3 -0
- package/dist/visio/edit-alt-text.d.ts.map +1 -0
- package/dist/visio/edit-commands.d.ts +7 -2
- package/dist/visio/edit-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-commands.d.ts +5 -0
- package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
- package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
- package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
- package/dist/visio/edit-line-jump-cache.d.ts +4 -0
- package/dist/visio/edit-line-jump-cache.d.ts.map +1 -0
- package/dist/visio/edit-master-index.d.ts.map +1 -1
- package/dist/visio/edit-metadata-commands.d.ts +10 -2
- package/dist/visio/edit-metadata-commands.d.ts.map +1 -1
- package/dist/visio/edit-metadata.d.ts +3 -1
- package/dist/visio/edit-metadata.d.ts.map +1 -1
- package/dist/visio/edit-page-alt-text.d.ts +4 -0
- package/dist/visio/edit-page-alt-text.d.ts.map +1 -0
- package/dist/visio/edit-page-layout.d.ts.map +1 -1
- package/dist/visio/edit-page-rename.d.ts.map +1 -1
- package/dist/visio/edit-page-setup-commands.d.ts +7 -1
- package/dist/visio/edit-page-setup-commands.d.ts.map +1 -1
- package/dist/visio/edit-page-size.d.ts.map +1 -1
- package/dist/visio/edit-pages.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/edit-shape-create.d.ts.map +1 -1
- package/dist/visio/edit-stencil-connector-write.d.ts.map +1 -1
- package/dist/visio/edit-style-admission.d.ts.map +1 -1
- package/dist/visio/edit-text.d.ts.map +1 -1
- package/dist/visio/edit.d.ts +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +1091 -233
- package/dist/visio/index.d.ts +2 -1
- package/dist/visio/index.d.ts.map +1 -1
- package/dist/visio/index.mjs +1091 -234
- package/dist/visio/line-jumps.d.ts +1 -5
- package/dist/visio/line-jumps.d.ts.map +1 -1
- package/dist/visio/model.d.ts +13 -0
- package/dist/visio/model.d.ts.map +1 -1
- package/dist/visio/page-layout.d.ts +11 -2
- package/dist/visio/page-layout.d.ts.map +1 -1
- package/dist/visio/parser.d.ts.map +1 -1
- package/dist/visio/shape-metadata.d.ts +6 -0
- package/dist/visio/shape-metadata.d.ts.map +1 -1
- package/dist/visio/shapes.d.ts.map +1 -1
- package/dist/visio/text-field-case.d.ts +2 -0
- package/dist/visio/text-field-case.d.ts.map +1 -0
- package/dist/visio/text-field-display.d.ts.map +1 -1
- package/dist/visio/text-field-numeric.d.ts +4 -0
- package/dist/visio/text-field-numeric.d.ts.map +1 -0
- package/dist/visio/ui/connector-preview.d.ts +1 -1
- package/dist/visio/ui/connector-preview.d.ts.map +1 -1
- package/dist/visio/ui/data-graphic-rules.d.ts +2 -0
- package/dist/visio/ui/data-graphic-rules.d.ts.map +1 -1
- package/dist/visio/ui/data-graphics.d.ts +3 -2
- package/dist/visio/ui/data-graphics.d.ts.map +1 -1
- package/dist/visio/ui/edit-commands.d.ts.map +1 -1
- package/dist/visio/ui/index.cjs +16898 -15855
- package/dist/visio/ui/index.mjs +16898 -15856
- package/dist/visio/ui/scene-details.d.ts.map +1 -1
- package/dist/visio/ui/scene-validation.d.ts.map +1 -1
- package/dist/visio/ui/snapshot-scene.d.ts +2 -1
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
- package/dist/visio/xml-attribute-whitespace.d.ts +5 -0
- package/dist/visio/xml-attribute-whitespace.d.ts.map +1 -0
- package/dist/xlsx/edit/index.d.ts +1 -0
- package/dist/xlsx/edit/index.d.ts.map +1 -1
- package/dist/xlsx/edit/insert-guard.d.ts.map +1 -1
- package/dist/xlsx/edit/merge.d.ts.map +1 -1
- package/dist/xlsx/edit/page-breaks.d.ts +5 -0
- package/dist/xlsx/edit/page-breaks.d.ts.map +1 -0
- package/dist/xlsx/edit/pivots.d.ts +8 -0
- package/dist/xlsx/edit/pivots.d.ts.map +1 -0
- package/dist/xlsx/edit/print-titles.d.ts +7 -0
- package/dist/xlsx/edit/print-titles.d.ts.map +1 -0
- package/dist/xlsx/edit/session.d.ts.map +1 -1
- package/dist/xlsx/edit/sheets.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-formulas.d.ts.map +1 -1
- package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
- package/dist/xlsx/edit/sparkline-ranges.d.ts +11 -0
- package/dist/xlsx/edit/sparkline-ranges.d.ts.map +1 -0
- package/dist/xlsx/edit/sparkline-xml.d.ts +13 -0
- package/dist/xlsx/edit/sparkline-xml.d.ts.map +1 -0
- package/dist/xlsx/edit/sparklines.d.ts +16 -0
- package/dist/xlsx/edit/sparklines.d.ts.map +1 -0
- package/dist/xlsx/edit/table-edits.d.ts.map +1 -1
- package/dist/xlsx/edit/tables.d.ts.map +1 -1
- package/dist/xlsx/edit/types.d.ts +22 -1
- package/dist/xlsx/edit/types.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +3415 -1374
- package/dist/xlsx/index.d.ts +1 -0
- package/dist/xlsx/index.d.ts.map +1 -1
- package/dist/xlsx/index.mjs +3396 -1375
- package/dist/xlsx/layout/cell-view.d.ts +2 -0
- package/dist/xlsx/layout/cell-view.d.ts.map +1 -1
- package/dist/xlsx/layout/header-footer.d.ts +58 -0
- package/dist/xlsx/layout/header-footer.d.ts.map +1 -0
- package/dist/xlsx/layout/index.d.ts +5 -0
- package/dist/xlsx/layout/index.d.ts.map +1 -1
- package/dist/xlsx/layout/print-breaks.d.ts +11 -0
- package/dist/xlsx/layout/print-breaks.d.ts.map +1 -0
- package/dist/xlsx/layout/print-layout.d.ts +34 -0
- package/dist/xlsx/layout/print-layout.d.ts.map +1 -0
- package/dist/xlsx/layout/print-merges.d.ts +18 -0
- package/dist/xlsx/layout/print-merges.d.ts.map +1 -0
- package/dist/xlsx/layout/print-repeat.d.ts +12 -0
- package/dist/xlsx/layout/print-repeat.d.ts.map +1 -0
- package/dist/xlsx/layout/print-titles.d.ts +20 -0
- package/dist/xlsx/layout/print-titles.d.ts.map +1 -0
- package/dist/xlsx/layout/sparkline-data.d.ts.map +1 -1
- package/dist/xlsx/layout/sparkline-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +7831 -6961
- package/dist/xlsx/load/index.mjs +7831 -6961
- package/dist/xlsx/model-pivots.d.ts +46 -0
- package/dist/xlsx/model-pivots.d.ts.map +1 -0
- package/dist/xlsx/model.d.ts +5 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/pivot/admission.d.ts +5 -0
- package/dist/xlsx/pivot/admission.d.ts.map +1 -0
- package/dist/xlsx/pivot/aggregate.d.ts +19 -0
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -0
- package/dist/xlsx/pivot/cache-xml.d.ts +9 -0
- package/dist/xlsx/pivot/cache-xml.d.ts.map +1 -0
- package/dist/xlsx/pivot/data.d.ts +12 -0
- package/dist/xlsx/pivot/data.d.ts.map +1 -0
- package/dist/xlsx/pivot/hierarchy.d.ts +7 -0
- package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -0
- package/dist/xlsx/pivot/index.d.ts +3 -0
- package/dist/xlsx/pivot/index.d.ts.map +1 -0
- package/dist/xlsx/pivot/read.d.ts +5 -0
- package/dist/xlsx/pivot/read.d.ts.map +1 -0
- package/dist/xlsx/pivot/table-xml.d.ts +5 -0
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -0
- package/dist/xlsx/pivot/write.d.ts +11 -0
- package/dist/xlsx/pivot/write.d.ts.map +1 -0
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/sheet-props.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/print-layout.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/print-layout.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/sparklines.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/page-breaks.d.ts +3 -0
- package/dist/xlsx/ui/commands/page-breaks.d.ts.map +1 -0
- package/dist/xlsx/ui/index.cjs +2451 -737
- package/dist/xlsx/ui/index.d.ts +1 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -1
- package/dist/xlsx/ui/index.mjs +2451 -738
- package/dist/xlsx/write/chart-cache.d.ts +8 -0
- package/dist/xlsx/write/chart-cache.d.ts.map +1 -0
- package/dist/xlsx/write/page-setup.d.ts.map +1 -1
- package/dist/xlsx/write/save.d.ts.map +1 -1
- package/dist/xlsx/write/sheet-parts.d.ts +1 -0
- package/dist/xlsx/write/sheet-parts.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/worksheet.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/pptx/chunks/index-Cn-GzYGp.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BHfAm5K9.d.ts.map +0 -1
package/dist/visio/index.cjs
CHANGED
|
@@ -1314,15 +1314,16 @@ function inspect(bytes, limits) {
|
|
|
1314
1314
|
// visio/edit-metadata-commands.ts
|
|
1315
1315
|
var VISIO_METADATA_TEXT_LIMIT = 4096;
|
|
1316
1316
|
var VISIO_PICTURE_MAX_BYTES = VISIO_RASTER_IMAGE_LIMITS.maxImageBytes;
|
|
1317
|
-
var isVisioMetadataEdit = (edit) => edit.type === "set-shape-hyperlink" || edit.type === "set-shape-screentip";
|
|
1317
|
+
var isVisioMetadataEdit = (edit) => edit.type === "set-shape-hyperlink" || edit.type === "set-shape-screentip" || edit.type === "set-shape-alt-text";
|
|
1318
1318
|
var invalidText = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
|
|
1319
|
-
function
|
|
1319
|
+
function metadataText(value, singleLine2) {
|
|
1320
1320
|
if (typeof value !== "string" || value.length > VISIO_METADATA_TEXT_LIMIT)
|
|
1321
|
-
fail("INVALID_EDIT", "
|
|
1322
|
-
if (invalidText.test(value) || /[\r\n\t]/.test(value))
|
|
1323
|
-
fail("INVALID_EDIT_TEXT", "
|
|
1321
|
+
fail("INVALID_EDIT", "Shape metadata text must be strings within the length limit.");
|
|
1322
|
+
if (invalidText.test(value) || singleLine2 && /[\r\n\t]/.test(value))
|
|
1323
|
+
fail("INVALID_EDIT_TEXT", "Shape metadata text contains invalid characters.");
|
|
1324
1324
|
return value;
|
|
1325
1325
|
}
|
|
1326
|
+
var field = metadataText;
|
|
1326
1327
|
function target(edit) {
|
|
1327
1328
|
if (typeof edit.pageId !== "string" || !edit.pageId || edit.pageId.length > 256 || typeof edit.shapeId !== "string" || !/^[1-9]\d{0,9}$/.test(edit.shapeId) || Number(edit.shapeId) > 4294967295)
|
|
1328
1329
|
fail("INVALID_EDIT", "Invalid edit shape target.");
|
|
@@ -1330,8 +1331,15 @@ function target(edit) {
|
|
|
1330
1331
|
}
|
|
1331
1332
|
function snapshotMetadataEdit(edit) {
|
|
1332
1333
|
const base2 = target(edit);
|
|
1334
|
+
if (edit.type === "set-shape-alt-text")
|
|
1335
|
+
return {
|
|
1336
|
+
...base2,
|
|
1337
|
+
type: edit.type,
|
|
1338
|
+
title: field(edit.title, true),
|
|
1339
|
+
description: field(edit.description, false)
|
|
1340
|
+
};
|
|
1333
1341
|
if (edit.type === "set-shape-screentip")
|
|
1334
|
-
return { ...base2, type: edit.type, text: field(edit.text) };
|
|
1342
|
+
return { ...base2, type: edit.type, text: field(edit.text, true) };
|
|
1335
1343
|
if (edit.row !== void 0 && (typeof edit.row !== "string" || !/^[A-Za-z_]\w{0,63}$/.test(edit.row)))
|
|
1336
1344
|
fail("INVALID_EDIT", "Hyperlink row names must be ShapeSheet row names.");
|
|
1337
1345
|
const link = edit.hyperlink;
|
|
@@ -1341,9 +1349,9 @@ function snapshotMetadataEdit(edit) {
|
|
|
1341
1349
|
}
|
|
1342
1350
|
if (!link || typeof link !== "object") fail("INVALID_EDIT", "Invalid hyperlink fields.");
|
|
1343
1351
|
const hyperlink2 = {
|
|
1344
|
-
address: field(link.address).trim(),
|
|
1345
|
-
subAddress: field(link.subAddress).trim(),
|
|
1346
|
-
description: field(link.description)
|
|
1352
|
+
address: field(link.address, true).trim(),
|
|
1353
|
+
subAddress: field(link.subAddress, true).trim(),
|
|
1354
|
+
description: field(link.description, true)
|
|
1347
1355
|
};
|
|
1348
1356
|
if (!hyperlink2.address && !hyperlink2.subAddress)
|
|
1349
1357
|
fail("INVALID_EDIT", "A hyperlink needs an address or a page target.");
|
|
@@ -1579,6 +1587,20 @@ function writeEditedPackage(parts, maxBytes, deadline, check) {
|
|
|
1579
1587
|
});
|
|
1580
1588
|
}
|
|
1581
1589
|
|
|
1590
|
+
// visio/xml-attribute-whitespace.ts
|
|
1591
|
+
function preserveAttributeWhitespace(xml) {
|
|
1592
|
+
return xml.replace(
|
|
1593
|
+
/<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<\/?[^!?\s>][^"'>]*(?:(?:"[^"]*"|'[^']*')[^"'>]*)*>/g,
|
|
1594
|
+
(token) => {
|
|
1595
|
+
if (token.startsWith("<!") || token.startsWith("<?")) return token;
|
|
1596
|
+
return token.replace(
|
|
1597
|
+
/"[^"]*"|'[^']*'/g,
|
|
1598
|
+
(value) => value.replace(/[\t\r\n]/g, (character) => `&#${character.charCodeAt(0)};`)
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1582
1604
|
// visio/cell-formula.ts
|
|
1583
1605
|
function executableCellFormula(source) {
|
|
1584
1606
|
return !source || source === "No Formula" || source === "Inh" ? void 0 : source;
|
|
@@ -1586,6 +1608,7 @@ function executableCellFormula(source) {
|
|
|
1586
1608
|
function inertDoubleClickFormula(cell, source) {
|
|
1587
1609
|
return cell === "EventDblClick" && /^\s*=?\s*(OPENTEXTWIN|DEFAULTEVENT)\(\s*\)\s*$/i.test(source);
|
|
1588
1610
|
}
|
|
1611
|
+
var shapeDataFormulaSection = (name3) => name3 === "Property" ? "Prop" : name3;
|
|
1589
1612
|
|
|
1590
1613
|
// visio/formula-theme.ts
|
|
1591
1614
|
var themeInputs = [
|
|
@@ -2975,6 +2998,19 @@ function createBox(root2, document, edit) {
|
|
|
2975
2998
|
value,
|
|
2976
2999
|
name3 === "LocPinX" ? "Width*0.5" : name3 === "LocPinY" ? "Height*0.5" : void 0
|
|
2977
3000
|
);
|
|
3001
|
+
if (edit.followShapeId !== void 0) {
|
|
3002
|
+
const owner = admitted(root2, edit.followShapeId);
|
|
3003
|
+
const local = cells(owner);
|
|
3004
|
+
if (isLineSheet(local))
|
|
3005
|
+
fail("UNSUPPORTED_GEOMETRY_EDIT", "Position followers require a 2D owner.");
|
|
3006
|
+
for (const [name3, value] of [
|
|
3007
|
+
["PinX", edit.x],
|
|
3008
|
+
["PinY", edit.y]
|
|
3009
|
+
]) {
|
|
3010
|
+
const offset = value - numeric(local.get(name3));
|
|
3011
|
+
setCell(shape, name3, value, `Sheet.${edit.followShapeId}!${name3}+(${offset}IN)`);
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
2978
3014
|
return shape;
|
|
2979
3015
|
}
|
|
2980
3016
|
function createRectangle(root2, document, edit) {
|
|
@@ -3558,7 +3594,7 @@ function indexCells(roots, options) {
|
|
|
3558
3594
|
for (const node2 of children2(sheet.node, "Cell"))
|
|
3559
3595
|
addNode(node2, attribute2(node2, "N") ?? "", false, false, glue);
|
|
3560
3596
|
for (const section3 of children2(sheet.node, "Section")) {
|
|
3561
|
-
const name3 = attribute2(section3, "N") ?? "";
|
|
3597
|
+
const name3 = shapeDataFormulaSection(attribute2(section3, "N") ?? "");
|
|
3562
3598
|
const prefix2 = name3 === "Geometry" ? `Geometry${Number(attribute2(section3, "IX") ?? "0") + 1}` : name3;
|
|
3563
3599
|
const deleted4 = ["1", "true"].includes(attribute2(section3, "Del") ?? "");
|
|
3564
3600
|
for (const node2 of children2(section3, "Cell"))
|
|
@@ -4154,6 +4190,7 @@ function effectiveShapeCell(shape, document, name3, category, rows) {
|
|
|
4154
4190
|
if (delegatedLocal && !(category === "TextStyle" && cellName && ["Character", "Paragraph"].includes(section3)))
|
|
4155
4191
|
fail("EDIT_PROTECTED_CELL", "Inherited formatting cells cannot be overwritten.");
|
|
4156
4192
|
if (local && !cellName) return local;
|
|
4193
|
+
if (/^ConLineJump(?:Code|Style|DirX|DirY)$/.test(name3)) return void 0;
|
|
4157
4194
|
if (cellName) {
|
|
4158
4195
|
const sources = rows?.source ?? effectiveFormattingRows(shape, document, section3);
|
|
4159
4196
|
const cells4 = sources.get(index) ?? sources.get("0");
|
|
@@ -4394,14 +4431,9 @@ function serializeEditedXml(root2, limits, check) {
|
|
|
4394
4431
|
const node2 = pending.pop();
|
|
4395
4432
|
if ((node2.nodeType === 3 || node2.nodeType === 4) && node2.nodeValue?.includes("\r"))
|
|
4396
4433
|
fail("UNSUPPORTED_XML_EDIT", "Carriage-return text cannot be preserved by this writer.");
|
|
4397
|
-
if (node2.nodeType === 1) {
|
|
4398
|
-
for (const attr2 of Array.from(node2.attributes))
|
|
4399
|
-
if (/[\t\r\n]/.test(attr2.value))
|
|
4400
|
-
fail("UNSUPPORTED_XML_EDIT", "Attribute whitespace cannot be preserved by this writer.");
|
|
4401
|
-
}
|
|
4402
4434
|
for (const child3 of Array.from(node2.childNodes)) pending.push(child3);
|
|
4403
4435
|
}
|
|
4404
|
-
let xml = buildXml(root2.ownerDocument);
|
|
4436
|
+
let xml = preserveAttributeWhitespace(buildXml(root2.ownerDocument));
|
|
4405
4437
|
xml = xml.replace(
|
|
4406
4438
|
/^<\?xml\s[^?]*\?>/,
|
|
4407
4439
|
(declaration) => declaration.replace(/encoding\s*=\s*(['"])[^'"]*\1/, 'encoding="UTF-8"')
|
|
@@ -7269,10 +7301,10 @@ function orderedColorTransforms(channels, transforms) {
|
|
|
7269
7301
|
else if (name3 === "inv") [r, g, b] = [255 - r, 255 - g, 255 - b];
|
|
7270
7302
|
else if (name3 === "gray") r = g = b = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
7271
7303
|
else if ((name3 === "shade" || name3 === "tint") && fraction !== void 0) {
|
|
7272
|
-
const
|
|
7304
|
+
const mix3 = (channel) => linearToSrgb255(
|
|
7273
7305
|
name3 === "shade" ? srgb255ToLinear(channel) * fraction : 1 - (1 - srgb255ToLinear(channel)) * fraction
|
|
7274
7306
|
);
|
|
7275
|
-
[r, g, b] = [
|
|
7307
|
+
[r, g, b] = [mix3(r), mix3(g), mix3(b)];
|
|
7276
7308
|
} else {
|
|
7277
7309
|
const hsl = rgbToHsl(r, g, b);
|
|
7278
7310
|
if (name3 === "comp") hsl.h = wrap(hsl.h + 180);
|
|
@@ -8625,6 +8657,230 @@ function characterExtras(cells4, report) {
|
|
|
8625
8657
|
};
|
|
8626
8658
|
}
|
|
8627
8659
|
|
|
8660
|
+
// visio/text-field-case.ts
|
|
8661
|
+
var LOWER = [
|
|
8662
|
+
[65, 90, 1, 32],
|
|
8663
|
+
[192, 214, 1, 32],
|
|
8664
|
+
[216, 222, 1, 32],
|
|
8665
|
+
[256, 302, 2, 1],
|
|
8666
|
+
[304, 304, 2, -199],
|
|
8667
|
+
[306, 310, 2, 1],
|
|
8668
|
+
[313, 327, 2, 1],
|
|
8669
|
+
[330, 374, 2, 1],
|
|
8670
|
+
[376, 376, 1, -121],
|
|
8671
|
+
[377, 381, 2, 1],
|
|
8672
|
+
[385, 385, 1, 210],
|
|
8673
|
+
[386, 388, 2, 1],
|
|
8674
|
+
[390, 390, 1, 206],
|
|
8675
|
+
[391, 391, 2, 1],
|
|
8676
|
+
[393, 394, 1, 205],
|
|
8677
|
+
[395, 395, 1, 1],
|
|
8678
|
+
[398, 398, 1, 79],
|
|
8679
|
+
[399, 399, 1, 202],
|
|
8680
|
+
[400, 400, 1, 203],
|
|
8681
|
+
[401, 401, 2, 1],
|
|
8682
|
+
[403, 403, 1, 205],
|
|
8683
|
+
[404, 404, 2, 207],
|
|
8684
|
+
[406, 406, 1, 211],
|
|
8685
|
+
[407, 407, 1, 209],
|
|
8686
|
+
[408, 408, 1, 1],
|
|
8687
|
+
[412, 412, 1, 211],
|
|
8688
|
+
[413, 413, 2, 213],
|
|
8689
|
+
[415, 415, 1, 214],
|
|
8690
|
+
[416, 420, 2, 1],
|
|
8691
|
+
[422, 422, 1, 218],
|
|
8692
|
+
[423, 423, 2, 1],
|
|
8693
|
+
[425, 425, 1, 218],
|
|
8694
|
+
[428, 428, 2, 1],
|
|
8695
|
+
[430, 430, 1, 218],
|
|
8696
|
+
[431, 431, 2, 1],
|
|
8697
|
+
[433, 434, 1, 217],
|
|
8698
|
+
[435, 437, 2, 1],
|
|
8699
|
+
[439, 439, 1, 219],
|
|
8700
|
+
[440, 440, 1, 1],
|
|
8701
|
+
[444, 444, 1, 1],
|
|
8702
|
+
[452, 452, 1, 2],
|
|
8703
|
+
[453, 453, 2, 1],
|
|
8704
|
+
[455, 455, 1, 2],
|
|
8705
|
+
[456, 456, 2, 1],
|
|
8706
|
+
[458, 458, 1, 2],
|
|
8707
|
+
[459, 475, 2, 1],
|
|
8708
|
+
[478, 494, 2, 1],
|
|
8709
|
+
[497, 497, 1, 2],
|
|
8710
|
+
[498, 500, 2, 1],
|
|
8711
|
+
[502, 502, 1, -97],
|
|
8712
|
+
[503, 503, 1, -56],
|
|
8713
|
+
[504, 542, 2, 1],
|
|
8714
|
+
[544, 544, 2, -130],
|
|
8715
|
+
[546, 562, 2, 1],
|
|
8716
|
+
[570, 570, 1, 10795],
|
|
8717
|
+
[571, 571, 2, 1],
|
|
8718
|
+
[573, 573, 1, -163],
|
|
8719
|
+
[574, 574, 1, 10792],
|
|
8720
|
+
[577, 577, 2, 1],
|
|
8721
|
+
[579, 579, 1, -195],
|
|
8722
|
+
[580, 580, 1, 69],
|
|
8723
|
+
[581, 581, 1, 71],
|
|
8724
|
+
[582, 590, 2, 1],
|
|
8725
|
+
[902, 902, 2, 38],
|
|
8726
|
+
[904, 906, 1, 37],
|
|
8727
|
+
[908, 908, 2, 64],
|
|
8728
|
+
[910, 911, 1, 63],
|
|
8729
|
+
[913, 929, 1, 32],
|
|
8730
|
+
[931, 939, 1, 32],
|
|
8731
|
+
[986, 1006, 2, 1],
|
|
8732
|
+
[1024, 1039, 1, 80],
|
|
8733
|
+
[1040, 1071, 1, 32],
|
|
8734
|
+
[1120, 1152, 2, 1],
|
|
8735
|
+
[1162, 1214, 2, 1],
|
|
8736
|
+
[1216, 1216, 1, 15],
|
|
8737
|
+
[1217, 1229, 2, 1],
|
|
8738
|
+
[1232, 1298, 2, 1],
|
|
8739
|
+
[1329, 1366, 1, 48],
|
|
8740
|
+
[4256, 4293, 1, 48],
|
|
8741
|
+
[7680, 7828, 2, 1],
|
|
8742
|
+
[7840, 7928, 2, 1],
|
|
8743
|
+
[8498, 8498, 1, 28],
|
|
8744
|
+
[8579, 8579, 1, 1],
|
|
8745
|
+
[9398, 9423, 1, 26],
|
|
8746
|
+
[11360, 11360, 2, 1],
|
|
8747
|
+
[11362, 11362, 1, -10743],
|
|
8748
|
+
[11363, 11363, 1, -3814],
|
|
8749
|
+
[11364, 11364, 1, -10727],
|
|
8750
|
+
[11367, 11371, 2, 1],
|
|
8751
|
+
[11381, 11381, 1, 1],
|
|
8752
|
+
[65313, 65338, 1, 32],
|
|
8753
|
+
[66560, 66599, 1, 40],
|
|
8754
|
+
[66736, 66771, 1, 40],
|
|
8755
|
+
[68736, 68786, 1, 64],
|
|
8756
|
+
[71840, 71871, 1, 32],
|
|
8757
|
+
[93760, 93791, 1, 32],
|
|
8758
|
+
[125184, 125217, 1, 34]
|
|
8759
|
+
];
|
|
8760
|
+
var UPPER = [
|
|
8761
|
+
[97, 122, 1, -32],
|
|
8762
|
+
[224, 246, 1, -32],
|
|
8763
|
+
[248, 254, 1, -32],
|
|
8764
|
+
[255, 255, 2, 121],
|
|
8765
|
+
[257, 303, 2, -1],
|
|
8766
|
+
[305, 305, 2, -232],
|
|
8767
|
+
[307, 311, 2, -1],
|
|
8768
|
+
[314, 328, 2, -1],
|
|
8769
|
+
[331, 375, 2, -1],
|
|
8770
|
+
[378, 382, 2, -1],
|
|
8771
|
+
[384, 384, 1, 195],
|
|
8772
|
+
[387, 389, 2, -1],
|
|
8773
|
+
[392, 392, 1, -1],
|
|
8774
|
+
[396, 396, 1, -1],
|
|
8775
|
+
[402, 402, 1, -1],
|
|
8776
|
+
[405, 405, 1, 97],
|
|
8777
|
+
[409, 409, 1, -1],
|
|
8778
|
+
[410, 410, 1, 163],
|
|
8779
|
+
[414, 414, 1, 130],
|
|
8780
|
+
[417, 421, 2, -1],
|
|
8781
|
+
[424, 424, 1, -1],
|
|
8782
|
+
[429, 429, 1, -1],
|
|
8783
|
+
[432, 432, 1, -1],
|
|
8784
|
+
[436, 438, 2, -1],
|
|
8785
|
+
[441, 441, 1, -1],
|
|
8786
|
+
[445, 445, 2, -1],
|
|
8787
|
+
[447, 447, 1, 56],
|
|
8788
|
+
[453, 453, 1, -1],
|
|
8789
|
+
[454, 454, 2, -2],
|
|
8790
|
+
[456, 456, 1, -1],
|
|
8791
|
+
[457, 457, 2, -2],
|
|
8792
|
+
[459, 459, 1, -1],
|
|
8793
|
+
[460, 460, 2, -2],
|
|
8794
|
+
[462, 476, 2, -1],
|
|
8795
|
+
[477, 477, 2, -79],
|
|
8796
|
+
[479, 495, 2, -1],
|
|
8797
|
+
[498, 498, 1, -1],
|
|
8798
|
+
[499, 499, 2, -2],
|
|
8799
|
+
[501, 501, 1, -1],
|
|
8800
|
+
[505, 543, 2, -1],
|
|
8801
|
+
[547, 563, 2, -1],
|
|
8802
|
+
[572, 572, 1, -1],
|
|
8803
|
+
[578, 578, 1, -1],
|
|
8804
|
+
[583, 591, 2, -1],
|
|
8805
|
+
[595, 595, 1, -210],
|
|
8806
|
+
[596, 596, 2, -206],
|
|
8807
|
+
[598, 599, 1, -205],
|
|
8808
|
+
[601, 601, 2, -202],
|
|
8809
|
+
[603, 603, 1, -203],
|
|
8810
|
+
[608, 608, 1, -205],
|
|
8811
|
+
[611, 611, 1, -207],
|
|
8812
|
+
[616, 616, 1, -209],
|
|
8813
|
+
[617, 617, 2, -211],
|
|
8814
|
+
[619, 619, 1, 10743],
|
|
8815
|
+
[623, 623, 1, -211],
|
|
8816
|
+
[626, 626, 1, -213],
|
|
8817
|
+
[629, 629, 1, -214],
|
|
8818
|
+
[637, 637, 1, 10727],
|
|
8819
|
+
[640, 640, 1, -218],
|
|
8820
|
+
[643, 643, 1, -218],
|
|
8821
|
+
[648, 648, 1, -218],
|
|
8822
|
+
[649, 649, 1, -69],
|
|
8823
|
+
[650, 651, 1, -217],
|
|
8824
|
+
[652, 652, 1, -71],
|
|
8825
|
+
[658, 658, 1, -219],
|
|
8826
|
+
[912, 912, 1, 26],
|
|
8827
|
+
[940, 940, 1, -38],
|
|
8828
|
+
[941, 943, 1, -37],
|
|
8829
|
+
[944, 944, 1, -5],
|
|
8830
|
+
[945, 961, 1, -32],
|
|
8831
|
+
[962, 962, 1, -31],
|
|
8832
|
+
[963, 971, 1, -32],
|
|
8833
|
+
[972, 972, 1, -64],
|
|
8834
|
+
[973, 974, 1, -63],
|
|
8835
|
+
[976, 976, 1, -62],
|
|
8836
|
+
[977, 977, 1, -57],
|
|
8837
|
+
[981, 981, 1, -47],
|
|
8838
|
+
[982, 982, 1, -54],
|
|
8839
|
+
[987, 1007, 2, -1],
|
|
8840
|
+
[1008, 1008, 1, -86],
|
|
8841
|
+
[1009, 1009, 1, -80],
|
|
8842
|
+
[1072, 1103, 1, -32],
|
|
8843
|
+
[1104, 1119, 1, -80],
|
|
8844
|
+
[1121, 1153, 2, -1],
|
|
8845
|
+
[1163, 1215, 2, -1],
|
|
8846
|
+
[1218, 1230, 2, -1],
|
|
8847
|
+
[1231, 1231, 2, -15],
|
|
8848
|
+
[1233, 1299, 2, -1],
|
|
8849
|
+
[1377, 1414, 1, -48],
|
|
8850
|
+
[7549, 7549, 1, 3814],
|
|
8851
|
+
[7681, 7829, 2, -1],
|
|
8852
|
+
[7841, 7929, 2, -1],
|
|
8853
|
+
[8526, 8526, 1, -28],
|
|
8854
|
+
[8580, 8580, 1, -1],
|
|
8855
|
+
[9424, 9449, 1, -26],
|
|
8856
|
+
[11361, 11361, 1, -1],
|
|
8857
|
+
[11365, 11365, 1, -10795],
|
|
8858
|
+
[11366, 11366, 2, -10792],
|
|
8859
|
+
[11368, 11372, 2, -1],
|
|
8860
|
+
[11382, 11382, 1, -1],
|
|
8861
|
+
[65345, 65370, 1, -32],
|
|
8862
|
+
[66600, 66639, 1, -40],
|
|
8863
|
+
[66776, 66811, 1, -40],
|
|
8864
|
+
[68800, 68850, 1, -64],
|
|
8865
|
+
[71872, 71903, 1, -32],
|
|
8866
|
+
[93792, 93823, 1, -32],
|
|
8867
|
+
[125218, 125251, 1, -34]
|
|
8868
|
+
];
|
|
8869
|
+
function visioFieldCase(text5, upper) {
|
|
8870
|
+
const ranges = upper ? UPPER : LOWER;
|
|
8871
|
+
return Array.from(text5, (character) => {
|
|
8872
|
+
const point2 = character.codePointAt(0);
|
|
8873
|
+
let low = 0, high = ranges.length;
|
|
8874
|
+
while (low < high) {
|
|
8875
|
+
const middle = low + high >>> 1;
|
|
8876
|
+
if (ranges[middle][1] < point2) low = middle + 1;
|
|
8877
|
+
else high = middle;
|
|
8878
|
+
}
|
|
8879
|
+
const range2 = ranges[low];
|
|
8880
|
+
return range2 && point2 >= range2[0] && (point2 - range2[0]) % range2[2] === 0 ? String.fromCodePoint(point2 + range2[3]) : character;
|
|
8881
|
+
}).join("");
|
|
8882
|
+
}
|
|
8883
|
+
|
|
8628
8884
|
// visio/text-fields.ts
|
|
8629
8885
|
var PROPERTY_FUNCTIONS = {
|
|
8630
8886
|
TITLE: "title",
|
|
@@ -8811,6 +9067,30 @@ function formatVisioFieldValue(value, format4 = "") {
|
|
|
8811
9067
|
return units2 || body === "" ? `${text5}${suffix}` : text5;
|
|
8812
9068
|
}
|
|
8813
9069
|
|
|
9070
|
+
// visio/text-field-numeric.ts
|
|
9071
|
+
function numericFieldPicture(value, code, displayUnit) {
|
|
9072
|
+
if (value.kind !== "number" || code < 2 || code > 9 || !Number.isInteger(code)) return void 0;
|
|
9073
|
+
const unit3 = displayUnit?.toUpperCase() ?? "NUM";
|
|
9074
|
+
const units2 = {
|
|
9075
|
+
NUM: ["scalar", 1, ""],
|
|
9076
|
+
IN: ["length", 1, " in."],
|
|
9077
|
+
MM: ["length", 25.4, " mm."],
|
|
9078
|
+
CM: ["length", 2.54, " cm."],
|
|
9079
|
+
FT: ["length", 1 / 12, " ft."],
|
|
9080
|
+
DEG: ["angle", 180 / Math.PI, " deg."],
|
|
9081
|
+
RAD: ["angle", 1, " rad."]
|
|
9082
|
+
};
|
|
9083
|
+
const definition = Object.hasOwn(units2, unit3) ? units2[unit3] : void 0;
|
|
9084
|
+
if (!definition || definition[0] !== value.unit) return void 0;
|
|
9085
|
+
const decimals = Math.floor((code - 2) / 2);
|
|
9086
|
+
const picture = decimals ? `0.${"0".repeat(decimals)}` : "0";
|
|
9087
|
+
const text5 = formatVisioFieldValue(
|
|
9088
|
+
{ kind: "number", value: value.value * definition[1], unit: "scalar" },
|
|
9089
|
+
picture
|
|
9090
|
+
);
|
|
9091
|
+
return text5 === void 0 ? void 0 : text5 + (code % 2 ? definition[2] : "");
|
|
9092
|
+
}
|
|
9093
|
+
|
|
8814
9094
|
// visio/text-field-display.ts
|
|
8815
9095
|
function cachedValue(value, unit3) {
|
|
8816
9096
|
if (value === void 0) return void 0;
|
|
@@ -8833,11 +9113,21 @@ function textFieldDisplay(element2, sheet, context) {
|
|
|
8833
9113
|
const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
|
|
8834
9114
|
const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
|
|
8835
9115
|
const result = { cached: cached5, ...formula ? { formula } : {} };
|
|
8836
|
-
if (!row2 || !context
|
|
8837
|
-
return { text: cached5, ...result };
|
|
9116
|
+
if (!row2 || !context) return { text: cached5, ...result };
|
|
8838
9117
|
const picture = format4?.value ?? "";
|
|
8839
9118
|
const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
|
|
8840
9119
|
const source = evaluated ?? cachedValue(value?.value, value?.unit);
|
|
9120
|
+
if (format4?.formula && /^\s*FIELDPICTURE\s*\(/i.test(format4.formula)) {
|
|
9121
|
+
const code = /^\s*FIELDPICTURE\s*\(\s*(\d+)\s*\)\s*$/i.exec(format4.formula)?.[1];
|
|
9122
|
+
let text6 = cached5;
|
|
9123
|
+
if (source?.kind === "string") {
|
|
9124
|
+
if (code === "0" || code === "37") text6 = source.text;
|
|
9125
|
+
else if (code === "38" || code === "39") text6 = visioFieldCase(source.text, code === "39");
|
|
9126
|
+
}
|
|
9127
|
+
if (source?.kind === "number" && code !== void 0)
|
|
9128
|
+
text6 = numericFieldPicture(source, Number(code), value?.unit) ?? cached5;
|
|
9129
|
+
return { text: text6, ...result };
|
|
9130
|
+
}
|
|
8841
9131
|
const text5 = source ? formatVisioFieldValue(source, picture) : void 0;
|
|
8842
9132
|
return { text: text5 ?? cached5, ...result };
|
|
8843
9133
|
}
|
|
@@ -9432,7 +9722,7 @@ function geometryPaths(sheet, width, height, report, consume, consumeWork = () =
|
|
|
9432
9722
|
else {
|
|
9433
9723
|
const radius = chord * chord / (8 * Math.abs(bow)) + Math.abs(bow) / 2;
|
|
9434
9724
|
commands.push(
|
|
9435
|
-
`A ${point(radius, radius)} 0 ${Math.abs(bow) > chord / 2 ? 1 : 0} ${bow < 0 ?
|
|
9725
|
+
`A ${point(radius, radius)} 0 ${Math.abs(bow) > chord / 2 ? 1 : 0} ${bow < 0 ? 0 : 1} ${point(x, y)}`
|
|
9436
9726
|
);
|
|
9437
9727
|
}
|
|
9438
9728
|
break;
|
|
@@ -10408,6 +10698,21 @@ function hyperlink(row2, budget, report) {
|
|
|
10408
10698
|
...sortKey === void 0 ? {} : { sortKey }
|
|
10409
10699
|
};
|
|
10410
10700
|
}
|
|
10701
|
+
function alternativeTextMetadata(sheet, report, budget) {
|
|
10702
|
+
const result = {};
|
|
10703
|
+
for (const section3 of sheet.sections.values()) {
|
|
10704
|
+
if (section3.deleted || section3.name !== "User") continue;
|
|
10705
|
+
for (const row2 of section3.rows.values()) {
|
|
10706
|
+
if (row2.deleted || !["visAltText", "visAltDescription"].includes(row2.name ?? row2.index))
|
|
10707
|
+
continue;
|
|
10708
|
+
budget.consumeRow();
|
|
10709
|
+
const value = cached(row2.cells, "Value", budget, report);
|
|
10710
|
+
if (value !== void 0)
|
|
10711
|
+
result[(row2.name ?? row2.index) === "visAltText" ? "accessibilityTitle" : "alternativeText"] = value;
|
|
10712
|
+
}
|
|
10713
|
+
}
|
|
10714
|
+
return result;
|
|
10715
|
+
}
|
|
10411
10716
|
function shapeMetadata(sheet, report, budget = createMetadataBudget()) {
|
|
10412
10717
|
const shapeData = [], hyperlinks = [];
|
|
10413
10718
|
let count = 0;
|
|
@@ -10424,7 +10729,12 @@ function shapeMetadata(sheet, report, budget = createMetadataBudget()) {
|
|
|
10424
10729
|
}
|
|
10425
10730
|
const comment = sheet.cells.get("Comment");
|
|
10426
10731
|
const screenTip = comment?.value && comment.error === void 0 ? budget.retain(comment.value) : void 0;
|
|
10427
|
-
return {
|
|
10732
|
+
return {
|
|
10733
|
+
shapeData,
|
|
10734
|
+
hyperlinks,
|
|
10735
|
+
...alternativeTextMetadata(sheet, report, budget),
|
|
10736
|
+
...screenTip === void 0 ? {} : { screenTip }
|
|
10737
|
+
};
|
|
10428
10738
|
}
|
|
10429
10739
|
|
|
10430
10740
|
// visio/theme-root.ts
|
|
@@ -10783,6 +11093,31 @@ function shapeConnections(sheet, local, inheritedSheet, transform2, oneD, report
|
|
|
10783
11093
|
return result;
|
|
10784
11094
|
}
|
|
10785
11095
|
|
|
11096
|
+
// visio/connector-jumps.ts
|
|
11097
|
+
function readConnectorJumps(cells4, report) {
|
|
11098
|
+
const result = {};
|
|
11099
|
+
for (const [key2, name3, maximum] of [
|
|
11100
|
+
["lineJumpCode", "ConLineJumpCode", 4],
|
|
11101
|
+
["lineJumpStyle", "ConLineJumpStyle", 9],
|
|
11102
|
+
["lineJumpDirectionX", "ConLineJumpDirX", 2],
|
|
11103
|
+
["lineJumpDirectionY", "ConLineJumpDirY", 2]
|
|
11104
|
+
]) {
|
|
11105
|
+
const cell = cells4.get(name3);
|
|
11106
|
+
if (!cell || cell.formula === "Inh") continue;
|
|
11107
|
+
const raw = cell.value?.trim();
|
|
11108
|
+
const value = raw && raw.length <= 64 && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(raw) ? Number(raw) : NaN;
|
|
11109
|
+
if (cell.error !== void 0 || !Number.isInteger(value) || value < 0 || value > maximum) {
|
|
11110
|
+
report(
|
|
11111
|
+
"unsupported-connector-jump",
|
|
11112
|
+
`${name3} has no supported cached value; the page setting is used.`
|
|
11113
|
+
);
|
|
11114
|
+
continue;
|
|
11115
|
+
}
|
|
11116
|
+
result[key2] = value;
|
|
11117
|
+
}
|
|
11118
|
+
return result;
|
|
11119
|
+
}
|
|
11120
|
+
|
|
10786
11121
|
// visio/shapes.ts
|
|
10787
11122
|
function mergeShape(base2, local, context) {
|
|
10788
11123
|
context.consumeExpansion();
|
|
@@ -10945,6 +11280,7 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
|
|
|
10945
11280
|
report("missing-geometry", "Shape has no supported cached geometry.");
|
|
10946
11281
|
return {
|
|
10947
11282
|
...shapeMetadata(sheet, report, context.metadataBudget),
|
|
11283
|
+
...oneD ? readConnectorJumps(sheet.cells, report) : {},
|
|
10948
11284
|
...structureOf(sheet),
|
|
10949
11285
|
id: shape.id,
|
|
10950
11286
|
name: shape.attributes.get("Name") ?? shape.attributes.get("NameU") ?? `Shape ${shape.id}`,
|
|
@@ -11168,6 +11504,12 @@ var VISIO_RULER_DENSITIES = Object.freeze([8, 16, 32]);
|
|
|
11168
11504
|
var VISIO_PAGE_LAYOUT_DEFAULTS = Object.freeze({
|
|
11169
11505
|
lineJumpCode: 1,
|
|
11170
11506
|
lineJumpStyle: 0,
|
|
11507
|
+
lineJumpDirectionX: 0,
|
|
11508
|
+
lineJumpDirectionY: 0,
|
|
11509
|
+
lineJumpFactorX: 2 / 3,
|
|
11510
|
+
lineJumpFactorY: 2 / 3,
|
|
11511
|
+
lineToLineX: 0.125,
|
|
11512
|
+
lineToLineY: 0.125,
|
|
11171
11513
|
gridDensityX: 8,
|
|
11172
11514
|
gridDensityY: 8,
|
|
11173
11515
|
gridSpacingX: 0,
|
|
@@ -11182,6 +11524,12 @@ var VISIO_PAGE_LAYOUT_DEFAULTS = Object.freeze({
|
|
|
11182
11524
|
var NAMES = {
|
|
11183
11525
|
lineJumpCode: "LineJumpCode",
|
|
11184
11526
|
lineJumpStyle: "LineJumpStyle",
|
|
11527
|
+
lineJumpDirectionX: "PageLineJumpDirX",
|
|
11528
|
+
lineJumpDirectionY: "PageLineJumpDirY",
|
|
11529
|
+
lineJumpFactorX: "LineJumpFactorX",
|
|
11530
|
+
lineJumpFactorY: "LineJumpFactorY",
|
|
11531
|
+
lineToLineX: "LineToLineX",
|
|
11532
|
+
lineToLineY: "LineToLineY",
|
|
11185
11533
|
gridDensityX: "XGridDensity",
|
|
11186
11534
|
gridDensityY: "YGridDensity",
|
|
11187
11535
|
gridSpacingX: "XGridSpacing",
|
|
@@ -12043,6 +12391,7 @@ async function parseVsdx(input, options = {}) {
|
|
|
12043
12391
|
localReport("dangling-connection", "A connection references a missing shape.");
|
|
12044
12392
|
pages.push({
|
|
12045
12393
|
id: id3,
|
|
12394
|
+
...alternativeTextMetadata(sheet, localReport, context.metadataBudget),
|
|
12046
12395
|
...pageModes,
|
|
12047
12396
|
...drawingToPageScale === 1 ? {} : { drawingToPageScale },
|
|
12048
12397
|
...pageSetup ? { pageSetup } : {},
|
|
@@ -21580,6 +21929,9 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
|
|
|
21580
21929
|
indexCells(roots, { check });
|
|
21581
21930
|
const shapeId2 = attribute2(shape, "ID");
|
|
21582
21931
|
const changedNames = new Set([...changed.keys()].map((name3) => name3.toLowerCase()));
|
|
21932
|
+
const jumpOnly = [...changedNames].every(
|
|
21933
|
+
(name3) => /^conlinejump(code|style|dirx|diry)$/.test(name3)
|
|
21934
|
+
);
|
|
21583
21935
|
const canonical2 = (name3) => name3.toLowerCase().replace(/^char\.([a-z]+)$/, "character.0.$1").replace(/^para\.([a-z]+)$/, "paragraph.0.$1");
|
|
21584
21936
|
const replaced = new Set(changed.values());
|
|
21585
21937
|
const textEdit = [...changedNames].some(
|
|
@@ -21600,6 +21952,9 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
|
|
|
21600
21952
|
if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
|
|
21601
21953
|
if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
|
|
21602
21954
|
if (isConnectedGlueCell(node2, source)) continue;
|
|
21955
|
+
const owner = node2.parentNode;
|
|
21956
|
+
if (jumpOnly && node2.localName === "Cell" && /^(BegTrigger|EndTrigger)$/.test(attribute2(node2, "N") ?? "") && owner?.localName === "Shape" && owner.parentNode?.parentNode?.localName === "PageContents" && visioGlueTriggerTarget(source) === attribute2(owner, "ID"))
|
|
21957
|
+
continue;
|
|
21603
21958
|
let localShapeId;
|
|
21604
21959
|
let parent = node2;
|
|
21605
21960
|
while (parent?.nodeType === 1) {
|
|
@@ -21682,7 +22037,7 @@ function masterCells(sheet, charge = () => {
|
|
|
21682
22037
|
};
|
|
21683
22038
|
for (const node2 of children2(sheet, "Cell")) add(attribute2(node2, "N") ?? "", node2);
|
|
21684
22039
|
for (const section3 of children2(sheet, "Section")) {
|
|
21685
|
-
const name3 = attribute2(section3, "N") ?? "";
|
|
22040
|
+
const name3 = shapeDataFormulaSection(attribute2(section3, "N") ?? "");
|
|
21686
22041
|
const prefix2 = name3 === "Geometry" ? `Geometry${Number(attribute2(section3, "IX") ?? "0") + 1}` : name3 === "Control" ? "Controls" : name3;
|
|
21687
22042
|
for (const node2 of children2(section3, "Cell"))
|
|
21688
22043
|
add(`${prefix2}.${attribute2(node2, "N") ?? ""}`, node2);
|
|
@@ -23224,6 +23579,99 @@ function connectorObstacles(root2, exclude) {
|
|
|
23224
23579
|
return result;
|
|
23225
23580
|
}
|
|
23226
23581
|
|
|
23582
|
+
// visio/connector-curve-aligned.ts
|
|
23583
|
+
function alignedVisioCurve(begin, end) {
|
|
23584
|
+
const a = begin.shape;
|
|
23585
|
+
const b = end.shape;
|
|
23586
|
+
if (!a || !b) return void 0;
|
|
23587
|
+
for (const shape of [a, b])
|
|
23588
|
+
if (shape.corners.some(
|
|
23589
|
+
(p) => Math.abs(p.x - shape.bounds.minX) > 1e-9 && Math.abs(p.x - shape.bounds.maxX) > 1e-9 || Math.abs(p.y - shape.bounds.minY) > 1e-9 && Math.abs(p.y - shape.bounds.maxY) > 1e-9
|
|
23590
|
+
))
|
|
23591
|
+
return void 0;
|
|
23592
|
+
for (const axis of ["x", "y"]) {
|
|
23593
|
+
const horizontal2 = axis === "x";
|
|
23594
|
+
const low = horizontal2 ? "minY" : "minX";
|
|
23595
|
+
const high = horizontal2 ? "maxY" : "maxX";
|
|
23596
|
+
const overlapLow = Math.max(a.bounds[low], b.bounds[low]);
|
|
23597
|
+
const overlapHigh = Math.min(a.bounds[high], b.bounds[high]);
|
|
23598
|
+
if (overlapHigh - overlapLow <= 1e-9) continue;
|
|
23599
|
+
const forward = b.center[axis] > a.center[axis];
|
|
23600
|
+
const from = horizontal2 ? a.bounds[forward ? "maxX" : "minX"] : a.bounds[forward ? "maxY" : "minY"];
|
|
23601
|
+
const to = horizontal2 ? b.bounds[forward ? "minX" : "maxX"] : b.bounds[forward ? "minY" : "maxY"];
|
|
23602
|
+
if ((to - from) * (forward ? 1 : -1) <= 1e-9) continue;
|
|
23603
|
+
const middle = (overlapLow + overlapHigh) / 2;
|
|
23604
|
+
return [0, 0.25, 0.75, 1].map((t) => {
|
|
23605
|
+
const along = from + (to - from) * t;
|
|
23606
|
+
return horizontal2 ? { x: along, y: middle } : { x: middle, y: along };
|
|
23607
|
+
});
|
|
23608
|
+
}
|
|
23609
|
+
return void 0;
|
|
23610
|
+
}
|
|
23611
|
+
|
|
23612
|
+
// visio/connector-curve-spans.ts
|
|
23613
|
+
var mix = (a, b, t) => ({
|
|
23614
|
+
x: a.x + (b.x - a.x) * t,
|
|
23615
|
+
y: a.y + (b.y - a.y) * t
|
|
23616
|
+
});
|
|
23617
|
+
function cornerCurve(path) {
|
|
23618
|
+
const [begin, corner, end] = path;
|
|
23619
|
+
return [begin, mix(begin, corner, 0.25), corner, mix(corner, end, 0.75), end];
|
|
23620
|
+
}
|
|
23621
|
+
function cornerCurveKnots(points) {
|
|
23622
|
+
const distance4 = (a, b) => Math.hypot(points[b].x - points[a].x, points[b].y - points[a].y) / 3;
|
|
23623
|
+
const internal = distance4(0, 3);
|
|
23624
|
+
return [internal, internal + distance4(1, 4)];
|
|
23625
|
+
}
|
|
23626
|
+
function connectorCurveSpans(points) {
|
|
23627
|
+
if (points.length === 4) return [[...points]];
|
|
23628
|
+
if (points.length !== 5) return [];
|
|
23629
|
+
const [internal, last] = cornerCurveKnots(points);
|
|
23630
|
+
const ratio = internal / last;
|
|
23631
|
+
const left = mix(points[1], points[2], ratio);
|
|
23632
|
+
const right2 = mix(points[2], points[3], ratio);
|
|
23633
|
+
const join = mix(left, right2, ratio);
|
|
23634
|
+
return [
|
|
23635
|
+
[points[0], points[1], left, join],
|
|
23636
|
+
[join, right2, points[3], points[4]]
|
|
23637
|
+
];
|
|
23638
|
+
}
|
|
23639
|
+
function connectorPolylineMiddle(points) {
|
|
23640
|
+
const lengths = points.slice(1).map((p, i) => Math.hypot(p.x - points[i].x, p.y - points[i].y));
|
|
23641
|
+
let remaining = lengths.reduce((sum, length) => sum + length, 0) / 2;
|
|
23642
|
+
for (const [i, length] of lengths.entries()) {
|
|
23643
|
+
if (remaining <= length && length > 0)
|
|
23644
|
+
return mix(points[i], points[i + 1], remaining / length);
|
|
23645
|
+
remaining -= length;
|
|
23646
|
+
}
|
|
23647
|
+
return points.at(-1);
|
|
23648
|
+
}
|
|
23649
|
+
function flattenCornerCurve(points) {
|
|
23650
|
+
const [internal, last] = cornerCurveKnots(points);
|
|
23651
|
+
const flattened = flattenNurbs(
|
|
23652
|
+
points.map((p) => ({ ...p, weight: 1 })),
|
|
23653
|
+
[0, 0, 0, 0, internal, last, last, last, last],
|
|
23654
|
+
3,
|
|
23655
|
+
() => {
|
|
23656
|
+
},
|
|
23657
|
+
() => {
|
|
23658
|
+
}
|
|
23659
|
+
);
|
|
23660
|
+
return flattened ? [points[0], ...flattened] : void 0;
|
|
23661
|
+
}
|
|
23662
|
+
function connectorCurveMiddle(points) {
|
|
23663
|
+
const spans = connectorCurveSpans(points);
|
|
23664
|
+
if (points.length === 5) {
|
|
23665
|
+
const flattened = flattenCornerCurve(points);
|
|
23666
|
+
if (flattened) return connectorPolylineMiddle(flattened);
|
|
23667
|
+
return mix(points[0], points.at(-1), 0.5);
|
|
23668
|
+
}
|
|
23669
|
+
const row2 = [...spans[0]];
|
|
23670
|
+
for (let count = row2.length - 1; count > 0; count--)
|
|
23671
|
+
for (let i = 0; i < count; i++) row2[i] = mix(row2[i], row2[i + 1], 0.5);
|
|
23672
|
+
return row2[0];
|
|
23673
|
+
}
|
|
23674
|
+
|
|
23227
23675
|
// visio/connector-route-walk.ts
|
|
23228
23676
|
var EPSILON3 = 1e-9;
|
|
23229
23677
|
var CHANNEL = 2 * VISIO_ROUTE_CLEARANCE;
|
|
@@ -23292,9 +23740,25 @@ function visioWalkRoute(begin, end, route, obstacles = []) {
|
|
|
23292
23740
|
const q = end.shape ? exit(end.shape, center(begin)) : end.point;
|
|
23293
23741
|
return Math.hypot(q.x - p.x, q.y - p.y) > EPSILON3 ? [p, q] : void 0;
|
|
23294
23742
|
}
|
|
23743
|
+
if (route === "curved") {
|
|
23744
|
+
const aligned = alignedVisioCurve(begin, end);
|
|
23745
|
+
if (aligned && !routeCrossings(aligned, obstacles)) return aligned;
|
|
23746
|
+
}
|
|
23295
23747
|
const path = visioWalkPath(begin, end);
|
|
23296
23748
|
if (!path || routeCrossings(path, obstacles)) return void 0;
|
|
23297
23749
|
if (route === "right-angle") return path;
|
|
23750
|
+
if (path.length === 3 && begin.shape && end.shape && [begin.shape, end.shape].every(
|
|
23751
|
+
(shape) => shape.sites.every(
|
|
23752
|
+
(site) => Math.abs(site.normal.x) < EPSILON3 || Math.abs(site.normal.y) < EPSILON3
|
|
23753
|
+
)
|
|
23754
|
+
)) {
|
|
23755
|
+
const curve = cornerCurve(path);
|
|
23756
|
+
if (obstacles.length) {
|
|
23757
|
+
const sampled = flattenCornerCurve(curve);
|
|
23758
|
+
if (!sampled || routeCrossings(sampled, obstacles)) return void 0;
|
|
23759
|
+
}
|
|
23760
|
+
return curve;
|
|
23761
|
+
}
|
|
23298
23762
|
const unit3 = (p, q) => {
|
|
23299
23763
|
const length = Math.hypot(q.x - p.x, q.y - p.y) || 1;
|
|
23300
23764
|
return { x: (q.x - p.x) / length, y: (q.y - p.y) / length };
|
|
@@ -23343,26 +23807,6 @@ function put(parent, inherited, name3, value, formula) {
|
|
|
23343
23807
|
node2.removeAttribute("E");
|
|
23344
23808
|
if (formula !== void 0) node2.setAttribute("F", formula);
|
|
23345
23809
|
}
|
|
23346
|
-
function midpoint(points) {
|
|
23347
|
-
const lengths = points.slice(1).map((point2, index) => Math.hypot(point2.x - points[index].x, point2.y - points[index].y));
|
|
23348
|
-
let left = lengths.reduce((sum, value) => sum + value, 0) / 2;
|
|
23349
|
-
for (const [index, length] of lengths.entries()) {
|
|
23350
|
-
if (left <= length && length > 0) {
|
|
23351
|
-
const from = points[index], to = points[index + 1];
|
|
23352
|
-
return {
|
|
23353
|
-
x: from.x + (to.x - from.x) * left / length,
|
|
23354
|
-
y: from.y + (to.y - from.y) * left / length
|
|
23355
|
-
};
|
|
23356
|
-
}
|
|
23357
|
-
left -= length;
|
|
23358
|
-
}
|
|
23359
|
-
return points.at(-1);
|
|
23360
|
-
}
|
|
23361
|
-
var bezier = (p, t) => {
|
|
23362
|
-
const u = 1 - t;
|
|
23363
|
-
const mix2 = (key2) => u * u * u * p[0][key2] + 3 * u * u * t * p[1][key2] + 3 * u * t * t * p[2][key2] + t * t * t * p[3][key2];
|
|
23364
|
-
return { x: mix2("x"), y: mix2("y") };
|
|
23365
|
-
};
|
|
23366
23810
|
function section(shape, name3, index) {
|
|
23367
23811
|
let node2 = children2(shape, "Section").find((item) => attribute2(item, "N") === name3);
|
|
23368
23812
|
if (!node2) {
|
|
@@ -23418,8 +23862,9 @@ function writeStencilConnector(shape, route, vertices) {
|
|
|
23418
23862
|
x: point2.x - (begin.x + end.x) / 2 + width / 2,
|
|
23419
23863
|
y: point2.y - (begin.y + end.y) / 2 + height / 2
|
|
23420
23864
|
});
|
|
23421
|
-
const curved2 = route === "curved" && !flatX && !flatY && vertices.length === 4;
|
|
23865
|
+
const curved2 = route === "curved" && (vertices.length === 5 || !flatX && !flatY && vertices.length === 4);
|
|
23422
23866
|
const local = (curved2 || route !== "curved" ? vertices : [begin, end]).map(at2);
|
|
23867
|
+
const [internalKnot, lastKnot] = local.length === 5 ? cornerCurveKnots(local) : [0, 1];
|
|
23423
23868
|
const masterGeometry = children2(template, "Section").find(
|
|
23424
23869
|
(item) => attribute2(item, "N") === "Geometry"
|
|
23425
23870
|
);
|
|
@@ -23444,15 +23889,15 @@ function writeStencilConnector(shape, route, vertices) {
|
|
|
23444
23889
|
{
|
|
23445
23890
|
type: "NURBSTo",
|
|
23446
23891
|
cells: [
|
|
23447
|
-
["X", local
|
|
23448
|
-
["Y", local
|
|
23449
|
-
["A",
|
|
23892
|
+
["X", local.at(-1).x, flatX ? void 0 : "Width*1"],
|
|
23893
|
+
["Y", local.at(-1).y, flatY ? void 0 : "Height*1"],
|
|
23894
|
+
["A", internalKnot],
|
|
23450
23895
|
["B", 1],
|
|
23451
23896
|
["C", 0],
|
|
23452
23897
|
["D", 1],
|
|
23453
23898
|
[
|
|
23454
23899
|
"E",
|
|
23455
|
-
`NURBS(
|
|
23900
|
+
`NURBS(${text2(lastKnot)},3,1,1,${local.slice(1, -1).map((point2) => `${text2(point2.x)},${text2(point2.y)},0,1`).join(",")})`
|
|
23456
23901
|
]
|
|
23457
23902
|
]
|
|
23458
23903
|
}
|
|
@@ -23489,7 +23934,7 @@ function writeStencilConnector(shape, route, vertices) {
|
|
|
23489
23934
|
}
|
|
23490
23935
|
}
|
|
23491
23936
|
drop(shape, geometry);
|
|
23492
|
-
const middle = curved2 ?
|
|
23937
|
+
const middle = curved2 ? connectorCurveMiddle(local) : connectorPolylineMiddle(local);
|
|
23493
23938
|
const masterControl = children2(template, "Section").filter((item) => attribute2(item, "N") === "Control").flatMap((item) => children2(item, "Row")).find((row2) => attribute2(row2, "N") === "TextPosition");
|
|
23494
23939
|
const control = section(shape, "Control");
|
|
23495
23940
|
let position = children2(control, "Row").find((row2) => attribute2(row2, "N") === "TextPosition");
|
|
@@ -24619,6 +25064,344 @@ async function refreshTextSizes(targets, result, options, deadline) {
|
|
|
24619
25064
|
return { ...result, diagnostics };
|
|
24620
25065
|
}
|
|
24621
25066
|
|
|
25067
|
+
// visio/line-jumps.ts
|
|
25068
|
+
var VISIO_LINE_JUMP_WIDTH = 2 / 3 * 0.125;
|
|
25069
|
+
var VISIO_LINE_JUMP_LIMITS = Object.freeze({ connectors: 2e3, segments: 2e4 });
|
|
25070
|
+
var TOKEN = /([MLZmlz]|[A-Za-z])|([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)/g;
|
|
25071
|
+
function polylines(path) {
|
|
25072
|
+
const result = [];
|
|
25073
|
+
let command2 = "";
|
|
25074
|
+
let pending;
|
|
25075
|
+
for (const match of path.matchAll(TOKEN)) {
|
|
25076
|
+
if (match[1]) {
|
|
25077
|
+
if (match[1] !== "M" && match[1] !== "L") return void 0;
|
|
25078
|
+
if (pending !== void 0) return void 0;
|
|
25079
|
+
command2 = match[1];
|
|
25080
|
+
continue;
|
|
25081
|
+
}
|
|
25082
|
+
const value = Number(match[2]);
|
|
25083
|
+
if (!Number.isFinite(value) || !command2) return void 0;
|
|
25084
|
+
if (pending === void 0) {
|
|
25085
|
+
pending = value;
|
|
25086
|
+
continue;
|
|
25087
|
+
}
|
|
25088
|
+
const point2 = { x: pending, y: value };
|
|
25089
|
+
pending = void 0;
|
|
25090
|
+
if (command2 === "M") {
|
|
25091
|
+
result.push([point2]);
|
|
25092
|
+
command2 = "L";
|
|
25093
|
+
} else result.at(-1)?.push(point2);
|
|
25094
|
+
}
|
|
25095
|
+
return pending === void 0 && result.every((line) => line.length > 1) ? result : void 0;
|
|
25096
|
+
}
|
|
25097
|
+
var apply2 = (m, p) => ({
|
|
25098
|
+
x: m[0] * p.x + m[2] * p.y + m[4],
|
|
25099
|
+
y: m[1] * p.x + m[3] * p.y + m[5]
|
|
25100
|
+
});
|
|
25101
|
+
function invert(m) {
|
|
25102
|
+
const det = m[0] * m[3] - m[1] * m[2];
|
|
25103
|
+
if (!Number.isFinite(det) || Math.abs(det) < 1e-12) return void 0;
|
|
25104
|
+
return [
|
|
25105
|
+
m[3] / det,
|
|
25106
|
+
-m[1] / det,
|
|
25107
|
+
-m[2] / det,
|
|
25108
|
+
m[0] / det,
|
|
25109
|
+
(m[2] * m[5] - m[3] * m[4]) / det,
|
|
25110
|
+
(m[1] * m[4] - m[0] * m[5]) / det
|
|
25111
|
+
];
|
|
25112
|
+
}
|
|
25113
|
+
var clean2 = (value) => Math.abs(value) < 1e-9 ? 0 : Number(value.toFixed(6));
|
|
25114
|
+
var text3 = (p) => `${clean2(p.x)} ${clean2(p.y)}`;
|
|
25115
|
+
var horizontal = (s) => Math.abs(s.b.x - s.a.x) > Math.abs(s.b.y - s.a.y);
|
|
25116
|
+
var vertical = (s) => Math.abs(s.b.y - s.a.y) > Math.abs(s.b.x - s.a.x);
|
|
25117
|
+
function crossing(s, other, margin) {
|
|
25118
|
+
const dx = s.b.x - s.a.x, dy = s.b.y - s.a.y, ox = other.b.x - other.a.x, oy = other.b.y - other.a.y;
|
|
25119
|
+
const det = dx * oy - dy * ox;
|
|
25120
|
+
const length = Math.hypot(dx, dy), otherLength = Math.hypot(ox, oy);
|
|
25121
|
+
if (Math.abs(det) < 1e-9 || Math.abs(det) / (length * otherLength) < 0.2) return void 0;
|
|
25122
|
+
const t = ((other.a.x - s.a.x) * oy - (other.a.y - s.a.y) * ox) / det;
|
|
25123
|
+
const u = ((other.a.x - s.a.x) * dy - (other.a.y - s.a.y) * dx) / det;
|
|
25124
|
+
if (u * otherLength < 1e-6 || (1 - u) * otherLength < 1e-6) return void 0;
|
|
25125
|
+
if (t * length < margin || (1 - t) * length < margin) return void 0;
|
|
25126
|
+
return t;
|
|
25127
|
+
}
|
|
25128
|
+
function jumps(code, s, other, shapes) {
|
|
25129
|
+
const own = shapes[s.owner]?.lineJumpCode ?? 0;
|
|
25130
|
+
const peer = shapes[other.owner]?.lineJumpCode ?? 0;
|
|
25131
|
+
if (own === 4 || peer === 4 || own === 1) return false;
|
|
25132
|
+
if (own !== peer) {
|
|
25133
|
+
if (own === 2 || peer === 3) return true;
|
|
25134
|
+
if (own === 3 || peer === 2) return false;
|
|
25135
|
+
}
|
|
25136
|
+
if (code === 1) return horizontal(s) && !horizontal(other);
|
|
25137
|
+
if (code === 2) return vertical(s) && !vertical(other);
|
|
25138
|
+
if (code === 3 || code === 4) return s.owner > other.owner;
|
|
25139
|
+
return code === 5 && s.owner < other.owner;
|
|
25140
|
+
}
|
|
25141
|
+
function jump(style2, from, to, local, reverse) {
|
|
25142
|
+
const half = Math.hypot(to.x - from.x, to.y - from.y) / 2;
|
|
25143
|
+
const ux = (to.x - from.x) / (2 * half), uy = (to.y - from.y) / (2 * half);
|
|
25144
|
+
let nx = -uy, ny = ux;
|
|
25145
|
+
if (ny < -1e-9 || Math.abs(ny) <= 1e-9 && nx > 0) {
|
|
25146
|
+
nx = -nx;
|
|
25147
|
+
ny = -ny;
|
|
25148
|
+
}
|
|
25149
|
+
if (reverse) {
|
|
25150
|
+
nx = -nx;
|
|
25151
|
+
ny = -ny;
|
|
25152
|
+
}
|
|
25153
|
+
const centre = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };
|
|
25154
|
+
const at2 = (along, out) => local({ x: centre.x + ux * along + nx * out, y: centre.y + uy * along + ny * out });
|
|
25155
|
+
const end = local(to);
|
|
25156
|
+
if (style2 === 1) return `M ${text3(end)}`;
|
|
25157
|
+
if (style2 === 2) return `L ${text3(at2(-half, half))} L ${text3(at2(half, half))} L ${text3(end)}`;
|
|
25158
|
+
if (style2 >= 3) {
|
|
25159
|
+
const sides = style2 - 1;
|
|
25160
|
+
let out = "";
|
|
25161
|
+
for (let index = 1; index < sides; ++index) {
|
|
25162
|
+
const angle = Math.PI - Math.PI * index / sides;
|
|
25163
|
+
out += `L ${text3(at2(Math.cos(angle) * half, Math.sin(angle) * half))} `;
|
|
25164
|
+
}
|
|
25165
|
+
return `${out}L ${text3(end)}`;
|
|
25166
|
+
}
|
|
25167
|
+
const start = local(from), top = at2(0, half);
|
|
25168
|
+
const radius = Math.hypot(end.x - start.x, end.y - start.y) / 2;
|
|
25169
|
+
const sweep = (end.x - start.x) * (top.y - start.y) - (end.y - start.y) * (top.x - start.x) > 0 ? 0 : 1;
|
|
25170
|
+
return `A ${clean2(radius)} ${clean2(radius)} 0 0 ${sweep} ${text3(end)}`;
|
|
25171
|
+
}
|
|
25172
|
+
var connector = (shape, glued) => shape.kind === "connector" && !shape.hidden && !shape.children.length && (shape.connectorRoute !== void 0 || glued.has(shape.id));
|
|
25173
|
+
function visioLineJumpPaths(page) {
|
|
25174
|
+
const result = /* @__PURE__ */ new Map();
|
|
25175
|
+
const layout = visioPageLayout(page);
|
|
25176
|
+
const code = layout.lineJumpCode;
|
|
25177
|
+
const glued = new Set(page.connectors.map((connection) => connection.fromShapeId));
|
|
25178
|
+
const shapes = page.shapes.filter((shape) => connector(shape, glued)).slice(0, VISIO_LINE_JUMP_LIMITS.connectors);
|
|
25179
|
+
for (const shape of shapes) {
|
|
25180
|
+
if (shape.connectorRoute !== "straight" || !shape.lineEnds) continue;
|
|
25181
|
+
if (shape.geometry.length !== 1) continue;
|
|
25182
|
+
const geometry = shape.geometry[0];
|
|
25183
|
+
if (!geometry.stroke || geometry.fill) continue;
|
|
25184
|
+
const { begin, end } = shape.lineEnds;
|
|
25185
|
+
if (![begin.x, begin.y, end.x, end.y].every(Number.isFinite)) continue;
|
|
25186
|
+
const path = `M ${text3(begin)} L ${text3(end)}`;
|
|
25187
|
+
if (geometry.path !== path) result.set(shape, [path]);
|
|
25188
|
+
}
|
|
25189
|
+
if (shapes.length < 2) return result;
|
|
25190
|
+
if ((code < 1 || code > 5) && !shapes.some((shape) => shape.lineJumpCode === 2 || shape.lineJumpCode === 3))
|
|
25191
|
+
return result;
|
|
25192
|
+
const lines2 = [];
|
|
25193
|
+
const segments = [];
|
|
25194
|
+
shapes.forEach((shape, owner) => {
|
|
25195
|
+
shape.geometry.forEach((geometry, index) => {
|
|
25196
|
+
if (!geometry.stroke || geometry.fill) return;
|
|
25197
|
+
for (const line of polylines(result.get(shape)?.[index] ?? geometry.path) ?? []) {
|
|
25198
|
+
const points = line.map((point2) => apply2(shape.transform, point2));
|
|
25199
|
+
lines2.push({ shape, owner, geometry: index, points });
|
|
25200
|
+
for (let i = 1; i < points.length; ++i)
|
|
25201
|
+
segments.push({ a: points[i - 1], b: points[i], owner });
|
|
25202
|
+
}
|
|
25203
|
+
});
|
|
25204
|
+
});
|
|
25205
|
+
if (segments.length > VISIO_LINE_JUMP_LIMITS.segments) return result;
|
|
25206
|
+
const bounded6 = (value, fallback, max) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= max ? value : fallback;
|
|
25207
|
+
const scale = bounded6(page.drawingToPageScale, 1, Number.MAX_VALUE);
|
|
25208
|
+
const halfX = bounded6(layout.lineJumpFactorX, 2 / 3, 10) * bounded6(layout.lineToLineX, 0.125, 1e4) * scale / 2;
|
|
25209
|
+
const halfY = bounded6(layout.lineJumpFactorY, 2 / 3, 10) * bounded6(layout.lineToLineY, 0.125, 1e4) * scale / 2;
|
|
25210
|
+
const paths = /* @__PURE__ */ new Map();
|
|
25211
|
+
const any = /* @__PURE__ */ new Set();
|
|
25212
|
+
for (const line of lines2) {
|
|
25213
|
+
const inverse = invert(line.shape.transform);
|
|
25214
|
+
if (!inverse) continue;
|
|
25215
|
+
const local = (point2) => apply2(inverse, point2);
|
|
25216
|
+
let out = `M ${text3(local(line.points[0]))}`;
|
|
25217
|
+
for (let i = 1; i < line.points.length; ++i) {
|
|
25218
|
+
const s = { a: line.points[i - 1], b: line.points[i], owner: line.owner };
|
|
25219
|
+
const length = Math.hypot(s.b.x - s.a.x, s.b.y - s.a.y);
|
|
25220
|
+
const half = vertical(s) ? halfY : halfX;
|
|
25221
|
+
if (half <= 0) {
|
|
25222
|
+
out += ` L ${text3(local(s.b))}`;
|
|
25223
|
+
continue;
|
|
25224
|
+
}
|
|
25225
|
+
const hits = segments.filter((other) => other.owner !== s.owner && jumps(code, s, other, shapes)).flatMap((other) => crossing(s, other, half * 1.5) ?? []).sort((a, b) => a - b);
|
|
25226
|
+
let last = -Infinity;
|
|
25227
|
+
for (const t of hits) {
|
|
25228
|
+
if ((t - last) * length < half * 2.5) continue;
|
|
25229
|
+
last = t;
|
|
25230
|
+
const at2 = (offset) => ({
|
|
25231
|
+
x: s.a.x + (s.b.x - s.a.x) * (t * length + offset) / length,
|
|
25232
|
+
y: s.a.y + (s.b.y - s.a.y) * (t * length + offset) / length
|
|
25233
|
+
});
|
|
25234
|
+
const override = line.shape.lineJumpStyle ?? 0;
|
|
25235
|
+
const savedStyle = override >= 1 && override <= 9 ? override : layout.lineJumpStyle;
|
|
25236
|
+
const style2 = savedStyle >= 1 && savedStyle <= 9 ? savedStyle - 1 : 0;
|
|
25237
|
+
const direction = horizontal(s) ? line.shape.lineJumpDirectionX || layout.lineJumpDirectionX : vertical(s) ? line.shape.lineJumpDirectionY || layout.lineJumpDirectionY : 0;
|
|
25238
|
+
out += ` L ${text3(local(at2(-half)))} ${jump(style2, at2(-half), at2(half), local, direction === 2)}`;
|
|
25239
|
+
any.add(line.shape);
|
|
25240
|
+
}
|
|
25241
|
+
out += ` L ${text3(local(s.b))}`;
|
|
25242
|
+
}
|
|
25243
|
+
const byGeometry = paths.get(line.shape) ?? /* @__PURE__ */ new Map();
|
|
25244
|
+
byGeometry.set(line.geometry, [...byGeometry.get(line.geometry) ?? [], out]);
|
|
25245
|
+
paths.set(line.shape, byGeometry);
|
|
25246
|
+
}
|
|
25247
|
+
for (const shape of any) {
|
|
25248
|
+
const byGeometry = paths.get(shape);
|
|
25249
|
+
result.set(
|
|
25250
|
+
shape,
|
|
25251
|
+
shape.geometry.map(
|
|
25252
|
+
(geometry, index) => byGeometry.get(index)?.join(" ") ?? result.get(shape)?.[index] ?? geometry.path
|
|
25253
|
+
)
|
|
25254
|
+
);
|
|
25255
|
+
}
|
|
25256
|
+
return result;
|
|
25257
|
+
}
|
|
25258
|
+
|
|
25259
|
+
// visio/edit-line-jump-cache.ts
|
|
25260
|
+
var jumpState = (page) => JSON.stringify([
|
|
25261
|
+
Object.entries(visioPageLayout(page)).filter(([key2]) => /^lineJump|^lineToLine/.test(key2)),
|
|
25262
|
+
page.shapes.map((shape) => [
|
|
25263
|
+
shape.id,
|
|
25264
|
+
shape.lineJumpCode,
|
|
25265
|
+
shape.lineJumpStyle,
|
|
25266
|
+
shape.lineJumpDirectionX,
|
|
25267
|
+
shape.lineJumpDirectionY
|
|
25268
|
+
])
|
|
25269
|
+
]);
|
|
25270
|
+
function plainRows(section3) {
|
|
25271
|
+
return children2(section3, "Row").every(
|
|
25272
|
+
(row2) => ["MoveTo", "LineTo", "ArcTo"].includes(attribute2(row2, "T") ?? "") && Array.from(row2.attributes).every((attr2) => ["IX", "T", "Del"].includes(attr2.name)) && Array.from(row2.children ?? row2.childNodes).filter((node2) => node2.nodeType === 1).every((node2) => {
|
|
25273
|
+
const cell = node2;
|
|
25274
|
+
return cell.localName === "Cell" && cell.namespaceURI === section3.namespaceURI && ["X", "Y", ...attribute2(row2, "T") === "ArcTo" ? ["A"] : []].includes(
|
|
25275
|
+
attribute2(cell, "N") ?? ""
|
|
25276
|
+
) && Array.from(cell.attributes).every((attr2) => ["N", "V", "U", "F"].includes(attr2.name)) && !executableCellFormula(attribute2(cell, "F")) && !Array.from(cell.childNodes).some((child3) => child3.nodeType === 1);
|
|
25277
|
+
})
|
|
25278
|
+
);
|
|
25279
|
+
}
|
|
25280
|
+
function cacheRows(path) {
|
|
25281
|
+
const tokens2 = path.trim().split(/\s+/);
|
|
25282
|
+
const rows = [];
|
|
25283
|
+
while (tokens2.length) {
|
|
25284
|
+
const command2 = tokens2.shift();
|
|
25285
|
+
if (command2 === "M" || command2 === "L") {
|
|
25286
|
+
rows.push({
|
|
25287
|
+
type: command2 === "M" ? "MoveTo" : "LineTo",
|
|
25288
|
+
x: Number(tokens2.shift()),
|
|
25289
|
+
y: Number(tokens2.shift())
|
|
25290
|
+
});
|
|
25291
|
+
} else if (command2 === "A") {
|
|
25292
|
+
const [rx, ry, rotation, large, sweep, x, y] = tokens2.splice(0, 7).map(Number);
|
|
25293
|
+
if (rx === void 0 || ry !== rx || rotation !== 0 || large !== 0 || sweep !== 0 && sweep !== 1 || x === void 0 || y === void 0)
|
|
25294
|
+
return [];
|
|
25295
|
+
rows.push({ type: "ArcTo", x, y, bow: sweep ? rx : -rx });
|
|
25296
|
+
} else return [];
|
|
25297
|
+
if (rows.length > 1e4) return [];
|
|
25298
|
+
}
|
|
25299
|
+
return rows.every((row2) => Number.isFinite(row2.x) && Number.isFinite(row2.y)) ? rows : [];
|
|
25300
|
+
}
|
|
25301
|
+
async function refreshLineJumpCaches(pageIds2, source, result, options, deadline) {
|
|
25302
|
+
if (!pageIds2.size || !result.changedParts.length) return result;
|
|
25303
|
+
const check = () => {
|
|
25304
|
+
if (Date.now() >= deadline) fail("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
25305
|
+
};
|
|
25306
|
+
const limits = {
|
|
25307
|
+
...DEFAULTS,
|
|
25308
|
+
...options.limits,
|
|
25309
|
+
maxRuntimeMs: Math.max(1, deadline - Date.now())
|
|
25310
|
+
};
|
|
25311
|
+
const { pkg, parts, pages } = await openEditablePackage(result.bytes, limits, check);
|
|
25312
|
+
const model2 = await parseVsdx(result.bytes, { limits });
|
|
25313
|
+
const before = source ? await parseVsdx(source, { limits }) : void 0;
|
|
25314
|
+
const template = masterTemplate(pkg);
|
|
25315
|
+
const changed = new Set(result.changedParts);
|
|
25316
|
+
const kept = [];
|
|
25317
|
+
let referenced = false;
|
|
25318
|
+
for (const path of pkg.paths()) {
|
|
25319
|
+
check();
|
|
25320
|
+
if (!/^visio\/.*\.xml$/i.test(path)) continue;
|
|
25321
|
+
const root2 = await pkg.readXml(path);
|
|
25322
|
+
for (const node2 of Array.from(root2.getElementsByTagName("*")))
|
|
25323
|
+
if (/\b(?:Geometry|Geom)\d*\./i.test(attribute2(node2, "F") ?? "")) referenced = true;
|
|
25324
|
+
}
|
|
25325
|
+
for (const page of model2.pages) {
|
|
25326
|
+
if (!pageIds2.has(page.id)) continue;
|
|
25327
|
+
const prior = before?.pages.find((item) => item.id === page.id);
|
|
25328
|
+
if (prior && jumpState(prior) === jumpState(page)) continue;
|
|
25329
|
+
const path = pages.get(page.id);
|
|
25330
|
+
const root2 = await visioXml(pkg, path, "PageContents");
|
|
25331
|
+
let dirty = false;
|
|
25332
|
+
for (const [shape, paths] of visioLineJumpPaths(page)) {
|
|
25333
|
+
check();
|
|
25334
|
+
if (shape.connectorRoute !== "straight" || paths.length !== 1) continue;
|
|
25335
|
+
const target2 = children2(children2(root2, "Shapes")[0], "Shape").find(
|
|
25336
|
+
(node2) => attribute2(node2, "ID") === shape.id
|
|
25337
|
+
);
|
|
25338
|
+
if (!target2) continue;
|
|
25339
|
+
const sections = children2(target2, "Section").filter(
|
|
25340
|
+
(node2) => attribute2(node2, "N") === "Geometry"
|
|
25341
|
+
);
|
|
25342
|
+
const section3 = sections[0];
|
|
25343
|
+
const rows = cacheRows(paths[0]);
|
|
25344
|
+
if (referenced || !section3 || sections.length !== 1 || !rows.length || !plainRows(section3) || Array.from(section3.getElementsByTagName("*")).some(
|
|
25345
|
+
(node2) => executableCellFormula(attribute2(node2, "F"))
|
|
25346
|
+
)) {
|
|
25347
|
+
kept.push(shape.id);
|
|
25348
|
+
continue;
|
|
25349
|
+
}
|
|
25350
|
+
const indices = /* @__PURE__ */ new Map();
|
|
25351
|
+
const masterId = attribute2(target2, "Master");
|
|
25352
|
+
if (masterId) {
|
|
25353
|
+
const master2 = await template(masterId, attribute2(target2, "MasterShape"));
|
|
25354
|
+
const base2 = children2(master2, "Section").find(
|
|
25355
|
+
(node2) => attribute2(node2, "N") === "Geometry" && attribute2(node2, "IX") === attribute2(section3, "IX")
|
|
25356
|
+
);
|
|
25357
|
+
for (const row2 of children2(base2, "Row"))
|
|
25358
|
+
indices.set(attribute2(row2, "IX"), attribute2(row2, "T"));
|
|
25359
|
+
}
|
|
25360
|
+
for (const row2 of children2(section3, "Row")) section3.removeChild(row2);
|
|
25361
|
+
for (const [index, value] of rows.entries()) {
|
|
25362
|
+
const row2 = root2.ownerDocument.createElementNS(root2.namespaceURI, "Row");
|
|
25363
|
+
row2.setAttribute("IX", String(index + 1));
|
|
25364
|
+
row2.setAttribute("T", value.type);
|
|
25365
|
+
setCell(row2, "X", value.x);
|
|
25366
|
+
setCell(row2, "Y", value.y);
|
|
25367
|
+
if (value.bow !== void 0) setCell(row2, "A", value.bow);
|
|
25368
|
+
section3.appendChild(row2);
|
|
25369
|
+
indices.delete(String(index + 1));
|
|
25370
|
+
}
|
|
25371
|
+
for (const [index, type] of indices) {
|
|
25372
|
+
const row2 = root2.ownerDocument.createElementNS(root2.namespaceURI, "Row");
|
|
25373
|
+
row2.setAttribute("IX", index);
|
|
25374
|
+
row2.setAttribute("T", type);
|
|
25375
|
+
row2.setAttribute("Del", "1");
|
|
25376
|
+
section3.appendChild(row2);
|
|
25377
|
+
}
|
|
25378
|
+
dirty = true;
|
|
25379
|
+
}
|
|
25380
|
+
if (dirty) {
|
|
25381
|
+
parts.set(path, serializeEditedXml(root2, limits, check).bytes);
|
|
25382
|
+
changed.add(path);
|
|
25383
|
+
}
|
|
25384
|
+
}
|
|
25385
|
+
return {
|
|
25386
|
+
bytes: await writeEditedPackage(
|
|
25387
|
+
parts,
|
|
25388
|
+
options.maxOutputBytes ?? limits.maxInputBytes,
|
|
25389
|
+
deadline,
|
|
25390
|
+
check
|
|
25391
|
+
),
|
|
25392
|
+
changedParts: [...changed].sort(),
|
|
25393
|
+
diagnostics: [
|
|
25394
|
+
...result.diagnostics,
|
|
25395
|
+
...kept.length ? [
|
|
25396
|
+
{
|
|
25397
|
+
code: "edit-line-jump-cache-kept",
|
|
25398
|
+
message: `Connector ${kept.join(", ")} retains its saved geometry because formula dependencies prevent refreshing native jump caches.`
|
|
25399
|
+
}
|
|
25400
|
+
] : []
|
|
25401
|
+
]
|
|
25402
|
+
};
|
|
25403
|
+
}
|
|
25404
|
+
|
|
24622
25405
|
// visio/resize-anchor.ts
|
|
24623
25406
|
function snapshotResizeAnchor(value) {
|
|
24624
25407
|
if (value === void 0) return void 0;
|
|
@@ -26554,6 +27337,9 @@ function assertDependencies(roots, pagesPart, pages, pagePaths, pageId2, changed
|
|
|
26554
27337
|
"gi"
|
|
26555
27338
|
) : void 0;
|
|
26556
27339
|
const paths = new Map([...pagePaths].map(([id3, path]) => [path, id3]));
|
|
27340
|
+
const jumpDecorationOnly = changed.every(
|
|
27341
|
+
(name3) => /^(LineJumpCode|LineJumpStyle|PageLineJumpDir[XY]|LineJumpFactor[XY])$/.test(name3)
|
|
27342
|
+
);
|
|
26557
27343
|
for (const [path, root2] of roots)
|
|
26558
27344
|
for (const node2 of [root2, ...Array.from(root2.getElementsByTagName("*"))]) {
|
|
26559
27345
|
check();
|
|
@@ -26574,8 +27360,10 @@ function assertDependencies(roots, pagesPart, pages, pagePaths, pageId2, changed
|
|
|
26574
27360
|
const nativeGlue = paths.has(path) && connected && node2.localName === "Cell" && node2.namespaceURI === root2.namespaceURI && (/^(BeginX|BeginY|EndX|EndY)$/.test(name3) && /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i.test(
|
|
26575
27361
|
code
|
|
26576
27362
|
) || /^(BegTrigger|EndTrigger)$/.test(name3) && /^\s*_XFTRIGGER\(Sheet\.[1-9]\d*!EventXFMod\)\s*$/i.test(code));
|
|
27363
|
+
const nativeJumpTrigger = jumpDecorationOnly && paths.has(path) && node2.localName === "Cell" && node2.namespaceURI === root2.namespaceURI && /^(BegTrigger|EndTrigger)$/.test(name3) && owner?.localName === "Shape" && owner.namespaceURI === root2.namespaceURI && container?.localName === "Shapes" && container.parentNode === root2 && !!ownerId2 && visioGlueTriggerTarget(formula) === ownerId2;
|
|
27364
|
+
const nativeJumpText = jumpDecorationOnly && node2.localName === "Cell" && node2.namespaceURI === root2.namespaceURI && (/^(TxtPinX|TxtPinY)$/.test(name3) && /^\s*SETATREF\(Controls\.TextPosition(?:\.Y)?\)\s*$/i.test(formula) || !!textSizeFormula(formula) || name3 === "XCon" && /^\s*IF\(OR\(STRSAME\(SHAPETEXT\(TheText\),""\),HideText\),5,0\)\s*$/i.test(formula));
|
|
26577
27365
|
let dynamic2 = false;
|
|
26578
|
-
if (!nativeGlue) {
|
|
27366
|
+
if (!nativeGlue && !nativeJumpTrigger && !nativeJumpText) {
|
|
26579
27367
|
try {
|
|
26580
27368
|
dynamic2 = analyzeVisioFormula(
|
|
26581
27369
|
mapVisioFormulaSyntax(
|
|
@@ -26590,7 +27378,7 @@ function assertDependencies(roots, pagesPart, pages, pagePaths, pageId2, changed
|
|
|
26590
27378
|
if (dynamic2)
|
|
26591
27379
|
fail(
|
|
26592
27380
|
"EDIT_UNSUPPORTED_PAGE_SIZE_DEPENDENCY",
|
|
26593
|
-
|
|
27381
|
+
`Dynamic or unknown page-size dependencies cannot be safely refreshed (${path}, ${name3}).`
|
|
26594
27382
|
);
|
|
26595
27383
|
let local = paths.get(path);
|
|
26596
27384
|
if (path === pagesPart) {
|
|
@@ -26808,6 +27596,12 @@ function setVisioPageProperties(pagesPart, pages, dirty, command2) {
|
|
|
26808
27596
|
var CELLS = [
|
|
26809
27597
|
["lineJumpCode", "LineJumpCode", false],
|
|
26810
27598
|
["lineJumpStyle", "LineJumpStyle", false],
|
|
27599
|
+
["lineJumpDirectionX", "PageLineJumpDirX", false],
|
|
27600
|
+
["lineJumpDirectionY", "PageLineJumpDirY", false],
|
|
27601
|
+
["lineJumpFactorX", "LineJumpFactorX", false],
|
|
27602
|
+
["lineJumpFactorY", "LineJumpFactorY", false],
|
|
27603
|
+
["lineToLineX", "LineToLineX", true],
|
|
27604
|
+
["lineToLineY", "LineToLineY", true],
|
|
26811
27605
|
["gridDensityX", "XGridDensity", false],
|
|
26812
27606
|
["gridDensityY", "YGridDensity", false],
|
|
26813
27607
|
["gridSpacingX", "XGridSpacing", true],
|
|
@@ -26821,8 +27615,13 @@ var CELLS = [
|
|
|
26821
27615
|
];
|
|
26822
27616
|
function valid(key2, value) {
|
|
26823
27617
|
const number5 = typeof value === "number" && Number.isFinite(value) ? value : Number.NaN;
|
|
27618
|
+
if (key2.startsWith("lineJumpFactor") || key2.startsWith("lineToLine")) {
|
|
27619
|
+
if (!(number5 >= 0 && number5 <= (key2.startsWith("lineJumpFactor") ? 10 : 1e4)))
|
|
27620
|
+
fail("INVALID_EDIT", `Invalid page layout value for ${key2}.`);
|
|
27621
|
+
return number5;
|
|
27622
|
+
}
|
|
26824
27623
|
const integer3 = Number.isSafeInteger(number5);
|
|
26825
|
-
const ok = key2 === "lineJumpCode" ? integer3 && number5 >= 0 && number5 <= 5 : key2 === "lineJumpStyle" ? integer3 && number5 >= 0 && number5 <=
|
|
27624
|
+
const ok = key2 === "lineJumpDirectionX" || key2 === "lineJumpDirectionY" ? integer3 && number5 >= 0 && number5 <= 2 : key2 === "lineJumpCode" ? integer3 && number5 >= 0 && number5 <= 5 : key2 === "lineJumpStyle" ? integer3 && number5 >= 0 && number5 <= 9 : key2.startsWith("gridDensity") ? VISIO_GRID_DENSITIES.includes(number5) : key2.startsWith("rulerDensity") ? VISIO_RULER_DENSITIES.includes(number5) : key2.startsWith("gridSpacing") ? number5 >= 0 && number5 <= 1e4 : Math.abs(number5) <= 1e6;
|
|
26826
27625
|
if (!ok) fail("INVALID_EDIT", `Invalid page layout value for ${key2}.`);
|
|
26827
27626
|
return number5;
|
|
26828
27627
|
}
|
|
@@ -27049,7 +27848,7 @@ function visioBorderShapes(style2, width, height, title = VISIO_DEFAULT_TITLE) {
|
|
|
27049
27848
|
|
|
27050
27849
|
// visio/edit-page-setup-commands.ts
|
|
27051
27850
|
var VISIO_SCALE_UNITS = Object.freeze(["IN", "FT", "MM", "CM", "M"]);
|
|
27052
|
-
var isVisioPageSetupEdit = (edit) => edit.type === "set-page-setup" || edit.type === "set-page-properties" || edit.type === "set-page-decoration" || edit.type === "set-page-layout" || edit.type === "set-snap-glue";
|
|
27851
|
+
var isVisioPageSetupEdit = (edit) => edit.type === "set-page-alt-text" || edit.type === "set-page-setup" || edit.type === "set-page-properties" || edit.type === "set-page-decoration" || edit.type === "set-page-layout" || edit.type === "set-snap-glue";
|
|
27053
27852
|
var pageId = (value, label) => {
|
|
27054
27853
|
if (typeof value !== "string" || !value || value.length > 256)
|
|
27055
27854
|
fail("INVALID_EDIT", `Invalid ${label}.`);
|
|
@@ -27069,6 +27868,13 @@ function snapshotPageSetupEdit(edit) {
|
|
|
27069
27868
|
if (edit.type === "set-page-layout") return snapshotPageLayoutEdit(edit);
|
|
27070
27869
|
if (edit.type === "set-snap-glue") return snapshotSnapGlueEdit(edit);
|
|
27071
27870
|
const id3 = pageId(edit.pageId, "page");
|
|
27871
|
+
if (edit.type === "set-page-alt-text")
|
|
27872
|
+
return {
|
|
27873
|
+
type: edit.type,
|
|
27874
|
+
pageId: id3,
|
|
27875
|
+
title: metadataText(edit.title, true),
|
|
27876
|
+
description: metadataText(edit.description, false)
|
|
27877
|
+
};
|
|
27072
27878
|
if (edit.type === "set-page-setup") {
|
|
27073
27879
|
const result = { type: edit.type, pageId: id3 };
|
|
27074
27880
|
if (edit.printOrientation !== void 0) {
|
|
@@ -28762,7 +29568,7 @@ var OFFICE_FALLBACK = [
|
|
|
28762
29568
|
"#4472c4",
|
|
28763
29569
|
"#70ad47"
|
|
28764
29570
|
];
|
|
28765
|
-
function
|
|
29571
|
+
function mix2(color2, target2, amount) {
|
|
28766
29572
|
return `#${[1, 3, 5].map((index) => {
|
|
28767
29573
|
const value = parseInt(color2.slice(index, index + 2), 16);
|
|
28768
29574
|
return Math.round(value + (target2 - value) * amount).toString(16).padStart(2, "0");
|
|
@@ -28775,15 +29581,15 @@ function visioFallbackQuickStyle(style2) {
|
|
|
28775
29581
|
case 1:
|
|
28776
29582
|
return { fill: light, line: base2, font: dark };
|
|
28777
29583
|
case 2:
|
|
28778
|
-
return { fill:
|
|
29584
|
+
return { fill: mix2(base2, 255, 0.8), line: base2, font: dark };
|
|
28779
29585
|
case 3:
|
|
28780
|
-
return { fill:
|
|
29586
|
+
return { fill: mix2(base2, 255, 0.6), line: base2, font: dark };
|
|
28781
29587
|
case 4:
|
|
28782
|
-
return { fill: base2, line:
|
|
29588
|
+
return { fill: base2, line: mix2(base2, 0, 0.25), font: light };
|
|
28783
29589
|
case 5:
|
|
28784
|
-
return { fill:
|
|
29590
|
+
return { fill: mix2(base2, 0, 0.25), line: mix2(base2, 0, 0.5), font: light };
|
|
28785
29591
|
default:
|
|
28786
|
-
return { fill:
|
|
29592
|
+
return { fill: mix2(base2, 0, 0.5), line: mix2(base2, 0, 0.5), font: light };
|
|
28787
29593
|
}
|
|
28788
29594
|
}
|
|
28789
29595
|
var rgb = (color2) => `RGB(${[1, 3, 5].map((index) => parseInt(color2.slice(index, index + 2), 16)).join(",")})`;
|
|
@@ -29087,7 +29893,11 @@ function snapshotFormatting(edit) {
|
|
|
29087
29893
|
["endArrow", 45, "Arrowheads are numbered 0 to 45."],
|
|
29088
29894
|
["beginArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
29089
29895
|
["endArrowSize", 6, "Arrowhead sizes are numbered 0 to 6."],
|
|
29090
|
-
["lineCap", 2, "Line caps are 0 (round), 1 (square) or 2 (extended)."]
|
|
29896
|
+
["lineCap", 2, "Line caps are 0 (round), 1 (square) or 2 (extended)."],
|
|
29897
|
+
["lineJumpCode", 4, "Connector jump policies are numbered 0 to 4."],
|
|
29898
|
+
["lineJumpStyle", 9, "Connector jump styles are numbered 0 to 9."],
|
|
29899
|
+
["lineJumpDirectionX", 2, "Connector jump directions are numbered 0 to 2."],
|
|
29900
|
+
["lineJumpDirectionY", 2, "Connector jump directions are numbered 0 to 2."]
|
|
29091
29901
|
]) {
|
|
29092
29902
|
const value = edit[name3];
|
|
29093
29903
|
if (value === void 0) continue;
|
|
@@ -29166,6 +29976,12 @@ function geometryChangedCells(edit) {
|
|
|
29166
29976
|
if (edit.type === "flip-shape") return ["Angle", edit.axis === "horizontal" ? "FlipX" : "FlipY"];
|
|
29167
29977
|
return ["PinX", "PinY", "Width", "Height"];
|
|
29168
29978
|
}
|
|
29979
|
+
function snapshotPositionFollower(value, own) {
|
|
29980
|
+
if (value === void 0) return {};
|
|
29981
|
+
if (typeof value !== "string" || !/^[1-9]\d{0,9}$/.test(value) || Number(value) > 4294967295 || value === own)
|
|
29982
|
+
fail("INVALID_EDIT", "A distinct numeric owner shape ID is required.");
|
|
29983
|
+
return { followShapeId: value };
|
|
29984
|
+
}
|
|
29169
29985
|
function snapshotVisioEdits(edits, maxEdits, maxText) {
|
|
29170
29986
|
if (!Array.isArray(edits) || edits.length > maxEdits)
|
|
29171
29987
|
fail("LIMIT_EDITS", "Edit command count exceeds limit.");
|
|
@@ -29257,6 +30073,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
|
|
|
29257
30073
|
case "create-text-box":
|
|
29258
30074
|
return {
|
|
29259
30075
|
...target2,
|
|
30076
|
+
...snapshotPositionFollower(edit.followShapeId, edit.shapeId),
|
|
29260
30077
|
type: edit.type,
|
|
29261
30078
|
x: numeric5(edit.x),
|
|
29262
30079
|
y: numeric5(edit.y),
|
|
@@ -29288,6 +30105,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
|
|
|
29288
30105
|
fail("INVALID_EDIT", "Unknown outline shape.");
|
|
29289
30106
|
return {
|
|
29290
30107
|
...target2,
|
|
30108
|
+
...snapshotPositionFollower(edit.followShapeId, edit.shapeId),
|
|
29291
30109
|
type: edit.type,
|
|
29292
30110
|
x: numeric5(edit.x),
|
|
29293
30111
|
y: numeric5(edit.y),
|
|
@@ -30314,7 +31132,7 @@ function cells2(sheet) {
|
|
|
30314
31132
|
};
|
|
30315
31133
|
for (const node2 of children2(sheet, "Cell")) add(attribute2(node2, "N") ?? "", node2);
|
|
30316
31134
|
for (const section3 of children2(sheet, "Section")) {
|
|
30317
|
-
const name3 = attribute2(section3, "N") ?? "";
|
|
31135
|
+
const name3 = shapeDataFormulaSection(attribute2(section3, "N") ?? "");
|
|
30318
31136
|
const prefix2 = name3 === "Geometry" ? `Geometry${Number(attribute2(section3, "IX") ?? "0") + 1}` : name3;
|
|
30319
31137
|
for (const node2 of children2(section3, "Cell"))
|
|
30320
31138
|
add(`${prefix2}.${attribute2(node2, "N") ?? ""}`, node2);
|
|
@@ -30678,7 +31496,7 @@ function localCell(node2) {
|
|
|
30678
31496
|
const row2 = node2.parentNode;
|
|
30679
31497
|
const section3 = row2?.parentNode;
|
|
30680
31498
|
if (row2?.localName === "Row" && section3?.localName === "Section") {
|
|
30681
|
-
const name3 = attribute2(section3, "N"), rowName = attribute2(row2, "N") ?? attribute2(row2, "IX");
|
|
31499
|
+
const name3 = shapeDataFormulaSection(attribute2(section3, "N") ?? ""), rowName = attribute2(row2, "N") ?? attribute2(row2, "IX");
|
|
30682
31500
|
if (!name3 || !rowName) return void 0;
|
|
30683
31501
|
return `${name3}.${rowName}${attribute2(node2, "N") === "Value" && ["User", "Prop"].includes(name3) ? "" : `.${attribute2(node2, "N")}`}`;
|
|
30684
31502
|
}
|
|
@@ -31015,6 +31833,87 @@ function addReplacementPage(pagesPart, pages, rels, types, pagePaths, parts, dir
|
|
|
31015
31833
|
);
|
|
31016
31834
|
}
|
|
31017
31835
|
|
|
31836
|
+
// visio/edit-alt-text.ts
|
|
31837
|
+
function writeShapeAltText(shape, title, description, inherited = false) {
|
|
31838
|
+
const sections = children2(shape, "Section").filter(
|
|
31839
|
+
(section4) => attribute2(section4, "N") === "User"
|
|
31840
|
+
);
|
|
31841
|
+
if (sections.length > 1 || sections[0]?.hasAttribute("Del"))
|
|
31842
|
+
fail("UNSUPPORTED_METADATA_EDIT", "Ambiguous or deleted User sections cannot be edited.");
|
|
31843
|
+
let section3 = sections[0];
|
|
31844
|
+
let changed = false;
|
|
31845
|
+
for (const [name3, value] of [
|
|
31846
|
+
["visAltText", title],
|
|
31847
|
+
["visAltDescription", description]
|
|
31848
|
+
]) {
|
|
31849
|
+
const rows = children2(section3, "Row").filter((row3) => attribute2(row3, "N") === name3);
|
|
31850
|
+
if (rows.length > 1 || rows[0]?.hasAttribute("Del"))
|
|
31851
|
+
fail(
|
|
31852
|
+
"UNSUPPORTED_METADATA_EDIT",
|
|
31853
|
+
"Ambiguous or deleted accessibility rows cannot be edited."
|
|
31854
|
+
);
|
|
31855
|
+
let row2 = rows[0];
|
|
31856
|
+
const cells4 = children2(row2, "Cell").filter((cell2) => attribute2(cell2, "N") === "Value");
|
|
31857
|
+
if (cells4.length > 1 || cells4[0]?.hasAttribute("E") || executableCellFormula(attribute2(cells4[0], "F")))
|
|
31858
|
+
fail("UNSUPPORTED_METADATA_EDIT", "Formula-driven alternative text cannot be replaced.");
|
|
31859
|
+
let cell = cells4[0];
|
|
31860
|
+
if (attribute2(cell, "V") === value || !row2 && !value && !inherited) continue;
|
|
31861
|
+
const create2 = (tag) => shape.ownerDocument.createElementNS(shape.namespaceURI, tag);
|
|
31862
|
+
if (!section3) {
|
|
31863
|
+
section3 = create2("Section");
|
|
31864
|
+
section3.setAttribute("N", "User");
|
|
31865
|
+
const after = Array.from(shape.childNodes).find(
|
|
31866
|
+
(node2) => node2.nodeType === 1 && ["Text", "Data1", "Data2", "Data3", "ForeignData", "Shapes"].includes(
|
|
31867
|
+
node2.localName
|
|
31868
|
+
)
|
|
31869
|
+
);
|
|
31870
|
+
shape.insertBefore(section3, after ?? null);
|
|
31871
|
+
}
|
|
31872
|
+
if (!row2) {
|
|
31873
|
+
row2 = create2("Row");
|
|
31874
|
+
row2.setAttribute("N", name3);
|
|
31875
|
+
section3.appendChild(row2);
|
|
31876
|
+
}
|
|
31877
|
+
if (!cell) {
|
|
31878
|
+
cell = create2("Cell");
|
|
31879
|
+
cell.setAttribute("N", "Value");
|
|
31880
|
+
row2.insertBefore(cell, row2.firstChild);
|
|
31881
|
+
}
|
|
31882
|
+
cell.setAttribute("V", value);
|
|
31883
|
+
cell.setAttribute("U", "STR");
|
|
31884
|
+
cell.removeAttribute("F");
|
|
31885
|
+
changed = true;
|
|
31886
|
+
}
|
|
31887
|
+
return changed;
|
|
31888
|
+
}
|
|
31889
|
+
|
|
31890
|
+
// visio/edit-page-alt-text.ts
|
|
31891
|
+
async function setVisioPageAltText(pkg, pagesPart, pages, dirty, command2, check) {
|
|
31892
|
+
const page = pageById(pages, command2.pageId);
|
|
31893
|
+
const sheets = children2(page, "PageSheet");
|
|
31894
|
+
if (sheets.length > 1) fail("UNSUPPORTED_METADATA_EDIT", "Ambiguous PageSheet metadata.");
|
|
31895
|
+
for (const path of pkg.paths()) {
|
|
31896
|
+
if (!/^visio\/.*\.xml$/i.test(path)) continue;
|
|
31897
|
+
const part = path === pagesPart ? pages : dirty.get(path) ?? await pkg.readXml(path);
|
|
31898
|
+
for (const cell of Array.from(part.getElementsByTagNameNS(part.namespaceURI, "Cell"))) {
|
|
31899
|
+
check();
|
|
31900
|
+
const formula = executableCellFormula(attribute2(cell, "F"));
|
|
31901
|
+
if (formula && /\bUser\s*\.\s*visAlt(?:Text|Description)\b/i.test(formula))
|
|
31902
|
+
fail(
|
|
31903
|
+
"UNSUPPORTED_METADATA_EDIT",
|
|
31904
|
+
"A formula reads alternative text; dependent caches cannot be recalculated."
|
|
31905
|
+
);
|
|
31906
|
+
}
|
|
31907
|
+
}
|
|
31908
|
+
let sheet = sheets[0];
|
|
31909
|
+
if (!sheet) {
|
|
31910
|
+
if (!command2.title && !command2.description) return;
|
|
31911
|
+
sheet = page.ownerDocument.createElementNS(page.namespaceURI, "PageSheet");
|
|
31912
|
+
page.insertBefore(sheet, page.firstChild);
|
|
31913
|
+
}
|
|
31914
|
+
if (writeShapeAltText(sheet, command2.title, command2.description)) dirty.set(pagesPart, pages);
|
|
31915
|
+
}
|
|
31916
|
+
|
|
31018
31917
|
// visio/edit-page-create.ts
|
|
31019
31918
|
var officeRel2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
31020
31919
|
var pageType2 = "http://schemas.microsoft.com/visio/2010/relationships/page";
|
|
@@ -31096,7 +31995,7 @@ function removeDecoration(root2, pageName, kind, pageRoots, check) {
|
|
|
31096
31995
|
for (const shape of targets) container.removeChild(shape);
|
|
31097
31996
|
return true;
|
|
31098
31997
|
}
|
|
31099
|
-
function
|
|
31998
|
+
function text4(shape, cellName, value) {
|
|
31100
31999
|
const node2 = shape.ownerDocument.createElementNS(shape.namespaceURI, "Cell");
|
|
31101
32000
|
node2.setAttribute("N", cellName);
|
|
31102
32001
|
node2.setAttribute("V", value);
|
|
@@ -31132,10 +32031,10 @@ function decorationShape(root2, document, id3, spec, ratio) {
|
|
|
31132
32031
|
setCell(shape, "LocPinY", height / 2, "Height*0.5");
|
|
31133
32032
|
setCell(shape, "Angle", 0);
|
|
31134
32033
|
setCell(shape, "FillPattern", spec.fill ? 1 : 0);
|
|
31135
|
-
if (spec.fill)
|
|
32034
|
+
if (spec.fill) text4(shape, "FillForegnd", spec.fill);
|
|
31136
32035
|
setCell(shape, "LinePattern", spec.line ? 1 : 0);
|
|
31137
32036
|
if (spec.line) {
|
|
31138
|
-
|
|
32037
|
+
text4(shape, "LineColor", spec.line);
|
|
31139
32038
|
setCell(shape, "LineWeight", 1 / 72);
|
|
31140
32039
|
}
|
|
31141
32040
|
setCell(shape, "ShdwPattern", 0);
|
|
@@ -31292,6 +32191,10 @@ async function editVsdxPages(original, pkg, parts, commands, limits, maxOutput,
|
|
|
31292
32191
|
for (const command2 of commands) {
|
|
31293
32192
|
check();
|
|
31294
32193
|
const existing = children2(pages, "Page");
|
|
32194
|
+
if (command2.type === "set-page-alt-text") {
|
|
32195
|
+
await setVisioPageAltText(pkg, pagesPart, pages, dirty, command2, check);
|
|
32196
|
+
continue;
|
|
32197
|
+
}
|
|
31295
32198
|
if (command2.type === "set-page-setup") {
|
|
31296
32199
|
await setVisioPageSetup(pkg, pagesPart, pages, pagePaths, dirty, command2, check);
|
|
31297
32200
|
continue;
|
|
@@ -31387,7 +32290,7 @@ async function editVsdxPages(original, pkg, parts, commands, limits, maxOutput,
|
|
|
31387
32290
|
return { bytes: original, changedParts: [], diagnostics: [] };
|
|
31388
32291
|
}
|
|
31389
32292
|
if (commands.some(
|
|
31390
|
-
(command2) => command2.type !== "set-page-size" && command2.type !== "set-page-setup" && command2.type !== "set-page-layout" && command2.type !== "set-snap-glue"
|
|
32293
|
+
(command2) => command2.type !== "set-page-size" && command2.type !== "set-page-setup" && command2.type !== "set-page-layout" && command2.type !== "set-page-alt-text" && command2.type !== "set-snap-glue"
|
|
31391
32294
|
)) {
|
|
31392
32295
|
await updatePageAppProperties(pkg, pages, priorCount, dirty, limits, check);
|
|
31393
32296
|
await recalculatePageFormulas(pkg, pagesPart, pages, pagePaths, dirty, check);
|
|
@@ -31715,7 +32618,11 @@ function shapeFormattingWrites(edit) {
|
|
|
31715
32618
|
["endArrow", "EndArrow"],
|
|
31716
32619
|
["beginArrowSize", "BeginArrowSize"],
|
|
31717
32620
|
["endArrowSize", "EndArrowSize"],
|
|
31718
|
-
["lineCap", "LineCap"]
|
|
32621
|
+
["lineCap", "LineCap"],
|
|
32622
|
+
["lineJumpCode", "ConLineJumpCode"],
|
|
32623
|
+
["lineJumpStyle", "ConLineJumpStyle"],
|
|
32624
|
+
["lineJumpDirectionX", "ConLineJumpDirX"],
|
|
32625
|
+
["lineJumpDirectionY", "ConLineJumpDirY"]
|
|
31719
32626
|
])
|
|
31720
32627
|
if (edit[name3] !== void 0) add(cell, edit[name3], "LineStyle");
|
|
31721
32628
|
if (edit.rounding !== void 0) add("Rounding", edit.rounding / 72, "LineStyle", "PT");
|
|
@@ -31788,6 +32695,14 @@ async function applyFormattingEdit(pkg, pagePaths, roots, document, edit, check)
|
|
|
31788
32695
|
}
|
|
31789
32696
|
async function formatTarget(pkg, pagePaths, roots, document, edit, check, instance, root2, lenient) {
|
|
31790
32697
|
const shape = instance?.view ?? targetShape(root2, edit.shapeId);
|
|
32698
|
+
if (edit.type === "format-shape" && [edit.lineJumpCode, edit.lineJumpStyle, edit.lineJumpDirectionX, edit.lineJumpDirectionY].some(
|
|
32699
|
+
(value) => value !== void 0
|
|
32700
|
+
) && !(children2(shape, "Cell").some(
|
|
32701
|
+
(cell) => attribute2(cell, "N") === "OneD" && Number(attribute2(cell, "V")) === 1
|
|
32702
|
+
) || ["BeginX", "EndX"].every(
|
|
32703
|
+
(name3) => children2(shape, "Cell").some((cell) => attribute2(cell, "N") === name3)
|
|
32704
|
+
)))
|
|
32705
|
+
fail("INVALID_EDIT", "Line jump settings require a connector.");
|
|
31791
32706
|
if (instance) {
|
|
31792
32707
|
const layers = children2(shape, "Cell").find((cell) => attribute2(cell, "N") === "LayerMember");
|
|
31793
32708
|
await assertInstanceLayersUnlocked(pkg, edit.pageId, attribute2(layers, "V"));
|
|
@@ -31821,7 +32736,7 @@ async function formatTarget(pkg, pagePaths, roots, document, edit, check, instan
|
|
|
31821
32736
|
continue;
|
|
31822
32737
|
throw error;
|
|
31823
32738
|
}
|
|
31824
|
-
if (/^(LinePattern|FillPattern|FillGradientEnabled|LineGradientEnabled|LineColorTrans|FillForegndTrans|FillBkgndTrans|FillBkgnd|ShdwPattern|ShdwForegndTrans|ShapeShdwType|GlowColorTrans|ReflectionTrans|ReflectionSize|QuickStyle[A-Za-z]+)$/.test(
|
|
32739
|
+
if (/^(ConLineJump(?:Code|Style|DirX|DirY)|LinePattern|FillPattern|FillGradientEnabled|LineGradientEnabled|LineColorTrans|FillForegndTrans|FillBkgndTrans|FillBkgnd|ShdwPattern|ShdwForegndTrans|ShapeShdwType|GlowColorTrans|ReflectionTrans|ReflectionSize|QuickStyle[A-Za-z]+)$/.test(
|
|
31825
32740
|
write2.name
|
|
31826
32741
|
) && effective?.hasAttribute("U") && visioFormulaCachedValue("0", attribute2(effective, "U")).unit !== "scalar")
|
|
31827
32742
|
fail(
|
|
@@ -32713,6 +33628,56 @@ function applyMetadataEdit(roots, edit, check) {
|
|
|
32713
33628
|
return true;
|
|
32714
33629
|
}
|
|
32715
33630
|
|
|
33631
|
+
// visio/edit-alt-text-scope.ts
|
|
33632
|
+
async function applyShapeAltText(pkg, pagePaths, roots, edit, check) {
|
|
33633
|
+
const root2 = roots.get(edit.pageId);
|
|
33634
|
+
if (!root2) fail("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
|
|
33635
|
+
const target2 = textTarget(root2, edit.shapeId, check);
|
|
33636
|
+
const inspect6 = (part) => {
|
|
33637
|
+
for (const cell of Array.from(part.getElementsByTagNameNS(part.namespaceURI, "Cell"))) {
|
|
33638
|
+
check();
|
|
33639
|
+
const formula = executableCellFormula(attribute2(cell, "F"));
|
|
33640
|
+
if (formula && /\bUser\s*\.\s*visAlt(?:Text|Description)\b/i.test(formula))
|
|
33641
|
+
fail(
|
|
33642
|
+
"UNSUPPORTED_METADATA_EDIT",
|
|
33643
|
+
"A formula reads alternative text; dependent caches cannot be recalculated."
|
|
33644
|
+
);
|
|
33645
|
+
}
|
|
33646
|
+
};
|
|
33647
|
+
for (const page of roots.values()) inspect6(page);
|
|
33648
|
+
for (const path of pkg.paths()) {
|
|
33649
|
+
if (/^visio\/.*\.xml$/i.test(path) && !pagePaths.has(path)) inspect6(await pkg.readXml(path));
|
|
33650
|
+
}
|
|
33651
|
+
if (target2.masterId !== void 0) {
|
|
33652
|
+
const template = await masterTemplate(pkg)(target2.masterId, target2.masterShapeId);
|
|
33653
|
+
if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
|
|
33654
|
+
fail("UNSUPPORTED_METADATA_EDIT", "Chained master accessibility metadata is not supported.");
|
|
33655
|
+
const inherited = template.cloneNode(true);
|
|
33656
|
+
for (const section3 of children2(inherited, "Section").filter(
|
|
33657
|
+
(section4) => attribute2(section4, "N") === "User"
|
|
33658
|
+
)) {
|
|
33659
|
+
for (const row2 of children2(section3, "Row")) {
|
|
33660
|
+
const localRow = children2(target2.node, "Section").filter((s) => attribute2(s, "N") === "User").flatMap((s) => children2(s, "Row")).find((r) => attribute2(r, "N") === attribute2(row2, "N"));
|
|
33661
|
+
const local = children2(localRow, "Cell").find((cell) => attribute2(cell, "N") === "Value");
|
|
33662
|
+
if (local && attribute2(local, "F") !== "Inh") {
|
|
33663
|
+
for (const cell of children2(row2, "Cell").filter(
|
|
33664
|
+
(cell2) => attribute2(cell2, "N") === "Value"
|
|
33665
|
+
))
|
|
33666
|
+
row2.removeChild(cell);
|
|
33667
|
+
row2.appendChild(local.cloneNode(true));
|
|
33668
|
+
}
|
|
33669
|
+
}
|
|
33670
|
+
}
|
|
33671
|
+
writeShapeAltText(inherited, edit.title, edit.description, true);
|
|
33672
|
+
}
|
|
33673
|
+
return writeShapeAltText(
|
|
33674
|
+
target2.node,
|
|
33675
|
+
edit.title,
|
|
33676
|
+
edit.description,
|
|
33677
|
+
target2.masterId !== void 0
|
|
33678
|
+
);
|
|
33679
|
+
}
|
|
33680
|
+
|
|
32716
33681
|
// visio/edit-picture.ts
|
|
32717
33682
|
var FORMATS = {
|
|
32718
33683
|
"image/png": { extension: "png", compression: "PNG" },
|
|
@@ -32924,7 +33889,7 @@ function assertParentIndependent(facts, from, ids) {
|
|
|
32924
33889
|
}
|
|
32925
33890
|
|
|
32926
33891
|
// visio/edit-group.ts
|
|
32927
|
-
var
|
|
33892
|
+
var clean3 = (value) => Math.abs(value) < 1e-12 ? 0 : value;
|
|
32928
33893
|
var NONE = /* @__PURE__ */ new Map();
|
|
32929
33894
|
function topLevel(root2) {
|
|
32930
33895
|
const containers = children2(root2, "Shapes");
|
|
@@ -33044,7 +34009,7 @@ function groupVisioShapes(root2, document, edit, check, instances = NONE) {
|
|
|
33044
34009
|
const topmost = members3[members3.length - 1];
|
|
33045
34010
|
topmost.parentNode.insertBefore(group, topmost);
|
|
33046
34011
|
for (const plan of plans) {
|
|
33047
|
-
const x =
|
|
34012
|
+
const x = clean3(plan.pinX - minX), y = clean3(plan.pinY - minY);
|
|
33048
34013
|
const instance = instances.get(plan.member);
|
|
33049
34014
|
if (instance) placeInstance(instance, x, y, check);
|
|
33050
34015
|
else {
|
|
@@ -33117,9 +34082,9 @@ function ungroupVisioShape(root2, document, edit, check, instances = NONE) {
|
|
|
33117
34082
|
if (Math.abs(Math.abs(angle) - Math.PI) < 1e-12) angle = Math.PI;
|
|
33118
34083
|
const plan = {
|
|
33119
34084
|
member,
|
|
33120
|
-
pinX:
|
|
33121
|
-
pinY:
|
|
33122
|
-
angle:
|
|
34085
|
+
pinX: clean3(a * box4.pinX + c * box4.pinY + e),
|
|
34086
|
+
pinY: clean3(b * box4.pinX + d * box4.pinY + f),
|
|
34087
|
+
angle: clean3(angle),
|
|
33123
34088
|
flipX: box4.flipX !== parent.flipX ? 1 : 0,
|
|
33124
34089
|
flipY: box4.flipY !== parent.flipY ? 1 : 0,
|
|
33125
34090
|
box: box4
|
|
@@ -34336,9 +35301,22 @@ function positive2(value) {
|
|
|
34336
35301
|
return value;
|
|
34337
35302
|
}
|
|
34338
35303
|
async function editVsdx(input, edits, options = {}) {
|
|
34339
|
-
const clock = {
|
|
35304
|
+
const clock = {
|
|
35305
|
+
deadline: 0,
|
|
35306
|
+
autoSize: /* @__PURE__ */ new Set(),
|
|
35307
|
+
textSizes: [],
|
|
35308
|
+
jumpPages: /* @__PURE__ */ new Set(),
|
|
35309
|
+
jumpSource: void 0
|
|
35310
|
+
};
|
|
34340
35311
|
const edited = await editVsdxTransaction(input, edits, options, clock);
|
|
34341
|
-
const
|
|
35312
|
+
const resized = await refreshTextSizes(clock.textSizes, edited, options, clock.deadline);
|
|
35313
|
+
const result = await refreshLineJumpCaches(
|
|
35314
|
+
clock.jumpPages,
|
|
35315
|
+
clock.jumpSource,
|
|
35316
|
+
resized,
|
|
35317
|
+
options,
|
|
35318
|
+
clock.deadline
|
|
35319
|
+
);
|
|
34342
35320
|
return growAutoSizePages(
|
|
34343
35321
|
clock.autoSize,
|
|
34344
35322
|
result,
|
|
@@ -34348,7 +35326,13 @@ async function editVsdx(input, edits, options = {}) {
|
|
|
34348
35326
|
})
|
|
34349
35327
|
);
|
|
34350
35328
|
}
|
|
34351
|
-
async function editVsdxTransaction(input, edits, options, clock = {
|
|
35329
|
+
async function editVsdxTransaction(input, edits, options, clock = {
|
|
35330
|
+
deadline: 0,
|
|
35331
|
+
autoSize: /* @__PURE__ */ new Set(),
|
|
35332
|
+
textSizes: [],
|
|
35333
|
+
jumpPages: /* @__PURE__ */ new Set(),
|
|
35334
|
+
jumpSource: void 0
|
|
35335
|
+
}) {
|
|
34352
35336
|
const limits = { ...DEFAULTS, ...options.limits };
|
|
34353
35337
|
for (const value of Object.values(limits)) positive2(value);
|
|
34354
35338
|
const maxEdits = positive2(options.maxEdits ?? 1e3);
|
|
@@ -34360,10 +35344,14 @@ async function editVsdxTransaction(input, edits, options, clock = { deadline: 0,
|
|
|
34360
35344
|
if (Date.now() >= deadline) fail("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|
|
34361
35345
|
};
|
|
34362
35346
|
const allCommands = snapshotVisioEdits(edits, maxEdits, maxText);
|
|
35347
|
+
for (const command2 of allCommands)
|
|
35348
|
+
if ((command2.type === "set-page-layout" || command2.type === "format-shape") && Object.keys(command2).some((key2) => /^lineJump|^lineToLine/.test(key2)))
|
|
35349
|
+
clock.jumpPages.add(command2.pageId);
|
|
34363
35350
|
const commands = allCommands.filter((command2) => !isVisioPageEdit(command2));
|
|
34364
35351
|
const source = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
34365
35352
|
if (source.length > limits.maxInputBytes) fail("LIMIT_INPUT", "ZIP input exceeds limit.");
|
|
34366
35353
|
const original = new Uint8Array(source);
|
|
35354
|
+
if (clock.jumpPages.size) clock.jumpSource ??= original;
|
|
34367
35355
|
const subprocess = allCommands.find((command2) => command2.type === "create-subprocess");
|
|
34368
35356
|
if (subprocess) {
|
|
34369
35357
|
if (allCommands.length !== 1)
|
|
@@ -34630,7 +35618,7 @@ async function editVsdxTransaction(input, edits, options, clock = { deadline: 0,
|
|
|
34630
35618
|
if (command2.type === "format-text") await noteTextSize(command2, root2);
|
|
34631
35619
|
}
|
|
34632
35620
|
} else if (isVisioMetadataEdit(command2)) {
|
|
34633
|
-
if (applyMetadataEdit(roots, command2, check)) {
|
|
35621
|
+
if (command2.type === "set-shape-alt-text" ? await applyShapeAltText(pkg, new Set(pages.values()), roots, command2, check) : applyMetadataEdit(roots, command2, check)) {
|
|
34634
35622
|
dirty.set(path, root2);
|
|
34635
35623
|
metadataChanged = true;
|
|
34636
35624
|
}
|
|
@@ -35015,162 +36003,6 @@ async function createVsdx(options = {}) {
|
|
|
35015
36003
|
return writeEditedPackage(parts, DEFAULTS.maxInputBytes, deadline, check);
|
|
35016
36004
|
}
|
|
35017
36005
|
|
|
35018
|
-
// visio/line-jumps.ts
|
|
35019
|
-
var VISIO_LINE_JUMP_WIDTH = 2 / 3 * (1 / 6);
|
|
35020
|
-
var VISIO_LINE_JUMP_LIMITS = Object.freeze({ connectors: 2e3, segments: 2e4 });
|
|
35021
|
-
var TOKEN = /([MLZmlz]|[A-Za-z])|([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)/g;
|
|
35022
|
-
function polylines(path) {
|
|
35023
|
-
const result = [];
|
|
35024
|
-
let command2 = "";
|
|
35025
|
-
let pending;
|
|
35026
|
-
for (const match of path.matchAll(TOKEN)) {
|
|
35027
|
-
if (match[1]) {
|
|
35028
|
-
if (match[1] !== "M" && match[1] !== "L") return void 0;
|
|
35029
|
-
if (pending !== void 0) return void 0;
|
|
35030
|
-
command2 = match[1];
|
|
35031
|
-
continue;
|
|
35032
|
-
}
|
|
35033
|
-
const value = Number(match[2]);
|
|
35034
|
-
if (!Number.isFinite(value) || !command2) return void 0;
|
|
35035
|
-
if (pending === void 0) {
|
|
35036
|
-
pending = value;
|
|
35037
|
-
continue;
|
|
35038
|
-
}
|
|
35039
|
-
const point2 = { x: pending, y: value };
|
|
35040
|
-
pending = void 0;
|
|
35041
|
-
if (command2 === "M") {
|
|
35042
|
-
result.push([point2]);
|
|
35043
|
-
command2 = "L";
|
|
35044
|
-
} else result.at(-1)?.push(point2);
|
|
35045
|
-
}
|
|
35046
|
-
return pending === void 0 && result.every((line) => line.length > 1) ? result : void 0;
|
|
35047
|
-
}
|
|
35048
|
-
var apply2 = (m, p) => ({
|
|
35049
|
-
x: m[0] * p.x + m[2] * p.y + m[4],
|
|
35050
|
-
y: m[1] * p.x + m[3] * p.y + m[5]
|
|
35051
|
-
});
|
|
35052
|
-
function invert(m) {
|
|
35053
|
-
const det = m[0] * m[3] - m[1] * m[2];
|
|
35054
|
-
if (!Number.isFinite(det) || Math.abs(det) < 1e-12) return void 0;
|
|
35055
|
-
return [
|
|
35056
|
-
m[3] / det,
|
|
35057
|
-
-m[1] / det,
|
|
35058
|
-
-m[2] / det,
|
|
35059
|
-
m[0] / det,
|
|
35060
|
-
(m[2] * m[5] - m[3] * m[4]) / det,
|
|
35061
|
-
(m[1] * m[4] - m[0] * m[5]) / det
|
|
35062
|
-
];
|
|
35063
|
-
}
|
|
35064
|
-
var clean3 = (value) => Math.abs(value) < 1e-9 ? 0 : Number(value.toFixed(6));
|
|
35065
|
-
var text4 = (p) => `${clean3(p.x)} ${clean3(p.y)}`;
|
|
35066
|
-
var horizontal = (s) => Math.abs(s.a.y - s.b.y) < 1e-6 && Math.abs(s.a.x - s.b.x) > 1e-6;
|
|
35067
|
-
var vertical = (s) => Math.abs(s.a.x - s.b.x) < 1e-6 && Math.abs(s.a.y - s.b.y) > 1e-6;
|
|
35068
|
-
function crossing(s, other, margin) {
|
|
35069
|
-
const dx = s.b.x - s.a.x, dy = s.b.y - s.a.y, ox = other.b.x - other.a.x, oy = other.b.y - other.a.y;
|
|
35070
|
-
const det = dx * oy - dy * ox;
|
|
35071
|
-
const length = Math.hypot(dx, dy), otherLength = Math.hypot(ox, oy);
|
|
35072
|
-
if (Math.abs(det) < 1e-9 || Math.abs(det) / (length * otherLength) < 0.2) return void 0;
|
|
35073
|
-
const t = ((other.a.x - s.a.x) * oy - (other.a.y - s.a.y) * ox) / det;
|
|
35074
|
-
const u = ((other.a.x - s.a.x) * dy - (other.a.y - s.a.y) * dx) / det;
|
|
35075
|
-
if (u * otherLength < 1e-6 || (1 - u) * otherLength < 1e-6) return void 0;
|
|
35076
|
-
if (t * length < margin || (1 - t) * length < margin) return void 0;
|
|
35077
|
-
return t;
|
|
35078
|
-
}
|
|
35079
|
-
function jumps(code, s, other) {
|
|
35080
|
-
if (code === 1) return horizontal(s) && !horizontal(other);
|
|
35081
|
-
if (code === 2) return vertical(s) && !vertical(other);
|
|
35082
|
-
if (code === 3 || code === 4) return s.owner > other.owner;
|
|
35083
|
-
return code === 5 && s.owner < other.owner;
|
|
35084
|
-
}
|
|
35085
|
-
function jump(style2, from, to, local) {
|
|
35086
|
-
const half = Math.hypot(to.x - from.x, to.y - from.y) / 2;
|
|
35087
|
-
const ux = (to.x - from.x) / (2 * half), uy = (to.y - from.y) / (2 * half);
|
|
35088
|
-
let nx = -uy, ny = ux;
|
|
35089
|
-
if (ny < -1e-9 || Math.abs(ny) <= 1e-9 && nx > 0) {
|
|
35090
|
-
nx = -nx;
|
|
35091
|
-
ny = -ny;
|
|
35092
|
-
}
|
|
35093
|
-
const centre = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };
|
|
35094
|
-
const at2 = (along, out) => local({ x: centre.x + ux * along + nx * out, y: centre.y + uy * along + ny * out });
|
|
35095
|
-
const end = local(to);
|
|
35096
|
-
if (style2 === 1) return `M ${text4(end)}`;
|
|
35097
|
-
if (style2 === 2) return `L ${text4(at2(-half, half))} L ${text4(at2(half, half))} L ${text4(end)}`;
|
|
35098
|
-
if (style2 >= 3) {
|
|
35099
|
-
const sides = style2 - 1;
|
|
35100
|
-
let out = "";
|
|
35101
|
-
for (let index = 1; index < sides; ++index) {
|
|
35102
|
-
const angle = Math.PI - Math.PI * index / sides;
|
|
35103
|
-
out += `L ${text4(at2(Math.cos(angle) * half, Math.sin(angle) * half))} `;
|
|
35104
|
-
}
|
|
35105
|
-
return `${out}L ${text4(end)}`;
|
|
35106
|
-
}
|
|
35107
|
-
const start = local(from), top = at2(0, half);
|
|
35108
|
-
const radius = Math.hypot(end.x - start.x, end.y - start.y) / 2;
|
|
35109
|
-
const sweep = (end.x - start.x) * (top.y - start.y) - (end.y - start.y) * (top.x - start.x) > 0 ? 0 : 1;
|
|
35110
|
-
return `A ${clean3(radius)} ${clean3(radius)} 0 0 ${sweep} ${text4(end)}`;
|
|
35111
|
-
}
|
|
35112
|
-
var connector = (shape, glued) => shape.kind === "connector" && !shape.hidden && !shape.children.length && (shape.connectorRoute !== void 0 || glued.has(shape.id));
|
|
35113
|
-
function visioLineJumpPaths(page) {
|
|
35114
|
-
const result = /* @__PURE__ */ new Map();
|
|
35115
|
-
const layout = visioPageLayout(page);
|
|
35116
|
-
const code = layout.lineJumpCode;
|
|
35117
|
-
if (code < 1 || code > 5) return result;
|
|
35118
|
-
const glued = new Set(page.connectors.map((connection) => connection.fromShapeId));
|
|
35119
|
-
const shapes = page.shapes.filter((shape) => connector(shape, glued)).slice(0, VISIO_LINE_JUMP_LIMITS.connectors);
|
|
35120
|
-
if (shapes.length < 2) return result;
|
|
35121
|
-
const lines2 = [];
|
|
35122
|
-
const segments = [];
|
|
35123
|
-
shapes.forEach((shape, owner) => {
|
|
35124
|
-
shape.geometry.forEach((geometry, index) => {
|
|
35125
|
-
if (!geometry.stroke || geometry.fill) return;
|
|
35126
|
-
for (const line of polylines(geometry.path) ?? []) {
|
|
35127
|
-
const points = line.map((point2) => apply2(shape.transform, point2));
|
|
35128
|
-
lines2.push({ shape, owner, geometry: index, points });
|
|
35129
|
-
for (let i = 1; i < points.length; ++i)
|
|
35130
|
-
segments.push({ a: points[i - 1], b: points[i], owner });
|
|
35131
|
-
}
|
|
35132
|
-
});
|
|
35133
|
-
});
|
|
35134
|
-
if (segments.length > VISIO_LINE_JUMP_LIMITS.segments) return result;
|
|
35135
|
-
const half = VISIO_LINE_JUMP_WIDTH / 2;
|
|
35136
|
-
const paths = /* @__PURE__ */ new Map();
|
|
35137
|
-
const any = /* @__PURE__ */ new Set();
|
|
35138
|
-
for (const line of lines2) {
|
|
35139
|
-
const inverse = invert(line.shape.transform);
|
|
35140
|
-
if (!inverse) continue;
|
|
35141
|
-
const local = (point2) => apply2(inverse, point2);
|
|
35142
|
-
let out = `M ${text4(local(line.points[0]))}`;
|
|
35143
|
-
for (let i = 1; i < line.points.length; ++i) {
|
|
35144
|
-
const s = { a: line.points[i - 1], b: line.points[i], owner: line.owner };
|
|
35145
|
-
const length = Math.hypot(s.b.x - s.a.x, s.b.y - s.a.y);
|
|
35146
|
-
const hits = segments.filter((other) => other.owner !== s.owner && jumps(code, s, other)).flatMap((other) => crossing(s, other, half * 1.5) ?? []).sort((a, b) => a - b);
|
|
35147
|
-
let last = -Infinity;
|
|
35148
|
-
for (const t of hits) {
|
|
35149
|
-
if ((t - last) * length < half * 2.5) continue;
|
|
35150
|
-
last = t;
|
|
35151
|
-
const at2 = (offset) => ({
|
|
35152
|
-
x: s.a.x + (s.b.x - s.a.x) * (t * length + offset) / length,
|
|
35153
|
-
y: s.a.y + (s.b.y - s.a.y) * (t * length + offset) / length
|
|
35154
|
-
});
|
|
35155
|
-
out += ` L ${text4(local(at2(-half)))} ${jump(layout.lineJumpStyle, at2(-half), at2(half), local)}`;
|
|
35156
|
-
any.add(line.shape);
|
|
35157
|
-
}
|
|
35158
|
-
out += ` L ${text4(local(s.b))}`;
|
|
35159
|
-
}
|
|
35160
|
-
const byGeometry = paths.get(line.shape) ?? /* @__PURE__ */ new Map();
|
|
35161
|
-
byGeometry.set(line.geometry, [...byGeometry.get(line.geometry) ?? [], out]);
|
|
35162
|
-
paths.set(line.shape, byGeometry);
|
|
35163
|
-
}
|
|
35164
|
-
for (const shape of any) {
|
|
35165
|
-
const byGeometry = paths.get(shape);
|
|
35166
|
-
result.set(
|
|
35167
|
-
shape,
|
|
35168
|
-
shape.geometry.map((geometry, index) => byGeometry.get(index)?.join(" ") ?? geometry.path)
|
|
35169
|
-
);
|
|
35170
|
-
}
|
|
35171
|
-
return result;
|
|
35172
|
-
}
|
|
35173
|
-
|
|
35174
36006
|
// visio/open-arrow.ts
|
|
35175
36007
|
function visioOpenArrowExtent(size3, lineWidth) {
|
|
35176
36008
|
const index = Number.isFinite(size3) ? Math.max(0, Math.min(6, Math.trunc(size3))) : 2;
|
|
@@ -35263,6 +36095,31 @@ function trimVisioArrowLine(path, start, end, beginExtension = 0) {
|
|
|
35263
36095
|
return `M ${point2(start)}${base2 > start ? ` L ${point2(base2)}` : ""} L ${point2(length - end)}`;
|
|
35264
36096
|
}
|
|
35265
36097
|
|
|
36098
|
+
// visio/accessibility.ts
|
|
36099
|
+
function checkVisioAlternativeText(document) {
|
|
36100
|
+
const issues = [];
|
|
36101
|
+
for (const page of document.pages) {
|
|
36102
|
+
const visit = (shapes) => {
|
|
36103
|
+
for (const shape of shapes) {
|
|
36104
|
+
if (shape.hidden) continue;
|
|
36105
|
+
const named2 = [shape.accessibilityTitle, shape.alternativeText, shape.text.plainText].some(
|
|
36106
|
+
(value) => value?.trim()
|
|
36107
|
+
);
|
|
36108
|
+
if (!named2 && shape.kind !== "group")
|
|
36109
|
+
issues.push({
|
|
36110
|
+
pageId: page.id,
|
|
36111
|
+
shapeId: shape.id,
|
|
36112
|
+
shapeName: shape.name,
|
|
36113
|
+
code: "missing-alternative-text"
|
|
36114
|
+
});
|
|
36115
|
+
if (!named2) visit(shape.children);
|
|
36116
|
+
}
|
|
36117
|
+
};
|
|
36118
|
+
visit(page.shapes);
|
|
36119
|
+
}
|
|
36120
|
+
return issues;
|
|
36121
|
+
}
|
|
36122
|
+
|
|
35266
36123
|
exports.VISIO_ARROW_SHAPES = VISIO_ARROW_SHAPES;
|
|
35267
36124
|
exports.VISIO_BACKGROUND_STYLES = VISIO_BACKGROUND_STYLES;
|
|
35268
36125
|
exports.VISIO_BASIC_SHAPES = VISIO_BASIC_SHAPES;
|
|
@@ -35324,6 +36181,7 @@ exports.VisioPackageError = VisioPackageError;
|
|
|
35324
36181
|
exports.analyzeVisioFormula = analyzeVisioFormula;
|
|
35325
36182
|
exports.canonicalShapeDataValue = canonicalShapeDataValue;
|
|
35326
36183
|
exports.captureVisioClipboard = captureVisioClipboard;
|
|
36184
|
+
exports.checkVisioAlternativeText = checkVisioAlternativeText;
|
|
35327
36185
|
exports.convertVisioMetafile = convertVisioMetafile;
|
|
35328
36186
|
exports.createVsdx = createVsdx;
|
|
35329
36187
|
exports.deserializeVisioClipboard = deserializeVisioClipboard;
|