@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,720 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __values = (this && this.__values) || function (o) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
14
|
+
if (m) return m.call(o);
|
|
15
|
+
return {
|
|
16
|
+
next: function () {
|
|
17
|
+
if (o && i >= o.length) o = void 0;
|
|
18
|
+
return { value: o && o[i++], done: !o };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Picture DrawingML host decode/encode helpers (`wp:inline` / `wp:anchor` + `pic:pic`).
|
|
24
|
+
*
|
|
25
|
+
* Schema cites (Transitional `dml-wordprocessingDrawing.xsd`):
|
|
26
|
+
* - `CT_Inline`, `CT_Anchor`, `EG_WrapType`
|
|
27
|
+
* - `CT_PosH` / `CT_PosV` (align XOR posOffset; relativeFrom required)
|
|
28
|
+
* - `ST_RelFromH`, `ST_RelFromV`, `ST_AlignH`, `ST_AlignV`
|
|
29
|
+
* DrawingML main: `a:xfrm` rot/flipH/flipV; `a:CT_NonVisualDrawingProps` name/descr/title
|
|
30
|
+
* Locks: `a:graphicFrameLocks/@noChangeAspect`
|
|
31
|
+
*
|
|
32
|
+
* Anchor promotion defaults mirror ink host-codec minimal Word-like anchor
|
|
33
|
+
* (distL/R 114300, relativeHeight 251658240, layoutInCell 1, allowOverlap 1,
|
|
34
|
+
* positionH column posOffset 0, positionV paragraph posOffset 0, wrapNone).
|
|
35
|
+
*
|
|
36
|
+
* @packageDocumentation
|
|
37
|
+
*/
|
|
38
|
+
import { emuToPoint, pointToCoordinateEmus, emus } from '../document/length';
|
|
39
|
+
import { isWml, wmlElement } from '../document/wml';
|
|
40
|
+
import { HorizontalOrigin, PicturePlacement, TextWrappingStyle, VerticalOrigin, isHorizontalAlignment, isHorizontalOrigin, isVerticalAlignment, isVerticalOrigin } from './layout-types';
|
|
41
|
+
var WP_NS = 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing';
|
|
42
|
+
var A_NS = 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
|
43
|
+
var PIC_NS = 'http://schemas.openxmlformats.org/drawingml/2006/picture';
|
|
44
|
+
var R_NS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
|
|
45
|
+
/** ST_Angle: 60000ths of a degree (ECMA-376 DrawingML). */
|
|
46
|
+
var ROTATION_UNITS_PER_DEGREE = 60000;
|
|
47
|
+
var PICTURE_GRAPHIC_DATA_URI = 'http://schemas.openxmlformats.org/drawingml/2006/picture';
|
|
48
|
+
function elementChildren(el) {
|
|
49
|
+
return el.children.filter(function (c) { return c.kind === 'element'; });
|
|
50
|
+
}
|
|
51
|
+
function isElement(el, namespaceUri, localName) {
|
|
52
|
+
return el.namespaceUri === namespaceUri && el.localName === localName;
|
|
53
|
+
}
|
|
54
|
+
function findFirstElement(root, namespaceUri, localName) {
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
if (isElement(root, namespaceUri, localName)) {
|
|
57
|
+
return root;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
for (var _b = __values(elementChildren(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
61
|
+
var child = _c.value;
|
|
62
|
+
var found = findFirstElement(child, namespaceUri, localName);
|
|
63
|
+
if (found !== undefined) {
|
|
64
|
+
return found;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
function attributeValue(el, namespaceUri, localName) {
|
|
78
|
+
var __ts33_0;
|
|
79
|
+
return ((__ts33_0 = el.attributes.find(function (a) { return a.namespaceUri === namespaceUri && a.localName === localName; })), __ts33_0 == null ? undefined : __ts33_0.value);
|
|
80
|
+
}
|
|
81
|
+
function textContent(el) {
|
|
82
|
+
var e_2, _a;
|
|
83
|
+
var out = '';
|
|
84
|
+
try {
|
|
85
|
+
for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
86
|
+
var child = _c.value;
|
|
87
|
+
if (child.kind === 'text') {
|
|
88
|
+
out += child.value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_2) throw e_2.error; }
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
function xmlElement(namespaceUri, prefix, localName, options) {
|
|
102
|
+
var __ts33_1, __ts33_2, __ts33_3;
|
|
103
|
+
return {
|
|
104
|
+
kind: 'element',
|
|
105
|
+
namespaceUri: namespaceUri,
|
|
106
|
+
localName: localName,
|
|
107
|
+
prefix: prefix,
|
|
108
|
+
attributes: ((__ts33_1 = options == null ? undefined : options.attributes), __ts33_1 != null ? __ts33_1 : []),
|
|
109
|
+
namespaceDeclarations: ((__ts33_2 = options == null ? undefined : options.namespaceDeclarations), __ts33_2 != null ? __ts33_2 : []),
|
|
110
|
+
children: ((__ts33_3 = options == null ? undefined : options.children), __ts33_3 != null ? __ts33_3 : []),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function attr(localName, value, namespaceUri, prefix) {
|
|
114
|
+
if (namespaceUri === void 0) { namespaceUri = ''; }
|
|
115
|
+
if (prefix === void 0) { prefix = ''; }
|
|
116
|
+
return { namespaceUri: namespaceUri, localName: localName, prefix: prefix, value: value };
|
|
117
|
+
}
|
|
118
|
+
function blipEmbedAttribute(id) {
|
|
119
|
+
return { namespaceUri: R_NS, localName: 'embed', prefix: 'r', value: id };
|
|
120
|
+
}
|
|
121
|
+
function extentAttributes(widthEmu, heightEmu) {
|
|
122
|
+
return [attr('cx', String(widthEmu)), attr('cy', String(heightEmu))];
|
|
123
|
+
}
|
|
124
|
+
function parseOnOff(raw) {
|
|
125
|
+
return raw === '1' || raw === 'true';
|
|
126
|
+
}
|
|
127
|
+
function parseXfrm(picRoot) {
|
|
128
|
+
var xfrm = findFirstElement(picRoot, A_NS, 'xfrm');
|
|
129
|
+
if (xfrm === undefined) {
|
|
130
|
+
return { rotation: 0, flipHorizontal: false, flipVertical: false };
|
|
131
|
+
}
|
|
132
|
+
var rotRaw = attributeValue(xfrm, '', 'rot');
|
|
133
|
+
var rotation = rotRaw !== undefined && /^-?\d+$/.test(rotRaw)
|
|
134
|
+
? Number.parseInt(rotRaw, 10) / ROTATION_UNITS_PER_DEGREE
|
|
135
|
+
: 0;
|
|
136
|
+
return {
|
|
137
|
+
rotation: rotation,
|
|
138
|
+
flipHorizontal: parseOnOff(attributeValue(xfrm, '', 'flipH')),
|
|
139
|
+
flipVertical: parseOnOff(attributeValue(xfrm, '', 'flipV')),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function parseHlinkClickRelId(parent) {
|
|
143
|
+
var e_3, _a;
|
|
144
|
+
if (parent === undefined) {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
for (var _b = __values(elementChildren(parent)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
149
|
+
var child = _c.value;
|
|
150
|
+
if (isElement(child, A_NS, 'hlinkClick')) {
|
|
151
|
+
var relId = attributeValue(child, R_NS, 'id');
|
|
152
|
+
if (relId !== undefined && relId.length > 0) {
|
|
153
|
+
return relId;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
159
|
+
finally {
|
|
160
|
+
try {
|
|
161
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
162
|
+
}
|
|
163
|
+
finally { if (e_3) throw e_3.error; }
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
function parseDocPr(host) {
|
|
168
|
+
var __ts33_4;
|
|
169
|
+
var docPr = findFirstElement(host, WP_NS, 'docPr');
|
|
170
|
+
if (docPr === undefined) {
|
|
171
|
+
return { name: 'Picture', title: undefined, description: undefined, id: 1, hyperlinkRelationshipId: undefined };
|
|
172
|
+
}
|
|
173
|
+
var idRaw = attributeValue(docPr, '', 'id');
|
|
174
|
+
var id = idRaw !== undefined && /^\d+$/.test(idRaw) ? Number.parseInt(idRaw, 10) : 1;
|
|
175
|
+
return {
|
|
176
|
+
name: ((__ts33_4 = attributeValue(docPr, '', 'name')), __ts33_4 != null ? __ts33_4 : 'Picture'),
|
|
177
|
+
title: attributeValue(docPr, '', 'title'),
|
|
178
|
+
description: attributeValue(docPr, '', 'descr'),
|
|
179
|
+
id: id,
|
|
180
|
+
hyperlinkRelationshipId: parseHlinkClickRelId(docPr),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function parseLockAspect(host) {
|
|
184
|
+
var locks = findFirstElement(host, A_NS, 'graphicFrameLocks');
|
|
185
|
+
if (locks === undefined) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return parseOnOff(attributeValue(locks, '', 'noChangeAspect'));
|
|
189
|
+
}
|
|
190
|
+
function parsePosOffset(parent) {
|
|
191
|
+
if (parent === undefined) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
var offset = elementChildren(parent).find(function (c) { return isElement(c, WP_NS, 'posOffset'); });
|
|
195
|
+
if (offset === undefined) {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
var raw = textContent(offset).trim();
|
|
199
|
+
if (!/^-?\d+$/.test(raw)) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
return emuToPoint(Number.parseInt(raw, 10));
|
|
203
|
+
}
|
|
204
|
+
function parseAlignChild(parent, axis) {
|
|
205
|
+
if (parent === undefined) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
var alignEl = elementChildren(parent).find(function (c) { return isElement(c, WP_NS, 'align'); });
|
|
209
|
+
if (alignEl === undefined) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
var raw = textContent(alignEl).trim();
|
|
213
|
+
if (axis === 'h') {
|
|
214
|
+
return isHorizontalAlignment(raw) ? raw : undefined;
|
|
215
|
+
}
|
|
216
|
+
return isVerticalAlignment(raw) ? raw : undefined;
|
|
217
|
+
}
|
|
218
|
+
function parseWrapping(host, placement) {
|
|
219
|
+
if (placement === PicturePlacement.Inline) {
|
|
220
|
+
return TextWrappingStyle.Inline;
|
|
221
|
+
}
|
|
222
|
+
if (findFirstElement(host, WP_NS, 'wrapNone') !== undefined) {
|
|
223
|
+
return TextWrappingStyle.None;
|
|
224
|
+
}
|
|
225
|
+
if (findFirstElement(host, WP_NS, 'wrapSquare') !== undefined) {
|
|
226
|
+
return TextWrappingStyle.Square;
|
|
227
|
+
}
|
|
228
|
+
if (findFirstElement(host, WP_NS, 'wrapTight') !== undefined) {
|
|
229
|
+
return TextWrappingStyle.Tight;
|
|
230
|
+
}
|
|
231
|
+
if (findFirstElement(host, WP_NS, 'wrapThrough') !== undefined) {
|
|
232
|
+
return TextWrappingStyle.Through;
|
|
233
|
+
}
|
|
234
|
+
if (findFirstElement(host, WP_NS, 'wrapTopAndBottom') !== undefined) {
|
|
235
|
+
return TextWrappingStyle.TopAndBottom;
|
|
236
|
+
}
|
|
237
|
+
return TextWrappingStyle.None;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Decode a picture `w:drawing` (inline or anchor with `a:blip` embed).
|
|
241
|
+
*
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
export function decodePictureHost(drawing) {
|
|
245
|
+
var __ts33_5;
|
|
246
|
+
if (!isWml(drawing, 'drawing')) {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
var blip = findFirstElement(drawing, A_NS, 'blip');
|
|
250
|
+
if (blip === undefined) {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
var embed = attributeValue(blip, R_NS, 'embed');
|
|
254
|
+
if (embed === undefined || embed.length === 0) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
var inline = findFirstElement(drawing, WP_NS, 'inline');
|
|
258
|
+
var anchor = findFirstElement(drawing, WP_NS, 'anchor');
|
|
259
|
+
var host = inline != null ? inline : anchor;
|
|
260
|
+
if (host === undefined) {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
var placement = inline !== undefined ? PicturePlacement.Inline : PicturePlacement.Anchored;
|
|
264
|
+
var extent = findFirstElement(host, WP_NS, 'extent');
|
|
265
|
+
if (extent === undefined) {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
var cxRaw = attributeValue(extent, '', 'cx');
|
|
269
|
+
var cyRaw = attributeValue(extent, '', 'cy');
|
|
270
|
+
// cx/cy=0 is invalid for DrawingML extents; keep the drawing opaque for round-trip.
|
|
271
|
+
if (cxRaw === undefined ||
|
|
272
|
+
cyRaw === undefined ||
|
|
273
|
+
!/^\d+$/.test(cxRaw) ||
|
|
274
|
+
!/^\d+$/.test(cyRaw) ||
|
|
275
|
+
cxRaw === '0' ||
|
|
276
|
+
cyRaw === '0') {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
var positionH = findFirstElement(host, WP_NS, 'positionH');
|
|
280
|
+
var positionV = findFirstElement(host, WP_NS, 'positionV');
|
|
281
|
+
var hOriginRaw = positionH !== undefined ? attributeValue(positionH, '', 'relativeFrom') : undefined;
|
|
282
|
+
var vOriginRaw = positionV !== undefined ? attributeValue(positionV, '', 'relativeFrom') : undefined;
|
|
283
|
+
var pic = ((__ts33_5 = findFirstElement(drawing, PIC_NS, 'pic')), __ts33_5 != null ? __ts33_5 : drawing);
|
|
284
|
+
var xfrm = parseXfrm(pic);
|
|
285
|
+
var docPr = parseDocPr(host);
|
|
286
|
+
var cNvPr = findFirstElement(pic, PIC_NS, 'cNvPr');
|
|
287
|
+
var hyperlinkRelationshipId = docPr.hyperlinkRelationshipId != null
|
|
288
|
+
? docPr.hyperlinkRelationshipId
|
|
289
|
+
: parseHlinkClickRelId(cNvPr);
|
|
290
|
+
return {
|
|
291
|
+
placement: placement,
|
|
292
|
+
wrapping: parseWrapping(host, placement),
|
|
293
|
+
widthEmu: emus(Number.parseInt(cxRaw, 10)),
|
|
294
|
+
heightEmu: emus(Number.parseInt(cyRaw, 10)),
|
|
295
|
+
relationshipId: embed,
|
|
296
|
+
name: docPr.name,
|
|
297
|
+
title: docPr.title,
|
|
298
|
+
description: docPr.description,
|
|
299
|
+
lockAspectRatio: parseLockAspect(host),
|
|
300
|
+
rotation: xfrm.rotation,
|
|
301
|
+
flipHorizontal: xfrm.flipHorizontal,
|
|
302
|
+
flipVertical: xfrm.flipVertical,
|
|
303
|
+
horizontalOrigin: hOriginRaw !== undefined && isHorizontalOrigin(hOriginRaw) ? hOriginRaw : undefined,
|
|
304
|
+
verticalOrigin: vOriginRaw !== undefined && isVerticalOrigin(vOriginRaw) ? vOriginRaw : undefined,
|
|
305
|
+
horizontalPosition: parsePosOffset(positionH),
|
|
306
|
+
verticalPosition: parsePosOffset(positionV),
|
|
307
|
+
horizontalAlignment: parseAlignChild(positionH, 'h'),
|
|
308
|
+
verticalAlignment: parseAlignChild(positionV, 'v'),
|
|
309
|
+
docPrId: docPr.id,
|
|
310
|
+
hyperlinkRelationshipId: hyperlinkRelationshipId,
|
|
311
|
+
preservedHost: drawing,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function buildHlinkClick(relationshipId) {
|
|
315
|
+
return xmlElement(A_NS, 'a', 'hlinkClick', {
|
|
316
|
+
attributes: [attr('id', relationshipId, R_NS, 'r')],
|
|
317
|
+
children: [],
|
|
318
|
+
namespaceDeclarations: [],
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function buildDocPr(input) {
|
|
322
|
+
var attributes = [
|
|
323
|
+
attr('id', String(input.docPrId)),
|
|
324
|
+
attr('name', input.name),
|
|
325
|
+
];
|
|
326
|
+
if (input.description !== undefined && input.description.length > 0) {
|
|
327
|
+
attributes.push(attr('descr', input.description));
|
|
328
|
+
}
|
|
329
|
+
if (input.title !== undefined && input.title.length > 0) {
|
|
330
|
+
attributes.push(attr('title', input.title));
|
|
331
|
+
}
|
|
332
|
+
var children = [];
|
|
333
|
+
if (input.hyperlinkRelationshipId !== undefined && input.hyperlinkRelationshipId.length > 0) {
|
|
334
|
+
children.push(buildHlinkClick(input.hyperlinkRelationshipId));
|
|
335
|
+
}
|
|
336
|
+
return xmlElement(WP_NS, 'wp', 'docPr', { attributes: attributes, children: children });
|
|
337
|
+
}
|
|
338
|
+
function buildEffectExtent() {
|
|
339
|
+
return xmlElement(WP_NS, 'wp', 'effectExtent', {
|
|
340
|
+
attributes: [attr('l', '0'), attr('t', '0'), attr('r', '0'), attr('b', '0')],
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function buildCNvGraphicFramePr(lockAspectRatio) {
|
|
344
|
+
var lockAttrs = lockAspectRatio
|
|
345
|
+
? [attr('noChangeAspect', '1')]
|
|
346
|
+
: [];
|
|
347
|
+
return xmlElement(WP_NS, 'wp', 'cNvGraphicFramePr', {
|
|
348
|
+
children: [
|
|
349
|
+
xmlElement(A_NS, 'a', 'graphicFrameLocks', {
|
|
350
|
+
attributes: lockAttrs,
|
|
351
|
+
}),
|
|
352
|
+
],
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function buildPic(input) {
|
|
356
|
+
var xfrmAttrs = [];
|
|
357
|
+
if (input.rotation !== 0) {
|
|
358
|
+
xfrmAttrs.push(attr('rot', String(Math.round(input.rotation * ROTATION_UNITS_PER_DEGREE))));
|
|
359
|
+
}
|
|
360
|
+
if (input.flipHorizontal) {
|
|
361
|
+
xfrmAttrs.push(attr('flipH', '1'));
|
|
362
|
+
}
|
|
363
|
+
if (input.flipVertical) {
|
|
364
|
+
xfrmAttrs.push(attr('flipV', '1'));
|
|
365
|
+
}
|
|
366
|
+
var blipFill = xmlElement(PIC_NS, 'pic', 'blipFill', {
|
|
367
|
+
children: [
|
|
368
|
+
xmlElement(A_NS, 'a', 'blip', { attributes: [blipEmbedAttribute(input.relationshipId)] }),
|
|
369
|
+
xmlElement(A_NS, 'a', 'stretch', {
|
|
370
|
+
children: [xmlElement(A_NS, 'a', 'fillRect')],
|
|
371
|
+
}),
|
|
372
|
+
],
|
|
373
|
+
});
|
|
374
|
+
var spPr = xmlElement(PIC_NS, 'pic', 'spPr', {
|
|
375
|
+
children: [
|
|
376
|
+
xmlElement(A_NS, 'a', 'xfrm', {
|
|
377
|
+
attributes: xfrmAttrs,
|
|
378
|
+
children: [
|
|
379
|
+
xmlElement(A_NS, 'a', 'off', {
|
|
380
|
+
attributes: [attr('x', '0'), attr('y', '0')],
|
|
381
|
+
}),
|
|
382
|
+
xmlElement(A_NS, 'a', 'ext', {
|
|
383
|
+
attributes: extentAttributes(input.widthEmu, input.heightEmu),
|
|
384
|
+
}),
|
|
385
|
+
],
|
|
386
|
+
}),
|
|
387
|
+
xmlElement(A_NS, 'a', 'prstGeom', {
|
|
388
|
+
attributes: [attr('prst', 'rect')],
|
|
389
|
+
children: [xmlElement(A_NS, 'a', 'avLst')],
|
|
390
|
+
}),
|
|
391
|
+
],
|
|
392
|
+
});
|
|
393
|
+
return xmlElement(PIC_NS, 'pic', 'pic', {
|
|
394
|
+
namespaceDeclarations: [
|
|
395
|
+
{ prefix: 'pic', namespaceUri: PIC_NS },
|
|
396
|
+
{ prefix: 'a', namespaceUri: A_NS },
|
|
397
|
+
{ prefix: 'r', namespaceUri: R_NS },
|
|
398
|
+
],
|
|
399
|
+
children: [
|
|
400
|
+
xmlElement(PIC_NS, 'pic', 'nvPicPr', {
|
|
401
|
+
children: [
|
|
402
|
+
xmlElement(PIC_NS, 'pic', 'cNvPr', {
|
|
403
|
+
attributes: [attr('id', '0'), attr('name', input.name)],
|
|
404
|
+
children: (input.hyperlinkRelationshipId !== undefined && input.hyperlinkRelationshipId.length > 0)
|
|
405
|
+
? [buildHlinkClick(input.hyperlinkRelationshipId)]
|
|
406
|
+
: [],
|
|
407
|
+
}),
|
|
408
|
+
xmlElement(PIC_NS, 'pic', 'cNvPicPr'),
|
|
409
|
+
],
|
|
410
|
+
}),
|
|
411
|
+
blipFill,
|
|
412
|
+
spPr,
|
|
413
|
+
],
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function buildGraphic(input) {
|
|
417
|
+
return xmlElement(A_NS, 'a', 'graphic', {
|
|
418
|
+
children: [
|
|
419
|
+
xmlElement(A_NS, 'a', 'graphicData', {
|
|
420
|
+
attributes: [attr('uri', PICTURE_GRAPHIC_DATA_URI)],
|
|
421
|
+
children: [buildPic(input)],
|
|
422
|
+
}),
|
|
423
|
+
],
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
function buildPositionH(input) {
|
|
427
|
+
var origin = input.horizontalOrigin;
|
|
428
|
+
var child;
|
|
429
|
+
if (input.horizontalAlignment !== undefined) {
|
|
430
|
+
child = xmlElement(WP_NS, 'wp', 'align', {
|
|
431
|
+
children: [{ kind: 'text', value: input.horizontalAlignment }],
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
// posOffset is a coordinate (0 / negative allowed), not an extent.
|
|
436
|
+
var emu = input.horizontalPosition !== undefined
|
|
437
|
+
? pointToCoordinateEmus(input.horizontalPosition)
|
|
438
|
+
: 0;
|
|
439
|
+
child = xmlElement(WP_NS, 'wp', 'posOffset', {
|
|
440
|
+
children: [{ kind: 'text', value: String(emu) }],
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
return xmlElement(WP_NS, 'wp', 'positionH', {
|
|
444
|
+
attributes: [attr('relativeFrom', origin)],
|
|
445
|
+
children: [child],
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function buildPositionV(input) {
|
|
449
|
+
var origin = input.verticalOrigin;
|
|
450
|
+
var child;
|
|
451
|
+
if (input.verticalAlignment !== undefined) {
|
|
452
|
+
child = xmlElement(WP_NS, 'wp', 'align', {
|
|
453
|
+
children: [{ kind: 'text', value: input.verticalAlignment }],
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
// posOffset is a coordinate (0 / negative allowed), not an extent.
|
|
458
|
+
var emu = input.verticalPosition !== undefined
|
|
459
|
+
? pointToCoordinateEmus(input.verticalPosition)
|
|
460
|
+
: 0;
|
|
461
|
+
child = xmlElement(WP_NS, 'wp', 'posOffset', {
|
|
462
|
+
children: [{ kind: 'text', value: String(emu) }],
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
return xmlElement(WP_NS, 'wp', 'positionV', {
|
|
466
|
+
attributes: [attr('relativeFrom', origin)],
|
|
467
|
+
children: [child],
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Build wrap element from modeled style.
|
|
472
|
+
* tight/through require wrapPolygon; without residual, fall back is not invented —
|
|
473
|
+
* callers should only dirty-author rectangular wraps unless residual provides polygon.
|
|
474
|
+
*/
|
|
475
|
+
function buildWrapElement(wrapping, residualWrap) {
|
|
476
|
+
if (residualWrap !== undefined &&
|
|
477
|
+
((wrapping === TextWrappingStyle.Tight && residualWrap.localName === 'wrapTight') ||
|
|
478
|
+
(wrapping === TextWrappingStyle.Through && residualWrap.localName === 'wrapThrough') ||
|
|
479
|
+
(wrapping === TextWrappingStyle.Square && residualWrap.localName === 'wrapSquare') ||
|
|
480
|
+
(wrapping === TextWrappingStyle.None && residualWrap.localName === 'wrapNone') ||
|
|
481
|
+
(wrapping === TextWrappingStyle.TopAndBottom &&
|
|
482
|
+
residualWrap.localName === 'wrapTopAndBottom'))) {
|
|
483
|
+
return residualWrap;
|
|
484
|
+
}
|
|
485
|
+
switch (wrapping) {
|
|
486
|
+
case TextWrappingStyle.None:
|
|
487
|
+
return xmlElement(WP_NS, 'wp', 'wrapNone');
|
|
488
|
+
case TextWrappingStyle.Square:
|
|
489
|
+
return xmlElement(WP_NS, 'wp', 'wrapSquare', {
|
|
490
|
+
attributes: [attr('wrapText', 'bothSides')],
|
|
491
|
+
});
|
|
492
|
+
case TextWrappingStyle.TopAndBottom:
|
|
493
|
+
return xmlElement(WP_NS, 'wp', 'wrapTopAndBottom');
|
|
494
|
+
case TextWrappingStyle.Tight:
|
|
495
|
+
// Prefer residual polygon; without citeable default polygon, emit residual or square-safe fallback
|
|
496
|
+
if (residualWrap !== undefined && residualWrap.localName === 'wrapTight') {
|
|
497
|
+
return residualWrap;
|
|
498
|
+
}
|
|
499
|
+
// Authoring tight without polygon is not schema-complete; keep residual if any wrapTight
|
|
500
|
+
return residualWrap != null ? residualWrap : xmlElement(WP_NS, 'wp', 'wrapNone');
|
|
501
|
+
case TextWrappingStyle.Through:
|
|
502
|
+
if (residualWrap !== undefined && residualWrap.localName === 'wrapThrough') {
|
|
503
|
+
return residualWrap;
|
|
504
|
+
}
|
|
505
|
+
return residualWrap != null ? residualWrap : xmlElement(WP_NS, 'wp', 'wrapNone');
|
|
506
|
+
default:
|
|
507
|
+
return xmlElement(WP_NS, 'wp', 'wrapNone');
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function findResidualWrap(anchor) {
|
|
511
|
+
var e_4, _a;
|
|
512
|
+
if (anchor === undefined) {
|
|
513
|
+
return undefined;
|
|
514
|
+
}
|
|
515
|
+
var _loop_1 = function (name_1) {
|
|
516
|
+
var found = elementChildren(anchor).find(function (c) { return isElement(c, WP_NS, name_1); });
|
|
517
|
+
if (found !== undefined) {
|
|
518
|
+
return { value: found };
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
try {
|
|
522
|
+
for (var _b = __values([
|
|
523
|
+
'wrapNone',
|
|
524
|
+
'wrapSquare',
|
|
525
|
+
'wrapTight',
|
|
526
|
+
'wrapThrough',
|
|
527
|
+
'wrapTopAndBottom',
|
|
528
|
+
]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
529
|
+
var name_1 = _c.value;
|
|
530
|
+
var state_1 = _loop_1(name_1);
|
|
531
|
+
if (typeof state_1 === "object")
|
|
532
|
+
return state_1.value;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
536
|
+
finally {
|
|
537
|
+
try {
|
|
538
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
539
|
+
}
|
|
540
|
+
finally { if (e_4) throw e_4.error; }
|
|
541
|
+
}
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|
|
544
|
+
function findResidualEffectExtent(host) {
|
|
545
|
+
if (host === undefined) {
|
|
546
|
+
return undefined;
|
|
547
|
+
}
|
|
548
|
+
return elementChildren(host).find(function (c) { return isElement(c, WP_NS, 'effectExtent'); });
|
|
549
|
+
}
|
|
550
|
+
function copyElementAttrs(source, localNames) {
|
|
551
|
+
var e_5, _a;
|
|
552
|
+
if (source === undefined) {
|
|
553
|
+
return [];
|
|
554
|
+
}
|
|
555
|
+
var out = [];
|
|
556
|
+
try {
|
|
557
|
+
for (var localNames_1 = __values(localNames), localNames_1_1 = localNames_1.next(); !localNames_1_1.done; localNames_1_1 = localNames_1.next()) {
|
|
558
|
+
var name_2 = localNames_1_1.value;
|
|
559
|
+
var value = attributeValue(source, '', name_2);
|
|
560
|
+
if (value !== undefined) {
|
|
561
|
+
out.push(attr(name_2, value));
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
566
|
+
finally {
|
|
567
|
+
try {
|
|
568
|
+
if (localNames_1_1 && !localNames_1_1.done && (_a = localNames_1.return)) _a.call(localNames_1);
|
|
569
|
+
}
|
|
570
|
+
finally { if (e_5) throw e_5.error; }
|
|
571
|
+
}
|
|
572
|
+
return out;
|
|
573
|
+
}
|
|
574
|
+
function buildInlineHost(input) {
|
|
575
|
+
var __ts33_6;
|
|
576
|
+
var preservedInline = input.preservedHost !== undefined
|
|
577
|
+
? findFirstElement(input.preservedHost, WP_NS, 'inline')
|
|
578
|
+
: undefined;
|
|
579
|
+
var effect = ((__ts33_6 = findResidualEffectExtent(preservedInline)), __ts33_6 != null ? __ts33_6 : buildEffectExtent());
|
|
580
|
+
return xmlElement(WP_NS, 'wp', 'inline', {
|
|
581
|
+
namespaceDeclarations: [
|
|
582
|
+
{ prefix: 'wp', namespaceUri: WP_NS },
|
|
583
|
+
{ prefix: 'a', namespaceUri: A_NS },
|
|
584
|
+
{ prefix: 'pic', namespaceUri: PIC_NS },
|
|
585
|
+
{ prefix: 'r', namespaceUri: R_NS },
|
|
586
|
+
],
|
|
587
|
+
attributes: [
|
|
588
|
+
attr('distT', '0'),
|
|
589
|
+
attr('distB', '0'),
|
|
590
|
+
attr('distL', '0'),
|
|
591
|
+
attr('distR', '0'),
|
|
592
|
+
],
|
|
593
|
+
children: [
|
|
594
|
+
xmlElement(WP_NS, 'wp', 'extent', {
|
|
595
|
+
attributes: extentAttributes(input.widthEmu, input.heightEmu),
|
|
596
|
+
}),
|
|
597
|
+
effect,
|
|
598
|
+
buildDocPr(input),
|
|
599
|
+
buildCNvGraphicFramePr(input.lockAspectRatio),
|
|
600
|
+
buildGraphic(input),
|
|
601
|
+
],
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
function buildAnchoredHost(input) {
|
|
605
|
+
var __ts33_7;
|
|
606
|
+
var preservedAnchor = input.preservedHost !== undefined
|
|
607
|
+
? findFirstElement(input.preservedHost, WP_NS, 'anchor')
|
|
608
|
+
: undefined;
|
|
609
|
+
var defaultAttrs = [
|
|
610
|
+
attr('distT', '0'),
|
|
611
|
+
attr('distB', '0'),
|
|
612
|
+
attr('distL', '114300'),
|
|
613
|
+
attr('distR', '114300'),
|
|
614
|
+
attr('simplePos', '0'),
|
|
615
|
+
attr('relativeHeight', '251658240'),
|
|
616
|
+
attr('behindDoc', '0'),
|
|
617
|
+
attr('locked', '0'),
|
|
618
|
+
attr('layoutInCell', '1'),
|
|
619
|
+
attr('allowOverlap', '1'),
|
|
620
|
+
];
|
|
621
|
+
var preservedAttrs = copyElementAttrs(preservedAnchor, [
|
|
622
|
+
'distT',
|
|
623
|
+
'distB',
|
|
624
|
+
'distL',
|
|
625
|
+
'distR',
|
|
626
|
+
'simplePos',
|
|
627
|
+
'relativeHeight',
|
|
628
|
+
'behindDoc',
|
|
629
|
+
'locked',
|
|
630
|
+
'layoutInCell',
|
|
631
|
+
'allowOverlap',
|
|
632
|
+
'hidden',
|
|
633
|
+
]);
|
|
634
|
+
var attrs = preservedAttrs.length > 0 ? preservedAttrs : defaultAttrs;
|
|
635
|
+
var residualWrap = findResidualWrap(preservedAnchor);
|
|
636
|
+
var residualEffect = ((__ts33_7 = findResidualEffectExtent(preservedAnchor)), __ts33_7 != null ? __ts33_7 : buildEffectExtent());
|
|
637
|
+
var residualSimplePos = preservedAnchor
|
|
638
|
+
? elementChildren(preservedAnchor).find(function (c) { return isElement(c, WP_NS, 'simplePos'); })
|
|
639
|
+
: undefined;
|
|
640
|
+
var useModeledLayout = input.layoutDirty || preservedAnchor === undefined;
|
|
641
|
+
var simplePos;
|
|
642
|
+
var positionH;
|
|
643
|
+
var positionV;
|
|
644
|
+
var wrap;
|
|
645
|
+
if (useModeledLayout) {
|
|
646
|
+
simplePos = residualSimplePos != null ? residualSimplePos : xmlElement(WP_NS, 'wp', 'simplePos', {
|
|
647
|
+
attributes: [attr('x', '0'), attr('y', '0')],
|
|
648
|
+
});
|
|
649
|
+
positionH = buildPositionH(input);
|
|
650
|
+
positionV = buildPositionV(input);
|
|
651
|
+
wrap = buildWrapElement(input.wrapping === TextWrappingStyle.Inline ? TextWrappingStyle.None : input.wrapping, residualWrap);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
var ph = elementChildren(preservedAnchor).find(function (c) { return isElement(c, WP_NS, 'positionH'); });
|
|
655
|
+
var pv = elementChildren(preservedAnchor).find(function (c) { return isElement(c, WP_NS, 'positionV'); });
|
|
656
|
+
simplePos = residualSimplePos != null ? residualSimplePos : xmlElement(WP_NS, 'wp', 'simplePos', {
|
|
657
|
+
attributes: [attr('x', '0'), attr('y', '0')],
|
|
658
|
+
});
|
|
659
|
+
positionH = ph != null ? ph : xmlElement(WP_NS, 'wp', 'positionH', {
|
|
660
|
+
attributes: [attr('relativeFrom', HorizontalOrigin.Column)],
|
|
661
|
+
children: [
|
|
662
|
+
xmlElement(WP_NS, 'wp', 'posOffset', { children: [{ kind: 'text', value: '0' }] }),
|
|
663
|
+
],
|
|
664
|
+
});
|
|
665
|
+
positionV = pv != null ? pv : xmlElement(WP_NS, 'wp', 'positionV', {
|
|
666
|
+
attributes: [attr('relativeFrom', VerticalOrigin.Paragraph)],
|
|
667
|
+
children: [
|
|
668
|
+
xmlElement(WP_NS, 'wp', 'posOffset', { children: [{ kind: 'text', value: '0' }] }),
|
|
669
|
+
],
|
|
670
|
+
});
|
|
671
|
+
wrap = residualWrap != null ? residualWrap : xmlElement(WP_NS, 'wp', 'wrapNone');
|
|
672
|
+
}
|
|
673
|
+
return xmlElement(WP_NS, 'wp', 'anchor', {
|
|
674
|
+
namespaceDeclarations: [
|
|
675
|
+
{ prefix: 'wp', namespaceUri: WP_NS },
|
|
676
|
+
{ prefix: 'a', namespaceUri: A_NS },
|
|
677
|
+
{ prefix: 'pic', namespaceUri: PIC_NS },
|
|
678
|
+
{ prefix: 'r', namespaceUri: R_NS },
|
|
679
|
+
],
|
|
680
|
+
attributes: attrs,
|
|
681
|
+
children: [
|
|
682
|
+
simplePos,
|
|
683
|
+
positionH,
|
|
684
|
+
positionV,
|
|
685
|
+
xmlElement(WP_NS, 'wp', 'extent', {
|
|
686
|
+
attributes: extentAttributes(input.widthEmu, input.heightEmu),
|
|
687
|
+
}),
|
|
688
|
+
residualEffect,
|
|
689
|
+
wrap,
|
|
690
|
+
buildDocPr(input),
|
|
691
|
+
buildCNvGraphicFramePr(input.lockAspectRatio),
|
|
692
|
+
buildGraphic(input),
|
|
693
|
+
],
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Encode a modeled picture host into `w:drawing`.
|
|
698
|
+
*
|
|
699
|
+
* @private
|
|
700
|
+
*/
|
|
701
|
+
export function encodePictureHost(input) {
|
|
702
|
+
if (input.relationshipId.length === 0) {
|
|
703
|
+
throw new Error('encodePictureHost: relationship id is not materialized');
|
|
704
|
+
}
|
|
705
|
+
var host = input.placement === PicturePlacement.Anchored ||
|
|
706
|
+
input.wrapping !== TextWrappingStyle.Inline
|
|
707
|
+
? buildAnchoredHost(__assign({}, input, { placement: PicturePlacement.Anchored, wrapping: input.wrapping === TextWrappingStyle.Inline
|
|
708
|
+
? TextWrappingStyle.None
|
|
709
|
+
: input.wrapping }))
|
|
710
|
+
: buildInlineHost(input);
|
|
711
|
+
return wmlElement('drawing', { children: [host] });
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Whether wrapping requires an anchor host.
|
|
715
|
+
*
|
|
716
|
+
* @private
|
|
717
|
+
*/
|
|
718
|
+
export function wrappingRequiresAnchor(wrapping) {
|
|
719
|
+
return wrapping !== TextWrappingStyle.Inline;
|
|
720
|
+
}
|