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()
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)
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  // lock the model to prevent broadcasting, speeds up load a lot
349  auto pModel = getScDocument().GetDrawLayer();
350  bool bWasLocked = pModel->isLocked();
351  pModel->setLock(true);
352 
353  ISegmentProgressBarRef xGlobalSegment = getProgressBar().createSegment( PROGRESS_LENGTH_GLOBALS );
354 
355  // read the theme substream
356  OUString aThemeFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
357  if( !aThemeFragmentPath.isEmpty() )
358  importOoxFragment( new ThemeFragmentHandler( getFilter(), aThemeFragmentPath, getTheme() ) );
359  xGlobalSegment->setPosition( 0.25 );
360 
361  // read the styles substream (requires finalized theme buffer)
362  OUString aStylesFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "styles" );
363  if( !aStylesFragmentPath.isEmpty() )
364  importOoxFragment( new StylesFragment( *this, aStylesFragmentPath ) );
365  xGlobalSegment->setPosition( 0.5 );
366 
367  // read the shared string table substream (requires finalized styles buffer)
368  OUString aSstFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "sharedStrings" );
369  if( !aSstFragmentPath.isEmpty() )
370  if (!importOoxFragment( new SharedStringsFragment( *this, aSstFragmentPath ) ))
371  importOoxFragment(new SharedStringsFragment(*this, aSstFragmentPath.replaceFirst("sharedStrings","SharedStrings")));
372  xGlobalSegment->setPosition( 0.75 );
373 
374  // read the connections substream
375  OUString aConnFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "connections" );
376  if( !aConnFragmentPath.isEmpty() )
377  importOoxFragment( new ConnectionsFragment( *this, aConnFragmentPath ) );
378  xGlobalSegment->setPosition( 1.0 );
379 
380  /* Create fragments for all sheets, before importing them. Needed to do
381  some preprocessing in the fragment constructors, e.g. loading the table
382  fragments for all sheets that are needed before the cell formulas are
383  loaded. Additionally, the instances of the WorkbookGlobals structures
384  have to be stored for every sheet. */
385  SheetFragmentVector aSheetFragments;
386  std::vector<WorksheetHelper*> aHelpers;
387  WorksheetBuffer& rWorksheets = getWorksheets();
388  sal_Int32 nWorksheetCount = rWorksheets.getWorksheetCount();
389  for( sal_Int32 nWorksheet = 0; nWorksheet < nWorksheetCount; ++nWorksheet )
390  {
391  sal_Int16 nCalcSheet = rWorksheets.getCalcSheetIndex( nWorksheet );
392  const Relation* pRelation = getRelations().getRelationFromRelId( rWorksheets.getWorksheetRelId( nWorksheet ) );
393  if( (nCalcSheet >= 0) && pRelation )
394  {
395  // get fragment path of the sheet
396  OUString aFragmentPath = getFragmentPathFromRelation( *pRelation );
397  OSL_ENSURE( !aFragmentPath.isEmpty(), "WorkbookFragment::finalizeImport - cannot access sheet fragment" );
398  if( !aFragmentPath.isEmpty() )
399  {
400  // leave space for formula processing ( calculate the segments as
401  // if there is an extra sheet )
402  double fSegmentLength = getProgressBar().getFreeLength() / (nWorksheetCount - ( nWorksheet - 1) );
403  ISegmentProgressBarRef xSheetSegment = getProgressBar().createSegment( fSegmentLength );
404 
405  // get the sheet type according to the relations type
406  WorksheetType eSheetType = WorksheetType::Empty;
407  if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "worksheet" ) ||
408  pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "worksheet" ))
409  eSheetType = WorksheetType::Work;
410  else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "chartsheet" ) ||
411  pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "chartsheet" ))
412  eSheetType = WorksheetType::Chart;
413  else if( (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlMacrosheet" )) ||
414  (pRelation->maType == CREATE_MSOFFICE_RELATION_TYPE( "xlIntlMacrosheet" )) )
415  eSheetType = WorksheetType::Macro;
416  else if( pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE( "dialogsheet" ) ||
417  pRelation->maType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT(" dialogsheet" ))
418  eSheetType = WorksheetType::Dialog;
419  OSL_ENSURE( eSheetType != WorksheetType::Empty, "WorkbookFragment::finalizeImport - unknown sheet type" );
420  if( eSheetType != WorksheetType::Empty )
421  {
422  // create the WorksheetGlobals object
423  WorksheetGlobalsRef xSheetGlob = WorksheetHelper::constructGlobals( *this, xSheetSegment, eSheetType, nCalcSheet );
424  OSL_ENSURE( xSheetGlob, "WorkbookFragment::finalizeImport - missing sheet in document" );
425  if( xSheetGlob )
426  {
427  // create the sheet fragment handler
429  switch( eSheetType )
430  {
431  case WorksheetType::Work:
434  xFragment.set( new WorksheetFragment( *xSheetGlob, aFragmentPath ) );
435  break;
437  xFragment.set( new ChartsheetFragment( *xSheetGlob, aFragmentPath ) );
438  break;
439  // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
441  break;
442  }
443 
444  // insert the fragment into the map
445  if( xFragment.is() )
446  {
447  aSheetFragments.emplace_back( xSheetGlob, xFragment.get() );
448  aHelpers.push_back(xFragment.get());
449  }
450  }
451  }
452  }
453  }
454  }
455 
456  // setup structure sizes for the number of sheets
457  getFormulaBuffer().SetSheetCount( nWorksheetCount );
458 
459  // create all database ranges and defined names, in that order
463  // open the VBA project storage
464  OUString aVbaFragmentPath = getFragmentPathFromFirstType( CREATE_MSOFFICE_RELATION_TYPE( "vbaProject" ) );
465  if( !aVbaFragmentPath.isEmpty() )
466  {
467  Reference< XInputStream > xInStrm = getBaseFilter().openInputStream( aVbaFragmentPath );
468  if( xInStrm.is() )
469  {
470  StorageRef xPrjStrg = std::make_shared<::oox::ole::OleStorage>( getBaseFilter().getComponentContext(), xInStrm, false );
471  setVbaProjectStorage( xPrjStrg );
472  getBaseFilter().getVbaProject().readVbaModules( *xPrjStrg );
473  }
474  }
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
489 
491 
492  for( WorksheetHelper* pHelper : aHelpers )
493  {
494  pHelper->finalizeDrawingImport();
495  }
496 
497  for( auto& [rxSheetGlob, rxFragment] : aSheetFragments )
498  {
499  // delete fragment object and WorkbookGlobals object, will free all allocated sheet buffers
500  rxFragment.clear();
501  rxSheetGlob.reset();
502  }
503 
504  OUString aRevHeadersPath = getFragmentPathFromFirstType(CREATE_OFFICEDOC_RELATION_TYPE("revisionHeaders"));
505  if (!aRevHeadersPath.isEmpty())
506  {
507  std::unique_ptr<oox::core::FastParser> xParser(oox::core::XmlFilterBase::createParser());
508  rtl::Reference<oox::core::FragmentHandler> xFragment(new RevisionHeadersFragment(*this, aRevHeadersPath));
509  importOoxFragment(xFragment, *xParser);
510  }
511 
512  // attach macros to registered objects now that all objects have been created.
514 
515  pModel->setLock(bWasLocked);
516 }
517 
518 namespace {
519 
520 ScDocShell& getDocShell(const ScDocument& rDoc)
521 {
522  return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
523 }
524 
525 class MessageWithCheck : public weld::MessageDialogController
526 {
527 private:
528  std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
529 public:
530  MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
531  : MessageDialogController(pParent, rUIFile, rDialogId, "ask")
532  , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
533  {
534  }
535  bool get_active() const { return m_xWarningOnBox->get_active(); }
536  void hide_ask() const { m_xWarningOnBox->set_visible(false); };
537 };
538 
539 }
540 
542 {
543  // Recalculate formula cells.
544  ScDocument& rDoc = getScDocument();
545  ScDocShell& rDocSh = getDocShell(rDoc);
547  ScRecalcOptions nRecalcMode =
548  static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
549  bool bHardRecalc = false;
550  if (nRecalcMode == RECALC_ASK)
551  {
552  if (rDoc.IsUserInteractionEnabled())
553  {
554  // Ask the user if full re-calculation is desired.
555  MessageWithCheck aQueryBox(ScDocShell::GetActiveDialogParent(), "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
556  aQueryBox.set_primary_text(ScResId(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
557  aQueryBox.set_default_response(RET_YES);
558 
559  if ( officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::isReadOnly() )
560  aQueryBox.hide_ask();
561 
562  bHardRecalc = aQueryBox.run() == RET_YES;
563 
564  if (aQueryBox.get_active())
565  {
566  // Always perform selected action in the future.
567  std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
568  officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
569  ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
570  aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
571  /* XXX is this really supposed to set the ScModule options?
572  * Not the ScDocShell options? */
573  SC_MOD()->SetFormulaOptions(aOpt);
574 
575  batch->commit();
576  }
577  }
578  }
579  else if (nRecalcMode == RECALC_ALWAYS)
580  bHardRecalc = true;
581 
582  if (bHardRecalc)
583  rDocSh.DoHardRecalc();
584  else
585  {
587  // Full ScDocument::CalcFormulaTree() of all dirty cells is not
588  // necessary here, the View will recalculate them in the visible area,
589  // or any other method accessing formula cell results.
590  }
591 }
592 
593 // private --------------------------------------------------------------------
594 
596 {
597  if( ExternalLink* pExtLink = getExternalLinks().importExternalReference( rAttribs ).get() )
598  importExternalLinkFragment( *pExtLink );
599 }
600 
602 {
604 }
605 
607 {
608  sal_Int32 nCacheId = rAttribs.getInteger( XML_cacheId, -1 );
609  OUString aRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
610  importPivotCacheDefFragment( aRelId, nCacheId );
611 }
612 
614 {
615  if( ExternalLink* pExtLink = getExternalLinks().importExternalRef( rStrm ).get() )
616  importExternalLinkFragment( *pExtLink );
617 }
618 
620 {
621  sal_Int32 nCacheId = rStrm.readInt32();
622  OUString aRelId = BiffHelper::readString( rStrm );
623  importPivotCacheDefFragment( aRelId, nCacheId );
624 }
625 
627 {
628  OUString aFragmentPath = getFragmentPathFromRelId( rExtLink.getRelId() );
629  if( !aFragmentPath.isEmpty() )
630  importOoxFragment( new ExternalLinkFragment( *this, aFragmentPath, rExtLink ) );
631 }
632 
633 void WorkbookFragment::importPivotCacheDefFragment( const OUString& rRelId, sal_Int32 nCacheId )
634 {
635  // pivot caches will be imported on demand, here we just store the fragment path in the buffer
636  getPivotCaches().registerPivotCacheFragment( nCacheId, getFragmentPathFromRelId( rRelId ) );
637 }
638 
639 } // namespace oox
640 
641 /* 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:220
void readVbaModules(StorageBase &rVbaPrjStrg)
ScDocumentImport & getDocImport()
void importExternalSelf(SequenceInputStream &rStrm)
Imports the EXTERNALSELF record from the passed stream.
Stores information about all sheets in a spreadsheet document.
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoinAll=true)
const sal_Int32 BIFF12_ID_EXTERNALREFS
Definition: biffhelper.hxx:110
static weld::Window * GetActiveDialogParent()
Definition: docsh.cxx:2949
void importWorkbookPr(const AttributeList &rAttribs)
Imports the workbookPr element containing global workbook settings.
const sal_Int32 BIFF12_ID_FILESHARING
Definition: biffhelper.hxx:118
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
bool isCurrentElement(sal_Int32 nElement) const
SC_DLLPUBLIC bool IsUserInteractionEnabled() const
Definition: document.hxx:1542
void finalizeImport()
Creates all defined names in the document.
#define CREATE_OFFICEDOC_RELATION_TYPE(ascii)
void SetOOXMLRecalcOptions(ScRecalcOptions eOpt)
Definition: formulaopt.hxx:62
const sal_Int32 BIFF12_ID_BOOKVIEWS
Definition: biffhelper.hxx:37
const sal_Int32 BIFF12_ID_WORKBOOKVIEW
Definition: biffhelper.hxx:241
void importCalcPr(const AttributeList &rAttribs)
Imports the calcPr element containing workbook calculation settings.
const sal_Int32 BIFF12_ID_WORKBOOK
Definition: biffhelper.hxx:239
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
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()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
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:1466
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2133
static ThreadPool & getSharedOptimalPool()
virtual double getFreeLength() const override
const sal_Int32 BIFF12_ID_PIVOTCACHES
Definition: biffhelper.hxx:187
const sal_Int32 BIFF12_ID_FUNCTIONGROUPS
Definition: biffhelper.hxx:130
::oox::ole::VbaProject & getVbaProject() const
void finalizeWorkbookImport()
Final conversion after importing the workbook.
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1059
double mfPosition
ScDocShell * getDocShell(const css::uno::Reference< css::frame::XModel > &xModel)
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:96
const sal_Int32 BIFF12_ID_EXTERNALSELF
Definition: biffhelper.hxx:111
#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:253
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:78
#define CREATE_MSOFFICE_RELATION_TYPE(ascii)
sal_Int32 getCurrentElement() const
const sal_Int32 BIFF12_ID_OLESIZE
Definition: biffhelper.hxx:152
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
virtual ISegmentProgressBarRef createSegment(double fLength) override
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
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:186
const sal_Int32 BIFF12_ID_EXTERNALSHEETS
Definition: biffhelper.hxx:113
const sal_Int32 BIFF12_ID_EXTERNALREF
Definition: biffhelper.hxx:109
const sal_Int32 BIFF12_ID_SHEET
Definition: biffhelper.hxx:215
void SetSheetCount(SCTAB nSheets)
ensure sizes of vectors matches the number of sheets
const sal_Int32 BIFF12_ID_EXTERNALSAME
Definition: biffhelper.hxx:112
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:240
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:94
Dialog sheet (BIFF5+).
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1058
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:41
void importPivotCache(const AttributeList &rAttribs)
const sal_Int32 BIFF12_ID_EXTERNALADDIN
Definition: biffhelper.hxx:106
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
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.