1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <workbookhelper.hxx>
21
22 #include <com/sun/star/container/XIndexAccess.hpp>
23 #include <com/sun/star/container/XNameContainer.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
26 #include <com/sun/star/sheet/XSpreadsheet.hpp>
27 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
28 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
29 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
30 #include <com/sun/star/document/XDocumentProperties.hpp>
31 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
32 #include <com/sun/star/document/XViewDataSupplier.hpp>
33 #include <comphelper/servicehelper.hxx>
34 #include <o3tl/any.hxx>
35 #include <osl/thread.h>
36 #include <osl/diagnose.h>
37 #include <oox/helper/progressbar.hxx>
38 #include <oox/helper/propertyset.hxx>
39 #include <oox/ole/vbaproject.hxx>
40 #include <oox/token/properties.hxx>
41 #include <addressconverter.hxx>
42 #include <connectionsbuffer.hxx>
43 #include <defnamesbuffer.hxx>
44 #include <excelchartconverter.hxx>
45 #include <excelfilter.hxx>
46 #include <externallinkbuffer.hxx>
47 #include <formulaparser.hxx>
48 #include <pagesettings.hxx>
49 #include <pivotcachebuffer.hxx>
50 #include <pivottablebuffer.hxx>
51 #include <scenariobuffer.hxx>
52 #include <sharedstringsbuffer.hxx>
53 #include <stylesbuffer.hxx>
54 #include <tablebuffer.hxx>
55 #include <themebuffer.hxx>
56 #include <unitconverter.hxx>
57 #include <viewsettings.hxx>
58 #include <workbooksettings.hxx>
59 #include <worksheetbuffer.hxx>
60 #include <docsh.hxx>
61 #include <document.hxx>
62 #include <docuno.hxx>
63 #include <rangenam.hxx>
64 #include <tokenarray.hxx>
65 #include <tokenuno.hxx>
66 #include <dbdata.hxx>
67 #include <datauno.hxx>
68 #include <globalnames.hxx>
69 #include <documentimport.hxx>
70 #include <drwlayer.hxx>
71 #include <globstr.hrc>
72 #include <scresid.hxx>
73
74 #include <formulabuffer.hxx>
75 #include <editutil.hxx>
76 #include <editeng/editstat.hxx>
77 #include <unotools/charclass.hxx>
78 #include <o3tl/string_view.hxx>
79 #include <ViewSettingsSequenceDefines.hxx>
80
81 #include <memory>
82
83 namespace oox::xls {
84
85 using namespace ::com::sun::star::container;
86 using namespace ::com::sun::star::document;
87 using namespace ::com::sun::star::lang;
88 using namespace ::com::sun::star::sheet;
89 using namespace ::com::sun::star::style;
90 using namespace ::com::sun::star::table;
91 using namespace ::com::sun::star::uno;
92 using namespace ::com::sun::star::beans;
93
94 using ::oox::core::FilterBase;
95 using ::oox::core::FragmentHandler;
96 using ::oox::core::XmlFilterBase;
97
operator ()(std::u16string_view rName1,std::u16string_view rName2) const98 bool IgnoreCaseCompare::operator()( std::u16string_view rName1, std::u16string_view rName2 ) const
99 {
100 // TODO: compare with collator
101 return o3tl::compareToIgnoreAsciiCase(rName1, rName2 ) < 0;
102 }
103
104 class WorkbookGlobals
105 {
106 public:
107 // noncopyable ------------------------------------------------------------
108
109 WorkbookGlobals(const WorkbookGlobals&) = delete;
110 const WorkbookGlobals& operator=(const WorkbookGlobals&) = delete;
111
112 explicit WorkbookGlobals( ExcelFilter& rFilter );
113 ~WorkbookGlobals();
114
115 /** Returns true, if this helper refers to a valid document. */
isValid() const116 bool isValid() const { return mxDoc.is(); }
117
118 // filter -----------------------------------------------------------------
119
120 /** Returns the base filter object (base class of all filters). */
getBaseFilter() const121 FilterBase& getBaseFilter() const { return mrBaseFilter; }
122 /** Returns the filter progress bar. */
getProgressBar() const123 SegmentProgressBar& getProgressBar() const { return *mxProgressBar; }
124 /** Returns the VBA project storage. */
getVbaProjectStorage() const125 const StorageRef& getVbaProjectStorage() const { return mxVbaPrjStrg; }
126 /** Returns the index of the current Calc sheet, if filter currently processes a sheet. */
getCurrentSheetIndex() const127 sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; }
128 /** Returns true when reading a file generated by a known good generator. */
isGeneratorKnownGood() const129 bool isGeneratorKnownGood() const { return mbGeneratorKnownGood; }
130 /** Returns true if any formula cell appears to have a calculated value
131 not 0.0 nor "", or when reading a known good generator's file. */
hasCalculatedFormulaCells() const132 bool hasCalculatedFormulaCells() const { return mbHasCalculatedFormulaCells; }
setCalculatedFormulaCells()133 void setCalculatedFormulaCells() { mbHasCalculatedFormulaCells = true; }
134
135 /** Sets the VBA project storage used to import VBA source code and forms. */
setVbaProjectStorage(const StorageRef & rxVbaPrjStrg)136 void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
137 /** Sets the index of the current Calc sheet, if filter currently processes a sheet. */
setCurrentSheetIndex(SCTAB nSheet)138 void setCurrentSheetIndex( SCTAB nSheet ) { mnCurrSheet = nSheet; }
139
140 // document model ---------------------------------------------------------
141
getEditEngine() const142 ScEditEngineDefaulter& getEditEngine() const
143 {
144 return *mxEditEngine;
145 }
146
getScDocument()147 ScDocument& getScDocument() { return *mpDoc; }
148
149 ScDocumentImport& getDocImport();
150
151 /** Returns a reference to the source/target spreadsheet document model. */
getDocument() const152 const rtl::Reference< ScModelObj >& getDocument() const { return mxDoc; }
153 /** Returns the cell or page styles container from the Calc document. */
154 Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const;
155 /** Returns the specified cell or page style from the Calc document. */
156 Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
157 /** Creates and returns a defined name on-the-fly in the Calc document. */
158 WorkbookHelper::RangeDataRet createNamedRangeObject(OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags);
159 /** Creates and returns a defined name on the-fly in the correct Calc sheet. */
160 WorkbookHelper::RangeDataRet createLocalNamedRangeObject(OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab);
161 /** Creates and returns a database range on-the-fly in the Calc document. */
162 Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr );
163 /** Creates and returns an unnamed database range on-the-fly in the Calc document. */
164 Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr );
165 /** Finds the (already existing) database range of the given formula token index. */
166 ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex );
167 /** Creates and returns a com.sun.star.style.Style object for cells or pages. */
168 Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
169 /** Helper to switch chart data table - specifically for xlsx imports */
170 void useInternalChartDataTable( bool bInternal );
171
172 // buffers ----------------------------------------------------------------
173
getFormulaBuffer() const174 FormulaBuffer& getFormulaBuffer() const { return *mxFormulaBuffer; }
175 /** Returns the global workbook settings object. */
getWorkbookSettings() const176 WorkbookSettings& getWorkbookSettings() const { return *mxWorkbookSettings; }
177 /** Returns the workbook and sheet view settings object. */
getViewSettings() const178 ViewSettings& getViewSettings() const { return *mxViewSettings; }
179 /** Returns the worksheet buffer containing sheet names and properties. */
getWorksheets() const180 WorksheetBuffer& getWorksheets() const { return *mxWorksheets; }
181 /** Returns the office theme object read from the theme substorage. */
getTheme() const182 ThemeBuffer& getTheme() const { return *mxTheme; }
183 /** Returns all cell formatting objects read from the styles substream. */
getStyles() const184 StylesBuffer& getStyles() const { return *mxStyles; }
185 /** Returns the shared strings read from the shared strings substream. */
getSharedStrings() const186 SharedStringsBuffer& getSharedStrings() const { return *mxSharedStrings; }
187 /** Returns the external links read from the external links substream. */
getExternalLinks() const188 ExternalLinkBuffer& getExternalLinks() const { return *mxExtLinks; }
189 /** Returns the defined names read from the workbook globals. */
getDefinedNames() const190 DefinedNamesBuffer& getDefinedNames() const { return *mxDefNames; }
191 /** Returns the tables collection (equivalent to Calc's database ranges). */
getTables() const192 TableBuffer& getTables() const { return *mxTables; }
193 /** Returns the scenarios collection. */
getScenarios() const194 ScenarioBuffer& getScenarios() const { return *mxScenarios; }
195 /** Returns the collection of external data connections. */
getConnections() const196 ConnectionsBuffer& getConnections() const { return *mxConnections; }
197 /** Returns the collection of pivot caches. */
getPivotCaches() const198 PivotCacheBuffer& getPivotCaches() const { return *mxPivotCaches; }
199 /** Returns the collection of pivot tables. */
getPivotTables()200 PivotTableBuffer& getPivotTables() { return *mxPivotTables; }
201 /** Shared cache of Font Classifications to avoid repeated lookups */
getFontClassificationCache()202 FontClassificationMap& getFontClassificationCache() { return maFontClassificationMap; }
203
204 // converters -------------------------------------------------------------
205
206 /** Returns a shared import formula parser. */
getFormulaParser() const207 FormulaParser& getFormulaParser() const { return *mxFmlaParser; }
208 /** Returns an unshared import formula parser. */
createFormulaParser()209 FormulaParser* createFormulaParser() { return new FormulaParser(*this); }
210 /** Returns the measurement unit converter. */
getUnitConverter() const211 UnitConverter& getUnitConverter() const { return *mxUnitConverter; }
212 /** Returns the converter for string to cell address/range conversion. */
getAddressConverter() const213 AddressConverter& getAddressConverter() const { return *mxAddrConverter; }
214 /** Returns the chart object converter. */
getChartConverter() const215 oox::drawingml::chart::ChartConverter* getChartConverter() const { return mxChartConverter.get(); }
216 /** Returns the page/print settings converter. */
getPageSettingsConverter() const217 PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; }
218
219 // OOXML/BIFF12 specific --------------------------------------------------
220
221 /** Returns the base OOXML/BIFF12 filter object. */
getOoxFilter() const222 XmlFilterBase& getOoxFilter() const { return *mpOoxFilter; }
223
224 // BIFF2-BIFF8 specific ---------------------------------------------------
225
226 /** Returns the text encoding used to import/export byte strings. */
getTextEncoding() const227 rtl_TextEncoding getTextEncoding() const { return meTextEnc; }
228
229 private:
230 /** Initializes some basic members and sets needed document properties. */
231 void initialize();
232 /** Finalizes the filter process (sets some needed document properties). */
233 void finalize();
234
235 void ImplDestroy();
236
237 private:
238 typedef ::std::unique_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr;
239 typedef ::std::unique_ptr< FormulaBuffer > FormulaBufferPtr;
240 typedef ::std::unique_ptr< SegmentProgressBar > ProgressBarPtr;
241 typedef ::std::unique_ptr< WorkbookSettings > WorkbookSettPtr;
242 typedef ::std::unique_ptr< ViewSettings > ViewSettingsPtr;
243 typedef ::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr;
244 typedef ::std::shared_ptr< ThemeBuffer > ThemeBfrRef;
245 typedef ::std::unique_ptr< StylesBuffer > StylesBfrPtr;
246 typedef ::std::unique_ptr< SharedStringsBuffer > SharedStrBfrPtr;
247 typedef ::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr;
248 typedef ::std::unique_ptr< DefinedNamesBuffer > DefNamesBfrPtr;
249 typedef ::std::unique_ptr< TableBuffer > TableBfrPtr;
250 typedef ::std::unique_ptr< ScenarioBuffer > ScenarioBfrPtr;
251 typedef ::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr;
252 typedef ::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr;
253 typedef ::std::unique_ptr< PivotTableBuffer > PivotTableBfrPtr;
254 typedef ::std::unique_ptr< FormulaParser > FormulaParserPtr;
255 typedef ::std::unique_ptr< UnitConverter > UnitConvPtr;
256 typedef ::std::unique_ptr< AddressConverter > AddressConvPtr;
257 typedef ::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr;
258 typedef ::std::unique_ptr< PageSettingsConverter > PageSettConvPtr;
259
260 OUString maCellStyles; /// Style family name for cell styles.
261 OUString maPageStyles; /// Style family name for page styles.
262 OUString maCellStyleServ; /// Service name for a cell style.
263 OUString maPageStyleServ; /// Service name for a page style.
264 rtl::Reference< ScModelObj > mxDoc; /// Document model (XSpreadsheetDocument)
265 FilterBase& mrBaseFilter; /// Base filter object.
266 ExcelFilter& mrExcelFilter; /// Base object for registration of this structure.
267 ProgressBarPtr mxProgressBar; /// The progress bar.
268 StorageRef mxVbaPrjStrg; /// Storage containing the VBA project.
269 sal_Int16 mnCurrSheet; /// Current sheet index in Calc document.
270 bool mbGeneratorKnownGood; /// Whether reading a file generated by Excel or Calc.
271 bool mbHasCalculatedFormulaCells; /// Assumed to have calculated formula cells.
272
273 // buffers
274 FormulaBufferPtr mxFormulaBuffer;
275 WorkbookSettPtr mxWorkbookSettings; /// Global workbook settings.
276 ViewSettingsPtr mxViewSettings; /// Workbook and sheet view settings.
277 WorksheetBfrPtr mxWorksheets; /// Sheet info buffer.
278 ThemeBfrRef mxTheme; /// Formatting theme from theme substream.
279 StylesBfrPtr mxStyles; /// All cell style objects from styles substream.
280 SharedStrBfrPtr mxSharedStrings; /// All strings from shared strings substream.
281 ExtLinkBfrPtr mxExtLinks; /// All external links.
282 DefNamesBfrPtr mxDefNames; /// All defined names.
283 TableBfrPtr mxTables; /// All tables (database ranges).
284 ScenarioBfrPtr mxScenarios; /// All scenarios.
285 ConnectionsBfrPtr mxConnections; /// All external data connections.
286 PivotCacheBfrPtr mxPivotCaches; /// All pivot caches in the document.
287 PivotTableBfrPtr mxPivotTables; /// All pivot tables in the document.
288 FontClassificationMap maFontClassificationMap; /// Shared to avoid repeated lookups
289
290 // converters
291 FormulaParserPtr mxFmlaParser; /// Import formula parser.
292 UnitConvPtr mxUnitConverter; /// General unit converter.
293 AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter.
294 ExcelChartConvPtr mxChartConverter; /// Chart object converter.
295 PageSettConvPtr mxPageSettConverter; /// Page/print settings converter.
296
297 EditEngineDefaulterPtr mxEditEngine;
298
299 // OOXML/BIFF12 specific
300 XmlFilterBase* mpOoxFilter; /// Base OOXML/BIFF12 filter object.
301
302 // BIFF2-BIFF8 specific
303 rtl_TextEncoding meTextEnc; /// BIFF byte string text encoding.
304 ScDocument* mpDoc;
305 ScDocShell* mpDocShell;
306 std::unique_ptr<ScDocumentImport> mxDocImport;
307 };
308
WorkbookGlobals(ExcelFilter & rFilter)309 WorkbookGlobals::WorkbookGlobals( ExcelFilter& rFilter ) :
310 mrBaseFilter( rFilter ),
311 mrExcelFilter( rFilter ),
312 mpOoxFilter( &rFilter ),
313 mpDoc(nullptr),
314 mpDocShell(nullptr)
315 {
316 // register at the filter, needed for virtual callbacks (even during construction)
317 mrExcelFilter.registerWorkbookGlobals( *this );
318 initialize();
319 }
320
ImplDestroy()321 void WorkbookGlobals::ImplDestroy()
322 {
323 finalize();
324 mrExcelFilter.unregisterWorkbookGlobals();
325 }
326
~WorkbookGlobals()327 WorkbookGlobals::~WorkbookGlobals()
328 {
329 suppress_fun_call_w_exception(ImplDestroy());
330 }
331
getDocImport()332 ScDocumentImport& WorkbookGlobals::getDocImport()
333 {
334 return *mxDocImport;
335 }
336
getStyleFamily(bool bPageStyles) const337 Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
338 {
339 Reference< XNameContainer > xStylesNC;
340 try
341 {
342 Reference< XNameAccess > xFamiliesNA( mxDoc->getStyleFamilies(), UNO_SET_THROW );
343 xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY );
344 }
345 catch( Exception& )
346 {
347 }
348 OSL_ENSURE( xStylesNC.is(), "WorkbookGlobals::getStyleFamily - cannot access style family" );
349 return xStylesNC;
350 }
351
getStyleObject(const OUString & rStyleName,bool bPageStyle) const352 Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
353 {
354 Reference< XStyle > xStyle;
355 try
356 {
357 Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
358 xStyle.set( xStylesNC->getByName( rStyleName ), UNO_QUERY );
359 }
360 catch( Exception& )
361 {
362 }
363 OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
364 return xStyle;
365 }
366
367 namespace {
368
lcl_addNewByName(ScDocument & rDoc,ScRangeName * pNames,const OUString & rName,sal_Int16 nIndex,sal_Int32 nUnoType)369 WorkbookHelper::RangeDataRet lcl_addNewByName(ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, sal_Int16 nIndex, sal_Int32 nUnoType)
370 {
371 bool bDone = false;
372 ScRangeData::Type nNewType = ScRangeData::Type::Name;
373 if ( nUnoType & NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria;
374 if ( nUnoType & NamedRangeFlag::PRINT_AREA ) nNewType |= ScRangeData::Type::PrintArea;
375 if ( nUnoType & NamedRangeFlag::COLUMN_HEADER ) nNewType |= ScRangeData::Type::ColHeader;
376 if ( nUnoType & NamedRangeFlag::ROW_HEADER ) nNewType |= ScRangeData::Type::RowHeader;
377 if ( nUnoType & NamedRangeFlag::HIDDEN ) nNewType |= ScRangeData::Type::Hidden;
378 ScTokenArray aTokenArray(rDoc);
379 ScRangeData* pNew = new ScRangeData(rDoc, rName, aTokenArray, ScAddress(), nNewType);
380 pNew->GuessPosition();
381 if ( nIndex )
382 pNew->SetIndex( nIndex );
383 // create but not insert hidden FILTER_CRITERIA named ranges to ScRangeName
384 if (((nUnoType & NamedRangeFlag::HIDDEN) == NamedRangeFlag::HIDDEN)
385 && ((nUnoType & NamedRangeFlag::FILTER_CRITERIA) == NamedRangeFlag::FILTER_CRITERIA))
386 {
387 return WorkbookHelper::RangeDataRet(pNew, true);
388 }
389 if ( pNames->insert(pNew) )
390 bDone = true;
391 if (!bDone)
392 {
393 delete pNew;
394 throw RuntimeException();
395 }
396 return WorkbookHelper::RangeDataRet(pNew, false);
397 }
398
findUnusedName(const ScRangeName * pRangeName,const OUString & rSuggestedName)399 OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
400 {
401 OUString aNewName = rSuggestedName;
402 sal_Int32 nIndex = 0;
403 while(pRangeName->findByUpperName(ScGlobal::getCharClass().uppercase(aNewName)))
404 aNewName = rSuggestedName + OUStringChar('_') + OUString::number( nIndex++ );
405
406 return aNewName;
407 }
408
409 }
410
createNamedRangeObject(OUString & orName,sal_Int32 nIndex,sal_Int32 nNameFlags)411 WorkbookHelper::RangeDataRet WorkbookGlobals::createNamedRangeObject(
412 OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags)
413 {
414 // create the name and insert it into the Calc document
415 WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
416 if( !orName.isEmpty() )
417 {
418 ScDocument& rDoc = getScDocument();
419 ScRangeName* pNames = rDoc.GetRangeName();
420 // find an unused name
421 orName = findUnusedName( pNames, orName );
422 // create the named range
423 aScRangeData = lcl_addNewByName(rDoc, pNames, orName, nIndex, nNameFlags);
424 }
425 return aScRangeData;
426 }
427
createLocalNamedRangeObject(OUString & orName,sal_Int32 nIndex,sal_Int32 nNameFlags,sal_Int32 nTab)428 WorkbookHelper::RangeDataRet WorkbookGlobals::createLocalNamedRangeObject(
429 OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab)
430 {
431 // create the name and insert it into the Calc document
432 WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
433 if( !orName.isEmpty() )
434 {
435 ScDocument& rDoc = getScDocument();
436 ScRangeName* pNames = rDoc.GetRangeName( nTab );
437 if(!pNames)
438 throw RuntimeException(u"invalid sheet index used"_ustr);
439 // find an unused name
440 orName = findUnusedName( pNames, orName );
441 // create the named range
442 aScRangeData = lcl_addNewByName(rDoc, pNames, orName, nIndex, nNameFlags);
443 }
444 return aScRangeData;
445 }
446
createDatabaseRangeObject(OUString & orName,const ScRange & rRangeAddr)447 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr )
448 {
449 // validate cell range
450 ScRange aDestRange = rRangeAddr;
451 bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
452
453 // create database range and insert it into the Calc document
454 Reference< XDatabaseRange > xDatabaseRange;
455 if( bValidRange && !orName.isEmpty() ) try
456 {
457 // find an unused name
458 PropertySet aDocProps(( Reference< css::beans::XPropertySet >(mxDoc) ));
459 Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
460 orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
461 // create the database range
462 CellRangeAddress aApiRange( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row(),
463 aDestRange.aEnd.Col(), aDestRange.aEnd.Row() );
464 xDatabaseRanges->addNewByName( orName, aApiRange );
465 xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
466 }
467 catch( Exception& )
468 {
469 }
470 OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
471 return xDatabaseRange;
472 }
473
createUnnamedDatabaseRangeObject(const ScRange & rRangeAddr)474 Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr )
475 {
476 // validate cell range
477 ScRange aDestRange = rRangeAddr;
478 bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
479
480 // create database range and insert it into the Calc document
481 Reference< XDatabaseRange > xDatabaseRange;
482 if( bValidRange ) try
483 {
484 ScDocument& rDoc = getScDocument();
485 if( rDoc.GetTableCount() <= aDestRange.aStart.Tab() )
486 throw css::lang::IndexOutOfBoundsException();
487 std::unique_ptr<ScDBData> pNewDBData(new ScDBData( STR_DB_LOCAL_NONAME, aDestRange.aStart.Tab(),
488 aDestRange.aStart.Col(), aDestRange.aStart.Row(),
489 aDestRange.aEnd.Col(), aDestRange.aEnd.Row() ));
490 rDoc.SetAnonymousDBData( aDestRange.aStart.Tab() , std::move(pNewDBData) );
491 ScDocShell* pDocSh = rDoc.GetDocumentShell();
492 xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aDestRange.aStart.Tab()));
493 }
494 catch( Exception& )
495 {
496 }
497 OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
498 return xDatabaseRange;
499 }
500
findDatabaseRangeByIndex(sal_uInt16 nIndex)501 ScDBData* WorkbookGlobals::findDatabaseRangeByIndex( sal_uInt16 nIndex )
502 {
503 ScDBCollection* pDBCollection = getScDocument().GetDBCollection();
504 if (!pDBCollection)
505 return nullptr;
506 return pDBCollection->getNamedDBs().findByIndex( nIndex );
507 }
508
createStyleObject(OUString & orStyleName,bool bPageStyle)509 Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
510 {
511 Reference< XStyle > xStyle;
512 try
513 {
514 Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
515 xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
516 orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ) );
517 }
518 catch( Exception& )
519 {
520 }
521 OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
522 return xStyle;
523 }
524
useInternalChartDataTable(bool bInternal)525 void WorkbookGlobals::useInternalChartDataTable( bool bInternal )
526 {
527 if( bInternal )
528 mxChartConverter.reset( new oox::drawingml::chart::ChartConverter() );
529 else
530 mxChartConverter.reset( new ExcelChartConverter( *this ) );
531 }
532
533 // BIFF specific --------------------------------------------------------------
534
535 // private --------------------------------------------------------------------
536
initialize()537 void WorkbookGlobals::initialize()
538 {
539 maCellStyles = "CellStyles";
540 maPageStyles = "PageStyles";
541 maCellStyleServ = "com.sun.star.style.CellStyle";
542 maPageStyleServ = "com.sun.star.style.PageStyle";
543 mnCurrSheet = -1;
544 mbGeneratorKnownGood = false;
545 mbHasCalculatedFormulaCells = false;
546 meTextEnc = osl_getThreadTextEncoding();
547
548 // the spreadsheet document
549 mxDoc = &dynamic_cast<ScModelObj&>(*mrBaseFilter.getModel());
550
551 mpDocShell = static_cast<ScDocShell*>(mxDoc->GetEmbeddedObject());
552 if (mpDocShell)
553 mpDoc = &mpDocShell->GetDocument();
554
555 if (!mpDoc)
556 throw RuntimeException(u"Workbookhelper::getScDocument(): Failed to access ScDocument from model"_ustr);
557
558 Reference< XDocumentProperties > xDocProps = mxDoc->getDocumentProperties();
559 const OUString aGenerator( xDocProps->getGenerator());
560
561 if (aGenerator.startsWithIgnoreAsciiCase("Microsoft"))
562 {
563 mbGeneratorKnownGood = true;
564 ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
565 aCalcConfig.SetStringRefSyntax( formula::FormulaGrammar::CONV_XL_A1 ) ;
566 mpDoc->SetCalcConfig(aCalcConfig);
567 }
568 else if (aGenerator.startsWithIgnoreAsciiCase("LibreOffice"))
569 {
570 mbGeneratorKnownGood = true;
571 }
572 mbHasCalculatedFormulaCells = mbGeneratorKnownGood;
573
574 mxDocImport.reset(new ScDocumentImport(*mpDoc));
575
576 mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
577 mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
578 mxViewSettings.reset( new ViewSettings( *this ) );
579 mxWorksheets.reset( new WorksheetBuffer( *this ) );
580 mxTheme = std::make_shared<ThemeBuffer>( *this );
581 mxStyles.reset( new StylesBuffer( *this ) );
582 mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
583 mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
584 mxDefNames.reset( new DefinedNamesBuffer( *this ) );
585 mxTables.reset( new TableBuffer( *this ) );
586 mxScenarios.reset( new ScenarioBuffer( *this ) );
587 mxConnections.reset( new ConnectionsBuffer( *this ) );
588 mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
589 mxPivotTables.reset( new PivotTableBuffer( *this ) );
590
591 mxUnitConverter.reset( new UnitConverter( *this ) );
592 mxAddrConverter.reset( new AddressConverter( *this ) );
593 mxChartConverter.reset( new ExcelChartConverter( *this ) );
594 mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
595
596 // initialise edit engine
597 ScDocument& rDoc = getScDocument();
598 mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
599 mxEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
600 mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
601 mxEditEngine->SetUpdateLayout( false );
602 mxEditEngine->EnableUndo( false );
603 mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
604
605 // set some document properties needed during import
606 if( mrBaseFilter.isImportFilter() )
607 {
608 // enable editing read-only documents (e.g. from read-only files)
609 mpDoc->EnableChangeReadOnly(true);
610 // #i76026# disable Undo while loading the document
611 mpDoc->EnableUndo(false);
612 // #i79826# disable calculating automatic row height while loading the document
613 mpDoc->LockAdjustHeight();
614 // disable automatic update of linked sheets and DDE links
615 mpDoc->EnableExecuteLink(false);
616
617 mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_LOAD_DOC) ) );
618 mxFmlaParser.reset( createFormulaParser() );
619
620 //prevent unnecessary broadcasts and "half way listeners" as
621 //is done in ScDocShell::BeforeXMLLoading() for ods
622 mpDoc->SetInsertingFromOtherDoc(true);
623 }
624 else if( mrBaseFilter.isExportFilter() )
625 {
626 mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_SAVE_DOC) ) );
627 }
628 }
629
finalize()630 void WorkbookGlobals::finalize()
631 {
632 // set some document properties needed after import
633 if( !mrBaseFilter.isImportFilter() )
634 return;
635
636 // #i74668# do not insert default sheets
637 mpDocShell->SetEmpty(false);
638 // enable automatic update of linked sheets and DDE links
639 mpDoc->EnableExecuteLink(true);
640 // #i79826# enable updating automatic row height after loading the document
641 mpDoc->UnlockAdjustHeight();
642 // check settings (potentially asking the user if optimal row height should be run now)
643 if (mpDocShell->GetRecalcRowHeightsMode()) // default is to always update
644 mpDocShell->UpdateAllRowHeights(/*bOnlyUsedRows=*/true);
645
646 // #i76026# enable Undo after loading the document
647 mpDoc->EnableUndo(true);
648
649 // disable editing read-only documents (e.g. from read-only files)
650 mpDoc->EnableChangeReadOnly(false);
651 // #111099# open forms in alive mode (has no effect, if no controls in document)
652 ScDrawLayer* pModel = mpDoc->GetDrawLayer();
653 if (pModel)
654 pModel->SetOpenInDesignMode(false);
655 }
656
657
~WorkbookHelper()658 WorkbookHelper::~WorkbookHelper()
659 {
660 }
661
constructGlobals(ExcelFilter & rFilter)662 /*static*/ WorkbookGlobalsRef WorkbookHelper::constructGlobals( ExcelFilter& rFilter )
663 {
664 WorkbookGlobalsRef xBookGlob = std::make_shared<WorkbookGlobals>( rFilter );
665 if( !xBookGlob->isValid() )
666 xBookGlob.reset();
667 return xBookGlob;
668 }
669
670 // filter ---------------------------------------------------------------------
671
getBaseFilter() const672 FilterBase& WorkbookHelper::getBaseFilter() const
673 {
674 return mrBookGlob.getBaseFilter();
675 }
676
getProgressBar() const677 SegmentProgressBar& WorkbookHelper::getProgressBar() const
678 {
679 return mrBookGlob.getProgressBar();
680 }
681
getCurrentSheetIndex() const682 sal_Int16 WorkbookHelper::getCurrentSheetIndex() const
683 {
684 return mrBookGlob.getCurrentSheetIndex();
685 }
686
isGeneratorKnownGood() const687 bool WorkbookHelper::isGeneratorKnownGood() const
688 {
689 return mrBookGlob.isGeneratorKnownGood();
690 }
691
hasCalculatedFormulaCells() const692 bool WorkbookHelper::hasCalculatedFormulaCells() const
693 {
694 return mrBookGlob.hasCalculatedFormulaCells();
695 }
696
setCalculatedFormulaCells()697 void WorkbookHelper::setCalculatedFormulaCells()
698 {
699 return mrBookGlob.setCalculatedFormulaCells();
700 }
701
setVbaProjectStorage(const StorageRef & rxVbaPrjStrg)702 void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg )
703 {
704 mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
705 }
706
setCurrentSheetIndex(SCTAB nSheet)707 void WorkbookHelper::setCurrentSheetIndex( SCTAB nSheet )
708 {
709 mrBookGlob.setCurrentSheetIndex( nSheet );
710 }
711
finalizeWorkbookImport()712 void WorkbookHelper::finalizeWorkbookImport()
713 {
714 // workbook settings, document and sheet view settings
715 mrBookGlob.getWorkbookSettings().finalizeImport();
716 mrBookGlob.getViewSettings().finalizeImport();
717
718 // Import the VBA project (after finalizing workbook settings which
719 // contains the workbook code name). Do it before processing formulas in
720 // order to correctly resolve VBA custom function names.
721 StorageRef xVbaPrjStrg = mrBookGlob.getVbaProjectStorage();
722 if( xVbaPrjStrg && xVbaPrjStrg->isStorage() )
723 getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
724
725 // need to import formulas before scenarios
726 mrBookGlob.getFormulaBuffer().finalizeImport();
727
728 // Insert all pivot tables. Must be done after loading all sheets and
729 // formulas, because data pilots expect existing source data on
730 // creation.
731 getPivotTables().finalizeImport();
732
733 /* Insert scenarios after all sheet processing is done, because new hidden
734 sheets are created for scenarios which would confuse code that relies
735 on certain sheet indexes. Must be done after pivot tables too. */
736 mrBookGlob.getScenarios().finalizeImport();
737
738 /* Set 'Default' page style to automatic page numbering (default is manual
739 number 1). Otherwise hidden sheets (e.g. for scenarios) which have
740 'Default' page style will break automatic page numbering for following
741 sheets. Automatic numbering is set by passing the value 0. */
742 PropertySet aDefPageStyle( getStyleObject( u"Default"_ustr, true ) );
743 aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
744
745 // Has any string ref syntax been imported?
746 // If not, we need to take action
747 ScCalcConfig aCalcConfig = getScDocument().GetCalcConfig();
748
749 if ( !aCalcConfig.mbHasStringRefSyntax )
750 {
751 aCalcConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_A1_XL_A1;
752 getScDocument().SetCalcConfig(aCalcConfig);
753 }
754
755 // set selected sheet and positionleft/positiontop for OLE objects
756 rtl::Reference<ScModelObj> xViewDataSupplier(getDocument());
757 if (!xViewDataSupplier.is())
758 return;
759
760 Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
761 if (!(xIndexAccess.is() && xIndexAccess->getCount() > 0))
762 return;
763
764 Sequence< PropertyValue > aSeq;
765 if (!(xIndexAccess->getByIndex(0) >>= aSeq))
766 return;
767
768 OUString sTabName;
769 Reference< XNameAccess > xSheetsNC;
770 for (const auto& rProp : aSeq)
771 {
772 OUString sName(rProp.Name);
773 if (sName == SC_ACTIVETABLE)
774 {
775 if(rProp.Value >>= sTabName)
776 {
777 SCTAB nTab(0);
778 if (getScDocument().GetTable(sTabName, nTab))
779 getScDocument().SetVisibleTab(nTab);
780 }
781 }
782 else if (sName == SC_TABLES)
783 {
784 rProp.Value >>= xSheetsNC;
785 }
786 }
787 if (!(xSheetsNC.is() && xSheetsNC->hasByName(sTabName)))
788 return;
789
790 Sequence<PropertyValue> aProperties;
791 Any aAny = xSheetsNC->getByName(sTabName);
792 if ( !(aAny >>= aProperties) )
793 return;
794
795 for (const auto& rProp : aProperties)
796 {
797 OUString sName(rProp.Name);
798 if (sName == SC_POSITIONLEFT)
799 {
800 SCCOL nPosLeft = *o3tl::doAccess<SCCOL>(rProp.Value);
801 getScDocument().SetPosLeft(nPosLeft);
802 }
803 else if (sName == SC_POSITIONTOP)
804 {
805 SCROW nPosTop = *o3tl::doAccess<SCROW>(rProp.Value);
806 getScDocument().SetPosTop(nPosTop);
807 }
808 }
809 }
810
811 // document model -------------------------------------------------------------
812
getScDocument()813 ScDocument& WorkbookHelper::getScDocument()
814 {
815 return mrBookGlob.getScDocument();
816 }
817
getScDocument() const818 const ScDocument& WorkbookHelper::getScDocument() const
819 {
820 return mrBookGlob.getScDocument();
821 }
822
getDocImport()823 ScDocumentImport& WorkbookHelper::getDocImport()
824 {
825 return mrBookGlob.getDocImport();
826 }
827
getDocImport() const828 const ScDocumentImport& WorkbookHelper::getDocImport() const
829 {
830 return mrBookGlob.getDocImport();
831 }
832
getEditEngine() const833 ScEditEngineDefaulter& WorkbookHelper::getEditEngine() const
834 {
835 return mrBookGlob.getEditEngine();
836 }
837
getDocument() const838 const rtl::Reference< ScModelObj > & WorkbookHelper::getDocument() const
839 {
840 return mrBookGlob.getDocument();
841 }
842
getSheetFromDoc(sal_Int32 nSheet) const843 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
844 {
845 Reference< XSpreadsheet > xSheet;
846 try
847 {
848 Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
849 xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
850 }
851 catch( Exception& )
852 {
853 }
854 return xSheet;
855 }
856
getSheetFromDoc(const OUString & rSheet) const857 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
858 {
859 Reference< XSpreadsheet > xSheet;
860 try
861 {
862 Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
863 xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
864 }
865 catch( Exception& )
866 {
867 }
868 return xSheet;
869 }
870
getCellRangeFromDoc(const ScRange & rRange) const871 Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
872 {
873 Reference< XCellRange > xRange;
874 try
875 {
876 Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
877 xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
878 }
879 catch( Exception& )
880 {
881 }
882 return xRange;
883 }
884
getCellStyleFamily() const885 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
886 {
887 return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );
888 }
889
getStyleObject(const OUString & rStyleName,bool bPageStyle) const890 Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
891 {
892 return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
893 }
894
createNamedRangeObject(OUString & orName,sal_Int32 nIndex,sal_Int32 nNameFlags) const895 WorkbookHelper::RangeDataRet WorkbookHelper::createNamedRangeObject(OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags) const
896 {
897 return mrBookGlob.createNamedRangeObject(orName, nIndex, nNameFlags);
898 }
899
createLocalNamedRangeObject(OUString & orName,sal_Int32 nIndex,sal_Int32 nNameFlags,sal_Int32 nTab) const900 WorkbookHelper::RangeDataRet WorkbookHelper::createLocalNamedRangeObject(OUString& orName, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab) const
901 {
902 return mrBookGlob.createLocalNamedRangeObject(orName, nIndex, nNameFlags, nTab);
903 }
904
createDatabaseRangeObject(OUString & orName,const ScRange & rRangeAddr) const905 Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr ) const
906 {
907 return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
908 }
909
createUnnamedDatabaseRangeObject(const ScRange & rRangeAddr) const910 Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr ) const
911 {
912 return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
913 }
914
findDatabaseRangeByIndex(sal_uInt16 nIndex) const915 ScDBData* WorkbookHelper::findDatabaseRangeByIndex( sal_uInt16 nIndex ) const
916 {
917 return mrBookGlob.findDatabaseRangeByIndex( nIndex );
918 }
919
createStyleObject(OUString & orStyleName,bool bPageStyle) const920 Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
921 {
922 return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
923 }
924
925 // buffers --------------------------------------------------------------------
926
getFormulaBuffer() const927 FormulaBuffer& WorkbookHelper::getFormulaBuffer() const
928 {
929 return mrBookGlob.getFormulaBuffer();
930 }
931
getWorkbookSettings() const932 WorkbookSettings& WorkbookHelper::getWorkbookSettings() const
933 {
934 return mrBookGlob.getWorkbookSettings();
935 }
936
getViewSettings() const937 ViewSettings& WorkbookHelper::getViewSettings() const
938 {
939 return mrBookGlob.getViewSettings();
940 }
941
getWorksheets() const942 WorksheetBuffer& WorkbookHelper::getWorksheets() const
943 {
944 return mrBookGlob.getWorksheets();
945 }
946
getTheme() const947 ThemeBuffer& WorkbookHelper::getTheme() const
948 {
949 return mrBookGlob.getTheme();
950 }
951
getStyles() const952 StylesBuffer& WorkbookHelper::getStyles() const
953 {
954 return mrBookGlob.getStyles();
955 }
956
getSharedStrings() const957 SharedStringsBuffer& WorkbookHelper::getSharedStrings() const
958 {
959 return mrBookGlob.getSharedStrings();
960 }
961
getExternalLinks() const962 ExternalLinkBuffer& WorkbookHelper::getExternalLinks() const
963 {
964 return mrBookGlob.getExternalLinks();
965 }
966
getDefinedNames() const967 DefinedNamesBuffer& WorkbookHelper::getDefinedNames() const
968 {
969 return mrBookGlob.getDefinedNames();
970 }
971
getTables() const972 TableBuffer& WorkbookHelper::getTables() const
973 {
974 return mrBookGlob.getTables();
975 }
976
getScenarios() const977 ScenarioBuffer& WorkbookHelper::getScenarios() const
978 {
979 return mrBookGlob.getScenarios();
980 }
981
getConnections() const982 ConnectionsBuffer& WorkbookHelper::getConnections() const
983 {
984 return mrBookGlob.getConnections();
985 }
986
getPivotCaches() const987 PivotCacheBuffer& WorkbookHelper::getPivotCaches() const
988 {
989 return mrBookGlob.getPivotCaches();
990 }
991
getPivotTables() const992 PivotTableBuffer& WorkbookHelper::getPivotTables() const
993 {
994 return mrBookGlob.getPivotTables();
995 }
996
getFontClassificationCache() const997 FontClassificationMap& WorkbookHelper::getFontClassificationCache() const
998 {
999 return mrBookGlob.getFontClassificationCache();
1000 }
1001
1002 // converters -----------------------------------------------------------------
1003
getFormulaParser() const1004 FormulaParser& WorkbookHelper::getFormulaParser() const
1005 {
1006 return mrBookGlob.getFormulaParser();
1007 }
1008
createFormulaParser() const1009 FormulaParser* WorkbookHelper::createFormulaParser() const
1010 {
1011 return mrBookGlob.createFormulaParser();
1012 }
1013
getUnitConverter() const1014 UnitConverter& WorkbookHelper::getUnitConverter() const
1015 {
1016 return mrBookGlob.getUnitConverter();
1017 }
1018
getAddressConverter() const1019 AddressConverter& WorkbookHelper::getAddressConverter() const
1020 {
1021 return mrBookGlob.getAddressConverter();
1022 }
1023
getChartConverter() const1024 oox::drawingml::chart::ChartConverter* WorkbookHelper::getChartConverter() const
1025 {
1026 return mrBookGlob.getChartConverter();
1027 }
1028
useInternalChartDataTable(bool bInternal)1029 void WorkbookHelper::useInternalChartDataTable( bool bInternal )
1030 {
1031 mrBookGlob.useInternalChartDataTable( bInternal );
1032 }
1033
getPageSettingsConverter() const1034 PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const
1035 {
1036 return mrBookGlob.getPageSettingsConverter();
1037 }
1038
1039 // OOXML/BIFF12 specific ------------------------------------------------------
1040
getOoxFilter() const1041 XmlFilterBase& WorkbookHelper::getOoxFilter() const
1042 {
1043 return mrBookGlob.getOoxFilter();
1044 }
1045
importOoxFragment(const rtl::Reference<FragmentHandler> & rxHandler)1046 bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler )
1047 {
1048 return getOoxFilter().importFragment( rxHandler );
1049 }
1050
importOoxFragment(const rtl::Reference<FragmentHandler> & rxHandler,oox::core::FastParser & rParser)1051 bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler, oox::core::FastParser& rParser )
1052 {
1053 return getOoxFilter().importFragment(rxHandler, rParser);
1054 }
1055
1056 // BIFF specific --------------------------------------------------------------
1057
getTextEncoding() const1058 rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1059 {
1060 return mrBookGlob.getTextEncoding();
1061 }
1062
1063 } // namespace oox
1064
1065 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1066