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 sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
481 getWorksheets().finalizeImport( nActiveSheet );
482
483 // final conversions, e.g. calculation settings and view settings
485
486 //stop preventing establishment of listeners as is done in
487 //ScDocShell::AfterXMLLoading() for ods
489
490 for( WorksheetHelper* pHelper : aHelpers )
491 {
492 pHelper->finalizeDrawingImport();
493 }
494
495 for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
496 {
497 // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
498 rxFragment.clear();
499 rxSheetGlob.reset();
500 }
501
503
505
506 OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
507 if (!aRevHeadersPath.isEmpty())
508 {
509 std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
510 rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
511 importOoxFragment(xFragment, *xParser);
512 }
513
514 // attach macros to registered objects now that all objects have been created.
516
517 pModel->setLock(bWasLocked);
518}
519
520namespace {
521
523{
524 return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
525}
526
527class MessageWithCheck : public weld::MessageDialogController
528{
529private:
530 std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
531public:
532 MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
533 : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
534 , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
535 {
536 }
537 bool get_active() const { return m_xWarningOnBox->get_active(); }
538 void hide_ask() const { m_xWarningOnBox->set_visible(false); };
539};
540
541}
542
544{
545 // Recalculate formula cells.
546 ScDocument& rDoc = getScDocument();
547 ScDocShell& rDocSh = getDocShell(rDoc);
548 ScRecalcOptions nRecalcMode =
549 static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get());
550 bool bHardRecalc = false;
551 if (nRecalcMode == RECALC_ASK)
552 {
553 if (rDoc.IsUserInteractionEnabled())
554 {
555 // Ask the user if full re-calculation is desired.
556 MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
557 aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
558 aQueryBox.set_default_response(RET_YES);
559
560 if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
561 aQueryBox.hide_ask();
562
563 bHardRecalc = aQueryBox.run() == RET_YES;
564
565 if (aQueryBox.get_active())
566 {
567 // Always perform selected action in the future.
568 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
569 officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
570 ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
572 /* XXX is this really supposed to set the ScModule options?
573 * Not the ScDocShell options? */
574 SC_MOD()->SetFormulaOptions(aOpt);
575
576 batch->commit();
577 }
578 }
579 }
580 else if (nRecalcMode == RECALC_ALWAYS)
581 bHardRecalc = true;
582
583 if (bHardRecalc)
584 rDocSh.DoHardRecalc();
585 else
586 {
588 // Full ScDocument::CalcFormulaTree() of all dirty cells is not
589 // necessary here, the View will recalculate them in the visible area,
590 // or any other method accessing formula cell results.
591 }
592}
593
594// private --------------------------------------------------------------------
595
597{
598 if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
599 importExternalLinkFragment( *pExtLink );
600}
601
603{
605}
606
608{
609 sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
610 OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
611 importPivotCacheDefFragment( aRelId, nCacheId );
612}
613
615{
617 importExternalLinkFragment( *pExtLink );
618}
619
621{
622 sal_Int32 nCacheId = rStrm.readInt32();
623 OUString aRelId = BiffHelper::readString( rStrm );
624 importPivotCacheDefFragment( aRelId, nCacheId );
625}
626
628{
629 OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
630 if( !aFragmentPath.isEmpty() )
631 importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
632}
633
634void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
635{
636 // pivot caches will be imported on demand, here we just store the fragment path in the buffer
637 getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
638}
639
640} // namespace oox
641
642/* 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:3091
void DoHardRecalc()
Definition: docsh4.cxx:1511
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
bool isCurrentElement(sal_Int32 nElement) const
sal_Int32 getCurrentElement() const
::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 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