pptxtojson 0.1.8 → 1.0.1

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/src/table.js ADDED
@@ -0,0 +1,126 @@
1
+ import { getShapeFill, getSolidFill } from './fill'
2
+ import { getTextByPathList } from './utils'
3
+
4
+
5
+ export function getTableCellParams(tcNode, thisTblStyle, cellSource, warpObj) {
6
+ const rowSpan = getTextByPathList(tcNode, ['attrs', 'rowSpan'])
7
+ const colSpan = getTextByPathList(tcNode, ['attrs', 'gridSpan'])
8
+ const vMerge = getTextByPathList(tcNode, ['attrs', 'vMerge'])
9
+ const hMerge = getTextByPathList(tcNode, ['attrs', 'hMerge'])
10
+ let fillColor
11
+ let fontColor
12
+ let fontBold
13
+
14
+ const getCelFill = getTextByPathList(tcNode, ['a:tcPr'])
15
+ if (getCelFill) {
16
+ const cellObj = { 'p:spPr': getCelFill }
17
+ fillColor = getShapeFill(cellObj, undefined, warpObj)
18
+ }
19
+ if (!fillColor) {
20
+ let bgFillschemeClr
21
+ if (cellSource) bgFillschemeClr = getTextByPathList(thisTblStyle, [cellSource, 'a:tcStyle', 'a:fill', 'a:solidFill'])
22
+ if (bgFillschemeClr) {
23
+ fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
24
+ }
25
+ }
26
+
27
+ let rowTxtStyl
28
+ if (cellSource) rowTxtStyl = getTextByPathList(thisTblStyle, [cellSource, 'a:tcTxStyle'])
29
+ if (rowTxtStyl) {
30
+ fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
31
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
32
+ }
33
+
34
+ return {
35
+ fillColor,
36
+ fontColor,
37
+ fontBold,
38
+ rowSpan,
39
+ colSpan,
40
+ vMerge,
41
+ hMerge,
42
+ }
43
+ }
44
+
45
+ export function getTableRowParams(trNodes, i, tblStylAttrObj, thisTblStyle, warpObj) {
46
+ let fillColor
47
+ let fontColor
48
+ let fontBold
49
+
50
+ if (thisTblStyle && thisTblStyle['a:wholeTbl']) {
51
+ const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:wholeTbl', 'a:tcStyle', 'a:fill', 'a:solidFill'])
52
+ if (bgFillschemeClr) {
53
+ const local_fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
54
+ if (local_fillColor) fillColor = local_fillColor
55
+ }
56
+ const rowTxtStyl = getTextByPathList(thisTblStyle, ['a:wholeTbl', 'a:tcTxStyle'])
57
+ if (rowTxtStyl) {
58
+ const local_fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
59
+ if (local_fontColor) fontColor = local_fontColor
60
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
61
+ }
62
+ }
63
+ if (i === 0 && tblStylAttrObj['isFrstRowAttr'] === 1 && thisTblStyle) {
64
+ const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:firstRow', 'a:tcStyle', 'a:fill', 'a:solidFill'])
65
+ if (bgFillschemeClr) {
66
+ const local_fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
67
+ if (local_fillColor) fillColor = local_fillColor
68
+ }
69
+ const rowTxtStyl = getTextByPathList(thisTblStyle, ['a:firstRow', 'a:tcTxStyle'])
70
+ if (rowTxtStyl) {
71
+ const local_fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
72
+ if (local_fontColor) fontColor = local_fontColor
73
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
74
+ }
75
+ }
76
+ else if (i > 0 && tblStylAttrObj['isBandRowAttr'] === 1 && thisTblStyle) {
77
+ fillColor = ''
78
+ if ((i % 2) === 0 && thisTblStyle['a:band2H']) {
79
+ const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:band2H', 'a:tcStyle', 'a:fill', 'a:solidFill'])
80
+ if (bgFillschemeClr) {
81
+ const local_fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
82
+ if (local_fillColor) fillColor = local_fillColor
83
+ }
84
+ const rowTxtStyl = getTextByPathList(thisTblStyle, ['a:band2H', 'a:tcTxStyle'])
85
+ if (rowTxtStyl) {
86
+ const local_fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
87
+ if (local_fontColor) fontColor = local_fontColor
88
+ }
89
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
90
+ }
91
+ if ((i % 2) !== 0 && thisTblStyle['a:band1H']) {
92
+ const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:band1H', 'a:tcStyle', 'a:fill', 'a:solidFill'])
93
+ if (bgFillschemeClr) {
94
+ const local_fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
95
+ if (local_fillColor) fillColor = local_fillColor
96
+ }
97
+ const rowTxtStyl = getTextByPathList(thisTblStyle, ['a:band1H', 'a:tcTxStyle'])
98
+ if (rowTxtStyl) {
99
+ const local_fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
100
+ if (local_fontColor) fontColor = local_fontColor
101
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
102
+ }
103
+ }
104
+ }
105
+ if (i === (trNodes.length - 1) && tblStylAttrObj['isLstRowAttr'] === 1 && thisTblStyle) {
106
+ const bgFillschemeClr = getTextByPathList(thisTblStyle, ['a:lastRow', 'a:tcStyle', 'a:fill', 'a:solidFill'])
107
+ if (bgFillschemeClr) {
108
+ const local_fillColor = getSolidFill(bgFillschemeClr, undefined, undefined, warpObj)
109
+ if (local_fillColor) {
110
+ fillColor = local_fillColor
111
+ }
112
+ }
113
+ const rowTxtStyl = getTextByPathList(thisTblStyle, ['a:lastRow', 'a:tcTxStyle'])
114
+ if (rowTxtStyl) {
115
+ const local_fontColor = getSolidFill(rowTxtStyl, undefined, undefined, warpObj)
116
+ if (local_fontColor) fontColor = local_fontColor
117
+ if (getTextByPathList(rowTxtStyl, ['attrs', 'b']) === 'on') fontBold = true
118
+ }
119
+ }
120
+
121
+ return {
122
+ fillColor,
123
+ fontColor,
124
+ fontBold,
125
+ }
126
+ }
package/src/text.js CHANGED
@@ -103,13 +103,13 @@ export function genSpanElement(node, slideLayoutSpNode, type, warpObj) {
103
103
 
104
104
  let styleText = ''
105
105
  const fontColor = getFontColor(node)
106
- const fontSize = getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles, warpObj.options.fontsizeFactor)
106
+ const fontSize = getFontSize(node, slideLayoutSpNode, type, slideMasterTextStyles)
107
107
  const fontType = getFontType(node, type, warpObj)
108
108
  const fontBold = getFontBold(node)
109
109
  const fontItalic = getFontItalic(node)
110
110
  const fontDecoration = getFontDecoration(node)
111
111
  const fontDecorationLine = getFontDecorationLine(node)
112
- const fontSpace = getFontSpace(node, warpObj.options.fontsizeFactor)
112
+ const fontSpace = getFontSpace(node)
113
113
  const shadow = getFontShadow(node, warpObj)
114
114
  const subscript = getFontSubscript(node)
115
115
 
package/src/utils.js CHANGED
@@ -128,12 +128,9 @@ export function getMimeType(imgFileExt) {
128
128
  case 'wav':
129
129
  mimeType = 'audio/wav'
130
130
  break
131
- case 'emf':
132
- mimeType = 'image/emf';
133
- break;
134
- case 'wmf':
135
- mimeType = 'image/wmf';
136
131
  case 'tif':
132
+ mimeType = 'image/tiff'
133
+ break
137
134
  case 'tiff':
138
135
  mimeType = 'image/tiff'
139
136
  break