LibreOffice Module sc (master) 1
workbookfragment.cxx
Go to the documentation of this file.
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 <utility>
21#include <workbookfragment.hxx>
22
30#include <oox/token/namespaces.hxx>
31#include <oox/token/tokens.hxx>
32
37#include <formulabuffer.hxx>
38#include <pivotcachebuffer.hxx>
40#include <revisionfragment.hxx>
41#include <stylesfragment.hxx>
42#include <tablebuffer.hxx>
43#include <themebuffer.hxx>
44#include <viewsettings.hxx>
45#include <workbooksettings.hxx>
46#include <worksheetbuffer.hxx>
47#include <worksheethelper.hxx>
48#include <worksheetfragment.hxx>
49#include <extlstcontext.hxx>
50#include <documentimport.hxx>
51#include <biffhelper.hxx>
52
53#include <document.hxx>
54#include <drwlayer.hxx>
55#include <docsh.hxx>
56#include <calcconfig.hxx>
57#include <globstr.hrc>
58#include <scresid.hxx>
59#include <scmod.hxx>
60#include <formulaopt.hxx>
61
62#include <vcl/svapp.hxx>
63#include <vcl/timer.hxx>
64#include <vcl/weld.hxx>
65
68#include <sal/log.hxx>
69#include <osl/diagnose.h>
70
71#include <memory>
72
74
76#include <officecfg/Office/Calc.hxx>
77
78namespace oox::xls {
79
80using namespace ::com::sun::star::io;
81using namespace ::com::sun::star::table;
82using namespace ::com::sun::star::uno;
83using namespace ::oox::core;
84
85using ::oox::drawingml::ThemeFragmentHandler;
86
87namespace {
88
89const double PROGRESS_LENGTH_GLOBALS = 0.1;
90
91} // namespace
92
93WorkbookFragment::WorkbookFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
94 WorkbookFragmentBase( rHelper, rFragmentPath )
95{
96}
97
99{
100 switch( getCurrentElement() )
101 {
102 case XML_ROOT_CONTEXT:
103 if( nElement == XLS_TOKEN( workbook ) ) return this;
104 break;
105
106 case XLS_TOKEN( workbook ):
107 switch( nElement )
108 {
109 case XLS_TOKEN( sheets ):
110 case XLS_TOKEN( bookViews ):
111 case XLS_TOKEN( externalReferences ):
112 case XLS_TOKEN( definedNames ):
113 case XLS_TOKEN( pivotCaches ): return this;
114
115 case XLS_TOKEN( fileSharing ): getWorkbookSettings().importFileSharing( rAttribs ); break;
116 case XLS_TOKEN( workbookPr ): getWorkbookSettings().importWorkbookPr( rAttribs ); break;
117 case XLS_TOKEN( calcPr ): getWorkbookSettings().importCalcPr( rAttribs ); break;
118 case XLS_TOKEN( oleSize ): getViewSettings().importOleSize( rAttribs ); break;
119
120 case XLS_TOKEN( extLst ): return new ExtLstGlobalWorkbookContext( *this );
121 }
122 break;
123
124 case XLS_TOKEN( sheets ):
125 if( nElement == XLS_TOKEN( sheet ) ) getWorksheets().importSheet( rAttribs );
126 break;
127 case XLS_TOKEN( bookViews ):
128 if( nElement == XLS_TOKEN( workbookView ) ) getViewSettings().importWorkbookView( rAttribs );
129 break;
130 case XLS_TOKEN( externalReferences ):
131 if( nElement == XLS_TOKEN( externalReference ) ) importExternalReference( rAttribs );
132 break;
133 case XLS_TOKEN( definedNames ):
134 if( nElement == XLS_TOKEN( definedName ) ) { importDefinedName( rAttribs ); return this; } // collect formula
135 break;
136 case XLS_TOKEN( pivotCaches ):
137 if( nElement == XLS_TOKEN( pivotCache ) ) importPivotCache( rAttribs );
138 break;
139 }
140 return nullptr;
141}
142
143void WorkbookFragment::onCharacters( const OUString& rChars )
144{
145 if( isCurrentElement( XLS_TOKEN( definedName ) ) && mxCurrName )
146 mxCurrName->setFormula( rChars );
147}
148
150{
151 switch( getCurrentElement() )
152 {
153 case XML_ROOT_CONTEXT:
154 if( nRecId == BIFF12_ID_WORKBOOK ) return this;
155 break;
156
158 switch( nRecId )
159 {
160 case BIFF12_ID_SHEETS:
163 case BIFF12_ID_PIVOTCACHES: return this;
164
170 }
171 break;
172
173 case BIFF12_ID_SHEETS:
174 if( nRecId == BIFF12_ID_SHEET ) getWorksheets().importSheet( rStrm );
175 break;
178 break;
179
181 switch( nRecId )
182 {
188 }
189 break;
190
193 }
194 return nullptr;
195}
196
197const RecordInfo* WorkbookFragment::getRecordInfos() const
198{
199 static const RecordInfo spRecInfos[] =
200 {
208 { -1, -1 }
209 };
210 return spRecInfos;
211}
212
213namespace {
214
215typedef std::pair<WorksheetGlobalsRef, FragmentHandlerRef> SheetFragmentHandler;
216typedef std::vector<SheetFragmentHandler> SheetFragmentVector;
217
218class WorkerThread : public comphelper::ThreadTask
219{
220 sal_Int32 &mrSheetsLeft;
221 WorkbookFragment& mrWorkbookHandler;
223
224public:
225 WorkerThread( const std::shared_ptr<comphelper::ThreadTaskTag> & pTag,
226 WorkbookFragment& rWorkbookHandler,
228 sal_Int32 &rSheetsLeft ) :
229 comphelper::ThreadTask( pTag ),
230 mrSheetsLeft( rSheetsLeft ),
231 mrWorkbookHandler( rWorkbookHandler ),
232 mxHandler(std::move( xHandler ))
233 {
234 }
235
236 virtual void doWork() override
237 {
238 // We hold the solar mutex in all threads except for
239 // the small safe section of the inner loop in
240 // sheetdatacontext.cxx
241 SAL_INFO( "sc.filter", "start wait on solar" );
242 SolarMutexGuard aGuard;
243 SAL_INFO( "sc.filter", "got solar" );
244
245 std::unique_ptr<oox::core::FastParser> xParser(
247
248 SAL_INFO( "sc.filter", "start import" );
249 mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
250 SAL_INFO( "sc.filter", "end import, release solar" );
251 mrSheetsLeft--;
252 assert( mrSheetsLeft >= 0 );
253 if( mrSheetsLeft == 0 )
255 }
256};
257
258class ProgressBarTimer : private Timer
259{
260 // FIXME: really we should unify all sheet loading
261 // progress reporting into something pleasant.
262 class ProgressWrapper : public ISegmentProgressBar
263 {
266 public:
267 explicit ProgressWrapper(ISegmentProgressBarRef xRef)
268 : mfPosition(0.0)
269 , mxWrapped(std::move(xRef))
270 {
271 }
272
273 // IProgressBar
274 virtual double getPosition() const override { return mfPosition; }
275 virtual void setPosition( double fPosition ) override { mfPosition = fPosition; }
276 // ISegmentProgressBar
277 virtual double getFreeLength() const override { return 0.0; }
278 virtual ISegmentProgressBarRef createSegment( double /* fLength */ ) override
279 {
280 return ISegmentProgressBarRef();
281 }
282 void UpdateBar()
283 {
284 mxWrapped->setPosition( mfPosition );
285 }
286 };
287 std::vector< ISegmentProgressBarRef > aSegments;
288public:
289 ProgressBarTimer() : Timer("sc ProgressBarTimer")
290 {
291 SetTimeout( 500 );
292 }
293 virtual ~ProgressBarTimer() override
294 {
295 aSegments.clear();
296 }
297 const ISegmentProgressBarRef& wrapProgress( const ISegmentProgressBarRef &xProgress )
298 {
299 aSegments.push_back( std::make_shared<ProgressWrapper>( xProgress ) );
300 return aSegments.back();
301 }
302 virtual void Invoke() override
303 {
304 for(std::shared_ptr<ISegmentProgressBar> & pSegment : aSegments)
305 static_cast< ProgressWrapper *>( pSegment.get() )->UpdateBar();
306 }
307};
308
309void importSheetFragments( WorkbookFragment& rWorkbookHandler, SheetFragmentVector& rSheets )
310{
311 rWorkbookHandler.getDocImport().initForSheets();
312
313 // test sequential read in this mode
315 std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag();
316
317 sal_Int32 nSheetsLeft = 0;
318 ProgressBarTimer aProgressUpdater;
319 for( auto& [rxSheetGlob, rxFragment] : rSheets )
320 {
321 // getting at the WorksheetGlobals is rather unpleasant
322 IWorksheetProgress *pProgress = WorksheetHelper::getWorksheetInterface( rxSheetGlob );
323 pProgress->setCustomRowProgress(
324 aProgressUpdater.wrapProgress(
325 pProgress->getRowProgress() ) );
326 rSharedPool.pushTask( std::make_unique<WorkerThread>( pTag, rWorkbookHandler, rxFragment,
327 /* ref */ nSheetsLeft ) );
328 nSheetsLeft++;
329 }
330
331 // coverity[loop_top] - this isn't an infinite loop where nSheetsLeft gets decremented by the above threads
332 while( nSheetsLeft > 0 && !Application::IsQuit())
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.
338 }
339 rSharedPool.waitUntilDone(pTag);
340
341 // threads joined in ThreadPool destructor
342}
343
344}
345
347{
348 ISegmentProgressBarRef xGlobalSegment = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS );
349
350 // read the theme substream
351 OUString aThemeFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" );
352 if( !aThemeFragmentPath.isEmpty() )
353 importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme() ) );
354 xGlobalSegment->setPosition( 0.25 );
355
356 // read the styles substream (requires finalized theme buffer)
357 OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"styles" );
358 if( !aStylesFragmentPath.isEmpty() )
359 importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
360 xGlobalSegment->setPosition( 0.5 );
361
362 // read the shared string table substream (requires finalized styles buffer)
363 OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"sharedStrings" );
364 if( !aSstFragmentPath.isEmpty() )
365 if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
366 importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
367 xGlobalSegment->setPosition( 0.75 );
368
369 // read the connections substream
370 OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"connections" );
371 if( !aConnFragmentPath.isEmpty() )
372 importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
373 xGlobalSegment->setPosition( 1.0 );
374
375 /* Create fragments for all sheets, before importing them. Needed to do
376 some preprocessing in the fragment constructors, e.g. loading the table
377 fragments for all sheets that are needed before the cell formulas are
378 loaded. Additionally, the instances of the WorkbookGlobals structures
379 have to be stored for every sheet. */
380 SheetFragmentVector aSheetFragments;
381 std::vector<WorksheetHelper*> aHelpers;
382 WorksheetBuffer& rWorksheets = getWorksheets();
383 sal_Int32 nWorksheetCount = rWorksheets.getWorksheetCount();
384 for( sal_Int32 nWorksheet = 0; nWorksheet < nWorksheetCount; ++nWorksheet )
385 {
386 sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet );
387 const Relation* pRelation = getRelations().getRelationFromRelId( rWorksheets.getWorksheetRelId( nWorksheet ) );
388 if( (nCalcSheet >= 0) && pRelation )
389 {
390 // get fragment path of the sheet
391 OUString aFragmentPath = getFragmentPathFromRelation( *pRelation );
392 OSL_ENSURE( !aFragmentPath.isEmpty(), "WorkbookFragment::finalizeImport - cannot access sheet fragment" );
393 if( !aFragmentPath.isEmpty() )
394 {
395 // leave space for formula processing ( calculate the segments as
396 // if there is an extra sheet )
397 double fSegmentLength = getProgressBar().getFreeLength() / (nWorksheetCount - ( nWorksheet - 1) );
398 ISegmentProgressBarRef xSheetSegment = getProgressBar().createSegment( fSegmentLength );
399
400 // get the sheet type according to the relations type
402 if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
403 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
404 eSheetType = WorksheetType::Work;
405 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
406 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
407 eSheetType = WorksheetType::Chart;
408 else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
409 (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
410 eSheetType = WorksheetType::Macro;
411 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
412 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
413 eSheetType = WorksheetType::Dialog;
414 OSL_ENSURE( eSheetType != WorksheetType::Empty, "WorkbookFragment::finalizeImport - unknown sheet type" );
415 if( eSheetType != WorksheetType::Empty )
416 {
417 // create the WorksheetGlobals object
418 WorksheetGlobalsRef xSheetGlob = WorksheetHelper::constructGlobals( *this, xSheetSegment, eSheetType, nCalcSheet );
419 OSL_ENSURE( xSheetGlob, "WorkbookFragment::finalizeImport - missing sheet in document" );
420 if( xSheetGlob )
421 {
422 // create the sheet fragment handler
424 switch( eSheetType )
425 {
429 xFragment.set( new WorksheetFragment( *xSheetGlob, aFragmentPath ) );
430 break;
432 xFragment.set( new ChartsheetFragment( *xSheetGlob, aFragmentPath ) );
433 break;
434 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
436 break;
437 }
438
439 // insert the fragment into the map
440 if( xFragment.is() )
441 {
442 aSheetFragments.emplace_back( xSheetGlob, xFragment.get() );
443 aHelpers.push_back(xFragment.get());
444 }
445 }
446 }
447 }
448 }
449 }
450
451 // setup structure sizes for the number of sheets
452 getFormulaBuffer().SetSheetCount( nWorksheetCount );
453
454 // create all database ranges and defined names, in that order
458 // open the VBA project storage
459 OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATION_TYPE( "vbaProject" ) );
460 if( !aVbaFragmentPath.isEmpty() )
461 {
462 Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath );
463 if( xInStrm.is() )
464 {
465 StorageRef xPrjStrg = std::make_shared<::oox::ole::OleStorage>( getBaseFilter().getComponentContext(), xInStrm, false );
466 setVbaProjectStorage( xPrjStrg );
468 }
469 }
470
471 // lock the model to prevent broadcasting, speeds up load a lot
473 auto pModel = getScDocument().GetDrawLayer();
474 bool bWasLocked = pModel->isLocked();
475 pModel->setLock(true);
476
477 // load all worksheets
478 importSheetFragments(*this, aSheetFragments);
479
480 // assumes getTables().finalizeImport ( which creates the DatabaseRanges )
481 // has been called already
483
484 sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
485 getWorksheets().finalizeImport( nActiveSheet );
486
487 // final conversions, e.g. calculation settings and view settings
489
490 //stop preventing establishment of listeners as is done in
491 //ScDocShell::AfterXMLLoading() for ods
493
494 for( WorksheetHelper* pHelper : aHelpers )
495 {
496 pHelper->finalizeDrawingImport();
497 }
498
499 for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
500 {
501 // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
502 rxFragment.clear();
503 rxSheetGlob.reset();
504 }
505
507
509
510 OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
511 if (!aRevHeadersPath.isEmpty())
512 {
513 std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
514 rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
515 importOoxFragment(xFragment, *xParser);
516 }
517
518 // attach macros to registered objects now that all objects have been created.
520
521 pModel->setLock(bWasLocked);
522}
523
524namespace {
525
527{
528 return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
529}
530
531class MessageWithCheck : public weld::MessageDialogController
532{
533private:
534 std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
535public:
536 MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
537 : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
538 , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
539 {
540 }
541 bool get_active() const { return m_xWarningOnBox->get_active(); }
542 void hide_ask() const { m_xWarningOnBox->set_visible(false); };
543};
544
545}
546
548{
549 // Recalculate formula cells.
550 ScDocument& rDoc = getScDocument();
551 ScDocShell& rDocSh = getDocShell(rDoc);
552 ScRecalcOptions nRecalcMode =
553 static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get());
554 bool bHardRecalc = false;
555 if (nRecalcMode == RECALC_ASK)
556 {
557 if (rDoc.IsUserInteractionEnabled())
558 {
559 // Ask the user if full re-calculation is desired.
560 MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
561 aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
562 aQueryBox.set_default_response(RET_YES);
563
564 if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
565 aQueryBox.hide_ask();
566
567 bHardRecalc = aQueryBox.run() == RET_YES;
568
569 if (aQueryBox.get_active())
570 {
571 // Always perform selected action in the future.
572 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
573 officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
574 ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
576 /* XXX is this really supposed to set the ScModule options?
577 * Not the ScDocShell options? */
578 SC_MOD()->SetFormulaOptions(aOpt);
579
580 batch->commit();
581 }
582 }
583 }
584 else if (nRecalcMode == RECALC_ALWAYS)
585 bHardRecalc = true;
586
587 if (bHardRecalc)
588 rDocSh.DoHardRecalc();
589 else
590 {
592 // Full ScDocument::CalcFormulaTree() of all dirty cells is not
593 // necessary here, the View will recalculate them in the visible area,
594 // or any other method accessing formula cell results.
595 }
596}
597
598// private --------------------------------------------------------------------
599
601{
602 if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
603 importExternalLinkFragment( *pExtLink );
604}
605
607{
609}
610
612{
613 sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
614 OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
615 importPivotCacheDefFragment( aRelId, nCacheId );
616}
617
619{
621 importExternalLinkFragment( *pExtLink );
622}
623
625{
626 sal_Int32 nCacheId = rStrm.readInt32();
627 OUString aRelId = BiffHelper::readString( rStrm );
628 importPivotCacheDefFragment( aRelId, nCacheId );
629}
630
632{
633 OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
634 if( !aFragmentPath.isEmpty() )
635 importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
636}
637
638void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
639{
640 // pivot caches will be imported on demand, here we just store the fragment path in the buffer
641 getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
642}
643
644} // namespace oox
645
646/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScRecalcOptions
Definition: calcconfig.hxx:24
@ RECALC_NEVER
Definition: calcconfig.hxx:26
@ RECALC_ALWAYS
Definition: calcconfig.hxx:25
@ RECALC_ASK
Definition: calcconfig.hxx:27
static void Yield()
static void EndYield()
static bool IsQuit()
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:3089
void DoHardRecalc()
Definition: docsh4.cxx:1516
void broadcastRecalcAfterImport()
Broadcast all formula cells that are marked with FormulaTokenArray::IsRecalcModeMustAfterImport() for...
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:98
SC_DLLPUBLIC bool IsUserInteractionEnabled() const
Definition: document.hxx:1604
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1082
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1081
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2218
void SetOOXMLRecalcOptions(ScRecalcOptions eOpt)
Definition: formulaopt.hxx:61
bool isLocked() const
static std::shared_ptr< ConfigurationChanges > create()
static ThreadPool & getSharedOptimalPool()
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoin=true)
static std::shared_ptr< ThreadTaskTag > createThreadTaskTag()
void pushTask(std::unique_ptr< ThreadTask > pTask)
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
std::optional< OUString > getString(sal_Int32 nAttrToken) const
virtual ISegmentProgressBarRef createSegment(double fLength) override
virtual double getFreeLength() const override
::oox::ole::VbaProject & getVbaProject() const
css::uno::Reference< css::io::XInputStream > openInputStream(const OUString &rStreamName) const
static FastParser * createParser()
void readVbaModules(StorageBase &rVbaPrjStrg)
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:79
DefinedNameRef importDefinedName(const AttributeList &rAttribs)
Imports a defined name from the passed attribute set.
void finalizeImport()
Creates all defined names in the document.
void importExternalAddin(SequenceInputStream &rStrm)
Imports the EXTERNALADDIN record from the passed stream.
void importExternalSelf(SequenceInputStream &rStrm)
Imports the EXTERNALSELF record from the passed stream.
void importExternalSheets(SequenceInputStream &rStrm)
Imports the EXTERNALSHEETS record from the passed stream.
void importExternalSame(SequenceInputStream &rStrm)
Imports the EXTERNALSAME record from the passed stream.
void SetSheetCount(SCTAB nSheets)
ensure sizes of vectors matches the number of sheets
void registerPivotCacheFragment(sal_Int32 nCacheId, const OUString &rFragmentPath)
Registers a pivot cache definition fragment.
void applyTableColumns()
Applies columns names from created database range ( requires finalizeImport to have run before being ...
void applyAutoFilters()
Applies autofilters from created database range ( requires finalizeImport to have run before being ca...
void finalizeImport()
Creates database ranges from all imported tables.
void importOleSize(const AttributeList &rAttribs)
Imports the oleSize element containing the visible size of the workbook.
void importWorkbookView(const AttributeList &rAttribs)
Imports the workbookView element containing workbook view settings.
sal_Int16 getActiveCalcSheet() const
Returns the Calc index of the active sheet.
Fragment handler derived from the WorkbookHelper helper class.
void importDefinedName(const AttributeList &rAttribs)
void importPivotCache(const AttributeList &rAttribs)
virtual ::oox::core::ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
virtual void onCharacters(const OUString &rChars) override
void importExternalReference(const AttributeList &rAttribs)
virtual void finalizeImport() override
void importExternalRef(SequenceInputStream &rStrm)
virtual const ::oox::core::RecordInfo * getRecordInfos() const override
void importPivotCacheDefFragment(const OUString &rRelId, sal_Int32 nCacheId)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
void importExternalLinkFragment(ExternalLink &rExtLink)
WorkbookFragment(const WorkbookHelper &rHelper, const OUString &rFragmentPath)
Helper class to provide access to global workbook data.
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
FormulaBuffer & getFormulaBuffer() const
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
ScDocumentImport & getDocImport()
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
void setVbaProjectStorage(const StorageRef &rxVbaPrjStrg)
Sets the VBA project storage used to import VBA source code and forms.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
void finalizeWorkbookImport()
Final conversion after importing the workbook.
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
ExternalLinkBuffer & getExternalLinks() const
Returns the external links read from the external links substream.
void importCalcPr(const AttributeList &rAttribs)
Imports the calcPr element containing workbook calculation settings.
void importFileSharing(const AttributeList &rAttribs)
Imports the fileSharing element containing write protection settings.
void importWorkbookPr(const AttributeList &rAttribs)
Imports the workbookPr element containing global workbook settings.
Stores information about all sheets in a spreadsheet document.
OUString getWorksheetRelId(sal_Int32 nWorksheet) const
Returns the OOXML relation identifier of the specified worksheet.
sal_Int32 getWorksheetCount() const
Returns the number of original sheets contained in the workbook.
sal_Int16 getCalcSheetIndex(sal_Int32 nWorksheet) const
Returns the Calc index of the specified worksheet.
void importSheet(const AttributeList &rAttribs)
Imports the attributes of a sheet element.
void finalizeImport(sal_Int16 nActiveSheet)
static WorksheetGlobalsRef constructGlobals(const WorkbookHelper &rHelper, const ISegmentProgressBarRef &rxProgressBar, WorksheetType eSheetType, SCTAB nSheet)
static IWorksheetProgress * getWorksheetInterface(const WorksheetGlobalsRef &xRef)
float u
#define SAL_INFO(area, stream)
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
void SvStream & rStrm
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
const sal_Int32 XML_ROOT_CONTEXT
const sal_Int32 BIFF12_ID_EXTERNALADDIN
Definition: biffhelper.hxx:105
const sal_Int32 BIFF12_ID_FUNCTIONGROUPS
Definition: biffhelper.hxx:129
const sal_Int32 BIFF12_ID_SHEET
Definition: biffhelper.hxx:214
const sal_Int32 BIFF12_ID_EXTERNALSAME
Definition: biffhelper.hxx:111
const sal_Int32 BIFF12_ID_WORKBOOKPR
Definition: biffhelper.hxx:239
const sal_Int32 BIFF12_ID_WORKBOOK
Definition: biffhelper.hxx:238
const sal_Int32 BIFF12_ID_WORKBOOKVIEW
Definition: biffhelper.hxx:240
const sal_Int32 BIFF12_ID_EXTERNALREF
Definition: biffhelper.hxx:108
const sal_Int32 BIFF12_ID_SHEETS
Definition: biffhelper.hxx:219
const sal_Int32 BIFF12_ID_OLESIZE
Definition: biffhelper.hxx:151
const sal_Int32 BIFF12_ID_PIVOTCACHE
Definition: biffhelper.hxx:185
const sal_Int32 BIFF12_ID_PIVOTCACHES
Definition: biffhelper.hxx:186
const sal_Int32 BIFF12_ID_FILESHARING
Definition: biffhelper.hxx:117
const sal_Int32 BIFF12_ID_DEFINEDNAME
Definition: biffhelper.hxx:93
const sal_Int32 BIFF12_ID_CALCPR
Definition: biffhelper.hxx:40
const sal_Int32 BIFF12_ID_EXTERNALSHEETS
Definition: biffhelper.hxx:112
const sal_Int32 BIFF12_ID_EXTERNALREFS
Definition: biffhelper.hxx:109
std::shared_ptr< WorksheetGlobals > WorksheetGlobalsRef
const sal_Int32 BIFF12_ID_EXTERNALSELF
Definition: biffhelper.hxx:110
WorksheetType
An enumeration for all types of sheets in a workbook.
@ Empty
Dialog sheet (BIFF5+).
const sal_Int32 BIFF12_ID_BOOKVIEWS
Definition: biffhelper.hxx:36
std::shared_ptr< StorageBase > StorageRef
std::shared_ptr< ISegmentProgressBar > ISegmentProgressBarRef
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
#define CREATE_OFFICEDOC_RELATION_TYPE(ascii)
#define CREATE_OFFICEDOC_RELATION_TYPE_STRICT(ascii)
#define CREATE_MSOFFICE_RELATION_TYPE(ascii)
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
#define SC_MOD()
Definition: scmod.hxx:249
@ Relation
RET_YES
WorkbookFragment & mrWorkbookHandler
double mfPosition
std::unique_ptr< weld::CheckButton > m_xWarningOnBox
std::vector< ISegmentProgressBarRef > aSegments
rtl::Reference< FragmentHandler > mxHandler
ISegmentProgressBarRef mxWrapped
sal_Int32 & mrSheetsLeft