@syncfusion/ej2-office-common 35.1.37 → 35.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-office-common.umd.min.js +2 -2
- package/dist/ej2-office-common.umd.min.js.map +1 -1
- package/dist/es6/ej2-office-common.es2015.js +5421 -6017
- package/dist/es6/ej2-office-common.es2015.js.map +1 -1
- package/dist/es6/ej2-office-common.es5.js +6270 -7203
- package/dist/es6/ej2-office-common.es5.js.map +1 -1
- package/dist/global/ej2-office-common.min.js +2 -2
- package/dist/global/ej2-office-common.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/office-common.js +4 -0
- package/package.json +11 -7
- package/src/index.d.ts +3 -17
- package/src/index.js +3 -18
- package/src/office-common/features/index.d.ts +6 -0
- package/src/office-common/features/index.js +6 -0
- package/src/office-common/features/mathml/index.d.ts +25 -0
- package/src/office-common/features/mathml/index.js +22 -0
- package/src/office-common/features/mathml/latex/latex-generator.d.ts +8 -0
- package/src/office-common/features/mathml/latex/latex-generator.js +357 -0
- package/src/office-common/features/mathml/latex/latex-parser.d.ts +87 -0
- package/src/office-common/features/mathml/latex/latex-parser.js +1206 -0
- package/src/office-common/features/mathml/latex/latex-symbols.d.ts +13 -0
- package/src/office-common/features/mathml/latex/latex-symbols.js +681 -0
- package/src/office-common/features/mathml/math-settings.d.ts +54 -0
- package/src/office-common/features/mathml/math-settings.js +174 -0
- package/src/office-common/features/mathml/office-math/adapter.d.ts +59 -0
- package/src/office-common/features/mathml/office-math/adapter.js +6 -0
- package/src/office-common/features/mathml/office-math/basic.d.ts +91 -0
- package/src/office-common/features/mathml/office-math/basic.js +93 -0
- package/src/office-common/features/mathml/office-math/break.d.ts +30 -0
- package/src/office-common/features/mathml/office-math/break.js +75 -0
- package/src/office-common/features/mathml/office-math/collection.d.ts +104 -0
- package/src/office-common/features/mathml/office-math/collection.js +170 -0
- package/src/office-common/features/mathml/office-math/entity.d.ts +12 -0
- package/src/office-common/features/mathml/office-math/entity.js +3 -0
- package/src/office-common/features/mathml/office-math/enums.d.ts +97 -0
- package/src/office-common/features/mathml/office-math/enums.js +108 -0
- package/src/office-common/features/mathml/office-math/format.d.ts +28 -0
- package/src/office-common/features/mathml/office-math/format.js +90 -0
- package/src/office-common/features/mathml/office-math/function-base.d.ts +27 -0
- package/src/office-common/features/mathml/office-math/function-base.js +69 -0
- package/src/office-common/features/mathml/office-math/function-collection.d.ts +29 -0
- package/src/office-common/features/mathml/office-math/function-collection.js +76 -0
- package/src/office-common/features/mathml/office-math/functions-basic.d.ts +118 -0
- package/src/office-common/features/mathml/office-math/functions-basic.js +331 -0
- package/src/office-common/features/mathml/office-math/functions-multi.d.ts +156 -0
- package/src/office-common/features/mathml/office-math/functions-multi.js +407 -0
- package/src/office-common/features/mathml/office-math/index.d.ts +27 -0
- package/src/office-common/features/mathml/office-math/index.js +25 -0
- package/src/office-common/features/mathml/office-math/keys.d.ts +6 -0
- package/src/office-common/features/mathml/office-math/keys.js +20 -0
- package/src/office-common/features/mathml/office-math/math-clone.d.ts +20 -0
- package/src/office-common/features/mathml/office-math/math-clone.js +203 -0
- package/src/office-common/features/mathml/office-math/math-collection.d.ts +19 -0
- package/src/office-common/features/mathml/office-math/math-collection.js +41 -0
- package/src/office-common/features/mathml/office-math/math-equality.d.ts +21 -0
- package/src/office-common/features/mathml/office-math/math-equality.js +115 -0
- package/src/office-common/features/mathml/office-math/math-paragraph.d.ts +58 -0
- package/src/office-common/features/mathml/office-math/math-paragraph.js +126 -0
- package/src/office-common/features/mathml/office-math/math-traversal.d.ts +23 -0
- package/src/office-common/features/mathml/office-math/math-traversal.js +95 -0
- package/src/office-common/features/mathml/office-math/matrix-collections.d.ts +54 -0
- package/src/office-common/features/mathml/office-math/matrix-collections.js +113 -0
- package/src/office-common/features/mathml/office-math/matrix-column.d.ts +43 -0
- package/src/office-common/features/mathml/office-math/matrix-column.js +96 -0
- package/src/office-common/features/mathml/office-math/matrix-row.d.ts +38 -0
- package/src/office-common/features/mathml/office-math/matrix-row.js +71 -0
- package/src/office-common/features/mathml/office-math/matrix.d.ts +62 -0
- package/src/office-common/features/mathml/office-math/matrix.js +158 -0
- package/src/office-common/features/mathml/office-math/office-math.d.ts +55 -0
- package/src/office-common/features/mathml/office-math/office-math.js +116 -0
- package/src/office-common/features/mathml/office-math/owner-holder.d.ts +42 -0
- package/src/office-common/features/mathml/office-math/owner-holder.js +87 -0
- package/src/office-common/features/mathml/office-math/property-store.d.ts +66 -0
- package/src/office-common/features/mathml/office-math/property-store.js +99 -0
- package/src/office-common/features/mathml/office-math/run-element.d.ts +31 -0
- package/src/office-common/features/mathml/office-math/run-element.js +97 -0
- package/src/office-common/features/mathml/office-math/unknown-element.d.ts +37 -0
- package/src/office-common/features/mathml/office-math/unknown-element.js +62 -0
- package/src/office-common/features/mathml/office-math/xml-equal.d.ts +13 -0
- package/src/office-common/features/mathml/office-math/xml-equal.js +24 -0
- package/src/office-common/features/mathml/parse/office-math-parser.d.ts +24 -0
- package/src/office-common/features/mathml/parse/office-math-parser.js +396 -0
- package/src/office-common/features/mathml/parse/office-math-properties.d.ts +165 -0
- package/src/office-common/features/mathml/parse/office-math-properties.js +432 -0
- package/src/office-common/features/mathml/parse/parse-options.d.ts +22 -0
- package/src/office-common/features/mathml/parse/parse-options.js +3 -0
- package/src/office-common/features/mathml/serialize/office-math-properties-writer.d.ts +38 -0
- package/src/office-common/features/mathml/serialize/office-math-properties-writer.js +267 -0
- package/src/office-common/features/mathml/serialize/office-math-serializer.d.ts +23 -0
- package/src/office-common/features/mathml/serialize/office-math-serializer.js +306 -0
- package/src/office-common/features/mathml/serialize/omml-writer.d.ts +123 -0
- package/src/office-common/features/mathml/serialize/omml-writer.js +135 -0
- package/src/office-common/index.d.ts +10 -0
- package/src/office-common/index.js +10 -0
- package/.eslintrc.json +0 -263
- package/.prettierrc.json +0 -5
- package/api-extractor.json +0 -35
- package/core.js +0 -4
- package/encryption.js +0 -4
- package/features.js +0 -4
- package/global.json +0 -6
- package/nuget.config +0 -7
- package/src/all.d.ts +0 -41
- package/src/all.js +0 -38
- package/src/features/index.d.ts +0 -11
- package/src/features/index.js +0 -11
- package/src/features/mathml/index.d.ts +0 -30
- package/src/features/mathml/index.js +0 -22
- package/src/features/mathml/math-factory.d.ts +0 -26
- package/src/features/mathml/math-factory.js +0 -568
- package/src/features/mathml/model/controls.d.ts +0 -896
- package/src/features/mathml/model/controls.js +0 -1541
- package/src/features/mathml/model/math-element.d.ts +0 -173
- package/src/features/mathml/model/math-element.js +0 -315
- package/src/features/mathml/model/roots.d.ts +0 -82
- package/src/features/mathml/model/roots.js +0 -177
- package/src/features/mathml/parse/math-parser.d.ts +0 -43
- package/src/features/mathml/parse/math-parser.js +0 -636
- package/src/features/mathml/serialize/math-serializer.d.ts +0 -34
- package/src/features/mathml/serialize/math-serializer.js +0 -749
- package/tsconfig.build.json +0 -13
- package/tsconfig.harness.json +0 -32
- package/tslint.json +0 -111
- /package/src/{core → office-common/core}/index.d.ts +0 -0
- /package/src/{core → office-common/core}/index.js +0 -0
- /package/src/{core → office-common/core}/xml/index.d.ts +0 -0
- /package/src/{core → office-common/core}/xml/index.js +0 -0
- /package/src/{core → office-common/core}/xml/model.d.ts +0 -0
- /package/src/{core → office-common/core}/xml/model.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-constants.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-constants.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-encryption-info.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-encryption-info.js +0 -0
- /package/src/{encryption → office-common/encryption}/agile-password.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/agile-password.js +0 -0
- /package/src/{encryption → office-common/encryption}/cfb-reader.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/cfb-reader.js +0 -0
- /package/src/{encryption → office-common/encryption}/crypto-primitives.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/crypto-primitives.js +0 -0
- /package/src/{encryption → office-common/encryption}/decrypt-encrypted-package.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/decrypt-encrypted-package.js +0 -0
- /package/src/{encryption → office-common/encryption}/encryption-info-xml.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/encryption-info-xml.js +0 -0
- /package/src/{encryption → office-common/encryption}/errors.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/errors.js +0 -0
- /package/src/{encryption → office-common/encryption}/index.d.ts +0 -0
- /package/src/{encryption → office-common/encryption}/index.js +0 -0
- /package/src/{features → office-common/features}/diagrams/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/constants.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-data-model.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-data-model.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-parsers.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-parsers.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-serializers.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-serializers.js +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-views.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/diagram-views.js +0 -0
- /package/src/{features → office-common/features}/diagrams/element-tree.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/element-tree.js +0 -0
- /package/src/{features → office-common/features}/diagrams/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/errors.js +0 -0
- /package/src/{features → office-common/features}/diagrams/index.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/index.js +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-catalog.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-catalog.js +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-diagram.d.ts +0 -0
- /package/src/{features → office-common/features}/diagrams/smart-art-diagram.js +0 -0
- /package/src/{features → office-common/features}/ink/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/constants.js +0 -0
- /package/src/{features → office-common/features}/ink/index.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/index.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-effects.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-effects.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-model.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-model.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-parser.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-parser.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-serializer.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-serializer.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-units.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-units.js +0 -0
- /package/src/{features → office-common/features}/ink/ink-xml.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/ink-xml.js +0 -0
- /package/src/{features → office-common/features}/ink/trace-codec.d.ts +0 -0
- /package/src/{features → office-common/features}/ink/trace-codec.js +0 -0
- /package/src/{features → office-common/features}/mathml/constants.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/constants.js +0 -0
- /package/src/{features → office-common/features}/mathml/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/errors.js +0 -0
- /package/src/{features → office-common/features}/mathml/model/enums.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/model/enums.js +0 -0
- /package/src/{features → office-common/features}/mathml/openxml.d.ts +0 -0
- /package/src/{features → office-common/features}/mathml/openxml.js +0 -0
- /package/src/{features → office-common/features}/smart-art/diagram-xml.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/diagram-xml.js +0 -0
- /package/src/{features → office-common/features}/smart-art/errors.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/errors.js +0 -0
- /package/src/{features → office-common/features}/smart-art/index.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/index.js +0 -0
- /package/src/{features → office-common/features}/smart-art/minimal-samples.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/minimal-samples.js +0 -0
- /package/src/{features → office-common/features}/smart-art/mutators.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/mutators.js +0 -0
- /package/src/{features → office-common/features}/smart-art/namespaces.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/namespaces.js +0 -0
- /package/src/{features → office-common/features}/smart-art/package-graph.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/package-graph.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-colors.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-colors.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-data.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-data.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-layout.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-layout.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-rel-ids.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-rel-ids.js +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-style.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/parse-style.js +0 -0
- /package/src/{features → office-common/features}/smart-art/point-text.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/point-text.js +0 -0
- /package/src/{features → office-common/features}/smart-art/register.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/register.js +0 -0
- /package/src/{features → office-common/features}/smart-art/serialize.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/serialize.js +0 -0
- /package/src/{features → office-common/features}/smart-art/types.d.ts +0 -0
- /package/src/{features → office-common/features}/smart-art/types.js +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Property readers that populate the Office Math model from `m:*Pr` elements.
|
|
3
|
+
*
|
|
4
|
+
* Source: ECMA-376-1 §22.1.2 (shared-math.xsd). Invalid values are ignored so the model default applies.
|
|
5
|
+
*/
|
|
6
|
+
import { OpenXmlElement } from '../openxml';
|
|
7
|
+
import { OfficeMathBreak } from '../office-math/break';
|
|
8
|
+
import { OfficeMath } from '../office-math/office-math';
|
|
9
|
+
import { OfficeMathFormat } from '../office-math/format';
|
|
10
|
+
import { OfficeMathAccent, OfficeMathBar, OfficeMathBorderBox, OfficeMathBox, OfficeMathGroupCharacter, OfficeMathPhantom, OfficeMathRadical } from '../office-math/functions-basic';
|
|
11
|
+
import { OfficeMathDelimiter, OfficeMathEquationArray, OfficeMathFraction, OfficeMathNArray, OfficeMathRightScript } from '../office-math/functions-multi';
|
|
12
|
+
import { OfficeMathMatrix } from '../office-math/matrix';
|
|
13
|
+
/**
|
|
14
|
+
* Finds the first `m:` child with the given local name. @private
|
|
15
|
+
*
|
|
16
|
+
* @param {OpenXmlElement | undefined} parent The parent element.
|
|
17
|
+
* @param {string} localName The local name to find.
|
|
18
|
+
* @returns {OpenXmlElement | undefined} The result.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findMathChild(parent: OpenXmlElement | undefined, localName: string): OpenXmlElement | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Finds every `m:` child with the given local name. @private
|
|
23
|
+
*
|
|
24
|
+
* @param {OpenXmlElement} parent The parent element.
|
|
25
|
+
* @param {string} localName The local name to find.
|
|
26
|
+
* @returns {OpenXmlElement[]} The result.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findMathChildren(parent: OpenXmlElement, localName: string): OpenXmlElement[];
|
|
29
|
+
/**
|
|
30
|
+
* Reads `m:brk` of a property container. @private
|
|
31
|
+
*
|
|
32
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
33
|
+
* @param {OfficeMath} owner Optional owning equation whose break collection creates the break.
|
|
34
|
+
* @returns {OfficeMathBreak | undefined} The result.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readBreak(pr: OpenXmlElement | undefined, owner?: OfficeMath): OfficeMathBreak | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Applies `m:rPr` to a run format. @private
|
|
39
|
+
*
|
|
40
|
+
* @param {OfficeMathFormat} format The Math run format to populate.
|
|
41
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
export declare function applyRunFormat(format: OfficeMathFormat, pr: OpenXmlElement | undefined): void;
|
|
45
|
+
/**
|
|
46
|
+
* Applies `m:accPr`. @private
|
|
47
|
+
*
|
|
48
|
+
* @param {OfficeMathAccent} fn The function being populated.
|
|
49
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
export declare function applyAccent(fn: OfficeMathAccent, pr: OpenXmlElement | undefined): void;
|
|
53
|
+
/**
|
|
54
|
+
* Applies `m:barPr`. @private
|
|
55
|
+
*
|
|
56
|
+
* @param {OfficeMathBar} fn The function being populated.
|
|
57
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
export declare function applyBar(fn: OfficeMathBar, pr: OpenXmlElement | undefined): void;
|
|
61
|
+
/**
|
|
62
|
+
* Applies `m:borderBoxPr`. @private
|
|
63
|
+
*
|
|
64
|
+
* @param {OfficeMathBorderBox} fn The function being populated.
|
|
65
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
export declare function applyBorderBox(fn: OfficeMathBorderBox, pr: OpenXmlElement | undefined): void;
|
|
69
|
+
/**
|
|
70
|
+
* Applies `m:boxPr`. @private
|
|
71
|
+
*
|
|
72
|
+
* @param {OfficeMathBox} fn The function being populated.
|
|
73
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
export declare function applyBox(fn: OfficeMathBox, pr: OpenXmlElement | undefined): void;
|
|
77
|
+
/**
|
|
78
|
+
* Applies `m:dPr`. @private
|
|
79
|
+
*
|
|
80
|
+
* @param {OfficeMathDelimiter} fn The function being populated.
|
|
81
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
export declare function applyDelimiter(fn: OfficeMathDelimiter, pr: OpenXmlElement | undefined): void;
|
|
85
|
+
/**
|
|
86
|
+
* Applies `m:eqArrPr`. @private
|
|
87
|
+
*
|
|
88
|
+
* @param {OfficeMathEquationArray} fn The function being populated.
|
|
89
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
90
|
+
* @returns {void}
|
|
91
|
+
*/
|
|
92
|
+
export declare function applyEquationArray(fn: OfficeMathEquationArray, pr: OpenXmlElement | undefined): void;
|
|
93
|
+
/**
|
|
94
|
+
* Applies `m:fPr`. @private
|
|
95
|
+
*
|
|
96
|
+
* @param {OfficeMathFraction} fn The function being populated.
|
|
97
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
98
|
+
* @returns {void}
|
|
99
|
+
*/
|
|
100
|
+
export declare function applyFraction(fn: OfficeMathFraction, pr: OpenXmlElement | undefined): void;
|
|
101
|
+
/**
|
|
102
|
+
* Applies `m:groupChrPr`. @private
|
|
103
|
+
*
|
|
104
|
+
* @param {OfficeMathGroupCharacter} fn The function being populated.
|
|
105
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
export declare function applyGroupCharacter(fn: OfficeMathGroupCharacter, pr: OpenXmlElement | undefined): void;
|
|
109
|
+
/**
|
|
110
|
+
* Applies `m:naryPr`. @private
|
|
111
|
+
*
|
|
112
|
+
* @param {OfficeMathNArray} fn The function being populated.
|
|
113
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
114
|
+
* @returns {void}
|
|
115
|
+
*/
|
|
116
|
+
export declare function applyNArray(fn: OfficeMathNArray, pr: OpenXmlElement | undefined): void;
|
|
117
|
+
/**
|
|
118
|
+
* Applies `m:phantPr`. @private
|
|
119
|
+
*
|
|
120
|
+
* @param {OfficeMathPhantom} fn The function being populated.
|
|
121
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
122
|
+
* @returns {void}
|
|
123
|
+
*/
|
|
124
|
+
export declare function applyPhantom(fn: OfficeMathPhantom, pr: OpenXmlElement | undefined): void;
|
|
125
|
+
/**
|
|
126
|
+
* Applies `m:radPr`. @private
|
|
127
|
+
*
|
|
128
|
+
* @param {OfficeMathRadical} fn The function being populated.
|
|
129
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
130
|
+
* @returns {void}
|
|
131
|
+
*/
|
|
132
|
+
export declare function applyRadical(fn: OfficeMathRadical, pr: OpenXmlElement | undefined): void;
|
|
133
|
+
/**
|
|
134
|
+
* Applies `m:sSubSupPr`. @private
|
|
135
|
+
*
|
|
136
|
+
* @param {OfficeMathRightScript} fn The function being populated.
|
|
137
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
138
|
+
* @returns {void}
|
|
139
|
+
*/
|
|
140
|
+
export declare function applyRightScript(fn: OfficeMathRightScript, pr: OpenXmlElement | undefined): void;
|
|
141
|
+
/**
|
|
142
|
+
* Applies the scalar settings of `m:mPr` (columns are handled by {@link applyMatrixColumns}). @private
|
|
143
|
+
*
|
|
144
|
+
* @param {OfficeMathMatrix} fn The function being populated.
|
|
145
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
146
|
+
* @returns {void}
|
|
147
|
+
*/
|
|
148
|
+
export declare function applyMatrix(fn: OfficeMathMatrix, pr: OpenXmlElement | undefined): void;
|
|
149
|
+
/**
|
|
150
|
+
* Creates matrix columns from `m:mcs`, then pads to `cellCount` so every row cell has a column.
|
|
151
|
+
*
|
|
152
|
+
* @param {OfficeMathMatrix} fn The matrix.
|
|
153
|
+
* @param {OpenXmlElement} pr The `m:mPr` element.
|
|
154
|
+
* @param {number} cellCount The widest row, in cells.
|
|
155
|
+
* @returns {void}
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
export declare function applyMatrixColumns(fn: OfficeMathMatrix, pr: OpenXmlElement | undefined, cellCount: number): void;
|
|
159
|
+
/**
|
|
160
|
+
* Reads `m:argPr/m:argSz` (ST_Integer2, -2..2). Invalid values are ignored. @private
|
|
161
|
+
*
|
|
162
|
+
* @param {OpenXmlElement | undefined} argPr The `m:argPr` element, if present.
|
|
163
|
+
* @returns {string | undefined} The valid size as text, or undefined.
|
|
164
|
+
*/
|
|
165
|
+
export declare function readArgumentSize(argPr: OpenXmlElement | undefined): string | undefined;
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Property readers that populate the Office Math model from `m:*Pr` elements.
|
|
3
|
+
*
|
|
4
|
+
* Source: ECMA-376-1 §22.1.2 (shared-math.xsd). Invalid values are ignored so the model default applies.
|
|
5
|
+
*/
|
|
6
|
+
import { MATH_NAMESPACE } from '../constants';
|
|
7
|
+
import { attrValue, childElements } from '../openxml';
|
|
8
|
+
import { MathDelimiterShapeType, MathFontType, MathFractionType, MathHorizontalAlignment, MathStyleType, MathVerticalAlignment } from '../office-math/enums';
|
|
9
|
+
import { OfficeMathBreak } from '../office-math/break';
|
|
10
|
+
import { OfficeMath } from '../office-math/office-math';
|
|
11
|
+
/**
|
|
12
|
+
* Finds the first `m:` child with the given local name. @private
|
|
13
|
+
*
|
|
14
|
+
* @param {OpenXmlElement | undefined} parent The parent element.
|
|
15
|
+
* @param {string} localName The local name to find.
|
|
16
|
+
* @returns {OpenXmlElement | undefined} The result.
|
|
17
|
+
*/
|
|
18
|
+
export function findMathChild(parent, localName) {
|
|
19
|
+
return parent === undefined ? undefined : childElements(parent)
|
|
20
|
+
.filter(function (c) { return c.namespaceUri === MATH_NAMESPACE && c.localName === localName; })[0];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Finds every `m:` child with the given local name. @private
|
|
24
|
+
*
|
|
25
|
+
* @param {OpenXmlElement} parent The parent element.
|
|
26
|
+
* @param {string} localName The local name to find.
|
|
27
|
+
* @returns {OpenXmlElement[]} The result.
|
|
28
|
+
*/
|
|
29
|
+
export function findMathChildren(parent, localName) {
|
|
30
|
+
return childElements(parent).filter(function (c) { return c.namespaceUri === MATH_NAMESPACE && c.localName === localName; });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Implementation helper. @private
|
|
34
|
+
*
|
|
35
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
36
|
+
* @param {string} name The local name of the child element.
|
|
37
|
+
* @returns {string | undefined} The result.
|
|
38
|
+
*/
|
|
39
|
+
function str(pr, name) {
|
|
40
|
+
var child = findMathChild(pr, name);
|
|
41
|
+
return child === undefined ? undefined : attrValue(child, 'val');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Implementation helper. @private
|
|
45
|
+
*
|
|
46
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
47
|
+
* @param {string} name The local name of the child element.
|
|
48
|
+
* @returns {boolean | undefined} The result.
|
|
49
|
+
*/
|
|
50
|
+
function onOff(pr, name) {
|
|
51
|
+
var child = findMathChild(pr, name);
|
|
52
|
+
if (child === undefined) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
var raw = attrValue(child, 'val');
|
|
56
|
+
if (raw === undefined) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
var v = raw.toLowerCase();
|
|
60
|
+
return v === '1' || v === 'true' || v === 'on' ? true : v === '0' || v === 'false' || v === 'off' ? false : undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Implementation helper. @private
|
|
64
|
+
*
|
|
65
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
66
|
+
* @param {string} name The local name of the child element.
|
|
67
|
+
* @returns {number | undefined} The result.
|
|
68
|
+
*/
|
|
69
|
+
function int(pr, name) {
|
|
70
|
+
var raw = str(pr, name);
|
|
71
|
+
return raw !== undefined && /^\d+$/.test(raw) ? Number(raw) : undefined;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Implementation helper. @private
|
|
75
|
+
*
|
|
76
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
77
|
+
* @param {Array<[string, Function]>} table The lookup table of valid values.
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
function flags(pr, table) {
|
|
81
|
+
table.forEach(function (entry) {
|
|
82
|
+
var value = onOff(pr, entry[0]);
|
|
83
|
+
if (value !== undefined) {
|
|
84
|
+
entry[1](value);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Implementation helper. @private
|
|
90
|
+
*
|
|
91
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
92
|
+
* @param {string} name The local name of the child element.
|
|
93
|
+
* @param {Function} set Callback receiving the parsed value.
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
function text(pr, name, set) {
|
|
97
|
+
var value = str(pr, name);
|
|
98
|
+
if (value !== undefined) {
|
|
99
|
+
set(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Implementation helper. @private
|
|
104
|
+
*
|
|
105
|
+
* @param {string | undefined} value The value to convert.
|
|
106
|
+
* @returns {MathVerticalAlignment | undefined} The result.
|
|
107
|
+
*/
|
|
108
|
+
function verticalAlignment(value) {
|
|
109
|
+
if (value === 'top') {
|
|
110
|
+
return MathVerticalAlignment.Top;
|
|
111
|
+
}
|
|
112
|
+
if (value === 'bottom') {
|
|
113
|
+
return MathVerticalAlignment.Bottom;
|
|
114
|
+
}
|
|
115
|
+
return value === 'center' ? MathVerticalAlignment.Center : undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Reads `m:brk` of a property container. @private
|
|
119
|
+
*
|
|
120
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
121
|
+
* @param {OfficeMath} owner Optional owning equation whose break collection creates the break.
|
|
122
|
+
* @returns {OfficeMathBreak | undefined} The result.
|
|
123
|
+
*/
|
|
124
|
+
export function readBreak(pr, owner) {
|
|
125
|
+
var brk = findMathChild(pr, 'brk');
|
|
126
|
+
if (brk === undefined) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
var result = owner !== undefined ? owner.breaks.add() : new OfficeMathBreak();
|
|
130
|
+
var raw = attrValue(brk, 'alnAt');
|
|
131
|
+
if (raw !== undefined && /^\d+$/.test(raw) && Number(raw) >= 1 && Number(raw) <= 255) {
|
|
132
|
+
result.alignAt = Number(raw);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
var FONTS = {
|
|
137
|
+
'roman': MathFontType.Roman, 'script': MathFontType.Script, 'fraktur': MathFontType.Fraktur,
|
|
138
|
+
'double-struck': MathFontType.DoubleStruck, 'sans-serif': MathFontType.SansSerif, 'monospace': MathFontType.Monospace
|
|
139
|
+
};
|
|
140
|
+
var STYLES = {
|
|
141
|
+
p: MathStyleType.Regular, b: MathStyleType.Bold, i: MathStyleType.Italic, bi: MathStyleType.BoldItalic
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Applies `m:rPr` to a run format. @private
|
|
145
|
+
*
|
|
146
|
+
* @param {OfficeMathFormat} format The Math run format to populate.
|
|
147
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
148
|
+
* @returns {void}
|
|
149
|
+
*/
|
|
150
|
+
export function applyRunFormat(format, pr) {
|
|
151
|
+
flags(pr, [['lit', function (v) { format.hasLiteral = v; }], ['nor', function (v) { format.hasNormalText = v; }],
|
|
152
|
+
['aln', function (v) { format.hasAlignment = v; }]]);
|
|
153
|
+
var scr = str(pr, 'scr');
|
|
154
|
+
if (scr !== undefined && FONTS.hasOwnProperty(scr)) {
|
|
155
|
+
format.font = FONTS[scr];
|
|
156
|
+
}
|
|
157
|
+
var sty = str(pr, 'sty');
|
|
158
|
+
if (sty !== undefined && STYLES.hasOwnProperty(sty)) {
|
|
159
|
+
format.style = STYLES[sty];
|
|
160
|
+
}
|
|
161
|
+
var brk = readBreak(pr);
|
|
162
|
+
if (brk !== undefined) {
|
|
163
|
+
format.break = brk;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Applies `m:accPr`. @private
|
|
168
|
+
*
|
|
169
|
+
* @param {OfficeMathAccent} fn The function being populated.
|
|
170
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
171
|
+
* @returns {void}
|
|
172
|
+
*/
|
|
173
|
+
export function applyAccent(fn, pr) {
|
|
174
|
+
text(pr, 'chr', function (v) { fn.accentCharacter = v; });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Applies `m:barPr`. @private
|
|
178
|
+
*
|
|
179
|
+
* @param {OfficeMathBar} fn The function being populated.
|
|
180
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
181
|
+
* @returns {void}
|
|
182
|
+
*/
|
|
183
|
+
export function applyBar(fn, pr) {
|
|
184
|
+
var pos = str(pr, 'pos');
|
|
185
|
+
if (pos === 'top' || pos === 'bot') {
|
|
186
|
+
fn.barTop = pos === 'top';
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Applies `m:borderBoxPr`. @private
|
|
191
|
+
*
|
|
192
|
+
* @param {OfficeMathBorderBox} fn The function being populated.
|
|
193
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
194
|
+
* @returns {void}
|
|
195
|
+
*/
|
|
196
|
+
export function applyBorderBox(fn, pr) {
|
|
197
|
+
flags(pr, [['hideTop', function (v) { fn.hideTop = v; }], ['hideBot', function (v) { fn.hideBottom = v; }],
|
|
198
|
+
['hideLeft', function (v) { fn.hideLeft = v; }], ['hideRight', function (v) { fn.hideRight = v; }],
|
|
199
|
+
['strikeH', function (v) { fn.strikeHorizontal = v; }], ['strikeV', function (v) { fn.strikeVertical = v; }],
|
|
200
|
+
['strikeBLTR', function (v) { fn.strikeDiagonalUp = v; }], ['strikeTLBR', function (v) { fn.strikeDiagonalDown = v; }]]);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Applies `m:boxPr`. @private
|
|
204
|
+
*
|
|
205
|
+
* @param {OfficeMathBox} fn The function being populated.
|
|
206
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
207
|
+
* @returns {void}
|
|
208
|
+
*/
|
|
209
|
+
export function applyBox(fn, pr) {
|
|
210
|
+
flags(pr, [['opEmu', function (v) { fn.operatorEmulator = v; }], ['noBreak', function (v) { fn.noBreak = v; }],
|
|
211
|
+
['diff', function (v) { fn.enableDifferential = v; }], ['aln', function (v) { fn.alignment = v; }]]);
|
|
212
|
+
var brk = readBreak(pr, fn.ownerMathEntity instanceof OfficeMath ? fn.ownerMathEntity : undefined);
|
|
213
|
+
if (brk !== undefined) {
|
|
214
|
+
fn.break = brk;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Applies `m:dPr`. @private
|
|
219
|
+
*
|
|
220
|
+
* @param {OfficeMathDelimiter} fn The function being populated.
|
|
221
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
222
|
+
* @returns {void}
|
|
223
|
+
*/
|
|
224
|
+
export function applyDelimiter(fn, pr) {
|
|
225
|
+
text(pr, 'begChr', function (v) { fn.beginCharacter = v; });
|
|
226
|
+
text(pr, 'sepChr', function (v) { fn.separator = v; });
|
|
227
|
+
text(pr, 'endChr', function (v) { fn.endCharacter = v; });
|
|
228
|
+
flags(pr, [['grow', function (v) { fn.isGrow = v; }]]);
|
|
229
|
+
var shp = str(pr, 'shp');
|
|
230
|
+
if (shp === 'centered' || shp === 'match') {
|
|
231
|
+
fn.delimiterShape = shp === 'centered' ? MathDelimiterShapeType.Centered : MathDelimiterShapeType.Match;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Implementation helper. @private
|
|
236
|
+
*
|
|
237
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
238
|
+
* @param {Function} rule Callback receiving the spacing rule.
|
|
239
|
+
* @param {Function} value Callback receiving the spacing value.
|
|
240
|
+
* @param {string} ruleName The local name of the rule element.
|
|
241
|
+
* @param {string} valueName The local name of the value element.
|
|
242
|
+
* @returns {void}
|
|
243
|
+
*/
|
|
244
|
+
function spacing(pr, rule, value, ruleName, valueName) {
|
|
245
|
+
var r = int(pr, ruleName);
|
|
246
|
+
if (r !== undefined && r <= 4) {
|
|
247
|
+
rule(r);
|
|
248
|
+
}
|
|
249
|
+
var v = int(pr, valueName);
|
|
250
|
+
if (v !== undefined) {
|
|
251
|
+
try {
|
|
252
|
+
value(v);
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
if (!(e instanceof RangeError)) {
|
|
256
|
+
throw e;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Applies `m:eqArrPr`. @private
|
|
263
|
+
*
|
|
264
|
+
* @param {OfficeMathEquationArray} fn The function being populated.
|
|
265
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
266
|
+
* @returns {void}
|
|
267
|
+
*/
|
|
268
|
+
export function applyEquationArray(fn, pr) {
|
|
269
|
+
var align = verticalAlignment(str(pr, 'baseJc'));
|
|
270
|
+
if (align !== undefined) {
|
|
271
|
+
fn.verticalAlignment = align;
|
|
272
|
+
}
|
|
273
|
+
flags(pr, [['maxDist', function (v) { fn.expandEquationContainer = v; }],
|
|
274
|
+
['objDist', function (v) { fn.expandEquationContent = v; }]]);
|
|
275
|
+
spacing(pr, function (v) { fn.rowSpacingRule = v; }, function (v) { fn.rowSpacing = v; }, 'rSpRule', 'rSp');
|
|
276
|
+
}
|
|
277
|
+
var FRACTIONS = {
|
|
278
|
+
bar: MathFractionType.NormalFractionBar, noBar: MathFractionType.NoFractionBar,
|
|
279
|
+
skw: MathFractionType.SkewedFractionBar, lin: MathFractionType.FractionInline
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Applies `m:fPr`. @private
|
|
283
|
+
*
|
|
284
|
+
* @param {OfficeMathFraction} fn The function being populated.
|
|
285
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
286
|
+
* @returns {void}
|
|
287
|
+
*/
|
|
288
|
+
export function applyFraction(fn, pr) {
|
|
289
|
+
var type = str(pr, 'type');
|
|
290
|
+
if (type !== undefined && FRACTIONS.hasOwnProperty(type)) {
|
|
291
|
+
fn.fractionType = FRACTIONS[type];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Applies `m:groupChrPr`. @private
|
|
296
|
+
*
|
|
297
|
+
* @param {OfficeMathGroupCharacter} fn The function being populated.
|
|
298
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
299
|
+
* @returns {void}
|
|
300
|
+
*/
|
|
301
|
+
export function applyGroupCharacter(fn, pr) {
|
|
302
|
+
text(pr, 'chr', function (v) { fn.groupCharacter = v; });
|
|
303
|
+
var pos = str(pr, 'pos');
|
|
304
|
+
if (pos === 'top' || pos === 'bot') {
|
|
305
|
+
fn.hasCharacterTop = pos === 'top';
|
|
306
|
+
}
|
|
307
|
+
var vert = str(pr, 'vertJc');
|
|
308
|
+
if (vert === 'top' || vert === 'bot') {
|
|
309
|
+
fn.hasAlignTop = vert === 'top';
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Applies `m:naryPr`. @private
|
|
314
|
+
*
|
|
315
|
+
* @param {OfficeMathNArray} fn The function being populated.
|
|
316
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
317
|
+
* @returns {void}
|
|
318
|
+
*/
|
|
319
|
+
export function applyNArray(fn, pr) {
|
|
320
|
+
text(pr, 'chr', function (v) { fn.nArrayCharacter = v; });
|
|
321
|
+
var loc = str(pr, 'limLoc');
|
|
322
|
+
if (loc === 'undOvr' || loc === 'subSup') {
|
|
323
|
+
fn.subSuperscriptLimit = loc === 'subSup';
|
|
324
|
+
}
|
|
325
|
+
flags(pr, [['grow', function (v) { fn.hasGrow = v; }], ['subHide', function (v) { fn.hideLowerLimit = v; }],
|
|
326
|
+
['supHide', function (v) { fn.hideUpperLimit = v; }]]);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Applies `m:phantPr`. @private
|
|
330
|
+
*
|
|
331
|
+
* @param {OfficeMathPhantom} fn The function being populated.
|
|
332
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
333
|
+
* @returns {void}
|
|
334
|
+
*/
|
|
335
|
+
export function applyPhantom(fn, pr) {
|
|
336
|
+
flags(pr, [['show', function (v) { fn.show = v; }], ['zeroWid', function (v) { fn.zeroWidth = v; }],
|
|
337
|
+
['zeroAsc', function (v) { fn.zeroAscent = v; }], ['zeroDesc', function (v) { fn.zeroDescent = v; }],
|
|
338
|
+
['transp', function (v) { fn.transparent = v; }]]);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Applies `m:radPr`. @private
|
|
342
|
+
*
|
|
343
|
+
* @param {OfficeMathRadical} fn The function being populated.
|
|
344
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
345
|
+
* @returns {void}
|
|
346
|
+
*/
|
|
347
|
+
export function applyRadical(fn, pr) {
|
|
348
|
+
flags(pr, [['degHide', function (v) { fn.hideDegree = v; }]]);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Applies `m:sSubSupPr`. @private
|
|
352
|
+
*
|
|
353
|
+
* @param {OfficeMathRightScript} fn The function being populated.
|
|
354
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
355
|
+
* @returns {void}
|
|
356
|
+
*/
|
|
357
|
+
export function applyRightScript(fn, pr) {
|
|
358
|
+
flags(pr, [['alnScr', function (v) { fn.isSkipAlign = v; }]]);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Implementation helper. @private
|
|
362
|
+
*
|
|
363
|
+
* @param {string | undefined} value The value to convert.
|
|
364
|
+
* @returns {MathHorizontalAlignment | undefined} The result.
|
|
365
|
+
*/
|
|
366
|
+
function columnAlignment(value) {
|
|
367
|
+
if (value === 'left') {
|
|
368
|
+
return MathHorizontalAlignment.Left;
|
|
369
|
+
}
|
|
370
|
+
if (value === 'right') {
|
|
371
|
+
return MathHorizontalAlignment.Right;
|
|
372
|
+
}
|
|
373
|
+
return value === 'center' ? MathHorizontalAlignment.Center : undefined;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Applies the scalar settings of `m:mPr` (columns are handled by {@link applyMatrixColumns}). @private
|
|
377
|
+
*
|
|
378
|
+
* @param {OfficeMathMatrix} fn The function being populated.
|
|
379
|
+
* @param {OpenXmlElement | undefined} pr The property element (`m:*Pr`), if present.
|
|
380
|
+
* @returns {void}
|
|
381
|
+
*/
|
|
382
|
+
export function applyMatrix(fn, pr) {
|
|
383
|
+
var align = verticalAlignment(str(pr, 'baseJc'));
|
|
384
|
+
if (align !== undefined) {
|
|
385
|
+
fn.verticalAlignment = align;
|
|
386
|
+
}
|
|
387
|
+
flags(pr, [['plcHide', function (v) { fn.hidePlaceholder = v; }]]);
|
|
388
|
+
spacing(pr, function (v) { fn.rowSpacingRule = v; }, function (v) { fn.rowSpacing = v; }, 'rSpRule', 'rSp');
|
|
389
|
+
spacing(pr, function (v) { fn.columnGapRule = v; }, function (v) { fn.columnGap = v; }, 'cGpRule', 'cGp');
|
|
390
|
+
var cSp = int(pr, 'cSp');
|
|
391
|
+
if (cSp !== undefined) {
|
|
392
|
+
fn.columnSpacing = cSp;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Creates matrix columns from `m:mcs`, then pads to `cellCount` so every row cell has a column.
|
|
397
|
+
*
|
|
398
|
+
* @param {OfficeMathMatrix} fn The matrix.
|
|
399
|
+
* @param {OpenXmlElement} pr The `m:mPr` element.
|
|
400
|
+
* @param {number} cellCount The widest row, in cells.
|
|
401
|
+
* @returns {void}
|
|
402
|
+
* @private
|
|
403
|
+
*/
|
|
404
|
+
export function applyMatrixColumns(fn, pr, cellCount) {
|
|
405
|
+
var mcs = findMathChild(pr, 'mcs');
|
|
406
|
+
var groups = mcs === undefined ? [] : findMathChildren(mcs, 'mc');
|
|
407
|
+
groups.forEach(function (mc) {
|
|
408
|
+
var mcPr = findMathChild(mc, 'mcPr');
|
|
409
|
+
var raw = int(mcPr, 'count');
|
|
410
|
+
var count = raw !== undefined && raw >= 1 && raw <= 255 ? raw : 1;
|
|
411
|
+
var align = columnAlignment(str(mcPr, 'mcJc'));
|
|
412
|
+
for (var i = 0; i < count; i++) {
|
|
413
|
+
var column = fn.columns.add();
|
|
414
|
+
if (align !== undefined) {
|
|
415
|
+
column.horizontalAlignment = align;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
while (fn.columns.count < cellCount) {
|
|
420
|
+
fn.columns.add();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Reads `m:argPr/m:argSz` (ST_Integer2, -2..2). Invalid values are ignored. @private
|
|
425
|
+
*
|
|
426
|
+
* @param {OpenXmlElement | undefined} argPr The `m:argPr` element, if present.
|
|
427
|
+
* @returns {string | undefined} The valid size as text, or undefined.
|
|
428
|
+
*/
|
|
429
|
+
export function readArgumentSize(argPr) {
|
|
430
|
+
var raw = str(argPr, 'argSz');
|
|
431
|
+
return raw !== undefined && /^-?\d+$/.test(raw) && Math.abs(Number(raw)) <= 2 ? raw : undefined;
|
|
432
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser options and diagnostics shared by the Office Math parser.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Optional diagnostic callback for degradation events.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface MathParseDiagnostic {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly localName: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parser options.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export interface ParseMathOptions {
|
|
20
|
+
/** Called when a structure is degraded to preserve-only. */
|
|
21
|
+
readonly onDiagnostic?: (d: MathParseDiagnostic) => void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writers that turn explicit Office Math properties into `m:*Pr` children.
|
|
3
|
+
*
|
|
4
|
+
* Source: ECMA-376-1 §22.1.2 (shared-math.xsd). Only explicitly set properties are written, in schema order.
|
|
5
|
+
*/
|
|
6
|
+
import { OpenXmlChild } from '../openxml';
|
|
7
|
+
import { OfficeMathBreak } from '../office-math/break';
|
|
8
|
+
import { OfficeMathFormat } from '../office-math/format';
|
|
9
|
+
import { OfficeMathFunctionBase } from '../office-math/function-base';
|
|
10
|
+
import { WriteContext } from './omml-writer';
|
|
11
|
+
/** Element name of the property container of each function. @private */
|
|
12
|
+
export declare const PROPERTY_ELEMENT: {
|
|
13
|
+
[type: number]: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Writes `m:brk` when the break has an explicit alignment point, otherwise an empty `m:brk`. @private
|
|
17
|
+
*
|
|
18
|
+
* @param {WriteContext} ctx The write context.
|
|
19
|
+
* @param {OfficeMathBreak} brk The break.
|
|
20
|
+
* @returns {OpenXmlChild} The element.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeBreak(ctx: WriteContext, brk: OfficeMathBreak): OpenXmlChild;
|
|
23
|
+
/**
|
|
24
|
+
* Writes the children of `m:rPr`. `m:nor` excludes `m:scr`/`m:sty` per the schema choice. @private
|
|
25
|
+
*
|
|
26
|
+
* @param {WriteContext} ctx The write context.
|
|
27
|
+
* @param {OfficeMathFormat} format The Math run format.
|
|
28
|
+
* @returns {OpenXmlChild[]} The children.
|
|
29
|
+
*/
|
|
30
|
+
export declare function runFormatChildren(ctx: WriteContext, format: OfficeMathFormat): OpenXmlChild[];
|
|
31
|
+
/**
|
|
32
|
+
* Writes the explicit properties of a function in schema order, excluding `m:ctrlPr`. @private
|
|
33
|
+
*
|
|
34
|
+
* @param {WriteContext} ctx The write context.
|
|
35
|
+
* @param {OfficeMathFunctionBase} fn The function.
|
|
36
|
+
* @returns {OpenXmlChild[]} The property children.
|
|
37
|
+
*/
|
|
38
|
+
export declare function functionProperties(ctx: WriteContext, fn: OfficeMathFunctionBase): OpenXmlChild[];
|