fcs
2025-04-10 0163870d662dc5b7d69ceff977490ede594f7d82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
 
/**
 * This function creating the wide screen plugin object.
 * @param {object} pluginsman Access to the plugins manager for pptx documents.
 * @constructor
 * @name MakeWidescreenPlugin
 */
function MakeWidescreenPlugin(pluginsman) {
  var funcThis = this
 
  if (pluginsman.docType !== 'pptx' && pluginsman.docType !== 'ppsx') {
    throw new Error(
      '[pptx-widescreen] This plugin supporting only PowerPoint based documents.'
    )
  } // Endif.
 
  this.pluginsman = pluginsman
  this.pptxData = pluginsman.getDataStorage()
 
  // We want to extend the main API of the pptx document object:
  pluginsman.registerCallback('makeDocApi', function(docObj) {
    funcThis.extendPptxApi(docObj)
  })
 
  return this
}
 
/**
 * This function extending the main document object with new API methods.
 * @param {object} docObj Document object.
 */
MakeWidescreenPlugin.prototype.extendPptxApi = function(docObj) {
  var funcThis = this
 
  docObj.setSlideSize = function(cx, cy, sizeType, cxSLD, cySLD) {
    if (cx && typeof cx === 'number') {
      funcThis.pptxData.pptWidth = cx * funcThis.pptxData.EMUS_PER_PT
    } // Endif.
 
    if (cy && typeof cy === 'number') {
      funcThis.pptxData.pptHeight = cy * funcThis.pptxData.EMUS_PER_PT
    } // Endif.
 
    if (cySLD && typeof cxSLD === 'number') {
      funcThis.pptxData.pptWidthSLD = cxSLD * funcThis.pptxData.EMUS_PER_PT
    } // Endif.
 
    if (cySLD && typeof cySLD === 'number') {
      funcThis.pptxData.pptHeightSLD = cySLD * funcThis.pptxData.EMUS_PER_PT
    } // Endif.
 
    /*
    Supported types:
 
    '35mm'
    'A3'
    'A4'
    'B4ISO'
    'B4JIS'
    'B5ISO'
    'B5JIS'
    'banner'
    'custom'
    'hagakiCard'
    'ledger'
    'letter'
    'overhead'
    'screen16x10'
    'screen16x9'
    'screen4x3'
    */
 
    if (sizeType && typeof sizeType === 'string') {
      funcThis.pptxData.pptType = sizeType
    } // Endif.
  }
 
  docObj.setWidescreen = function(wide) {
    funcThis.pptxData.pptWidth = wide
      ? 960 * funcThis.pptxData.EMUS_PER_PT
      : funcThis.pptxData.pptWidth
    funcThis.pptxData.pptType = wide ? 'screen16x9' : 'screen4x3'
  }
}
 
module.exports = MakeWidescreenPlugin