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 "workbookfragment.hxx"
21 :
22 : #include <com/sun/star/table/CellAddress.hpp>
23 : #include "oox/core/filterbase.hxx"
24 : #include "oox/drawingml/themefragmenthandler.hxx"
25 : #include "oox/helper/attributelist.hxx"
26 : #include "oox/helper/progressbar.hxx"
27 : #include "oox/helper/propertyset.hxx"
28 : #include "oox/ole/olestorage.hxx"
29 :
30 : #include "biffinputstream.hxx"
31 : #include "chartsheetfragment.hxx"
32 : #include "connectionsfragment.hxx"
33 : #include "externallinkbuffer.hxx"
34 : #include "externallinkfragment.hxx"
35 : #include "formulabuffer.hxx"
36 : #include "pivotcachebuffer.hxx"
37 : #include "sharedstringsbuffer.hxx"
38 : #include "sharedstringsfragment.hxx"
39 : #include "stylesfragment.hxx"
40 : #include "tablebuffer.hxx"
41 : #include "themebuffer.hxx"
42 : #include "viewsettings.hxx"
43 : #include "workbooksettings.hxx"
44 : #include "worksheetbuffer.hxx"
45 : #include "worksheethelper.hxx"
46 : #include "worksheetfragment.hxx"
47 : #include "sheetdatacontext.hxx"
48 : #include "threadpool.hxx"
49 : #include "officecfg/Office/Common.hxx"
50 :
51 : #include "document.hxx"
52 : #include "docsh.hxx"
53 : #include "calcconfig.hxx"
54 :
55 : #include <vcl/svapp.hxx>
56 : #include <vcl/timer.hxx>
57 :
58 : #include <oox/core/fastparser.hxx>
59 : #include <salhelper/thread.hxx>
60 : #include <osl/conditn.hxx>
61 :
62 : #include <queue>
63 : #include <boost/scoped_ptr.hpp>
64 :
65 : #include "oox/ole/vbaproject.hxx"
66 :
67 : namespace oox {
68 : namespace xls {
69 :
70 : using namespace ::com::sun::star::io;
71 : using namespace ::com::sun::star::table;
72 : using namespace ::com::sun::star::uno;
73 : using namespace ::com::sun::star::sheet;
74 : using namespace ::oox::core;
75 :
76 : using ::oox::drawingml::ThemeFragmentHandler;
77 :
78 : namespace {
79 :
80 : const double PROGRESS_LENGTH_GLOBALS = 0.1; /// 10% of progress bar for globals import.
81 :
82 : } // namespace
83 :
84 44 : WorkbookFragment::WorkbookFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
85 44 : WorkbookFragmentBase( rHelper, rFragmentPath )
86 : {
87 44 : }
88 :
89 438 : ContextHandlerRef WorkbookFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
90 : {
91 438 : switch( getCurrentElement() )
92 : {
93 : case XML_ROOT_CONTEXT:
94 44 : if( nElement == XLS_TOKEN( workbook ) ) return this;
95 0 : break;
96 :
97 : case XLS_TOKEN( workbook ):
98 253 : switch( nElement )
99 : {
100 : case XLS_TOKEN( sheets ):
101 : case XLS_TOKEN( bookViews ):
102 : case XLS_TOKEN( externalReferences ):
103 : case XLS_TOKEN( definedNames ):
104 92 : case XLS_TOKEN( pivotCaches ): return this;
105 :
106 0 : case XLS_TOKEN( fileSharing ): getWorkbookSettings().importFileSharing( rAttribs ); break;
107 44 : case XLS_TOKEN( workbookPr ): getWorkbookSettings().importWorkbookPr( rAttribs ); break;
108 44 : case XLS_TOKEN( calcPr ): getWorkbookSettings().importCalcPr( rAttribs ); break;
109 0 : case XLS_TOKEN( oleSize ): getViewSettings().importOleSize( rAttribs ); break;
110 : }
111 161 : break;
112 :
113 : case XLS_TOKEN( sheets ):
114 85 : if( nElement == XLS_TOKEN( sheet ) ) getWorksheets().importSheet( rAttribs );
115 85 : break;
116 : case XLS_TOKEN( bookViews ):
117 44 : if( nElement == XLS_TOKEN( workbookView ) ) getViewSettings().importWorkbookView( rAttribs );
118 44 : break;
119 : case XLS_TOKEN( externalReferences ):
120 1 : if( nElement == XLS_TOKEN( externalReference ) ) importExternalReference( rAttribs );
121 1 : break;
122 : case XLS_TOKEN( definedNames ):
123 11 : if( nElement == XLS_TOKEN( definedName ) ) { importDefinedName( rAttribs ); return this; } // collect formula
124 0 : break;
125 : case XLS_TOKEN( pivotCaches ):
126 0 : if( nElement == XLS_TOKEN( pivotCache ) ) importPivotCache( rAttribs );
127 0 : break;
128 : }
129 291 : return 0;
130 : }
131 :
132 11 : void WorkbookFragment::onCharacters( const OUString& rChars )
133 : {
134 11 : if( isCurrentElement( XLS_TOKEN( definedName ) ) && mxCurrName.get() )
135 11 : mxCurrName->setFormula( rChars );
136 11 : }
137 :
138 0 : ContextHandlerRef WorkbookFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
139 : {
140 0 : switch( getCurrentElement() )
141 : {
142 : case XML_ROOT_CONTEXT:
143 0 : if( nRecId == BIFF12_ID_WORKBOOK ) return this;
144 0 : break;
145 :
146 : case BIFF12_ID_WORKBOOK:
147 0 : switch( nRecId )
148 : {
149 : case BIFF12_ID_SHEETS:
150 : case BIFF12_ID_BOOKVIEWS:
151 : case BIFF12_ID_EXTERNALREFS:
152 0 : case BIFF12_ID_PIVOTCACHES: return this;
153 :
154 0 : case BIFF12_ID_FILESHARING: getWorkbookSettings().importFileSharing( rStrm ); break;
155 0 : case BIFF12_ID_WORKBOOKPR: getWorkbookSettings().importWorkbookPr( rStrm ); break;
156 0 : case BIFF12_ID_CALCPR: getWorkbookSettings().importCalcPr( rStrm ); break;
157 0 : case BIFF12_ID_OLESIZE: getViewSettings().importOleSize( rStrm ); break;
158 0 : case BIFF12_ID_DEFINEDNAME: getDefinedNames().importDefinedName( rStrm ); break;
159 : }
160 0 : break;
161 :
162 : case BIFF12_ID_SHEETS:
163 0 : if( nRecId == BIFF12_ID_SHEET ) getWorksheets().importSheet( rStrm );
164 0 : break;
165 : case BIFF12_ID_BOOKVIEWS:
166 0 : if( nRecId == BIFF12_ID_WORKBOOKVIEW ) getViewSettings().importWorkbookView( rStrm );
167 0 : break;
168 :
169 : case BIFF12_ID_EXTERNALREFS:
170 0 : switch( nRecId )
171 : {
172 0 : case BIFF12_ID_EXTERNALREF: importExternalRef( rStrm ); break;
173 0 : case BIFF12_ID_EXTERNALSELF: getExternalLinks().importExternalSelf( rStrm ); break;
174 0 : case BIFF12_ID_EXTERNALSAME: getExternalLinks().importExternalSame( rStrm ); break;
175 0 : case BIFF12_ID_EXTERNALADDIN: getExternalLinks().importExternalAddin( rStrm ); break;
176 0 : case BIFF12_ID_EXTERNALSHEETS: getExternalLinks().importExternalSheets( rStrm ); break;
177 : }
178 0 : break;
179 :
180 : case BIFF12_ID_PIVOTCACHES:
181 0 : if( nRecId == BIFF12_ID_PIVOTCACHE ) importPivotCache( rStrm );
182 : }
183 0 : return 0;
184 : }
185 :
186 0 : const RecordInfo* WorkbookFragment::getRecordInfos() const
187 : {
188 : static const RecordInfo spRecInfos[] =
189 : {
190 : { BIFF12_ID_BOOKVIEWS, BIFF12_ID_BOOKVIEWS + 1 },
191 : { BIFF12_ID_EXTERNALREFS, BIFF12_ID_EXTERNALREFS + 1 },
192 : { BIFF12_ID_FUNCTIONGROUPS, BIFF12_ID_FUNCTIONGROUPS + 2 },
193 : { BIFF12_ID_PIVOTCACHE, BIFF12_ID_PIVOTCACHE + 1 },
194 : { BIFF12_ID_PIVOTCACHES, BIFF12_ID_PIVOTCACHES + 1 },
195 : { BIFF12_ID_SHEETS, BIFF12_ID_SHEETS + 1 },
196 : { BIFF12_ID_WORKBOOK, BIFF12_ID_WORKBOOK + 1 },
197 : { -1, -1 }
198 : };
199 0 : return spRecInfos;
200 : }
201 :
202 : namespace {
203 :
204 : typedef std::pair<WorksheetGlobalsRef, FragmentHandlerRef> SheetFragmentHandler;
205 : typedef std::vector<SheetFragmentHandler> SheetFragmentVector;
206 :
207 0 : class WorkerThread : public ThreadTask
208 : {
209 : sal_Int32 &mrSheetsLeft;
210 : WorkbookFragment& mrWorkbookHandler;
211 : rtl::Reference<FragmentHandler> mxHandler;
212 :
213 : public:
214 0 : WorkerThread( WorkbookFragment& rWorkbookHandler,
215 : const rtl::Reference<FragmentHandler>& xHandler,
216 : sal_Int32 &rSheetsLeft ) :
217 : mrSheetsLeft( rSheetsLeft ),
218 : mrWorkbookHandler( rWorkbookHandler ),
219 0 : mxHandler( xHandler )
220 : {
221 0 : }
222 :
223 0 : virtual void doWork() SAL_OVERRIDE
224 : {
225 : // We hold the solar mutex in all threads except for
226 : // the small safe section of the inner loop in
227 : // sheetdatacontext.cxx
228 : SAL_INFO( "sc.filter", "start wait on solar\n" );
229 0 : SolarMutexGuard maGuard;
230 : SAL_INFO( "sc.filter", "got solar\n" );
231 :
232 : boost::scoped_ptr<oox::core::FastParser> xParser(
233 0 : mrWorkbookHandler.getOoxFilter().createParser() );
234 :
235 : SAL_INFO( "sc.filter", "start import\n" );
236 0 : mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
237 : SAL_INFO( "sc.filter", "end import, release solar\n" );
238 0 : mrSheetsLeft--;
239 : assert( mrSheetsLeft >= 0 );
240 0 : if( mrSheetsLeft == 0 )
241 0 : Application::EndYield();
242 0 : }
243 : };
244 :
245 : class ProgressBarTimer : Timer
246 : {
247 : // FIXME: really we should unify all sheet loading
248 : // progress reporting into something pleasant.
249 : class ProgressWrapper : public ISegmentProgressBar
250 : {
251 : double mfPosition;
252 : ISegmentProgressBarRef mxWrapped;
253 : public:
254 0 : ProgressWrapper(const ISegmentProgressBarRef &xRef)
255 : : mfPosition(0.0)
256 0 : , mxWrapped(xRef)
257 : {
258 0 : }
259 0 : virtual ~ProgressWrapper() {}
260 : // IProgressBar
261 0 : virtual double getPosition() const SAL_OVERRIDE { return mfPosition; }
262 0 : virtual void setPosition( double fPosition ) SAL_OVERRIDE { mfPosition = fPosition; }
263 : // ISegmentProgressBar
264 0 : virtual double getFreeLength() const SAL_OVERRIDE { return 0.0; }
265 0 : virtual ISegmentProgressBarRef createSegment( double /* fLength */ ) SAL_OVERRIDE
266 : {
267 0 : return ISegmentProgressBarRef();
268 : }
269 0 : void UpdateBar()
270 : {
271 0 : mxWrapped->setPosition( mfPosition );
272 0 : }
273 : };
274 : std::vector< ISegmentProgressBarRef > aSegments;
275 : public:
276 0 : ProgressBarTimer() : Timer()
277 : {
278 0 : SetTimeout( 500 );
279 0 : }
280 0 : virtual ~ProgressBarTimer()
281 0 : {
282 0 : aSegments.clear();
283 0 : }
284 0 : ISegmentProgressBarRef wrapProgress( const ISegmentProgressBarRef &xProgress )
285 : {
286 0 : aSegments.push_back( ISegmentProgressBarRef( new ProgressWrapper( xProgress ) ) );
287 0 : return aSegments.back();
288 : }
289 0 : virtual void Timeout() SAL_OVERRIDE
290 : {
291 0 : for( size_t i = 0; i < aSegments.size(); i++)
292 0 : static_cast< ProgressWrapper *>( aSegments[ i ].get() )->UpdateBar();
293 0 : }
294 : };
295 :
296 44 : static void importSheetFragments( WorkbookFragment& rWorkbookHandler, SheetFragmentVector& rSheets )
297 : {
298 44 : sal_Int32 nThreads = std::min( rSheets.size(), (size_t) 4 /* FIXME: ncpus/2 */ );
299 :
300 44 : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
301 :
302 : // Force threading off unless experimental mode or env. var is set.
303 44 : if( !officecfg::Office::Common::Misc::ExperimentalMode::get( xContext ) )
304 44 : nThreads = 0;
305 :
306 : const char *pEnv;
307 44 : if( ( pEnv = getenv( "SC_IMPORT_THREADS" ) ) )
308 0 : nThreads = rtl_str_toInt32( pEnv, 10 );
309 :
310 44 : if( nThreads != 0 )
311 : {
312 : // test sequential read in this mode
313 0 : if( nThreads < 0)
314 0 : nThreads = 0;
315 0 : ThreadPool aPool( nThreads );
316 :
317 0 : sal_Int32 nSheetsLeft = 0;
318 0 : ProgressBarTimer aProgressUpdater;
319 0 : SheetFragmentVector::iterator it = rSheets.begin(), itEnd = rSheets.end();
320 0 : for( ; it != itEnd; ++it )
321 : {
322 : // getting at the WorksheetGlobals is rather unpleasant
323 0 : IWorksheetProgress *pProgress = WorksheetHelper::getWorksheetInterface( it->first );
324 : pProgress->setCustomRowProgress(
325 : aProgressUpdater.wrapProgress(
326 0 : pProgress->getRowProgress() ) );
327 0 : aPool.pushTask( new WorkerThread( rWorkbookHandler, it->second,
328 0 : /* ref */ nSheetsLeft ) );
329 0 : nSheetsLeft++;
330 : }
331 :
332 0 : while( nSheetsLeft > 0)
333 : {
334 : // This is a much more controlled re-enterancy hazard than
335 : // allowing a yield deeper inside the filter code for progress
336 : // bar updating.
337 0 : Application::Yield();
338 : }
339 : // join all the threads:
340 0 : aPool.waitUntilWorkersDone();
341 : }
342 : else
343 : {
344 44 : SheetFragmentVector::iterator it = rSheets.begin(), itEnd = rSheets.end();
345 129 : for( ; it != itEnd; ++it )
346 85 : rWorkbookHandler.importOoxFragment( it->second );
347 44 : }
348 44 : }
349 :
350 : }
351 :
352 44 : void WorkbookFragment::finalizeImport()
353 : {
354 44 : ISegmentProgressBarRef xGlobalSegment = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS );
355 :
356 : // read the theme substream
357 88 : OUString aThemeFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
358 44 : if( !aThemeFragmentPath.isEmpty() )
359 21 : importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme() ) );
360 44 : xGlobalSegment->setPosition( 0.25 );
361 :
362 : // read the styles substream (requires finalized theme buffer)
363 88 : OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "styles" );
364 44 : if( !aStylesFragmentPath.isEmpty() )
365 44 : importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
366 44 : xGlobalSegment->setPosition( 0.5 );
367 :
368 : // read the shared string table substream (requires finalized styles buffer)
369 88 : OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "sharedStrings" );
370 44 : if( !aSstFragmentPath.isEmpty() )
371 31 : if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
372 0 : importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
373 44 : xGlobalSegment->setPosition( 0.75 );
374 :
375 : // read the connections substream
376 88 : OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "connections" );
377 44 : if( !aConnFragmentPath.isEmpty() )
378 0 : importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
379 44 : xGlobalSegment->setPosition( 1.0 );
380 :
381 :
382 : /* Create fragments for all sheets, before importing them. Needed to do
383 : some preprocessing in the fragment constructors, e.g. loading the table
384 : fragments for all sheets that are needed before the cell formulas are
385 : loaded. Additionally, the instances of the WorkbookGlobals structures
386 : have to be stored for every sheet. */
387 88 : SheetFragmentVector aSheetFragments;
388 88 : std::vector<WorksheetHelper*> maHelpers;
389 44 : WorksheetBuffer& rWorksheets = getWorksheets();
390 44 : sal_Int32 nWorksheetCount = rWorksheets.getWorksheetCount();
391 129 : for( sal_Int32 nWorksheet = 0; nWorksheet < nWorksheetCount; ++nWorksheet )
392 : {
393 85 : sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet );
394 85 : const Relation* pRelation = getRelations().getRelationFromRelId( rWorksheets.getWorksheetRelId( nWorksheet ) );
395 85 : if( (nCalcSheet >= 0) && pRelation )
396 : {
397 : // get fragment path of the sheet
398 85 : OUString aFragmentPath = getFragmentPathFromRelation( *pRelation );
399 : OSL_ENSURE( !aFragmentPath.isEmpty(), "WorkbookFragment::finalizeImport - cannot access sheet fragment" );
400 85 : if( !aFragmentPath.isEmpty() )
401 : {
402 : // leave space for formula processing ( calcuate the segments as
403 : // if there is an extra sheet )
404 85 : double fSegmentLength = getProgressBar().getFreeLength() / (nWorksheetCount - ( nWorksheet - 1) );
405 85 : ISegmentProgressBarRef xSheetSegment = getProgressBar().createSegment( fSegmentLength );
406 :
407 : // get the sheet type according to the relations type
408 85 : WorksheetType eSheetType = SHEETTYPE_EMPTYSHEET;
409 85 : if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
410 0 : pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
411 85 : eSheetType = SHEETTYPE_WORKSHEET;
412 0 : else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
413 0 : pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
414 0 : eSheetType = SHEETTYPE_CHARTSHEET;
415 0 : else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
416 0 : (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
417 0 : eSheetType = SHEETTYPE_MACROSHEET;
418 0 : else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
419 0 : pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
420 0 : eSheetType = SHEETTYPE_DIALOGSHEET;
421 : OSL_ENSURE( eSheetType != SHEETTYPE_EMPTYSHEET, "WorkbookFragment::finalizeImport - unknown sheet type" );
422 85 : if( eSheetType != SHEETTYPE_EMPTYSHEET )
423 : {
424 : // create the WorksheetGlobals object
425 85 : WorksheetGlobalsRef xSheetGlob = WorksheetHelper::constructGlobals( *this, xSheetSegment, eSheetType, nCalcSheet );
426 : OSL_ENSURE( xSheetGlob.get(), "WorkbookFragment::finalizeImport - missing sheet in document" );
427 85 : if( xSheetGlob.get() )
428 : {
429 : // create the sheet fragment handler
430 85 : ::rtl::Reference< WorksheetFragmentBase > xFragment;
431 85 : switch( eSheetType )
432 : {
433 : case SHEETTYPE_WORKSHEET:
434 : case SHEETTYPE_MACROSHEET:
435 : case SHEETTYPE_DIALOGSHEET:
436 85 : xFragment.set( new WorksheetFragment( *xSheetGlob, aFragmentPath ) );
437 85 : break;
438 : case SHEETTYPE_CHARTSHEET:
439 0 : xFragment.set( new ChartsheetFragment( *xSheetGlob, aFragmentPath ) );
440 0 : break;
441 : case SHEETTYPE_EMPTYSHEET:
442 : case SHEETTYPE_MODULESHEET:
443 0 : break;
444 : }
445 :
446 : // insert the fragment into the map
447 85 : if( xFragment.is() )
448 : {
449 85 : aSheetFragments.push_back( SheetFragmentHandler( xSheetGlob, xFragment.get() ) );
450 85 : maHelpers.push_back(xFragment.get());
451 85 : }
452 85 : }
453 85 : }
454 85 : }
455 : }
456 : }
457 :
458 : // setup structure sizes for the number of sheets
459 44 : getFormulaBuffer().SetSheetCount( aSheetFragments.size() );
460 :
461 : // create all defined names and database ranges
462 44 : getDefinedNames().finalizeImport();
463 44 : getTables().finalizeImport();
464 : // open the VBA project storage
465 44 : OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATION_TYPE( "vbaProject" ) );
466 44 : if( !aVbaFragmentPath.isEmpty() )
467 : {
468 0 : Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath );
469 0 : if( xInStrm.is() )
470 : {
471 0 : StorageRef xPrjStrg( new ::oox::ole::OleStorage( getBaseFilter().getComponentContext(), xInStrm, false ) );
472 0 : setVbaProjectStorage( xPrjStrg );
473 0 : getBaseFilter().getVbaProject().readVbaModules( *xPrjStrg );
474 0 : }
475 : }
476 :
477 : // load all worksheets
478 44 : importSheetFragments(*this, aSheetFragments);
479 :
480 129 : for( std::vector<WorksheetHelper*>::iterator aIt = maHelpers.begin(), aEnd = maHelpers.end(); aIt != aEnd; ++aIt )
481 : {
482 85 : (*aIt)->finalizeDrawingImport();
483 : }
484 :
485 129 : for( SheetFragmentVector::iterator aIt = aSheetFragments.begin(), aEnd = aSheetFragments.end(); aIt != aEnd; ++aIt )
486 : {
487 : // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
488 85 : aIt->second.clear();
489 85 : aIt->first.reset();
490 : }
491 :
492 : // final conversions, e.g. calculation settings and view settings
493 88 : finalizeWorkbookImport();
494 44 : }
495 :
496 : // private --------------------------------------------------------------------
497 :
498 1 : void WorkbookFragment::importExternalReference( const AttributeList& rAttribs )
499 : {
500 1 : if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
501 1 : importExternalLinkFragment( *pExtLink );
502 1 : }
503 :
504 11 : void WorkbookFragment::importDefinedName( const AttributeList& rAttribs )
505 : {
506 11 : mxCurrName = getDefinedNames().importDefinedName( rAttribs );
507 11 : }
508 :
509 0 : void WorkbookFragment::importPivotCache( const AttributeList& rAttribs )
510 : {
511 0 : sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
512 0 : OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
513 0 : importPivotCacheDefFragment( aRelId, nCacheId );
514 0 : }
515 :
516 0 : void WorkbookFragment::importExternalRef( SequenceInputStream& rStrm )
517 : {
518 0 : if( ExternalLink* pExtLink = getExternalLinks().importExternalRef( rStrm ).get() )
519 0 : importExternalLinkFragment( *pExtLink );
520 0 : }
521 :
522 0 : void WorkbookFragment::importPivotCache( SequenceInputStream& rStrm )
523 : {
524 0 : sal_Int32 nCacheId = rStrm.readInt32();
525 0 : OUString aRelId = BiffHelper::readString( rStrm );
526 0 : importPivotCacheDefFragment( aRelId, nCacheId );
527 0 : }
528 :
529 1 : void WorkbookFragment::importExternalLinkFragment( ExternalLink& rExtLink )
530 : {
531 1 : OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
532 1 : if( !aFragmentPath.isEmpty() )
533 1 : importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
534 1 : }
535 :
536 0 : void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
537 : {
538 : // pivot caches will be imported on demand, here we just store the fragment path in the buffer
539 0 : getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
540 0 : }
541 :
542 : } // namespace xls
543 18 : } // namespace oox
544 :
545 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|