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