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
67#include <svx/svdpage.hxx>
69#include <sal/log.hxx>
70#include <osl/diagnose.h>
71
72#include <memory>
73
75
77#include <officecfg/Office/Calc.hxx>
78
79namespace oox::xls {
80
81using namespace ::com::sun::star::io;
82using namespace ::com::sun::star::table;
83using namespace ::com::sun::star::uno;
84using namespace ::oox::core;
85
86using ::oox::drawingml::ThemeFragmentHandler;
87
88namespace {
89
90const double PROGRESS_LENGTH_GLOBALS = 0.1;
91
92} // namespace
93
94WorkbookFragment::WorkbookFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
95 WorkbookFragmentBase( rHelper, rFragmentPath )
96{
97}
98
100{
101 switch( getCurrentElement() )
102 {
103 case XML_ROOT_CONTEXT:
104 if( nElement == XLS_TOKEN( workbook ) ) return this;
105 break;
106
107 case XLS_TOKEN( workbook ):
108 switch( nElement )
109 {
110 case XLS_TOKEN( sheets ):
111 case XLS_TOKEN( bookViews ):
112 case XLS_TOKEN( externalReferences ):
113 case XLS_TOKEN( definedNames ):
114 case XLS_TOKEN( pivotCaches ): return this;
115
116 case XLS_TOKEN( fileSharing ): getWorkbookSettings().importFileSharing( rAttribs ); break;
117 case XLS_TOKEN( workbookPr ): getWorkbookSettings().importWorkbookPr( rAttribs ); break;
118 case XLS_TOKEN( calcPr ): getWorkbookSettings().importCalcPr( rAttribs ); break;
119 case XLS_TOKEN( oleSize ): getViewSettings().importOleSize( rAttribs ); break;
120
121 case XLS_TOKEN( extLst ): return new ExtLstGlobalWorkbookContext( *this );
122 }
123 break;
124
125 case XLS_TOKEN( sheets ):
126 if( nElement == XLS_TOKEN( sheet ) ) getWorksheets().importSheet( rAttribs );
127 break;
128 case XLS_TOKEN( bookViews ):
129 if( nElement == XLS_TOKEN( workbookView ) ) getViewSettings().importWorkbookView( rAttribs );
130 break;
131 case XLS_TOKEN( externalReferences ):
132 if( nElement == XLS_TOKEN( externalReference ) ) importExternalReference( rAttribs );
133 break;
134 case XLS_TOKEN( definedNames ):
135 if( nElement == XLS_TOKEN( definedName ) ) { importDefinedName( rAttribs ); return this; } // collect formula
136 break;
137 case XLS_TOKEN( pivotCaches ):
138 if( nElement == XLS_TOKEN( pivotCache ) ) importPivotCache( rAttribs );
139 break;
140 }
141 return nullptr;
142}
143
144void WorkbookFragment::onCharacters( const OUString& rChars )
145{
146 if( isCurrentElement( XLS_TOKEN( definedName ) ) && mxCurrName )
147 mxCurrName->setFormula( rChars );
148}
149
151{
152 switch( getCurrentElement() )
153 {
154 case XML_ROOT_CONTEXT:
155 if( nRecId == BIFF12_ID_WORKBOOK ) return this;
156 break;
157
159 switch( nRecId )
160 {
161 case BIFF12_ID_SHEETS:
164 case BIFF12_ID_PIVOTCACHES: return this;
165
171 }
172 break;
173
174 case BIFF12_ID_SHEETS:
175 if( nRecId == BIFF12_ID_SHEET ) getWorksheets().importSheet( rStrm );
176 break;
179 break;
180
182 switch( nRecId )
183 {
189 }
190 break;
191
194 }
195 return nullptr;
196}
197
198const RecordInfo* WorkbookFragment::getRecordInfos() const
199{
200 static const RecordInfo spRecInfos[] =
201 {
209 { -1, -1 }
210 };
211 return spRecInfos;
212}
213
214namespace {
215
216typedef std::pair<WorksheetGlobalsRef, FragmentHandlerRef> SheetFragmentHandler;
217typedef std::vector<SheetFragmentHandler> SheetFragmentVector;
218
219class WorkerThread : public comphelper::ThreadTask
220{
221 sal_Int32 &mrSheetsLeft;
222 WorkbookFragment& mrWorkbookHandler;
224
225public:
226 WorkerThread( const std::shared_ptr<comphelper::ThreadTaskTag> & pTag,
227 WorkbookFragment& rWorkbookHandler,
229 sal_Int32 &rSheetsLeft ) :
230 comphelper::ThreadTask( pTag ),
231 mrSheetsLeft( rSheetsLeft ),
232 mrWorkbookHandler( rWorkbookHandler ),
233 mxHandler(std::move( xHandler ))
234 {
235 }
236
237 virtual void doWork() override
238 {
239 // We hold the solar mutex in all threads except for
240 // the small safe section of the inner loop in
241 // sheetdatacontext.cxx
242 SAL_INFO( "sc.filter", "start wait on solar" );
243 SolarMutexGuard aGuard;
244 SAL_INFO( "sc.filter", "got solar" );
245
246 std::unique_ptr<oox::core::FastParser> xParser(
248
249 SAL_INFO( "sc.filter", "start import" );
250 mrWorkbookHandler.importOoxFragment( mxHandler, *xParser );
251 SAL_INFO( "sc.filter", "end import, release solar" );
252 mrSheetsLeft--;
253 assert( mrSheetsLeft >= 0 );
254 if( mrSheetsLeft == 0 )
256 }
257};
258
259class ProgressBarTimer : private Timer
260{
261 // FIXME: really we should unify all sheet loading
262 // progress reporting into something pleasant.
263 class ProgressWrapper : public ISegmentProgressBar
264 {
267 public:
268 explicit ProgressWrapper(ISegmentProgressBarRef xRef)
269 : mfPosition(0.0)
270 , mxWrapped(std::move(xRef))
271 {
272 }
273
274 // IProgressBar
275 virtual double getPosition() const override { return mfPosition; }
276 virtual void setPosition( double fPosition ) override { mfPosition = fPosition; }
277 // ISegmentProgressBar
278 virtual double getFreeLength() const override { return 0.0; }
279 virtual ISegmentProgressBarRef createSegment( double /* fLength */ ) override
280 {
281 return ISegmentProgressBarRef();
282 }
283 void UpdateBar()
284 {
285 mxWrapped->setPosition( mfPosition );
286 }
287 };
288 std::vector< ISegmentProgressBarRef > aSegments;
289public:
290 ProgressBarTimer() : Timer("sc ProgressBarTimer")
291 {
292 SetTimeout( 500 );
293 }
294 virtual ~ProgressBarTimer() override
295 {
296 aSegments.clear();
297 }
298 const ISegmentProgressBarRef& wrapProgress( const ISegmentProgressBarRef &xProgress )
299 {
300 aSegments.push_back( std::make_shared<ProgressWrapper>( xProgress ) );
301 return aSegments.back();
302 }
303 virtual void Invoke() override
304 {
305 for(std::shared_ptr<ISegmentProgressBar> & pSegment : aSegments)
306 static_cast< ProgressWrapper *>( pSegment.get() )->UpdateBar();
307 }
308};
309
310void importSheetFragments( WorkbookFragment& rWorkbookHandler, SheetFragmentVector& rSheets )
311{
312 rWorkbookHandler.getDocImport().initForSheets();
313
314 // test sequential read in this mode
316 std::shared_ptr<comphelper::ThreadTaskTag> pTag = comphelper::ThreadPool::createThreadTaskTag();
317
318 sal_Int32 nSheetsLeft = 0;
319 ProgressBarTimer aProgressUpdater;
320 for( auto& [rxSheetGlob, rxFragment] : rSheets )
321 {
322 // getting at the WorksheetGlobals is rather unpleasant
323 IWorksheetProgress *pProgress = WorksheetHelper::getWorksheetInterface( rxSheetGlob );
324 pProgress->setCustomRowProgress(
325 aProgressUpdater.wrapProgress(
326 pProgress->getRowProgress() ) );
327 rSharedPool.pushTask( std::make_unique<WorkerThread>( pTag, rWorkbookHandler, rxFragment,
328 /* ref */ nSheetsLeft ) );
329 nSheetsLeft++;
330 }
331
332 // coverity[loop_top] - this isn't an infinite loop where nSheetsLeft gets decremented by the above threads
333 while( nSheetsLeft > 0 && !Application::IsQuit())
334 {
335 // This is a much more controlled re-enterancy hazard than
336 // allowing a yield deeper inside the filter code for progress
337 // bar updating.
339 }
340 rSharedPool.waitUntilDone(pTag);
341
342 // threads joined in ThreadPool destructor
343}
344
345}
346
348{
349 ISegmentProgressBarRef xGlobalSegment = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS );
350
351 // read the theme substream
352 OUString aThemeFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" );
353 auto& rOoxTheme = getTheme();
354
355 auto pTheme = rOoxTheme.oox::drawingml::Theme::getTheme(); // needed full name here because a conflict with WorkbookHelper and Theme in ThemeBuffer
356 if (!pTheme)
357 {
358 pTheme = std::make_shared<model::Theme>();
359 rOoxTheme.setTheme(pTheme);
360 }
361
362 if( !aThemeFragmentPath.isEmpty() )
363 importOoxFragment(new ThemeFragmentHandler(getFilter(), aThemeFragmentPath, rOoxTheme, *pTheme));
364 xGlobalSegment->setPosition( 0.25 );
365
366 // read the styles substream (requires finalized theme buffer)
367 OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"styles" );
368 if( !aStylesFragmentPath.isEmpty() )
369 importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
370 xGlobalSegment->setPosition( 0.5 );
371
372 // read the shared string table substream (requires finalized styles buffer)
373 OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"sharedStrings" );
374 if( !aSstFragmentPath.isEmpty() )
375 if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
376 importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
377 xGlobalSegment->setPosition( 0.75 );
378
379 // read the connections substream
380 OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"connections" );
381 if( !aConnFragmentPath.isEmpty() )
382 importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
383 xGlobalSegment->setPosition( 1.0 );
384
385 /* Create fragments for all sheets, before importing them. Needed to do
386 some preprocessing in the fragment constructors, e.g. loading the table
387 fragments for all sheets that are needed before the cell formulas are
388 loaded. Additionally, the instances of the WorkbookGlobals structures
389 have to be stored for every sheet. */
390 SheetFragmentVector aSheetFragments;
391 std::vector<WorksheetHelper*> aHelpers;
392 WorksheetBuffer& rWorksheets = getWorksheets();
393 sal_Int32 nWorksheetCount = rWorksheets.getWorksheetCount();
394 for( sal_Int32 nWorksheet = 0; nWorksheet < nWorksheetCount; ++nWorksheet )
395 {
396 sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet );
397 const Relation* pRelation = getRelations().getRelationFromRelId( rWorksheets.getWorksheetRelId( nWorksheet ) );
398 if( (nCalcSheet >= 0) && pRelation )
399 {
400 // get fragment path of the sheet
401 OUString aFragmentPath = getFragmentPathFromRelation( *pRelation );
402 OSL_ENSURE( !aFragmentPath.isEmpty(), "WorkbookFragment::finalizeImport - cannot access sheet fragment" );
403 if( !aFragmentPath.isEmpty() )
404 {
405 // leave space for formula processing ( calculate the segments as
406 // if there is an extra sheet )
407 double fSegmentLength = getProgressBar().getFreeLength() / (nWorksheetCount - ( nWorksheet - 1) );
408 ISegmentProgressBarRef xSheetSegment = getProgressBar().createSegment( fSegmentLength );
409
410 // get the sheet type according to the relations type
412 if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
413 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
414 eSheetType = WorksheetType::Work;
415 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
416 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
417 eSheetType = WorksheetType::Chart;
418 else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
419 (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
420 eSheetType = WorksheetType::Macro;
421 else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
422 pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
423 eSheetType = WorksheetType::Dialog;
424 OSL_ENSURE( eSheetType != WorksheetType::Empty, "WorkbookFragment::finalizeImport - unknown sheet type" );
425 if( eSheetType != WorksheetType::Empty )
426 {
427 // create the WorksheetGlobals object
428 WorksheetGlobalsRef xSheetGlob = WorksheetHelper::constructGlobals( *this, xSheetSegment, eSheetType, nCalcSheet );
429 OSL_ENSURE( xSheetGlob, "WorkbookFragment::finalizeImport - missing sheet in document" );
430 if( xSheetGlob )
431 {
432 // create the sheet fragment handler
434 switch( eSheetType )
435 {
439 xFragment.set( new WorksheetFragment( *xSheetGlob, aFragmentPath ) );
440 break;
442 xFragment.set( new ChartsheetFragment( *xSheetGlob, aFragmentPath ) );
443 break;
444 // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
446 break;
447 }
448
449 // insert the fragment into the map
450 if( xFragment.is() )
451 {
452 aSheetFragments.emplace_back( xSheetGlob, xFragment.get() );
453 aHelpers.push_back(xFragment.get());
454 }
455 }
456 }
457 }
458 }
459 }
460
461 // setup structure sizes for the number of sheets
462 getFormulaBuffer().SetSheetCount( nWorksheetCount );
463
464 // create all database ranges and defined names, in that order
468 // open the VBA project storage
469 OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATION_TYPE( "vbaProject" ) );
470 if( !aVbaFragmentPath.isEmpty() )
471 {
472 Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath );
473 if( xInStrm.is() )
474 {
475 StorageRef xPrjStrg = std::make_shared<::oox::ole::OleStorage>( getBaseFilter().getComponentContext(), xInStrm, false );
476 setVbaProjectStorage( xPrjStrg );
478 }
479 }
480
481 // lock the model to prevent broadcasting, speeds up load a lot
483 auto pModel = getScDocument().GetDrawLayer();
484 bool bWasLocked = pModel->isLocked();
485 pModel->setLock(true);
486
487 // load all worksheets
488 importSheetFragments(*this, aSheetFragments);
489
490 SdrPage* pPage = pModel->GetPage(0);
491 if (pPage && pTheme && !pTheme->GetName().isEmpty())
492 {
493 pPage->getSdrPageProperties().SetTheme(pTheme);
494 }
495
496 // assumes getTables().finalizeImport ( which creates the DatabaseRanges )
497 // has been called already
499
500 sal_Int16 nActiveSheet = getViewSettings().getActiveCalcSheet();
501 getWorksheets().finalizeImport( nActiveSheet );
502
503 // final conversions, e.g. calculation settings and view settings
505
506 //stop preventing establishment of listeners as is done in
507 //ScDocShell::AfterXMLLoading() for ods
509
510 for( WorksheetHelper* pHelper : aHelpers )
511 {
512 pHelper->finalizeDrawingImport();
513 }
514
515 for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
516 {
517 // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
518 rxFragment.clear();
519 rxSheetGlob.reset();
520 }
521
522
524
526
527 OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
528 if (!aRevHeadersPath.isEmpty())
529 {
530 std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
531 rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
532 importOoxFragment(xFragment, *xParser);
533 }
534
535 // attach macros to registered objects now that all objects have been created.
537
538 pModel->setLock(bWasLocked);
539}
540
541namespace {
542
544{
545 return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
546}
547
548class MessageWithCheck : public weld::MessageDialogController
549{
550private:
551 std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
552public:
553 MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OUString& rDialogId)
554 : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
555 , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
556 {
557 }
558 bool get_active() const { return m_xWarningOnBox->get_active(); }
559 void hide_ask() const { m_xWarningOnBox->set_visible(false); };
560};
561
562}
563
565{
566 // Recalculate formula cells.
567 ScDocument& rDoc = getScDocument();
568 ScDocShell& rDocSh = getDocShell(rDoc);
569 ScRecalcOptions nRecalcMode =
570 static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get());
571 bool bHardRecalc = false;
572 if (nRecalcMode == RECALC_ASK)
573 {
574 if (rDoc.IsUserInteractionEnabled())
575 {
576 // Ask the user if full re-calculation is desired.
577 MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
578 aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
579 aQueryBox.set_default_response(RET_YES);
580
581 if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
582 aQueryBox.hide_ask();
583
584 bHardRecalc = aQueryBox.run() == RET_YES;
585
586 if (aQueryBox.get_active())
587 {
588 // Always perform selected action in the future.
589 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
590 officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
591 ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
593 /* XXX is this really supposed to set the ScModule options?
594 * Not the ScDocShell options? */
595 SC_MOD()->SetFormulaOptions(aOpt);
596
597 batch->commit();
598 }
599 }
600 }
601 else if (nRecalcMode == RECALC_ALWAYS)
602 bHardRecalc = true;
603 else if (!hasCalculatedFormulaCells())
604 {
605 // Did not encounter any other formula result than 0.0 (or none / no
606 // formula cells at all, in which case recalculation is almost a no-op)
607 // in a non-known-good-generator document.
608 bHardRecalc = true;
609 }
610
611 if (bHardRecalc)
612 rDocSh.DoHardRecalc();
613 else
614 {
616 // Full ScDocument::CalcFormulaTree() of all dirty cells is not
617 // necessary here, the View will recalculate them in the visible area,
618 // or any other method accessing formula cell results.
619 }
620}
621
622// private --------------------------------------------------------------------
623
625{
626 if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
627 importExternalLinkFragment( *pExtLink );
628}
629
631{
633}
634
636{
637 sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
638 OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
639 importPivotCacheDefFragment( aRelId, nCacheId );
640}
641
643{
645 importExternalLinkFragment( *pExtLink );
646}
647
649{
650 sal_Int32 nCacheId = rStrm.readInt32();
651 OUString aRelId = BiffHelper::readString( rStrm );
652 importPivotCacheDefFragment( aRelId, nCacheId );
653}
654
656{
657 OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
658 if( !aFragmentPath.isEmpty() )
659 importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
660}
661
662void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
663{
664 // pivot caches will be imported on demand, here we just store the fragment path in the buffer
665 getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
666}
667
668} // namespace oox
669
670/* 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:3112
void DoHardRecalc()
Definition: docsh4.cxx:1530
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:1606
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1083
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2223
void SetOOXMLRecalcOptions(ScRecalcOptions eOpt)
Definition: formulaopt.hxx:61
bool isLocked() const
void SetTheme(std::shared_ptr< model::Theme > const &pTheme)
SdrPageProperties & getSdrPageProperties()
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 hasCalculatedFormulaCells() const
Returns true if any formula cell is calculated.
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:247
@ 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