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