@@ -12,6 +12,8 @@ export class Chart extends Shape implements IChart {
1212 sourceWorksheet : number | string ;
1313 targetWorksheet : number | string ;
1414 worksheetFilePrefix : string ;
15+ wbEmbeddingsPath : string ;
16+ wbExtension : string ;
1517
1618 constructor ( shape : ImportedElement ) {
1719 super ( shape ) ;
@@ -20,6 +22,9 @@ export class Chart extends Shape implements IChart {
2022 this . relAttribute = 'r:id' ;
2123 this . relParent = ( element : Element ) =>
2224 element . parentNode . parentNode . parentNode as Element ;
25+
26+ this . wbEmbeddingsPath = `../embeddings/` ;
27+ this . wbExtension = '.xlsx' ;
2328 }
2429
2530 async modify (
@@ -93,7 +98,7 @@ export class Chart extends Shape implements IChart {
9398 async readWorkbook ( ) : Promise < Workbook > {
9499 const worksheet = await FileHelper . extractFromArchive (
95100 this . targetArchive ,
96- `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } .xlsx ` ,
101+ `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } ${ this . wbExtension } ` ,
97102 'nodebuffer' ,
98103 ) ;
99104 const archive = await FileHelper . extractFileContent (
@@ -141,7 +146,7 @@ export class Chart extends Shape implements IChart {
141146 type : 'nodebuffer' ,
142147 } ) ;
143148 this . targetArchive . file (
144- `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } .xlsx ` ,
149+ `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } ${ this . wbExtension } ` ,
145150 worksheet ,
146151 ) ;
147152 }
@@ -150,15 +155,14 @@ export class Chart extends Shape implements IChart {
150155 await this . copyChartFiles ( ) ;
151156
152157 const wbRelsPath = `ppt/charts/_rels/chart${ this . sourceNumber } .xml.rels` ;
153- const wbEmbeddingsPath = `../embeddings/` ;
154158
155159 this . worksheetFilePrefix = await this . getWorksheetFilePrefix ( wbRelsPath ) ;
156160
157161 const worksheets = await XmlHelper . getTargetsFromRelationships (
158162 this . sourceArchive ,
159163 wbRelsPath ,
160- `${ wbEmbeddingsPath } ${ this . worksheetFilePrefix } ` ,
161- '.xlsx' ,
164+ `${ this . wbEmbeddingsPath } ${ this . worksheetFilePrefix } ` ,
165+ this . wbExtension ,
162166 ) ;
163167 const worksheet = worksheets [ 0 ] ;
164168
@@ -175,13 +179,13 @@ export class Chart extends Shape implements IChart {
175179 const relationTargets = await XmlHelper . getTargetsFromRelationships (
176180 this . sourceArchive ,
177181 targetRelFile ,
178- `../embeddings/` ,
179- '.xlsx' ,
182+ this . wbEmbeddingsPath ,
183+ this . wbExtension ,
180184 ) ;
181185
182186 let wbPath = relationTargets [ 0 ] . file
183- . replace ( `../embeddings/` , '' )
184- . replace ( '.xlsx' , '' )
187+ . replace ( this . wbEmbeddingsPath , '' )
188+ . replace ( this . wbExtension , '' )
185189
186190 const wbTitle = wbPath . match ( / ^ ( .+ ?) ( \d + ) * $ / )
187191
@@ -263,7 +267,7 @@ export class Chart extends Shape implements IChart {
263267 case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/package' :
264268 element . setAttribute (
265269 'Target' ,
266- `../embeddings/ ${ this . worksheetFilePrefix } ${ this . targetWorksheet } .xlsx ` ,
270+ `${ this . wbEmbeddingsPath } ${ this . worksheetFilePrefix } ${ this . targetWorksheet } ${ this . wbExtension } ` ,
267271 ) ;
268272 break ;
269273 case 'http://schemas.microsoft.com/office/2011/relationships/chartColorStyle' :
@@ -281,9 +285,9 @@ export class Chart extends Shape implements IChart {
281285 async copyWorksheetFile ( ) : Promise < void > {
282286 await FileHelper . zipCopy (
283287 this . sourceArchive ,
284- `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . sourceWorksheet } .xlsx ` ,
288+ `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . sourceWorksheet } ${ this . wbExtension } ` ,
285289 this . targetArchive ,
286- `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } .xlsx ` ,
290+ `ppt/embeddings/${ this . worksheetFilePrefix } ${ this . targetWorksheet } ${ this . wbExtension } ` ,
287291 ) ;
288292 }
289293
0 commit comments