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 auto& rOoxTheme = getTheme();
353
354 auto pTheme = rOoxTheme.oox::drawingml::Theme::getTheme(); // needed full name here because a conflict with WorkbookHelper and Theme in ThemeBuffer
355 if (!pTheme)
356 {
357 pTheme = std::make_shared<model::Theme>();
358 rOoxTheme.setTheme(pTheme);
359 }
360
361 if( !aThemeFragmentPath.isEmpty() )
362 importOoxFragment(new ThemeFragmentHandler(getFilter(), aThemeFragmentPath, rOoxTheme, *pTheme));
363 xGlobalSegment->setPosition( 0.25 );
364
365 // read the styles substream (requires finalized theme buffer)
366 OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"styles" );
367 if( !aStylesFragmentPath.isEmpty() )
368 importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
369 xGlobalSegment->setPosition( 0.5 );
370
371 // read the shared string table substream (requires finalized styles buffer)
372 OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"sharedStrings" );
373 if( !aSstFragmentPath.isEmpty() )
374 if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
375 importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
376 xGlobalSegment->setPosition( 0.75 );
377
378 // read the connections substream
379 OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"connections" );
380 if( !aConnFragmentPath.isEmpty() )
381 importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
382 xGlobalSegment->setPosition( 1.0 );
383
384 /* Create fragments for all sheets, before importing them. Needed to do
385 some preprocessing in the fragment constructors, e.g. loading the table
386 fragments for all sheets that are needed before the cell formulas are
387 loaded. Additionally, the instances of the WorkbookGlobals structures
388 have to be stored for every sheet. */
389 SheetFragmentVector aSheetFragments;
390 std::vector<WorksheetHelper*> aHelpers;
391 WorksheetBuffer& rWorksheets = getWorksheets();
392 sal_Int32 nWorksheetCount = rWorksheets.getWorksheetCount();
393 for( sal_Int32 nWorksheet = 0; nWorksheet < nWorksheetCount; ++nWorksheet )
394 {
395 sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet );
396 const Relation* pRelation = getRelations().getRelationFromRelId( rWorksheets.getWorksheetRelId( nWorksheet ) );
397 if( (nCalcSheet >= 0) && pRelation )
398 {
399 // get fragment path of the sheet
400 OUString aFragmentPath = getFragmentPathFromRelation( *pRelation );
401 OSL_ENSURE( !aFragmentPath.isEmpty(), "WorkbookFragment::finalizeImport - cannot access sheet fragment" );
402 if( !aFragmentPath.isEmpty() )
403 {
404 // leave space for formula processing ( calculate the segments as
405 // if there is an extra sheet )
406 double fSegmentLength = getProgressBar().getFreeLength() / (nWorksheetCount - ( nWorksheet - 1) );
407 ISegmentProgressBarRef xSheetSegment = getProgressBar().createSegment( fSegmentLength );
408
409 // get the sheet type according to the relations type
411 if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
412 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
413 eSheetType = WorksheetType::Work;
414 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
415 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
416 eSheetType = WorksheetType::Chart;
417 else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
418 (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
419 eSheetType = WorksheetType::Macro;
420 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
421 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
422 eSheetType = WorksheetType::Dialog;
423 OSL_ENSURE( eSheetType != WorksheetType::Empty, "WorkbookFragment::finalizeImport - unknown sheet type" );
424 if( eSheetType != WorksheetType::Empty )
425 {
426 // create the WorksheetGlobals object
427 WorksheetGlobalsRef xSheetGlob = WorksheetHelper::constructGlobals( *this, xSheetSegment, eSheetType, nCalcSheet );
428 OSL_ENSURE( xSheetGlob, "WorkbookFragment::finalizeImport - missing sheet in document" );
429 if( xSheetGlob )
430 {
431 // create the sheet fragment handler
433 switch( eSheetType )
434 {
438 xFragment.set( new WorksheetFragment( *xSheetGlob, aFragmentPath ) );
439 break;
441 xFragment.set( new ChartsheetFragment( *xSheetGlob, aFragmentPath ) );
442 break;
443 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
445 break;
446 }
447
448 // insert the fragment into the map
449 if( xFragment.is() )
450 {
451 aSheetFragments.emplace_back( xSheetGlob, xFragment.get() );
452 aHelpers.push_back(xFragment.get());
453 }
454 }
455 }
456 }
457 }
458 }
459
460 // setup structure sizes for the number of sheets
461 getFormulaBuffer().SetSheetCount( nWorksheetCount );
462
463 // create all database ranges and defined names, in that order
467 // open the VBA project storage
468 OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATION_TYPE( "vbaProject" ) );
469 if( !aVbaFragmentPath.isEmpty() )
470 {
471 Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath );
472 if( xInStrm.is() )
473 {
474 StorageRef xPrjStrg = std::make_shared<::oox::ole::OleStorage>( getBaseFilter().getComponentContext(), xInStrm, false );
475 setVbaProjectStorage( xPrjStrg );
477 }
478 }
479
480 // lock the model to prevent broadcasting, speeds up load a lot
482 auto pModel = getScDocument().GetDrawLayer();
483 bool bWasLocked = pModel->isLocked();
484 pModel->setLock(true);
485
486 // load all worksheets
487 importSheetFragments(*this, aSheetFragments);
488
489 // assumes getTables().finalizeImport ( which creates the DatabaseRanges )
490 // has been called already
492
493 sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
494 getWorksheets().finalizeImport( nActiveSheet );
495
496 // final conversions, e.g. calculation settings and view settings
498
499 //stop preventing establishment of listeners as is done in
500 //ScDocShell::AfterXMLLoading() for ods
502
503 for( WorksheetHelper* pHelper : aHelpers )
504 {
505 pHelper->finalizeDrawingImport();
506 }
507
508 for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
509 {
510 // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
511 rxFragment.clear();
512 rxSheetGlob.reset();
513 }
514
516
518
519 OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
520 if (!aRevHeadersPath.isEmpty())
521 {
522 std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
523 rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
524 importOoxFragment(xFragment, *xParser);
525 }
526
527 // attach macros to registered objects now that all objects have been created.
529
530 pModel->setLock(bWasLocked);
531}
532
533namespace {
534
536{
537 return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
538}
539
540class MessageWithCheck : public weld::MessageDialogController
541{
542private:
543 std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
544public:
545 MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OUString& rDialogId)
546 : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
547 , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
548 {
549 }
550 bool get_active() const { return m_xWarningOnBox->get_active(); }
551 void hide_ask() const { m_xWarningOnBox->set_visible(false); };
552};
553
554}
555
557{
558 // Recalculate formula cells.
559 ScDocument& rDoc = getScDocument();
560 ScDocShell& rDocSh = getDocShell(rDoc);
561 ScRecalcOptions nRecalcMode =
562 static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get());
563 bool bHardRecalc = false;
564 if (nRecalcMode == RECALC_ASK)
565 {
566 if (rDoc.IsUserInteractionEnabled())
567 {
568 // Ask the user if full re-calculation is desired.
569 MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
570 aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
571 aQueryBox.set_default_response(RET_YES);
572
573 if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
574 aQueryBox.hide_ask();
575
576 bHardRecalc = aQueryBox.run() == RET_YES;
577
578 if (aQueryBox.get_active())
579 {
580 // Always perform selected action in the future.
581 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
582 officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
583 ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
585 /* XXX is this really supposed to set the ScModule options?
586 * Not the ScDocShell options? */
587 SC_MOD()->SetFormulaOptions(aOpt);
588
589 batch->commit();
590 }
591 }
592 }
593 else if (nRecalcMode == RECALC_ALWAYS)
594 bHardRecalc = true;
595
596 if (bHardRecalc)
597 rDocSh.DoHardRecalc();
598 else
599 {
601 // Full ScDocument::CalcFormulaTree() of all dirty cells is not
602 // necessary here, the View will recalculate them in the visible area,
603 // or any other method accessing formula cell results.
604 }
605}
606
607// private --------------------------------------------------------------------
608
610{
611 if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
612 importExternalLinkFragment( *pExtLink );
613}
614
616{
618}
619
621{
622 sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
623 OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
624 importPivotCacheDefFragment( aRelId, nCacheId );
625}
626
628{
630 importExternalLinkFragment( *pExtLink );
631}
632
634{
635 sal_Int32 nCacheId = rStrm.readInt32();
636 OUString aRelId = BiffHelper::readString( rStrm );
637 importPivotCacheDefFragment( aRelId, nCacheId );
638}
639
641{
642 OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
643 if( !aFragmentPath.isEmpty() )
644 importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
645}
646
647void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
648{
649 // pivot caches will be imported on demand, here we just store the fragment path in the buffer
650 getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
651}
652
653} // namespace oox
654
655/* 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:3128
void DoHardRecalc()
Definition: docsh4.cxx:1531
void broadcastRecalcAfterImport()
Broadcast all formula cells that are marked with FormulaTokenArray::IsRecalcModeMustAfterImport() for...
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:105
SC_DLLPUBLIC bool IsUserInteractionEnabled() const
Definition: document.hxx:1605
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1083
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1082
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2222
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