@syncfusion/ej2-docx 0.0.0-stage → 35.1.40
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/.gitleaksignore +35 -0
- package/README.md +68 -2
- package/core.js +4 -0
- package/dist/ej2-docx.umd.min.js +11 -0
- package/dist/ej2-docx.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx.es2015.js +66697 -0
- package/dist/es6/ej2-docx.es2015.js.map +1 -0
- package/dist/es6/ej2-docx.es5.js +77568 -0
- package/dist/es6/ej2-docx.es5.js.map +1 -0
- package/dist/global/ej2-docx.min.js +11 -0
- package/dist/global/ej2-docx.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/features.js +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -3
- package/src/all.d.ts +50 -0
- package/src/all.js +147 -0
- package/src/core/compat/base64.d.ts +13 -0
- package/src/core/compat/base64.js +90 -0
- package/src/core/compat/object-compat.d.ts +30 -0
- package/src/core/compat/object-compat.js +40 -0
- package/src/core/compat/sha256.d.ts +9 -0
- package/src/core/compat/sha256.js +98 -0
- package/src/core/errors/docx-error.d.ts +89 -0
- package/src/core/errors/docx-error.js +138 -0
- package/src/core/errors/error-codes.d.ts +8 -0
- package/src/core/errors/error-codes.js +0 -0
- package/src/core/errors/index.d.ts +10 -0
- package/src/core/errors/index.js +9 -0
- package/src/core/index.d.ts +12 -0
- package/src/core/index.js +12 -0
- package/src/core/mc/alternate-content.d.ts +7 -0
- package/src/core/mc/alternate-content.js +67 -0
- package/src/core/mc/attributes.d.ts +24 -0
- package/src/core/mc/attributes.js +82 -0
- package/src/core/mc/index.d.ts +7 -0
- package/src/core/mc/index.js +5 -0
- package/src/core/mc/inspect.d.ts +16 -0
- package/src/core/mc/inspect.js +148 -0
- package/src/core/mc/namespaces.d.ts +4 -0
- package/src/core/mc/namespaces.js +4 -0
- package/src/core/mc/scope.d.ts +6 -0
- package/src/core/mc/scope.js +47 -0
- package/src/core/opc/content-types.d.ts +34 -0
- package/src/core/opc/content-types.js +162 -0
- package/src/core/opc/index.d.ts +8 -0
- package/src/core/opc/index.js +4 -0
- package/src/core/opc/package.d.ts +49 -0
- package/src/core/opc/package.js +324 -0
- package/src/core/opc/part-name.d.ts +47 -0
- package/src/core/opc/part-name.js +205 -0
- package/src/core/opc/relationships.d.ts +46 -0
- package/src/core/opc/relationships.js +212 -0
- package/src/core/preservation/index.d.ts +2 -0
- package/src/core/preservation/index.js +1 -0
- package/src/core/preservation/opaque-body.d.ts +16 -0
- package/src/core/preservation/opaque-body.js +69 -0
- package/src/core/registry/block-handlers.d.ts +30 -0
- package/src/core/registry/block-handlers.js +36 -0
- package/src/core/registry/create-defaults.d.ts +39 -0
- package/src/core/registry/create-defaults.js +42 -0
- package/src/core/registry/feature-registry.d.ts +20 -0
- package/src/core/registry/feature-registry.js +29 -0
- package/src/core/registry/index.d.ts +9 -0
- package/src/core/registry/index.js +8 -0
- package/src/core/registry/inline-handlers.d.ts +20 -0
- package/src/core/registry/inline-handlers.js +30 -0
- package/src/core/registry/materialize-handlers.d.ts +35 -0
- package/src/core/registry/materialize-handlers.js +75 -0
- package/src/core/registry/multi-part-handlers.d.ts +37 -0
- package/src/core/registry/multi-part-handlers.js +206 -0
- package/src/core/registry/package-part-handlers.d.ts +28 -0
- package/src/core/registry/package-part-handlers.js +190 -0
- package/src/core/registry/part-handlers.d.ts +24 -0
- package/src/core/registry/part-handlers.js +172 -0
- package/src/core/registry/run-leaf-handlers.d.ts +26 -0
- package/src/core/registry/run-leaf-handlers.js +72 -0
- package/src/core/security/limits.d.ts +40 -0
- package/src/core/security/limits.js +26 -0
- package/src/core/xml/index.d.ts +7 -0
- package/src/core/xml/index.js +3 -0
- package/src/core/xml/model.d.ts +66 -0
- package/src/core/xml/model.js +17 -0
- package/src/core/xml/parse.d.ts +12 -0
- package/src/core/xml/parse.js +382 -0
- package/src/core/xml/serialize.d.ts +6 -0
- package/src/core/xml/serialize.js +93 -0
- package/src/core/zip/crc32.d.ts +2 -0
- package/src/core/zip/crc32.js +25 -0
- package/src/core/zip/deflate.d.ts +6 -0
- package/src/core/zip/deflate.js +6 -0
- package/src/core/zip/index.d.ts +10 -0
- package/src/core/zip/index.js +4 -0
- package/src/core/zip/inflate-raw.d.ts +17 -0
- package/src/core/zip/inflate-raw.js +450 -0
- package/src/core/zip/names.d.ts +6 -0
- package/src/core/zip/names.js +52 -0
- package/src/core/zip/read.d.ts +8 -0
- package/src/core/zip/read.js +262 -0
- package/src/core/zip/write.d.ts +7 -0
- package/src/core/zip/write.js +189 -0
- package/src/core/zip/zip-entry.d.ts +4 -0
- package/src/core/zip/zip-entry.js +0 -0
- package/src/features/bibliography/index.d.ts +100 -0
- package/src/features/bibliography/index.js +290 -0
- package/src/features/bookmarks/index.d.ts +331 -0
- package/src/features/bookmarks/index.js +1009 -0
- package/src/features/comments/comment-extensions.d.ts +157 -0
- package/src/features/comments/comment-extensions.js +356 -0
- package/src/features/comments/index.d.ts +579 -0
- package/src/features/comments/index.js +1727 -0
- package/src/features/content-controls/index.d.ts +821 -0
- package/src/features/content-controls/index.js +2857 -0
- package/src/features/custom-xml/index.d.ts +236 -0
- package/src/features/custom-xml/index.js +661 -0
- package/src/features/document/alignment.d.ts +23 -0
- package/src/features/document/alignment.js +36 -0
- package/src/features/document/alt-chunk.d.ts +103 -0
- package/src/features/document/alt-chunk.js +221 -0
- package/src/features/document/assert-never.d.ts +1 -0
- package/src/features/document/assert-never.js +4 -0
- package/src/features/document/augmentations.d.ts +578 -0
- package/src/features/document/augmentations.js +0 -0
- package/src/features/document/body-always-on.d.ts +36 -0
- package/src/features/document/body-always-on.js +66 -0
- package/src/features/document/body-blocks.d.ts +7 -0
- package/src/features/document/body-blocks.js +78 -0
- package/src/features/document/body-item-adapters.d.ts +62 -0
- package/src/features/document/body-item-adapters.js +97 -0
- package/src/features/document/body-item-collection.d.ts +151 -0
- package/src/features/document/body-item-collection.js +440 -0
- package/src/features/document/body-item.d.ts +35 -0
- package/src/features/document/body-item.js +8 -0
- package/src/features/document/body.d.ts +150 -0
- package/src/features/document/body.js +263 -0
- package/src/features/document/character-format.d.ts +413 -0
- package/src/features/document/character-format.js +2054 -0
- package/src/features/document/color.d.ts +178 -0
- package/src/features/document/color.js +495 -0
- package/src/features/document/document.d.ts +410 -0
- package/src/features/document/document.js +1049 -0
- package/src/features/document/element-type.d.ts +68 -0
- package/src/features/document/element-type.js +133 -0
- package/src/features/document/entity-type.d.ts +92 -0
- package/src/features/document/entity-type.js +93 -0
- package/src/features/document/feature-block.d.ts +16 -0
- package/src/features/document/feature-block.js +0 -0
- package/src/features/document/feature-inline.d.ts +13 -0
- package/src/features/document/feature-inline.js +0 -0
- package/src/features/document/feature-multi-package-part.d.ts +19 -0
- package/src/features/document/feature-multi-package-part.js +8 -0
- package/src/features/document/feature-package-level-part.d.ts +18 -0
- package/src/features/document/feature-package-level-part.js +8 -0
- package/src/features/document/feature-package-part.d.ts +14 -0
- package/src/features/document/feature-package-part.js +0 -0
- package/src/features/document/feature-run-leaf.d.ts +9 -0
- package/src/features/document/feature-run-leaf.js +0 -0
- package/src/features/document/headers-footers.d.ts +206 -0
- package/src/features/document/headers-footers.js +384 -0
- package/src/features/document/index.d.ts +41 -0
- package/src/features/document/index.js +34 -0
- package/src/features/document/length.d.ts +152 -0
- package/src/features/document/length.js +245 -0
- package/src/features/document/load-options.d.ts +14 -0
- package/src/features/document/load-options.js +0 -0
- package/src/features/document/locale-ids.d.ts +227 -0
- package/src/features/document/locale-ids.js +485 -0
- package/src/features/document/on-off.d.ts +9 -0
- package/src/features/document/on-off.js +27 -0
- package/src/features/document/page-setup.d.ts +339 -0
- package/src/features/document/page-setup.js +244 -0
- package/src/features/document/paragraph-format.d.ts +880 -0
- package/src/features/document/paragraph-format.js +2807 -0
- package/src/features/document/paragraph-item-collection.d.ts +162 -0
- package/src/features/document/paragraph-item-collection.js +363 -0
- package/src/features/document/paragraph-item.d.ts +83 -0
- package/src/features/document/paragraph-item.js +103 -0
- package/src/features/document/paragraph.d.ts +435 -0
- package/src/features/document/paragraph.js +888 -0
- package/src/features/document/run.d.ts +1 -0
- package/src/features/document/run.js +768 -0
- package/src/features/document/section-partition-flatten.d.ts +124 -0
- package/src/features/document/section-partition-flatten.js +217 -0
- package/src/features/document/section-properties-model.d.ts +13 -0
- package/src/features/document/section-properties-model.js +0 -0
- package/src/features/document/section.d.ts +93 -0
- package/src/features/document/section.js +178 -0
- package/src/features/document/sections.d.ts +103 -0
- package/src/features/document/sections.js +217 -0
- package/src/features/document/sub-super-script.d.ts +23 -0
- package/src/features/document/sub-super-script.js +43 -0
- package/src/features/document/text-range.d.ts +445 -0
- package/src/features/document/text-range.js +1156 -0
- package/src/features/document/typed-body-collections.d.ts +162 -0
- package/src/features/document/typed-body-collections.js +371 -0
- package/src/features/document/underline-style.d.ts +38 -0
- package/src/features/document/underline-style.js +126 -0
- package/src/features/document/units.d.ts +8 -0
- package/src/features/document/units.js +7 -0
- package/src/features/document/wml.d.ts +16 -0
- package/src/features/document/wml.js +67 -0
- package/src/features/drawing/authoring.d.ts +27 -0
- package/src/features/drawing/authoring.js +271 -0
- package/src/features/drawing/body-pr.d.ts +271 -0
- package/src/features/drawing/body-pr.js +663 -0
- package/src/features/drawing/drawing-shape.d.ts +1192 -0
- package/src/features/drawing/drawing-shape.js +3239 -0
- package/src/features/drawing/encode-builders.d.ts +176 -0
- package/src/features/drawing/encode-builders.js +390 -0
- package/src/features/drawing/fill-format.d.ts +52 -0
- package/src/features/drawing/fill-format.js +124 -0
- package/src/features/drawing/host-codec.d.ts +632 -0
- package/src/features/drawing/host-codec.js +2595 -0
- package/src/features/drawing/index.d.ts +13 -0
- package/src/features/drawing/index.js +33 -0
- package/src/features/drawing/line-format.d.ts +76 -0
- package/src/features/drawing/line-format.js +343 -0
- package/src/features/drawing/parse-register.d.ts +50 -0
- package/src/features/drawing/parse-register.js +257 -0
- package/src/features/drawing/residual-utils.d.ts +47 -0
- package/src/features/drawing/residual-utils.js +290 -0
- package/src/features/drawing/shape-types.d.ts +433 -0
- package/src/features/drawing/shape-types.js +437 -0
- package/src/features/drawing/sp-pr.d.ts +396 -0
- package/src/features/drawing/sp-pr.js +610 -0
- package/src/features/drawing/text-frame.d.ts +90 -0
- package/src/features/drawing/text-frame.js +152 -0
- package/src/features/drawing/types.d.ts +352 -0
- package/src/features/drawing/types.js +60 -0
- package/src/features/drawing/wrap-format.d.ts +62 -0
- package/src/features/drawing/wrap-format.js +114 -0
- package/src/features/editable-ranges/index.d.ts +494 -0
- package/src/features/editable-ranges/index.js +1348 -0
- package/src/features/fields/index.d.ts +428 -0
- package/src/features/fields/index.js +2148 -0
- package/src/features/fields/paragraph-field.d.ts +187 -0
- package/src/features/fields/paragraph-field.js +692 -0
- package/src/features/font-table/font-substitution-table.d.ts +75 -0
- package/src/features/font-table/font-substitution-table.js +257 -0
- package/src/features/font-table/font-table-entry.d.ts +255 -0
- package/src/features/font-table/font-table-entry.js +823 -0
- package/src/features/font-table/font-table.d.ts +128 -0
- package/src/features/font-table/font-table.js +313 -0
- package/src/features/font-table/index.d.ts +27 -0
- package/src/features/font-table/index.js +48 -0
- package/src/features/glossary/index.d.ts +97 -0
- package/src/features/glossary/index.js +286 -0
- package/src/features/headers-footers/index.d.ts +506 -0
- package/src/features/headers-footers/index.js +1666 -0
- package/src/features/hyperlinks/index.d.ts +230 -0
- package/src/features/hyperlinks/index.js +685 -0
- package/src/features/images/caption-authoring-api.d.ts +33 -0
- package/src/features/images/caption-authoring-api.js +33 -0
- package/src/features/images/caption-enums.d.ts +52 -0
- package/src/features/images/caption-enums.js +141 -0
- package/src/features/images/caption-host.d.ts +10 -0
- package/src/features/images/caption-host.js +21 -0
- package/src/features/images/captions.d.ts +13 -0
- package/src/features/images/captions.js +142 -0
- package/src/features/images/host-codec.d.ts +103 -0
- package/src/features/images/host-codec.js +720 -0
- package/src/features/images/image-sniff.d.ts +21 -0
- package/src/features/images/image-sniff.js +71 -0
- package/src/features/images/index.d.ts +506 -0
- package/src/features/images/index.js +1429 -0
- package/src/features/images/layout-types.d.ts +232 -0
- package/src/features/images/layout-types.js +294 -0
- package/src/features/images/public-entry.d.ts +9 -0
- package/src/features/images/public-entry.js +9 -0
- package/src/features/index.d.ts +35 -0
- package/src/features/index.js +36 -0
- package/src/features/mail-merge/index.d.ts +113 -0
- package/src/features/mail-merge/index.js +315 -0
- package/src/features/notes/index.d.ts +573 -0
- package/src/features/notes/index.js +1725 -0
- package/src/features/numbering/abstract-numbering.d.ts +90 -0
- package/src/features/numbering/abstract-numbering.js +292 -0
- package/src/features/numbering/index.d.ts +182 -0
- package/src/features/numbering/index.js +668 -0
- package/src/features/numbering/list-format.d.ts +158 -0
- package/src/features/numbering/list-format.js +590 -0
- package/src/features/numbering/list-string.d.ts +7 -0
- package/src/features/numbering/list-string.js +423 -0
- package/src/features/numbering/list-style.d.ts +204 -0
- package/src/features/numbering/list-style.js +1084 -0
- package/src/features/numbering/numbering-instance.d.ts +101 -0
- package/src/features/numbering/numbering-instance.js +329 -0
- package/src/features/numbering/numbering-level.d.ts +118 -0
- package/src/features/numbering/numbering-level.js +501 -0
- package/src/features/numbering/picture-bullet.d.ts +34 -0
- package/src/features/numbering/picture-bullet.js +88 -0
- package/src/features/ole-object/catalog.d.ts +300 -0
- package/src/features/ole-object/catalog.js +908 -0
- package/src/features/ole-object/index.d.ts +526 -0
- package/src/features/ole-object/index.js +1421 -0
- package/src/features/ole-object/relationship.d.ts +27 -0
- package/src/features/ole-object/relationship.js +27 -0
- package/src/features/ole-object/typed-dom.d.ts +186 -0
- package/src/features/ole-object/typed-dom.js +595 -0
- package/src/features/properties/index.d.ts +205 -0
- package/src/features/properties/index.js +549 -0
- package/src/features/revisions/index.d.ts +204 -0
- package/src/features/revisions/index.js +695 -0
- package/src/features/sections/column-collection.d.ts +119 -0
- package/src/features/sections/column-collection.js +478 -0
- package/src/features/sections/column.d.ts +15 -0
- package/src/features/sections/column.js +37 -0
- package/src/features/sections/index.d.ts +91 -0
- package/src/features/sections/index.js +1096 -0
- package/src/features/sections/margins.d.ts +40 -0
- package/src/features/sections/margins.js +105 -0
- package/src/features/sections/page-number-style.d.ts +21 -0
- package/src/features/sections/page-number-style.js +62 -0
- package/src/features/sections/page-orientation.d.ts +10 -0
- package/src/features/sections/page-orientation.js +10 -0
- package/src/features/sections/page-setup.d.ts +435 -0
- package/src/features/sections/page-setup.js +1479 -0
- package/src/features/sections/page-size.d.ts +59 -0
- package/src/features/sections/page-size.js +68 -0
- package/src/features/sections/section-break-code.d.ts +27 -0
- package/src/features/sections/section-break-code.js +60 -0
- package/src/features/sections/section-document-association.d.ts +18 -0
- package/src/features/sections/section-document-association.js +31 -0
- package/src/features/sections/section-validation.d.ts +43 -0
- package/src/features/sections/section-validation.js +97 -0
- package/src/features/settings/attached-template.d.ts +35 -0
- package/src/features/settings/attached-template.js +98 -0
- package/src/features/settings/compat-settings.d.ts +216 -0
- package/src/features/settings/compat-settings.js +508 -0
- package/src/features/settings/document-background.d.ts +59 -0
- package/src/features/settings/document-background.js +131 -0
- package/src/features/settings/document-protection.d.ts +65 -0
- package/src/features/settings/document-protection.js +157 -0
- package/src/features/settings/document-settings-facades.d.ts +108 -0
- package/src/features/settings/document-settings-facades.js +312 -0
- package/src/features/settings/document-settings-values.d.ts +43 -0
- package/src/features/settings/document-settings-values.js +60 -0
- package/src/features/settings/footnote-properties.d.ts +211 -0
- package/src/features/settings/footnote-properties.js +591 -0
- package/src/features/settings/index.d.ts +356 -0
- package/src/features/settings/index.js +829 -0
- package/src/features/settings/settings-children.d.ts +151 -0
- package/src/features/settings/settings-children.js +505 -0
- package/src/features/settings/web-settings.d.ts +88 -0
- package/src/features/settings/web-settings.js +227 -0
- package/src/features/settings/zoom.d.ts +79 -0
- package/src/features/settings/zoom.js +147 -0
- package/src/features/styles/builtin-catalog.d.ts +159 -0
- package/src/features/styles/builtin-catalog.js +963 -0
- package/src/features/styles/builtin-resolver.d.ts +49 -0
- package/src/features/styles/builtin-resolver.js +165 -0
- package/src/features/styles/default-styles.d.ts +37 -0
- package/src/features/styles/default-styles.js +186 -0
- package/src/features/styles/default-theme.d.ts +13 -0
- package/src/features/styles/default-theme.js +13 -0
- package/src/features/styles/doc-defaults.d.ts +58 -0
- package/src/features/styles/doc-defaults.js +178 -0
- package/src/features/styles/formatting-resolver.d.ts +27 -0
- package/src/features/styles/formatting-resolver.js +72 -0
- package/src/features/styles/index.d.ts +256 -0
- package/src/features/styles/index.js +1325 -0
- package/src/features/styles/latent-styles.d.ts +68 -0
- package/src/features/styles/latent-styles.js +305 -0
- package/src/features/styles/paragraph-properties.d.ts +71 -0
- package/src/features/styles/paragraph-properties.js +237 -0
- package/src/features/styles/run-properties.d.ts +93 -0
- package/src/features/styles/run-properties.js +516 -0
- package/src/features/styles/style-base.d.ts +402 -0
- package/src/features/styles/style-base.js +1026 -0
- package/src/features/styles/style-collection.d.ts +264 -0
- package/src/features/styles/style-collection.js +714 -0
- package/src/features/styles/style-format-bridge.d.ts +64 -0
- package/src/features/styles/style-format-bridge.js +100 -0
- package/src/features/styles/style.d.ts +84 -0
- package/src/features/styles/style.js +375 -0
- package/src/features/styles/styles-with-effects.d.ts +71 -0
- package/src/features/styles/styles-with-effects.js +180 -0
- package/src/features/styles/table-style.d.ts +272 -0
- package/src/features/styles/table-style.js +1226 -0
- package/src/features/styles/theme.d.ts +126 -0
- package/src/features/styles/theme.js +377 -0
- package/src/features/tables/border-style-map.d.ts +24 -0
- package/src/features/tables/border-style-map.js +81 -0
- package/src/features/tables/borders.d.ts +126 -0
- package/src/features/tables/borders.js +527 -0
- package/src/features/tables/collections.d.ts +113 -0
- package/src/features/tables/collections.js +261 -0
- package/src/features/tables/format.d.ts +208 -0
- package/src/features/tables/format.js +716 -0
- package/src/features/tables/index.d.ts +597 -0
- package/src/features/tables/index.js +2386 -0
- package/src/features/tables/paddings.d.ts +41 -0
- package/src/features/tables/paddings.js +97 -0
- package/src/features/tables/tbl-pr-positioning.d.ts +27 -0
- package/src/features/tables/tbl-pr-positioning.js +178 -0
- package/src/features/tables/tbl-pr.d.ts +528 -0
- package/src/features/tables/tbl-pr.js +1208 -0
- package/src/features/tables/tc-pr.d.ts +168 -0
- package/src/features/tables/tc-pr.js +553 -0
- package/src/features/tables/tr-pr.d.ts +60 -0
- package/src/features/tables/tr-pr.js +215 -0
- package/src/features/watermark/detect.d.ts +76 -0
- package/src/features/watermark/detect.js +219 -0
- package/src/features/watermark/index.d.ts +28 -0
- package/src/features/watermark/index.js +91 -0
- package/src/features/watermark/logical-store.d.ts +29 -0
- package/src/features/watermark/logical-store.js +31 -0
- package/src/features/watermark/model.d.ts +285 -0
- package/src/features/watermark/model.js +597 -0
- package/src/features/watermark/parse.d.ts +84 -0
- package/src/features/watermark/parse.js +815 -0
- package/src/features/watermark/serialize.d.ts +98 -0
- package/src/features/watermark/serialize.js +1517 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function (o) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
import { objectValues } from '../../core/compat/object-compat';
|
|
12
|
+
import { DocxError } from '../../core/errors/docx-error';
|
|
13
|
+
import { isStShapeType } from './shape-types';
|
|
14
|
+
import { A_NS, WPS_NS } from './host-codec';
|
|
15
|
+
/**
|
|
16
|
+
* DrawingML line preset dash (`ST_PresetLineDashVal` / `a:prstDash/@val`).
|
|
17
|
+
*
|
|
18
|
+
* Members are schema wire tokens. Prefer these constants over raw strings.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* DrawingML line dash style for public LineFormat APIs.
|
|
24
|
+
*
|
|
25
|
+
* Preset members match `ST_PresetLineDashVal` / `a:prstDash/@val` wire tokens.
|
|
26
|
+
* `Unknown` is model-only (custom dash, residual, or unrecognized). Never
|
|
27
|
+
* serialize `Unknown` as `a:prstDash/@val`.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export var LineDashing = {
|
|
32
|
+
Solid: 'solid',
|
|
33
|
+
Dot: 'dot',
|
|
34
|
+
Dash: 'dash',
|
|
35
|
+
LargeDash: 'lgDash',
|
|
36
|
+
DashDot: 'dashDot',
|
|
37
|
+
LargeDashDot: 'lgDashDot',
|
|
38
|
+
LargeDashDotDot: 'lgDashDotDot',
|
|
39
|
+
SystemDash: 'sysDash',
|
|
40
|
+
SystemDot: 'sysDot',
|
|
41
|
+
SystemDashDot: 'sysDashDot',
|
|
42
|
+
SystemDashDotDot: 'sysDashDotDot',
|
|
43
|
+
Unknown: 'unknown',
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Closed set of public LineDashing values.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export var LINE_DASHING_VALUES = objectValues(LineDashing);
|
|
50
|
+
/** Wire tokens for `a:prstDash/@val` (excludes model-only Unknown). @private */
|
|
51
|
+
var PRESET_LINE_DASH_WIRE_VALUES = LINE_DASHING_VALUES.filter(function (v) {
|
|
52
|
+
return v !== LineDashing.Unknown;
|
|
53
|
+
});
|
|
54
|
+
var LINE_DASHING_SET = new Set(LINE_DASHING_VALUES);
|
|
55
|
+
var PRESET_LINE_DASH_WIRE_SET = new Set(PRESET_LINE_DASH_WIRE_VALUES);
|
|
56
|
+
/**
|
|
57
|
+
* Whether `value` is a public LineDashing token (including Unknown).
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export function isLineDashing(value) {
|
|
61
|
+
return LINE_DASHING_SET.has(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether `value` is a schema `ST_PresetLineDashVal` wire token.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
function isPresetLineDashWire(value) {
|
|
68
|
+
return PRESET_LINE_DASH_WIRE_SET.has(value);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Specifies how open line ends are capped (`ST_LineCap` / `a:ln/@cap`).
|
|
72
|
+
*
|
|
73
|
+
* Prefer these constants over raw strings when setting line cap style.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export var LineCap = {
|
|
78
|
+
/**
|
|
79
|
+
* Round cap at each open end of the stroke.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
Round: 'rnd',
|
|
83
|
+
/**
|
|
84
|
+
* Square cap extending half the line width past each open end.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
Square: 'sq',
|
|
88
|
+
/**
|
|
89
|
+
* Flat cap that ends exactly at the line endpoint.
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
Flat: 'flat',
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Closed set of `ST_LineCap` wire tokens.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export var LINE_CAP_VALUES = objectValues(LineCap);
|
|
99
|
+
/**
|
|
100
|
+
* Specifies the arrowhead shape drawn at the beginning or end of a line
|
|
101
|
+
* (`ST_LineEndType` / `a:headEnd|a:tailEnd/@type`).
|
|
102
|
+
*
|
|
103
|
+
* Prefer these constants over raw strings when setting line end type.
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export var LineEndType = {
|
|
108
|
+
/**
|
|
109
|
+
* No arrowhead at the line end.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
None: 'none',
|
|
113
|
+
/**
|
|
114
|
+
* Filled triangular arrowhead.
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
Triangle: 'triangle',
|
|
118
|
+
/**
|
|
119
|
+
* Stealth (indented) arrowhead.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
Stealth: 'stealth',
|
|
123
|
+
/**
|
|
124
|
+
* Diamond-shaped line end marker.
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
Diamond: 'diamond',
|
|
128
|
+
/**
|
|
129
|
+
* Oval line end marker.
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
Oval: 'oval',
|
|
133
|
+
/**
|
|
134
|
+
* Open arrowhead.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
Arrow: 'arrow',
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Closed set of `ST_LineEndType` wire tokens.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export var LINE_END_TYPE_VALUES = objectValues(LineEndType);
|
|
144
|
+
/**
|
|
145
|
+
* DrawingML arrow end size tokens (`ST_LineEndWidth` / `ST_LineEndLength`).
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
148
|
+
export var LINE_END_SIZE_VALUES = ['sm', 'med', 'lg'];
|
|
149
|
+
/**
|
|
150
|
+
* Shape line fill kind discriminant (`EG_LineFillProperties` MVP).
|
|
151
|
+
*
|
|
152
|
+
* Members are model tokens (not a single XSD enum). Prefer these constants
|
|
153
|
+
* over raw strings when authoring {@link ShapeLine}.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export var ShapeLineKind = {
|
|
158
|
+
Solid: 'solid',
|
|
159
|
+
None: 'none',
|
|
160
|
+
Theme: 'theme',
|
|
161
|
+
Unknown: 'unknown',
|
|
162
|
+
};
|
|
163
|
+
var LINE_CAP_SET = new Set(LINE_CAP_VALUES);
|
|
164
|
+
var LINE_END_TYPE_SET = new Set(LINE_END_TYPE_VALUES);
|
|
165
|
+
var LINE_END_SIZE_SET = new Set(LINE_END_SIZE_VALUES);
|
|
166
|
+
/** Schema max for `ST_LineWidth` (`ST_Coordinate32Unqualified` ≤ 20116800). */
|
|
167
|
+
var LINE_WIDTH_MAX_EMU = 20116800;
|
|
168
|
+
/**
|
|
169
|
+
* Whether `value` is a schema `ST_LineCap` token.
|
|
170
|
+
*
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
export function isLineCap(value) {
|
|
174
|
+
return LINE_CAP_SET.has(value);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Whether `value` is a schema `ST_LineEndType` token.
|
|
178
|
+
*
|
|
179
|
+
* @private
|
|
180
|
+
*/
|
|
181
|
+
export function isLineEndType(value) {
|
|
182
|
+
return LINE_END_TYPE_SET.has(value);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Whether `value` is a schema `ST_LineEndWidth`/`ST_LineEndLength` token.
|
|
186
|
+
*
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
export function isLineEndSize(value) {
|
|
190
|
+
return LINE_END_SIZE_SET.has(value);
|
|
191
|
+
}
|
|
192
|
+
function elementChildren(el) {
|
|
193
|
+
return el.children.filter(function (c) { return c.kind === 'element'; });
|
|
194
|
+
}
|
|
195
|
+
function isElement(el, namespaceUri, localName) {
|
|
196
|
+
return el.namespaceUri === namespaceUri && el.localName === localName;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Shallow child lookup under `root` (direct element children only).
|
|
200
|
+
* Use for children of a known `wps:spPr` or `a:ln` parent.
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
export function findSpPrElement(root, namespaceUri, localName) {
|
|
205
|
+
var e_1, _a;
|
|
206
|
+
try {
|
|
207
|
+
for (var _b = __values(elementChildren(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
208
|
+
var child = _c.value;
|
|
209
|
+
if (isElement(child, namespaceUri, localName)) {
|
|
210
|
+
return child;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
215
|
+
finally {
|
|
216
|
+
try {
|
|
217
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
218
|
+
}
|
|
219
|
+
finally { if (e_1) throw e_1.error; }
|
|
220
|
+
}
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Deep first-match walker under `root` (including `root` itself).
|
|
225
|
+
* Local to this module so residual dual-AC hosts can be searched without a
|
|
226
|
+
* circular import on host-codec `findFirstElement`.
|
|
227
|
+
*/
|
|
228
|
+
function findDeepElement(root, namespaceUri, localName) {
|
|
229
|
+
var e_2, _a;
|
|
230
|
+
if (isElement(root, namespaceUri, localName)) {
|
|
231
|
+
return root;
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
for (var _b = __values(elementChildren(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
235
|
+
var child = _c.value;
|
|
236
|
+
var found = findDeepElement(child, namespaceUri, localName);
|
|
237
|
+
if (found !== undefined) {
|
|
238
|
+
return found;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
243
|
+
finally {
|
|
244
|
+
try {
|
|
245
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
246
|
+
}
|
|
247
|
+
finally { if (e_2) throw e_2.error; }
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
/** s:ST_HexColorRGB — six hex digits. */
|
|
252
|
+
var HEX6 = /^[0-9a-fA-F]{6}$/;
|
|
253
|
+
/**
|
|
254
|
+
* Read the sRGB color from a `CT_SolidColorFillProperties` (or `a:ln` fill).
|
|
255
|
+
* Only `a:srgbClr` is typed (GO MVP); other `EG_ColorChoice` members read as
|
|
256
|
+
* theme-ish `undefined` so the typed surface never invents values.
|
|
257
|
+
*/
|
|
258
|
+
export function solidFillSrgb(parent) {
|
|
259
|
+
var __ts33_0;
|
|
260
|
+
var srgb = findSpPrElement(parent, A_NS, 'srgbClr');
|
|
261
|
+
if (srgb === undefined) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
var val = ((__ts33_0 = srgb.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'val'; })), __ts33_0 == null ? undefined : __ts33_0.value);
|
|
265
|
+
return val !== undefined && HEX6.test(val) ? val.toLowerCase() : undefined;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Read DrawingML `a:alpha/@val` under a solid-fill parent (0…100000 opacity units).
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
export function solidFillAlpha(parent) {
|
|
272
|
+
var __ts33_a;
|
|
273
|
+
var srgb = findSpPrElement(parent, A_NS, 'srgbClr');
|
|
274
|
+
if (srgb === undefined) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
var alpha = findSpPrElement(srgb, A_NS, 'alpha');
|
|
278
|
+
if (alpha === undefined) {
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
var raw = ((__ts33_a = alpha.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'val'; })), __ts33_a == null ? undefined : __ts33_a.value);
|
|
282
|
+
if (raw === undefined || !/^\d+$/.test(raw)) {
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
var n = Number.parseInt(raw, 10);
|
|
286
|
+
return n >= 0 && n <= 100000 ? n : undefined;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Convert public transparency percent (0–100) to DrawingML alpha (0–100000 opacity).
|
|
290
|
+
* @private
|
|
291
|
+
*/
|
|
292
|
+
export function transparencyToAlpha(transparency) {
|
|
293
|
+
var t = Math.max(0, Math.min(100, transparency));
|
|
294
|
+
return Math.round((100 - t) * 1000);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Convert DrawingML alpha (0–100000 opacity) to public transparency percent (0–100).
|
|
298
|
+
* @private
|
|
299
|
+
*/
|
|
300
|
+
export function alphaToTransparency(alpha) {
|
|
301
|
+
if (alpha === undefined) {
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
var a = Math.max(0, Math.min(100000, alpha));
|
|
305
|
+
return Math.round(100 - a / 1000);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Read `wps:spPr` geometry/fill/line MVP state.
|
|
309
|
+
*
|
|
310
|
+
* Residual hosts are dual MC AlternateContent trees (`w:drawing` /
|
|
311
|
+
* `mc:AlternateContent` / `mc:Choice` / `wp:anchor` / `a:graphic` /
|
|
312
|
+
* `wps:wsp`), so `wps:spPr` and sibling `wps:style` are located with a deep
|
|
313
|
+
* walk. Children of the found `spPr` stay shallow.
|
|
314
|
+
*
|
|
315
|
+
* Cites: `CT_ShapeProperties` sequence + `EG_FillProperties`/`CT_LineProperties`
|
|
316
|
+
* (dml-main.xsd); `wps:style` residual theme formatting (CT_ShapeStyle).
|
|
317
|
+
*/
|
|
318
|
+
export function readShapePropertiesState(residual) {
|
|
319
|
+
var __ts33_1;
|
|
320
|
+
var spPr = findDeepElement(residual, WPS_NS, 'spPr');
|
|
321
|
+
if (spPr === undefined) {
|
|
322
|
+
return {
|
|
323
|
+
presetGeometry: undefined,
|
|
324
|
+
useCustomGeometry: false,
|
|
325
|
+
fill: undefined,
|
|
326
|
+
line: undefined,
|
|
327
|
+
hasThemeStyle: false,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
var prstGeom = findSpPrElement(spPr, A_NS, 'prstGeom');
|
|
331
|
+
var custGeom = findSpPrElement(spPr, A_NS, 'custGeom');
|
|
332
|
+
var prstRaw = prstGeom !== undefined
|
|
333
|
+
? (((__ts33_1 = prstGeom.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'prst'; })), __ts33_1 == null ? undefined : __ts33_1.value))
|
|
334
|
+
: undefined;
|
|
335
|
+
var presetGeometry = prstRaw !== undefined && isStShapeType(prstRaw) ? prstRaw : undefined;
|
|
336
|
+
var fill = parseFill(spPr);
|
|
337
|
+
var line = parseLine(spPr, findSpPrElement(spPr, A_NS, 'ln'));
|
|
338
|
+
var hasThemeStyle = findDeepElement(residual, WPS_NS, 'style') !== undefined;
|
|
339
|
+
return {
|
|
340
|
+
presetGeometry: presetGeometry,
|
|
341
|
+
useCustomGeometry: prstGeom === undefined && custGeom !== undefined,
|
|
342
|
+
fill: fill,
|
|
343
|
+
line: line,
|
|
344
|
+
hasThemeStyle: hasThemeStyle,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function parseFill(spPr) {
|
|
348
|
+
var __ts33_2;
|
|
349
|
+
if (findSpPrElement(spPr, A_NS, 'noFill') !== undefined) {
|
|
350
|
+
return { kind: 'none' };
|
|
351
|
+
}
|
|
352
|
+
var solid = findSpPrElement(spPr, A_NS, 'solidFill');
|
|
353
|
+
if (solid !== undefined) {
|
|
354
|
+
var srgb = solidFillSrgb(solid);
|
|
355
|
+
if (srgb === undefined) {
|
|
356
|
+
return { kind: 'theme' };
|
|
357
|
+
}
|
|
358
|
+
var alpha = solidFillAlpha(solid);
|
|
359
|
+
return alpha !== undefined
|
|
360
|
+
? { kind: 'solid', srgb: srgb, alpha: alpha }
|
|
361
|
+
: { kind: 'solid', srgb: srgb };
|
|
362
|
+
}
|
|
363
|
+
if (findSpPrElement(spPr, A_NS, 'pattFill') !== undefined) {
|
|
364
|
+
var patt = findSpPrElement(spPr, A_NS, 'pattFill');
|
|
365
|
+
var prst = patt !== undefined
|
|
366
|
+
? (((__ts33_2 = patt.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'prst'; })), __ts33_2 == null ? undefined : __ts33_2.value))
|
|
367
|
+
: undefined;
|
|
368
|
+
return { kind: 'pattern', preset: prst };
|
|
369
|
+
}
|
|
370
|
+
// gradFill / blipFill / grpFill are residual by GO; unmodeled → undefined.
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
function parseLineEnd(parent, localName) {
|
|
374
|
+
var __ts33_3, __ts33_4;
|
|
375
|
+
var el = findSpPrElement(parent, A_NS, localName);
|
|
376
|
+
if (el === undefined) {
|
|
377
|
+
return { type: undefined, size: undefined };
|
|
378
|
+
}
|
|
379
|
+
var typeRaw = ((__ts33_3 = el.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'type'; })), __ts33_3 == null ? undefined : __ts33_3.value);
|
|
380
|
+
var sizeRaw = ((__ts33_4 = el.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'w'; })), __ts33_4 == null ? undefined : __ts33_4.value);
|
|
381
|
+
return {
|
|
382
|
+
type: typeRaw !== undefined && isLineEndType(typeRaw) ? typeRaw : undefined,
|
|
383
|
+
size: sizeRaw !== undefined && isLineEndSize(sizeRaw) ? sizeRaw : undefined,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function parseLine(spPr, lnElement) {
|
|
387
|
+
var __ts33_5, __ts33_6, __ts33_7;
|
|
388
|
+
if (lnElement === undefined) {
|
|
389
|
+
// Absent a:ln: line formatting is inherited from wps:style lnRef (theme) —
|
|
390
|
+
// never invent a solid color.
|
|
391
|
+
return {
|
|
392
|
+
kind: 'theme',
|
|
393
|
+
widthEmu: undefined,
|
|
394
|
+
srgbColor: undefined,
|
|
395
|
+
alpha: undefined,
|
|
396
|
+
dash: undefined,
|
|
397
|
+
cap: undefined,
|
|
398
|
+
beginArrowType: undefined,
|
|
399
|
+
beginArrowSize: undefined,
|
|
400
|
+
endArrowType: undefined,
|
|
401
|
+
endArrowSize: undefined,
|
|
402
|
+
residual: false,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
// noFill inside a:ln == no line (EG_LineFillProperties choice).
|
|
406
|
+
var lnNoFill = findSpPrElement(lnElement, A_NS, 'noFill') !== undefined;
|
|
407
|
+
var lnSolid = findSpPrElement(lnElement, A_NS, 'solidFill');
|
|
408
|
+
var kind = lnSolid !== undefined ? 'solid' : 'theme';
|
|
409
|
+
var widthRaw = ((__ts33_5 = lnElement.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'w'; })), __ts33_5 == null ? undefined : __ts33_5.value);
|
|
410
|
+
var widthEmu = widthRaw !== undefined && /^\d+$/.test(widthRaw)
|
|
411
|
+
? Number.parseInt(widthRaw, 10)
|
|
412
|
+
: undefined;
|
|
413
|
+
var capRaw = ((__ts33_6 = lnElement.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'cap'; })), __ts33_6 == null ? undefined : __ts33_6.value);
|
|
414
|
+
var dashEl = findSpPrElement(lnElement, A_NS, 'prstDash');
|
|
415
|
+
var dashRaw = dashEl !== undefined
|
|
416
|
+
? ((__ts33_7 = dashEl.attributes.find(function (a) { return a.namespaceUri === '' && a.localName === 'val'; })), __ts33_7 == null ? undefined : __ts33_7.value) : undefined;
|
|
417
|
+
var head = parseLineEnd(lnElement, 'headEnd');
|
|
418
|
+
var tail = parseLineEnd(lnElement, 'tailEnd');
|
|
419
|
+
var residual = findSpPrElement(lnElement, A_NS, 'custDash') !== undefined ||
|
|
420
|
+
findSpPrElement(lnElement, A_NS, 'round') !== undefined ||
|
|
421
|
+
findSpPrElement(lnElement, A_NS, 'bevel') !== undefined ||
|
|
422
|
+
findSpPrElement(lnElement, A_NS, 'miter') !== undefined ||
|
|
423
|
+
(dashEl !== undefined && dashRaw !== undefined && !isPresetLineDashWire(dashRaw));
|
|
424
|
+
return {
|
|
425
|
+
kind: lnNoFill ? 'none' : kind,
|
|
426
|
+
widthEmu: widthEmu,
|
|
427
|
+
srgbColor: lnSolid !== undefined ? solidFillSrgb(lnSolid) : undefined,
|
|
428
|
+
alpha: lnSolid !== undefined ? solidFillAlpha(lnSolid) : undefined,
|
|
429
|
+
dash: dashRaw !== undefined && isPresetLineDashWire(dashRaw) ? dashRaw : undefined,
|
|
430
|
+
cap: capRaw !== undefined && isLineCap(capRaw) ? capRaw : undefined,
|
|
431
|
+
beginArrowType: head.type,
|
|
432
|
+
beginArrowSize: head.size,
|
|
433
|
+
endArrowType: tail.type,
|
|
434
|
+
endArrowSize: tail.size,
|
|
435
|
+
residual: residual,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function buildSrgbClr(val, alpha) {
|
|
439
|
+
var children = [];
|
|
440
|
+
if (alpha !== undefined && alpha >= 0 && alpha < 100000) {
|
|
441
|
+
children.push({
|
|
442
|
+
kind: 'element',
|
|
443
|
+
namespaceUri: A_NS,
|
|
444
|
+
localName: 'alpha',
|
|
445
|
+
prefix: 'a',
|
|
446
|
+
attributes: [
|
|
447
|
+
{ namespaceUri: '', localName: 'val', prefix: '', value: String(Math.round(alpha)) },
|
|
448
|
+
],
|
|
449
|
+
namespaceDeclarations: [],
|
|
450
|
+
children: [],
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
return {
|
|
454
|
+
kind: 'element',
|
|
455
|
+
namespaceUri: A_NS,
|
|
456
|
+
localName: 'srgbClr',
|
|
457
|
+
prefix: 'a',
|
|
458
|
+
attributes: [
|
|
459
|
+
{ namespaceUri: '', localName: 'val', prefix: '', value: val.toLowerCase() },
|
|
460
|
+
],
|
|
461
|
+
namespaceDeclarations: [],
|
|
462
|
+
children: children,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
function buildSolidFill(srgb, alpha) {
|
|
466
|
+
return {
|
|
467
|
+
kind: 'element',
|
|
468
|
+
namespaceUri: A_NS,
|
|
469
|
+
localName: 'solidFill',
|
|
470
|
+
prefix: 'a',
|
|
471
|
+
attributes: [],
|
|
472
|
+
namespaceDeclarations: [],
|
|
473
|
+
children: [buildSrgbClr(srgb, alpha)],
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function buildNoFill() {
|
|
477
|
+
return {
|
|
478
|
+
kind: 'element',
|
|
479
|
+
namespaceUri: A_NS,
|
|
480
|
+
localName: 'noFill',
|
|
481
|
+
prefix: 'a',
|
|
482
|
+
attributes: [],
|
|
483
|
+
namespaceDeclarations: [],
|
|
484
|
+
children: [],
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Build the fill element for modeled fill MVP. Throws on non-solid/none kinds
|
|
489
|
+
* (those go through residual).
|
|
490
|
+
*/
|
|
491
|
+
export function buildFillElement(fill) {
|
|
492
|
+
if (fill.kind === 'solid') {
|
|
493
|
+
return buildSolidFill(fill.srgb, fill.alpha);
|
|
494
|
+
}
|
|
495
|
+
if (fill.kind === 'none') {
|
|
496
|
+
return buildNoFill();
|
|
497
|
+
}
|
|
498
|
+
throw new DocxError('content/invalid-shape', "Only solid or noFill can be authored; kind \"" + String(fill.kind) + "\" is residual");
|
|
499
|
+
}
|
|
500
|
+
function buildHeadTail(localName, type, size) {
|
|
501
|
+
if (type === undefined && size === undefined) {
|
|
502
|
+
return undefined;
|
|
503
|
+
}
|
|
504
|
+
var attributes = [];
|
|
505
|
+
if (type !== undefined) {
|
|
506
|
+
attributes.push({ namespaceUri: '', localName: 'type', prefix: '', value: type });
|
|
507
|
+
}
|
|
508
|
+
if (size !== undefined) {
|
|
509
|
+
attributes.push({ namespaceUri: '', localName: 'w', prefix: '', value: size });
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
kind: 'element',
|
|
513
|
+
namespaceUri: A_NS,
|
|
514
|
+
localName: localName,
|
|
515
|
+
prefix: 'a',
|
|
516
|
+
attributes: attributes,
|
|
517
|
+
namespaceDeclarations: [],
|
|
518
|
+
children: [],
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Build `a:ln` from the modeled MVP subset; residual line children (join,
|
|
523
|
+
* custDash) are not re-emitted on this path.
|
|
524
|
+
*/
|
|
525
|
+
export function buildLineElement(line) {
|
|
526
|
+
var attributes = [];
|
|
527
|
+
if (line.widthEmu !== undefined) {
|
|
528
|
+
if (line.widthEmu < 0 || line.widthEmu > LINE_WIDTH_MAX_EMU) {
|
|
529
|
+
throw new DocxError('content/invalid-shape', "Line width " + String(line.widthEmu) + " EMU outside ST_LineWidth range 0\u202620116800");
|
|
530
|
+
}
|
|
531
|
+
attributes.push({
|
|
532
|
+
namespaceUri: '',
|
|
533
|
+
localName: 'w',
|
|
534
|
+
prefix: '',
|
|
535
|
+
value: String(line.widthEmu),
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
if (line.cap !== undefined) {
|
|
539
|
+
attributes.push({ namespaceUri: '', localName: 'cap', prefix: '', value: line.cap });
|
|
540
|
+
}
|
|
541
|
+
var children = [];
|
|
542
|
+
if (line.kind === 'solid') {
|
|
543
|
+
if (line.srgb === undefined) {
|
|
544
|
+
throw new DocxError('content/invalid-shape', 'Solid line requires an sRGB color');
|
|
545
|
+
}
|
|
546
|
+
children.push(buildSolidFill(line.srgb, line.alpha));
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
children.push(buildNoFill());
|
|
550
|
+
}
|
|
551
|
+
if (line.dash !== undefined) {
|
|
552
|
+
children.push({
|
|
553
|
+
kind: 'element',
|
|
554
|
+
namespaceUri: A_NS,
|
|
555
|
+
localName: 'prstDash',
|
|
556
|
+
prefix: 'a',
|
|
557
|
+
attributes: [
|
|
558
|
+
{ namespaceUri: '', localName: 'val', prefix: '', value: line.dash },
|
|
559
|
+
],
|
|
560
|
+
namespaceDeclarations: [],
|
|
561
|
+
children: [],
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
var head = buildHeadTail('headEnd', line.beginArrowType, line.beginArrowSize);
|
|
565
|
+
if (head !== undefined) {
|
|
566
|
+
children.push(head);
|
|
567
|
+
}
|
|
568
|
+
var tail = buildHeadTail('tailEnd', line.endArrowType, line.endArrowSize);
|
|
569
|
+
if (tail !== undefined) {
|
|
570
|
+
children.push(tail);
|
|
571
|
+
}
|
|
572
|
+
return {
|
|
573
|
+
kind: 'element',
|
|
574
|
+
namespaceUri: A_NS,
|
|
575
|
+
localName: 'ln',
|
|
576
|
+
prefix: 'a',
|
|
577
|
+
attributes: attributes,
|
|
578
|
+
namespaceDeclarations: [],
|
|
579
|
+
children: children,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Compound line style for shape outlines (public model).
|
|
584
|
+
* Single is the only modeled style in the current codec; other values stay residual-safe.
|
|
585
|
+
* @public
|
|
586
|
+
*/
|
|
587
|
+
export var LineStyle = {
|
|
588
|
+
Single: 'single',
|
|
589
|
+
};
|
|
590
|
+
/**
|
|
591
|
+
* Arrowhead style at a line end. Maps 1:1 to DrawingML `ST_LineEndType`.
|
|
592
|
+
* @public
|
|
593
|
+
*/
|
|
594
|
+
export var ArrowheadStyle = {
|
|
595
|
+
None: 'none',
|
|
596
|
+
Triangle: 'triangle',
|
|
597
|
+
Stealth: 'stealth',
|
|
598
|
+
Diamond: 'diamond',
|
|
599
|
+
Oval: 'oval',
|
|
600
|
+
Arrow: 'arrow',
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Arrowhead size (`ST_LineEndWidth` / `ST_LineEndLength`).
|
|
604
|
+
* @public
|
|
605
|
+
*/
|
|
606
|
+
export var ArrowheadSize = {
|
|
607
|
+
Small: 'sm',
|
|
608
|
+
Medium: 'med',
|
|
609
|
+
Large: 'lg',
|
|
610
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public TextFrame owned by Shape.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { TextDirection, TextVerticalAlignment } from './body-pr';
|
|
6
|
+
/**
|
|
7
|
+
* Owner hooks for {@link TextFrame} / {@link InternalMargin}.
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export interface TextFrameOwner {
|
|
11
|
+
/** @private */
|
|
12
|
+
readTextFrameDirection(): TextDirection | undefined;
|
|
13
|
+
/** @private */
|
|
14
|
+
writeTextFrameDirection(value: TextDirection): void;
|
|
15
|
+
/** @private */
|
|
16
|
+
readTextFrameVerticalAlignment(): TextVerticalAlignment | undefined;
|
|
17
|
+
/** @private */
|
|
18
|
+
writeTextFrameVerticalAlignment(value: TextVerticalAlignment): void;
|
|
19
|
+
/** @private */
|
|
20
|
+
readInternalMarginLeft(): number;
|
|
21
|
+
/** @private */
|
|
22
|
+
writeInternalMarginLeft(value: number): void;
|
|
23
|
+
/** @private */
|
|
24
|
+
readInternalMarginTop(): number;
|
|
25
|
+
/** @private */
|
|
26
|
+
writeInternalMarginTop(value: number): void;
|
|
27
|
+
/** @private */
|
|
28
|
+
readInternalMarginRight(): number;
|
|
29
|
+
/** @private */
|
|
30
|
+
writeInternalMarginRight(value: number): void;
|
|
31
|
+
/** @private */
|
|
32
|
+
readInternalMarginBottom(): number;
|
|
33
|
+
/** @private */
|
|
34
|
+
writeInternalMarginBottom(value: number): void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Internal text-frame margins in points (`wps:bodyPr` lIns/tIns/rIns/bIns).
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class InternalMargin {
|
|
41
|
+
private readonly owner;
|
|
42
|
+
/** @private */
|
|
43
|
+
constructor(owner: TextFrameOwner);
|
|
44
|
+
/**
|
|
45
|
+
* Distance between the text and the left shape boundary, in points.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
left: number;
|
|
49
|
+
/**
|
|
50
|
+
* Distance between the text and the top shape boundary, in points.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
top: number;
|
|
54
|
+
/**
|
|
55
|
+
* Distance between the text and the right shape boundary, in points.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
right: number;
|
|
59
|
+
/**
|
|
60
|
+
* Distance between the text and the bottom shape boundary, in points.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
bottom: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Text frame body properties (`wps:bodyPr` vertical direction + anchor + insets).
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare class TextFrame {
|
|
70
|
+
private readonly owner;
|
|
71
|
+
private readonly internalMarginValue;
|
|
72
|
+
/** @private */
|
|
73
|
+
constructor(owner: TextFrameOwner);
|
|
74
|
+
/**
|
|
75
|
+
* Text direction (`wps:bodyPr/@vert`).
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
textDirection: TextDirection;
|
|
79
|
+
/**
|
|
80
|
+
* Vertical text alignment inside the frame (`wps:bodyPr/@anchor`).
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
textVerticalAlignment: TextVerticalAlignment;
|
|
84
|
+
/**
|
|
85
|
+
* Internal margins between the shape boundary and its text (points).
|
|
86
|
+
* The returned object is owned by the text frame for the shape lifetime.
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
readonly internalMargin: InternalMargin;
|
|
90
|
+
}
|