Line data Source code
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/document/XActionLockable.hpp>
25 : #include <com/sun/star/sheet/XDatabaseRange.hpp>
26 : #include <com/sun/star/sheet/XDatabaseRanges.hpp>
27 : #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
28 : #include <com/sun/star/sheet/XNamedRange.hpp>
29 : #include <com/sun/star/sheet/XNamedRanges.hpp>
30 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
31 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
32 : #include <com/sun/star/sheet/NamedRangeFlag.hpp>
33 : #include <com/sun/star/style/XStyle.hpp>
34 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
35 : #include <com/sun/star/table/CellAddress.hpp>
36 : #include <com/sun/star/container/XNamed.hpp>
37 : #include <osl/thread.h>
38 : #include <oox/helper/progressbar.hxx>
39 : #include <oox/helper/propertyset.hxx>
40 : #include <oox/ole/vbaproject.hxx>
41 : #include <vcl/msgbox.hxx>
42 : #include "addressconverter.hxx"
43 : #include "biffinputstream.hxx"
44 : #include "biffcodec.hxx"
45 : #include "connectionsbuffer.hxx"
46 : #include "defnamesbuffer.hxx"
47 : #include "excelchartconverter.hxx"
48 : #include "excelfilter.hxx"
49 : #include "externallinkbuffer.hxx"
50 : #include "formulaparser.hxx"
51 : #include "pagesettings.hxx"
52 : #include "pivotcachebuffer.hxx"
53 : #include "pivottablebuffer.hxx"
54 : #include "scenariobuffer.hxx"
55 : #include "sharedstringsbuffer.hxx"
56 : #include "stylesbuffer.hxx"
57 : #include "tablebuffer.hxx"
58 : #include "themebuffer.hxx"
59 : #include "unitconverter.hxx"
60 : #include "viewsettings.hxx"
61 : #include "workbooksettings.hxx"
62 : #include "worksheetbuffer.hxx"
63 : #include "scmod.hxx"
64 : #include "docsh.hxx"
65 : #include "document.hxx"
66 : #include "docuno.hxx"
67 : #include "rangenam.hxx"
68 : #include "tokenarray.hxx"
69 : #include "tokenuno.hxx"
70 : #include "convuno.hxx"
71 : #include "dbdata.hxx"
72 : #include "datauno.hxx"
73 : #include "globalnames.hxx"
74 : #include "documentimport.hxx"
75 : #include "drwlayer.hxx"
76 : #include "globstr.hrc"
77 :
78 : #include "formulabuffer.hxx"
79 : #include <vcl/mapmod.hxx>
80 : #include "editutil.hxx"
81 : #include <editeng/editstat.hxx>
82 :
83 : #include <comphelper/processfactory.hxx>
84 : #include <officecfg/Office/Calc.hxx>
85 :
86 : #include <boost/noncopyable.hpp>
87 : #include <boost/scoped_ptr.hpp>
88 :
89 : namespace oox {
90 : namespace xls {
91 :
92 : using namespace ::com::sun::star::awt;
93 : using namespace ::com::sun::star::container;
94 : using namespace ::com::sun::star::document;
95 : using namespace ::com::sun::star::lang;
96 : using namespace ::com::sun::star::sheet;
97 : using namespace ::com::sun::star::style;
98 : using namespace ::com::sun::star::table;
99 : using namespace ::com::sun::star::uno;
100 :
101 : using ::oox::core::FilterBase;
102 : using ::oox::core::FragmentHandler;
103 : using ::oox::core::XmlFilterBase;
104 :
105 7006 : bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
106 : {
107 : // there is no wrapper in OUString, TODO: compare with collator
108 : return ::rtl_ustr_compareIgnoreAsciiCase_WithLength(
109 7006 : rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0;
110 : }
111 :
112 : class WorkbookGlobals : boost::noncopyable
113 : {
114 : public:
115 : explicit WorkbookGlobals( ExcelFilter& rFilter );
116 : ~WorkbookGlobals();
117 :
118 : /** Returns true, if this helper refers to a valid document. */
119 128 : inline bool isValid() const { return mxDoc.is(); }
120 :
121 : // filter -----------------------------------------------------------------
122 :
123 : /** Returns the base filter object (base class of all filters). */
124 6592 : inline FilterBase& getBaseFilter() const { return mrBaseFilter; }
125 : /** Returns the filter progress bar. */
126 904 : inline SegmentProgressBar& getProgressBar() const { return *mxProgressBar; }
127 : /** Returns the file type of the current filter. */
128 5538 : inline FilterType getFilterType() const { return meFilterType; }
129 : /** Returns true, if the file is a multi-sheet document, or false if single-sheet. */
130 0 : inline bool isWorkbookFile() const { return mbWorkbook; }
131 : /** Returns the VBA project storage. */
132 128 : inline StorageRef getVbaProjectStorage() const { return mxVbaPrjStrg; }
133 : /** Returns the index of the current Calc sheet, if filter currently processes a sheet. */
134 106 : inline sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; }
135 :
136 : /** Sets the VBA project storage used to import VBA source code and forms. */
137 2 : inline void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
138 : /** Sets the index of the current Calc sheet, if filter currently processes a sheet. */
139 520 : inline void setCurrentSheetIndex( sal_Int16 nSheet ) { mnCurrSheet = nSheet; }
140 :
141 : // document model ---------------------------------------------------------
142 :
143 2 : inline ScEditEngineDefaulter& getEditEngine() const
144 : {
145 2 : return *mxEditEngine.get();
146 : }
147 :
148 4958 : ScDocument& getScDocument() { return *mpDoc; }
149 :
150 128 : ScDocShell& getDocShell() { return *mpDocShell; }
151 :
152 : ScDocumentImport& getDocImport();
153 :
154 : /** Returns a reference to the source/target spreadsheet document model. */
155 2100 : inline Reference< XSpreadsheetDocument > getDocument() const { return mxDoc; }
156 : /** Returns the cell or page styles container from the Calc document. */
157 : Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const;
158 : /** Returns the specified cell or page style from the Calc document. */
159 : Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
160 : /** Creates and returns a defined name on-the-fly in the Calc document. */
161 : ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags );
162 : /** Creates and returns a defined name on the-fly in the correct Calc sheet. */
163 : ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab );
164 : /** Creates and returns a database range on-the-fly in the Calc document. */
165 : Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr );
166 : /** Creates and returns an unnamed database range on-the-fly in the Calc document. */
167 : Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr );
168 : /** Creates and returns a com.sun.star.style.Style object for cells or pages. */
169 : Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
170 : /** Helper to switch chart data table - specifically for xlsx imports */
171 : void useInternalChartDataTable( bool bInternal );
172 :
173 : // buffers ----------------------------------------------------------------
174 :
175 6884 : inline FormulaBuffer& getFormulaBuffer() const { return *mxFormulaBuffer; }
176 : /** Returns the global workbook settings object. */
177 512 : inline WorkbookSettings& getWorkbookSettings() const { return *mxWorkbookSettings; }
178 : /** Returns the workbook and sheet view settings object. */
179 908 : inline ViewSettings& getViewSettings() const { return *mxViewSettings; }
180 : /** Returns the worksheet buffer containing sheet names and properties. */
181 846 : inline WorksheetBuffer& getWorksheets() const { return *mxWorksheets; }
182 : /** Returns the office theme object read from the theme substorage. */
183 5814 : inline ThemeBuffer& getTheme() const { return *mxTheme; }
184 : /** Returns all cell formatting objects read from the styles substream. */
185 20854 : inline StylesBuffer& getStyles() const { return *mxStyles; }
186 : /** Returns the shared strings read from the shared strings substream. */
187 3064 : inline SharedStringsBuffer& getSharedStrings() const { return *mxSharedStrings; }
188 : /** Returns the external links read from the external links substream. */
189 302 : inline ExternalLinkBuffer& getExternalLinks() const { return *mxExtLinks; }
190 : /** Returns the defined names read from the workbook globals. */
191 410 : inline DefinedNamesBuffer& getDefinedNames() const { return *mxDefNames; }
192 : /** Returns the tables collection (equivalent to Calc's database ranges). */
193 388 : inline TableBuffer& getTables() const { return *mxTables; }
194 : /** Returns the scenarios collection. */
195 128 : inline ScenarioBuffer& getScenarios() const { return *mxScenarios; }
196 : /** Returns the collection of external data connections. */
197 0 : inline ConnectionsBuffer& getConnections() const { return *mxConnections; }
198 : /** Returns the collection of pivot caches. */
199 16 : inline PivotCacheBuffer& getPivotCaches() const { return *mxPivotCaches; }
200 : /** Returns the collection of pivot tables. */
201 136 : inline PivotTableBuffer& getPivotTables() { return *mxPivotTables; }
202 :
203 : // converters -------------------------------------------------------------
204 :
205 : /** Returns a shared import formula parser. */
206 150 : inline FormulaParser& getFormulaParser() const { return *mxFmlaParser; }
207 : /** Returns an unshared import formula parser. */
208 388 : inline FormulaParser* createFormulaParser() { return new FormulaParser(*this); }
209 : /** Returns the measurement unit converter. */
210 4208 : inline UnitConverter& getUnitConverter() const { return *mxUnitConverter; }
211 : /** Returns the converter for string to cell address/range conversion. */
212 6680 : inline AddressConverter& getAddressConverter() const { return *mxAddrConverter; }
213 : /** Returns the chart object converter. */
214 68 : inline oox::drawingml::chart::ChartConverter* getChartConverter() const { return mxChartConverter.get(); }
215 : /** Returns the page/print settings converter. */
216 260 : inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; }
217 :
218 : // OOXML/BIFF12 specific --------------------------------------------------
219 :
220 : /** Returns the base OOXML/BIFF12 filter object. */
221 2186 : inline XmlFilterBase& getOoxFilter() const { return *mpOoxFilter; }
222 :
223 : // BIFF2-BIFF8 specific ---------------------------------------------------
224 :
225 : /** Returns the BIFF type in binary filter. */
226 388 : inline BiffType getBiff() const { return meBiff; }
227 : /** Returns the text encoding used to import/export byte strings. */
228 2 : inline rtl_TextEncoding getTextEncoding() const { return meTextEnc; }
229 : /** Returns the codec helper that stores the encoder/decoder object. */
230 0 : inline BiffCodecHelper& getCodecHelper() { return *mxCodecHelper; }
231 :
232 : private:
233 : /** Initializes some basic members and sets needed document properties. */
234 : void initialize( bool bWorkbookFile );
235 : /** Finalizes the filter process (sets some needed document properties). */
236 : void finalize();
237 :
238 : void recalcFormulaCells();
239 :
240 : private:
241 : typedef ::std::unique_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr;
242 : typedef ::std::unique_ptr< FormulaBuffer > FormulaBufferPtr;
243 : typedef ::std::unique_ptr< SegmentProgressBar > ProgressBarPtr;
244 : typedef ::std::unique_ptr< WorkbookSettings > WorkbookSettPtr;
245 : typedef ::std::unique_ptr< ViewSettings > ViewSettingsPtr;
246 : typedef ::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr;
247 : typedef ::boost::shared_ptr< ThemeBuffer > ThemeBfrRef;
248 : typedef ::std::unique_ptr< StylesBuffer > StylesBfrPtr;
249 : typedef ::std::unique_ptr< SharedStringsBuffer > SharedStrBfrPtr;
250 : typedef ::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr;
251 : typedef ::std::unique_ptr< DefinedNamesBuffer > DefNamesBfrPtr;
252 : typedef ::std::unique_ptr< TableBuffer > TableBfrPtr;
253 : typedef ::std::unique_ptr< ScenarioBuffer > ScenarioBfrPtr;
254 : typedef ::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr;
255 : typedef ::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr;
256 : typedef ::std::unique_ptr< PivotTableBuffer > PivotTableBfrPtr;
257 : typedef ::std::unique_ptr< FormulaParser > FormulaParserPtr;
258 : typedef ::std::unique_ptr< UnitConverter > UnitConvPtr;
259 : typedef ::std::unique_ptr< AddressConverter > AddressConvPtr;
260 : typedef ::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr;
261 : typedef ::std::unique_ptr< PageSettingsConverter > PageSettConvPtr;
262 : typedef ::std::unique_ptr< BiffCodecHelper > BiffCodecHelperPtr;
263 :
264 : OUString maCellStyles; /// Style family name for cell styles.
265 : OUString maPageStyles; /// Style family name for page styles.
266 : OUString maCellStyleServ; /// Service name for a cell style.
267 : OUString maPageStyleServ; /// Service name for a page style.
268 : Reference< XSpreadsheetDocument > mxDoc; /// Document model.
269 : FilterBase& mrBaseFilter; /// Base filter object.
270 : ExcelFilter& mrExcelFilter; /// Base object for registration of this structure.
271 : FilterType meFilterType; /// File type of the filter.
272 : ProgressBarPtr mxProgressBar; /// The progress bar.
273 : StorageRef mxVbaPrjStrg; /// Storage containing the VBA project.
274 : sal_Int16 mnCurrSheet; /// Current sheet index in Calc document.
275 : bool mbWorkbook; /// True = multi-sheet file.
276 :
277 : // buffers
278 : FormulaBufferPtr mxFormulaBuffer;
279 : WorkbookSettPtr mxWorkbookSettings; /// Global workbook settings.
280 : ViewSettingsPtr mxViewSettings; /// Workbook and sheet view settings.
281 : WorksheetBfrPtr mxWorksheets; /// Sheet info buffer.
282 : ThemeBfrRef mxTheme; /// Formatting theme from theme substream.
283 : StylesBfrPtr mxStyles; /// All cell style objects from styles substream.
284 : SharedStrBfrPtr mxSharedStrings; /// All strings from shared strings substream.
285 : ExtLinkBfrPtr mxExtLinks; /// All external links.
286 : DefNamesBfrPtr mxDefNames; /// All defined names.
287 : TableBfrPtr mxTables; /// All tables (database ranges).
288 : ScenarioBfrPtr mxScenarios; /// All scenarios.
289 : ConnectionsBfrPtr mxConnections; /// All external data connections.
290 : PivotCacheBfrPtr mxPivotCaches; /// All pivot caches in the document.
291 : PivotTableBfrPtr mxPivotTables; /// All pivot tables in the document.
292 :
293 : // converters
294 : FormulaParserPtr mxFmlaParser; /// Import formula parser.
295 : UnitConvPtr mxUnitConverter; /// General unit converter.
296 : AddressConvPtr mxAddrConverter; /// Cell address and cell range address converter.
297 : ExcelChartConvPtr mxChartConverter; /// Chart object converter.
298 : PageSettConvPtr mxPageSettConverter; /// Page/print settings converter.
299 :
300 : EditEngineDefaulterPtr mxEditEngine;
301 :
302 : // OOXML/BIFF12 specific
303 : XmlFilterBase* mpOoxFilter; /// Base OOXML/BIFF12 filter object.
304 :
305 : // BIFF2-BIFF8 specific
306 : BiffCodecHelperPtr mxCodecHelper; /// Encoder/decoder helper.
307 : BiffType meBiff; /// BIFF version for BIFF import/export.
308 : rtl_TextEncoding meTextEnc; /// BIFF byte string text encoding.
309 : bool mbHasCodePage; /// True = CODEPAGE record exists in imported stream.
310 : ScDocument* mpDoc;
311 : ScDocShell* mpDocShell;
312 : boost::scoped_ptr<ScDocumentImport> mxDocImport;
313 : };
314 :
315 128 : WorkbookGlobals::WorkbookGlobals( ExcelFilter& rFilter ) :
316 : mrBaseFilter( rFilter ),
317 : mrExcelFilter( rFilter ),
318 : meFilterType( FILTER_OOXML ),
319 : mpOoxFilter( &rFilter ),
320 : meBiff( BIFF_UNKNOWN ),
321 : mpDoc(NULL),
322 128 : mpDocShell(NULL)
323 : {
324 : // register at the filter, needed for virtual callbacks (even during construction)
325 128 : mrExcelFilter.registerWorkbookGlobals( *this );
326 128 : initialize( true );
327 128 : }
328 :
329 256 : WorkbookGlobals::~WorkbookGlobals()
330 : {
331 128 : finalize();
332 128 : mrExcelFilter.unregisterWorkbookGlobals();
333 128 : }
334 :
335 7878 : ScDocumentImport& WorkbookGlobals::getDocImport()
336 : {
337 7878 : return *mxDocImport;
338 : }
339 :
340 516 : Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
341 : {
342 516 : Reference< XNameContainer > xStylesNC;
343 : try
344 : {
345 516 : Reference< XStyleFamiliesSupplier > xFamiliesSup( mxDoc, UNO_QUERY_THROW );
346 1032 : Reference< XNameAccess > xFamiliesNA( xFamiliesSup->getStyleFamilies(), UNO_QUERY_THROW );
347 1032 : xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY );
348 : }
349 0 : catch( Exception& )
350 : {
351 : }
352 : OSL_ENSURE( xStylesNC.is(), "WorkbookGlobals::getStyleFamily - cannot access style family" );
353 516 : return xStylesNC;
354 : }
355 :
356 128 : Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
357 : {
358 128 : Reference< XStyle > xStyle;
359 : try
360 : {
361 128 : Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
362 128 : xStyle.set( xStylesNC->getByName( rStyleName ), UNO_QUERY );
363 : }
364 0 : catch( Exception& )
365 : {
366 : }
367 : OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
368 128 : return xStyle;
369 : }
370 :
371 : namespace {
372 :
373 22 : ScRangeData* lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
374 : {
375 22 : bool bDone = false;
376 22 : sal_uInt16 nNewType = RT_NAME;
377 22 : if ( nUnoType & NamedRangeFlag::FILTER_CRITERIA ) nNewType |= RT_CRITERIA;
378 22 : if ( nUnoType & NamedRangeFlag::PRINT_AREA ) nNewType |= RT_PRINTAREA;
379 22 : if ( nUnoType & NamedRangeFlag::COLUMN_HEADER ) nNewType |= RT_COLHEADER;
380 22 : if ( nUnoType & NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER;
381 22 : ScTokenArray aTokenArray;
382 22 : (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
383 22 : ScRangeData* pNew = new ScRangeData( &rDoc, rName, aTokenArray, ScAddress(), nNewType );
384 22 : pNew->GuessPosition();
385 22 : if ( nIndex )
386 22 : pNew->SetIndex( nIndex );
387 22 : if ( pNames->insert(pNew) )
388 22 : bDone = true;
389 22 : if (!bDone)
390 0 : throw RuntimeException();
391 22 : return pNew;
392 : }
393 :
394 22 : OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
395 : {
396 22 : OUString aNewName = rSuggestedName;
397 22 : sal_Int32 nIndex = 0;
398 44 : while(pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(aNewName)))
399 0 : aNewName = OUStringBuffer(rSuggestedName).append( '_' ).append( nIndex++ ).makeStringAndClear();
400 :
401 22 : return aNewName;
402 : }
403 :
404 : }
405 :
406 12 : ScRangeData* WorkbookGlobals::createNamedRangeObject(
407 : OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags )
408 : {
409 : // create the name and insert it into the Calc document
410 12 : ScRangeData* pScRangeData = NULL;
411 12 : if( !orName.isEmpty() )
412 : {
413 12 : ScDocument& rDoc = getScDocument();
414 12 : ScRangeName* pNames = rDoc.GetRangeName();
415 : // find an unused name
416 12 : orName = findUnusedName( pNames, orName );
417 : // create the named range
418 12 : pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
419 : }
420 12 : return pScRangeData;
421 : }
422 :
423 10 : ScRangeData* WorkbookGlobals::createLocalNamedRangeObject(
424 : OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab )
425 : {
426 : // create the name and insert it into the Calc document
427 10 : ScRangeData* pScRangeData = NULL;
428 10 : if( !orName.isEmpty() )
429 : {
430 10 : ScDocument& rDoc = getScDocument();
431 10 : ScRangeName* pNames = rDoc.GetRangeName( nTab );
432 10 : if(!pNames)
433 0 : throw RuntimeException("invalid sheet index used");
434 : // find an unused name
435 10 : orName = findUnusedName( pNames, orName );
436 : // create the named range
437 10 : pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
438 : }
439 10 : return pScRangeData;
440 : }
441 :
442 0 : Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr )
443 : {
444 : // validate cell range
445 0 : CellRangeAddress aDestRange = rRangeAddr;
446 0 : bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
447 :
448 : // create database range and insert it into the Calc document
449 0 : Reference< XDatabaseRange > xDatabaseRange;
450 0 : if( bValidRange && !orName.isEmpty() ) try
451 : {
452 : // find an unused name
453 0 : PropertySet aDocProps( mxDoc );
454 0 : Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
455 0 : orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
456 : // create the database range
457 0 : xDatabaseRanges->addNewByName( orName, aDestRange );
458 0 : xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
459 : }
460 0 : catch( Exception& )
461 : {
462 : }
463 : OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
464 0 : return xDatabaseRange;
465 : }
466 :
467 2 : Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr )
468 : {
469 : // validate cell range
470 2 : CellRangeAddress aDestRange = rRangeAddr;
471 2 : bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
472 :
473 : // create database range and insert it into the Calc document
474 2 : Reference< XDatabaseRange > xDatabaseRange;
475 2 : if( bValidRange ) try
476 : {
477 2 : ScDocument& rDoc = getScDocument();
478 2 : if( rDoc.GetTableCount() <= aDestRange.Sheet )
479 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
480 2 : ScRange aScRange;
481 2 : ScUnoConversion::FillScRange(aScRange, aDestRange);
482 2 : ScDBData* pNewDBData = new ScDBData( STR_DB_LOCAL_NONAME, aScRange.aStart.Tab(),
483 2 : aScRange.aStart.Col(), aScRange.aStart.Row(),
484 6 : aScRange.aEnd.Col(), aScRange.aEnd.Row() );
485 2 : rDoc.SetAnonymousDBData( aScRange.aStart.Tab() , pNewDBData );
486 2 : ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
487 2 : xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aScRange.aStart.Tab()));
488 : }
489 0 : catch( Exception& )
490 : {
491 : }
492 : OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
493 2 : return xDatabaseRange;
494 : }
495 :
496 260 : Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
497 : {
498 260 : Reference< XStyle > xStyle;
499 : try
500 : {
501 260 : Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
502 260 : xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
503 260 : orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ), false );
504 : }
505 0 : catch( Exception& )
506 : {
507 : }
508 : OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
509 260 : return xStyle;
510 : }
511 :
512 0 : void WorkbookGlobals::useInternalChartDataTable( bool bInternal )
513 : {
514 0 : if( bInternal )
515 0 : mxChartConverter.reset( new oox::drawingml::chart::ChartConverter() );
516 : else
517 0 : mxChartConverter.reset( new ExcelChartConverter( *this ) );
518 0 : }
519 :
520 : // BIFF specific --------------------------------------------------------------
521 :
522 : // private --------------------------------------------------------------------
523 :
524 128 : void WorkbookGlobals::initialize( bool bWorkbookFile )
525 : {
526 128 : maCellStyles = "CellStyles";
527 128 : maPageStyles = "PageStyles";
528 128 : maCellStyleServ = "com.sun.star.style.CellStyle";
529 128 : maPageStyleServ = "com.sun.star.style.PageStyle";
530 128 : mnCurrSheet = -1;
531 128 : mbWorkbook = bWorkbookFile;
532 128 : meTextEnc = osl_getThreadTextEncoding();
533 128 : mbHasCodePage = false;
534 :
535 : // the spreadsheet document
536 128 : mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
537 : OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
538 :
539 128 : if (mxDoc.get())
540 : {
541 128 : ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
542 128 : if (pModel)
543 128 : mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
544 128 : if (mpDocShell)
545 128 : mpDoc = &mpDocShell->GetDocument();
546 : }
547 :
548 128 : if (!mpDoc)
549 0 : throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
550 :
551 128 : mxDocImport.reset(new ScDocumentImport(*mpDoc));
552 :
553 128 : mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
554 128 : mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
555 128 : mxViewSettings.reset( new ViewSettings( *this ) );
556 128 : mxWorksheets.reset( new WorksheetBuffer( *this ) );
557 128 : mxTheme.reset( new ThemeBuffer( *this ) );
558 128 : mxStyles.reset( new StylesBuffer( *this ) );
559 128 : mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
560 128 : mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
561 128 : mxDefNames.reset( new DefinedNamesBuffer( *this ) );
562 128 : mxTables.reset( new TableBuffer( *this ) );
563 128 : mxScenarios.reset( new ScenarioBuffer( *this ) );
564 128 : mxConnections.reset( new ConnectionsBuffer( *this ) );
565 128 : mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
566 128 : mxPivotTables.reset( new PivotTableBuffer( *this ) );
567 :
568 128 : mxUnitConverter.reset( new UnitConverter( *this ) );
569 128 : mxAddrConverter.reset( new AddressConverter( *this ) );
570 128 : mxChartConverter.reset( new ExcelChartConverter( *this ) );
571 128 : mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
572 :
573 : // initialise edit engine
574 128 : ScDocument& rDoc = getScDocument();
575 128 : mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
576 128 : mxEditEngine->SetRefMapMode( MAP_100TH_MM );
577 128 : mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
578 128 : mxEditEngine->SetUpdateMode( false );
579 128 : mxEditEngine->EnableUndo( false );
580 128 : mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EE_CNTRL_ALLOWBIGOBJS );
581 :
582 : // set some document properties needed during import
583 128 : if( mrBaseFilter.isImportFilter() )
584 : {
585 : // enable editing read-only documents (e.g. from read-only files)
586 128 : mpDoc->EnableChangeReadOnly(true);
587 : // #i76026# disable Undo while loading the document
588 128 : mpDoc->EnableUndo(false);
589 : // #i79826# disable calculating automatic row height while loading the document
590 128 : mpDoc->EnableAdjustHeight(true);
591 : // disable automatic update of linked sheets and DDE links
592 128 : mpDoc->EnableExecuteLink(false);
593 :
594 128 : mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScGlobal::GetRscString(STR_LOAD_DOC) ) );
595 128 : mxFmlaParser.reset( createFormulaParser() );
596 :
597 : //prevent unnecessary broadcasts and "half way listeners" as
598 : //is done in ScDocShell::BeforeXMLLoading() for ods
599 128 : mpDoc->SetInsertingFromOtherDoc(true);
600 : }
601 0 : else if( mrBaseFilter.isExportFilter() )
602 : {
603 0 : mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScGlobal::GetRscString(STR_SAVE_DOC) ) );
604 : }
605 : // filter specific
606 128 : switch( getFilterType() )
607 : {
608 : case FILTER_BIFF:
609 0 : mxCodecHelper.reset( new BiffCodecHelper( *this ) );
610 0 : break;
611 :
612 : case FILTER_OOXML:
613 128 : break;
614 :
615 : case FILTER_UNKNOWN:
616 0 : break;
617 : }
618 128 : }
619 :
620 128 : void WorkbookGlobals::finalize()
621 : {
622 : // set some document properties needed after import
623 128 : if( mrBaseFilter.isImportFilter() )
624 : {
625 : // #i74668# do not insert default sheets
626 128 : mpDocShell->SetEmpty(false);
627 : // enable automatic update of linked sheets and DDE links
628 128 : mpDoc->EnableExecuteLink(true);
629 : // #i79826# enable updating automatic row height after loading the document
630 128 : mpDoc->EnableAdjustHeight(true);
631 :
632 : // #i76026# enable Undo after loading the document
633 128 : mpDoc->EnableUndo(true);
634 :
635 : // disable editing read-only documents (e.g. from read-only files)
636 128 : mpDoc->EnableChangeReadOnly(false);
637 : // #111099# open forms in alive mode (has no effect, if no controls in document)
638 128 : ScDrawLayer* pModel = mpDoc->GetDrawLayer();
639 128 : if (pModel)
640 128 : pModel->SetOpenInDesignMode(false);
641 :
642 : //stop preventing establishment of listeners as is done in
643 : //ScDocShell::AfterXMLLoading() for ods
644 128 : mpDoc->SetInsertingFromOtherDoc(false);
645 128 : getDocImport().finalize();
646 :
647 128 : recalcFormulaCells();
648 : }
649 128 : }
650 :
651 128 : void WorkbookGlobals::recalcFormulaCells()
652 : {
653 : // Recalculate formula cells.
654 128 : ScDocument& rDoc = getScDocument();
655 128 : ScDocShell& rDocSh = getDocShell();
656 128 : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
657 : ScRecalcOptions nRecalcMode =
658 128 : static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
659 128 : bool bHardRecalc = false;
660 128 : if (nRecalcMode == RECALC_ASK)
661 : {
662 0 : if (rDoc.IsUserInteractionEnabled())
663 : {
664 : // Ask the user if full re-calculation is desired.
665 : QueryBox aBox(
666 : rDocSh.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
667 0 : ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
668 0 : aBox.SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
669 :
670 0 : sal_Int32 nRet = aBox.Execute();
671 0 : bHardRecalc = nRet == RET_YES;
672 :
673 0 : if (aBox.GetCheckBoxState())
674 : {
675 : // Always perform selected action in the future.
676 0 : boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
677 0 : officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
678 0 : ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
679 0 : aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
680 : /* XXX is this really supposed to set the ScModule options?
681 : * Not the ScDocShell options? */
682 0 : SC_MOD()->SetFormulaOptions(aOpt);
683 :
684 0 : batch->commit();
685 0 : }
686 : }
687 : }
688 128 : else if (nRecalcMode == RECALC_ALWAYS)
689 0 : bHardRecalc = true;
690 :
691 128 : if (bHardRecalc)
692 0 : rDocSh.DoHardRecalc(false);
693 : else
694 128 : rDoc.CalcFormulaTree(false, true, false);
695 128 : }
696 :
697 42906 : WorkbookHelper::~WorkbookHelper()
698 : {
699 42906 : }
700 :
701 128 : /*static*/ WorkbookGlobalsRef WorkbookHelper::constructGlobals( ExcelFilter& rFilter )
702 : {
703 128 : WorkbookGlobalsRef xBookGlob( new WorkbookGlobals( rFilter ) );
704 128 : if( !xBookGlob->isValid() )
705 0 : xBookGlob.reset();
706 128 : return xBookGlob;
707 : }
708 :
709 : // filter ---------------------------------------------------------------------
710 :
711 6592 : FilterBase& WorkbookHelper::getBaseFilter() const
712 : {
713 6592 : return mrBookGlob.getBaseFilter();
714 : }
715 :
716 5410 : FilterType WorkbookHelper::getFilterType() const
717 : {
718 5410 : return mrBookGlob.getFilterType();
719 : }
720 :
721 904 : SegmentProgressBar& WorkbookHelper::getProgressBar() const
722 : {
723 904 : return mrBookGlob.getProgressBar();
724 : }
725 :
726 0 : bool WorkbookHelper::isWorkbookFile() const
727 : {
728 0 : return mrBookGlob.isWorkbookFile();
729 : }
730 :
731 106 : sal_Int16 WorkbookHelper::getCurrentSheetIndex() const
732 : {
733 106 : return mrBookGlob.getCurrentSheetIndex();
734 : }
735 :
736 2 : void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg )
737 : {
738 2 : mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
739 2 : }
740 :
741 520 : void WorkbookHelper::setCurrentSheetIndex( sal_Int16 nSheet )
742 : {
743 520 : mrBookGlob.setCurrentSheetIndex( nSheet );
744 520 : }
745 :
746 128 : void WorkbookHelper::finalizeWorkbookImport()
747 : {
748 : // workbook settings, document and sheet view settings
749 128 : mrBookGlob.getWorkbookSettings().finalizeImport();
750 128 : mrBookGlob.getViewSettings().finalizeImport();
751 :
752 : // Import the VBA project (after finalizing workbook settings which
753 : // contains the workbook code name). Do it before processing formulas in
754 : // order to correctly resolve VBA custom function names.
755 128 : StorageRef xVbaPrjStrg = mrBookGlob.getVbaProjectStorage();
756 128 : if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
757 2 : getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
758 :
759 : // need to import formulas before scenarios
760 128 : mrBookGlob.getFormulaBuffer().finalizeImport();
761 :
762 : // Insert all pivot tables. Must be done after loading all sheets and
763 : // formulas, because data pilots expect existing source data on
764 : // creation.
765 128 : getPivotTables().finalizeImport();
766 :
767 : /* Insert scenarios after all sheet processing is done, because new hidden
768 : sheets are created for scenarios which would confuse code that relies
769 : on certain sheet indexes. Must be done after pivot tables too. */
770 128 : mrBookGlob.getScenarios().finalizeImport();
771 :
772 : /* Set 'Default' page style to automatic page numbering (default is manual
773 : number 1). Otherwise hidden sheets (e.g. for scenarios) which have
774 : 'Default' page style will break automatic page numbering for following
775 : sheets. Automatic numbering is set by passing the value 0. */
776 256 : PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
777 256 : aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
778 128 : }
779 :
780 : // document model -------------------------------------------------------------
781 :
782 4342 : ScDocument& WorkbookHelper::getScDocument()
783 : {
784 4342 : return mrBookGlob.getScDocument();
785 : }
786 :
787 336 : const ScDocument& WorkbookHelper::getScDocument() const
788 : {
789 336 : return mrBookGlob.getScDocument();
790 : }
791 :
792 7750 : ScDocumentImport& WorkbookHelper::getDocImport()
793 : {
794 7750 : return mrBookGlob.getDocImport();
795 : }
796 :
797 2 : ScEditEngineDefaulter& WorkbookHelper::getEditEngine() const
798 : {
799 2 : return mrBookGlob.getEditEngine();
800 : }
801 :
802 2100 : Reference< XSpreadsheetDocument > WorkbookHelper::getDocument() const
803 : {
804 2100 : return mrBookGlob.getDocument();
805 : }
806 :
807 404 : Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
808 : {
809 404 : Reference< XSpreadsheet > xSheet;
810 : try
811 : {
812 404 : Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
813 404 : xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
814 : }
815 0 : catch( Exception& )
816 : {
817 : }
818 404 : return xSheet;
819 : }
820 :
821 0 : Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
822 : {
823 0 : Reference< XSpreadsheet > xSheet;
824 : try
825 : {
826 0 : Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
827 0 : xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
828 : }
829 0 : catch( Exception& )
830 : {
831 : }
832 0 : return xSheet;
833 : }
834 :
835 136 : Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const CellRangeAddress& rRange ) const
836 : {
837 136 : Reference< XCellRange > xRange;
838 : try
839 : {
840 136 : Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.Sheet ), UNO_SET_THROW );
841 136 : xRange = xSheet->getCellRangeByPosition( rRange.StartColumn, rRange.StartRow, rRange.EndColumn, rRange.EndRow );
842 : }
843 0 : catch( Exception& )
844 : {
845 : }
846 136 : return xRange;
847 : }
848 :
849 128 : Reference< XNameContainer > WorkbookHelper::getStyleFamily( bool bPageStyles ) const
850 : {
851 128 : return mrBookGlob.getStyleFamily( bPageStyles );
852 : }
853 :
854 128 : Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
855 : {
856 128 : return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
857 : }
858 :
859 12 : ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
860 : {
861 12 : return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags );
862 : }
863 :
864 10 : ScRangeData* WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
865 : {
866 10 : return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
867 : }
868 :
869 0 : Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const
870 : {
871 0 : return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
872 : }
873 :
874 2 : Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
875 : {
876 2 : return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
877 : }
878 :
879 260 : Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
880 : {
881 260 : return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
882 : }
883 :
884 : // buffers --------------------------------------------------------------------
885 :
886 6756 : FormulaBuffer& WorkbookHelper::getFormulaBuffer() const
887 : {
888 6756 : return mrBookGlob.getFormulaBuffer();
889 : }
890 :
891 384 : WorkbookSettings& WorkbookHelper::getWorkbookSettings() const
892 : {
893 384 : return mrBookGlob.getWorkbookSettings();
894 : }
895 :
896 780 : ViewSettings& WorkbookHelper::getViewSettings() const
897 : {
898 780 : return mrBookGlob.getViewSettings();
899 : }
900 :
901 846 : WorksheetBuffer& WorkbookHelper::getWorksheets() const
902 : {
903 846 : return mrBookGlob.getWorksheets();
904 : }
905 :
906 5814 : ThemeBuffer& WorkbookHelper::getTheme() const
907 : {
908 5814 : return mrBookGlob.getTheme();
909 : }
910 :
911 20854 : StylesBuffer& WorkbookHelper::getStyles() const
912 : {
913 20854 : return mrBookGlob.getStyles();
914 : }
915 :
916 3064 : SharedStringsBuffer& WorkbookHelper::getSharedStrings() const
917 : {
918 3064 : return mrBookGlob.getSharedStrings();
919 : }
920 :
921 302 : ExternalLinkBuffer& WorkbookHelper::getExternalLinks() const
922 : {
923 302 : return mrBookGlob.getExternalLinks();
924 : }
925 :
926 410 : DefinedNamesBuffer& WorkbookHelper::getDefinedNames() const
927 : {
928 410 : return mrBookGlob.getDefinedNames();
929 : }
930 :
931 388 : TableBuffer& WorkbookHelper::getTables() const
932 : {
933 388 : return mrBookGlob.getTables();
934 : }
935 :
936 0 : ScenarioBuffer& WorkbookHelper::getScenarios() const
937 : {
938 0 : return mrBookGlob.getScenarios();
939 : }
940 :
941 0 : ConnectionsBuffer& WorkbookHelper::getConnections() const
942 : {
943 0 : return mrBookGlob.getConnections();
944 : }
945 :
946 16 : PivotCacheBuffer& WorkbookHelper::getPivotCaches() const
947 : {
948 16 : return mrBookGlob.getPivotCaches();
949 : }
950 :
951 136 : PivotTableBuffer& WorkbookHelper::getPivotTables() const
952 : {
953 136 : return mrBookGlob.getPivotTables();
954 : }
955 :
956 : // converters -----------------------------------------------------------------
957 :
958 150 : FormulaParser& WorkbookHelper::getFormulaParser() const
959 : {
960 150 : return mrBookGlob.getFormulaParser();
961 : }
962 :
963 260 : FormulaParser* WorkbookHelper::createFormulaParser() const
964 : {
965 260 : return mrBookGlob.createFormulaParser();
966 : }
967 :
968 4208 : UnitConverter& WorkbookHelper::getUnitConverter() const
969 : {
970 4208 : return mrBookGlob.getUnitConverter();
971 : }
972 :
973 6678 : AddressConverter& WorkbookHelper::getAddressConverter() const
974 : {
975 6678 : return mrBookGlob.getAddressConverter();
976 : }
977 :
978 68 : oox::drawingml::chart::ChartConverter* WorkbookHelper::getChartConverter() const
979 : {
980 68 : return mrBookGlob.getChartConverter();
981 : }
982 :
983 0 : void WorkbookHelper::useInternalChartDataTable( bool bInternal )
984 : {
985 0 : mrBookGlob.useInternalChartDataTable( bInternal );
986 0 : }
987 :
988 260 : PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const
989 : {
990 260 : return mrBookGlob.getPageSettingsConverter();
991 : }
992 :
993 : // OOXML/BIFF12 specific ------------------------------------------------------
994 :
995 2186 : XmlFilterBase& WorkbookHelper::getOoxFilter() const
996 : {
997 : OSL_ENSURE( mrBookGlob.getFilterType() == FILTER_OOXML, "WorkbookHelper::getOoxFilter - invalid call" );
998 2186 : return mrBookGlob.getOoxFilter();
999 : }
1000 :
1001 362 : bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler )
1002 : {
1003 362 : return getOoxFilter().importFragment( rxHandler );
1004 : }
1005 :
1006 280 : bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler, oox::core::FastParser& rParser )
1007 : {
1008 280 : return getOoxFilter().importFragment(rxHandler, rParser);
1009 : }
1010 :
1011 : // BIFF specific --------------------------------------------------------------
1012 :
1013 388 : BiffType WorkbookHelper::getBiff() const
1014 : {
1015 388 : return mrBookGlob.getBiff();
1016 : }
1017 :
1018 2 : rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1019 : {
1020 2 : return mrBookGlob.getTextEncoding();
1021 : }
1022 :
1023 0 : BiffCodecHelper& WorkbookHelper::getCodecHelper() const
1024 : {
1025 0 : return mrBookGlob.getCodecHelper();
1026 : }
1027 :
1028 : } // namespace xls
1029 48 : } // namespace oox
1030 :
1031 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|