LibreOffice Module sc (master)  1
workbookhelper.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 <workbookhelper.hxx>
21 
22 #include <com/sun/star/container/XIndexAccess.hpp>
23 #include <com/sun/star/container/XNameContainer.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
26 #include <com/sun/star/sheet/XSpreadsheet.hpp>
27 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
28 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
29 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
30 #include <com/sun/star/document/XDocumentProperties.hpp>
31 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
32 #include <com/sun/star/document/XViewDataSupplier.hpp>
33 #include <o3tl/any.hxx>
34 #include <osl/thread.h>
35 #include <osl/diagnose.h>
38 #include <oox/ole/vbaproject.hxx>
39 #include <oox/token/properties.hxx>
40 #include <addressconverter.hxx>
41 #include <connectionsbuffer.hxx>
42 #include <defnamesbuffer.hxx>
43 #include <excelchartconverter.hxx>
44 #include <excelfilter.hxx>
45 #include <externallinkbuffer.hxx>
46 #include <formulaparser.hxx>
47 #include <pagesettings.hxx>
48 #include <pivotcachebuffer.hxx>
49 #include <pivottablebuffer.hxx>
50 #include <scenariobuffer.hxx>
51 #include <sharedstringsbuffer.hxx>
52 #include <stylesbuffer.hxx>
53 #include <tablebuffer.hxx>
54 #include <themebuffer.hxx>
55 #include <unitconverter.hxx>
56 #include <viewsettings.hxx>
57 #include <workbooksettings.hxx>
58 #include <worksheetbuffer.hxx>
59 #include <docsh.hxx>
60 #include <document.hxx>
61 #include <docuno.hxx>
62 #include <rangenam.hxx>
63 #include <tokenarray.hxx>
64 #include <tokenuno.hxx>
65 #include <dbdata.hxx>
66 #include <datauno.hxx>
67 #include <globalnames.hxx>
68 #include <documentimport.hxx>
69 #include <drwlayer.hxx>
70 #include <globstr.hrc>
71 #include <scresid.hxx>
72 
73 #include <formulabuffer.hxx>
74 #include <editutil.hxx>
75 #include <editeng/editstat.hxx>
76 #include <unotools/charclass.hxx>
78 
79 #include <memory>
80 
81 namespace oox::xls {
82 
83 using namespace ::com::sun::star::container;
84 using namespace ::com::sun::star::document;
85 using namespace ::com::sun::star::lang;
86 using namespace ::com::sun::star::sheet;
87 using namespace ::com::sun::star::style;
88 using namespace ::com::sun::star::table;
89 using namespace ::com::sun::star::uno;
90 using namespace ::com::sun::star::beans;
91 
92 using ::oox::core::FilterBase;
93 using ::oox::core::FragmentHandler;
94 using ::oox::core::XmlFilterBase;
95 
96 bool IgnoreCaseCompare::operator()( const OUString& rName1, std::u16string_view rName2 ) const
97 {
98  // TODO: compare with collator
99  return rName1.compareToIgnoreAsciiCase(rName2 ) < 0;
100 }
101 
103 {
104 public:
105  // noncopyable ------------------------------------------------------------
106 
107  WorkbookGlobals(const WorkbookGlobals&) = delete;
108  const WorkbookGlobals& operator=(const WorkbookGlobals&) = delete;
109 
110  explicit WorkbookGlobals( ExcelFilter& rFilter );
112 
114  bool isValid() const { return mxDoc.is(); }
115 
116  // filter -----------------------------------------------------------------
117 
119  FilterBase& getBaseFilter() const { return mrBaseFilter; }
123  const StorageRef& getVbaProjectStorage() const { return mxVbaPrjStrg; }
125  sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; }
128 
130  void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
132  void setCurrentSheetIndex( SCTAB nSheet ) { mnCurrSheet = nSheet; }
133 
134  // document model ---------------------------------------------------------
135 
137  {
138  return *mxEditEngine;
139  }
140 
142 
144 
146  const Reference< XSpreadsheetDocument >& getDocument() const { return mxDoc; }
148  Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const;
150  Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
152  WorkbookHelper::RangeDataRet createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden );
154  WorkbookHelper::RangeDataRet createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden );
156  Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr );
158  Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr );
160  ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex );
162  Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
164  void useInternalChartDataTable( bool bInternal );
165 
166  // buffers ----------------------------------------------------------------
167 
176  ThemeBuffer& getTheme() const { return *mxTheme; }
178  StylesBuffer& getStyles() const { return *mxStyles; }
186  TableBuffer& getTables() const { return *mxTables; }
195 
196  // converters -------------------------------------------------------------
197 
210 
211  // OOXML/BIFF12 specific --------------------------------------------------
212 
214  XmlFilterBase& getOoxFilter() const { return *mpOoxFilter; }
215 
216  // BIFF2-BIFF8 specific ---------------------------------------------------
217 
219  rtl_TextEncoding getTextEncoding() const { return meTextEnc; }
220 
221 private:
223  void initialize();
225  void finalize();
226 
227 private:
228  typedef ::std::unique_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr;
229  typedef ::std::unique_ptr< FormulaBuffer > FormulaBufferPtr;
230  typedef ::std::unique_ptr< SegmentProgressBar > ProgressBarPtr;
231  typedef ::std::unique_ptr< WorkbookSettings > WorkbookSettPtr;
232  typedef ::std::unique_ptr< ViewSettings > ViewSettingsPtr;
233  typedef ::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr;
234  typedef ::std::shared_ptr< ThemeBuffer > ThemeBfrRef;
235  typedef ::std::unique_ptr< StylesBuffer > StylesBfrPtr;
236  typedef ::std::unique_ptr< SharedStringsBuffer > SharedStrBfrPtr;
237  typedef ::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr;
238  typedef ::std::unique_ptr< DefinedNamesBuffer > DefNamesBfrPtr;
239  typedef ::std::unique_ptr< TableBuffer > TableBfrPtr;
240  typedef ::std::unique_ptr< ScenarioBuffer > ScenarioBfrPtr;
241  typedef ::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr;
242  typedef ::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr;
243  typedef ::std::unique_ptr< PivotTableBuffer > PivotTableBfrPtr;
244  typedef ::std::unique_ptr< FormulaParser > FormulaParserPtr;
245  typedef ::std::unique_ptr< UnitConverter > UnitConvPtr;
246  typedef ::std::unique_ptr< AddressConverter > AddressConvPtr;
247  typedef ::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr;
248  typedef ::std::unique_ptr< PageSettingsConverter > PageSettConvPtr;
249 
250  OUString maCellStyles;
251  OUString maPageStyles;
252  OUString maCellStyleServ;
253  OUString maPageStyleServ;
254  Reference< XSpreadsheetDocument > mxDoc;
255  FilterBase& mrBaseFilter;
257  ProgressBarPtr mxProgressBar;
259  sal_Int16 mnCurrSheet;
261 
262  // buffers
263  FormulaBufferPtr mxFormulaBuffer;
264  WorkbookSettPtr mxWorkbookSettings;
265  ViewSettingsPtr mxViewSettings;
266  WorksheetBfrPtr mxWorksheets;
267  ThemeBfrRef mxTheme;
268  StylesBfrPtr mxStyles;
269  SharedStrBfrPtr mxSharedStrings;
270  ExtLinkBfrPtr mxExtLinks;
271  DefNamesBfrPtr mxDefNames;
272  TableBfrPtr mxTables;
273  ScenarioBfrPtr mxScenarios;
274  ConnectionsBfrPtr mxConnections;
275  PivotCacheBfrPtr mxPivotCaches;
276  PivotTableBfrPtr mxPivotTables;
277 
278  // converters
279  FormulaParserPtr mxFmlaParser;
280  UnitConvPtr mxUnitConverter;
281  AddressConvPtr mxAddrConverter;
282  ExcelChartConvPtr mxChartConverter;
283  PageSettConvPtr mxPageSettConverter;
284 
285  EditEngineDefaulterPtr mxEditEngine;
286 
287  // OOXML/BIFF12 specific
288  XmlFilterBase* mpOoxFilter;
289 
290  // BIFF2-BIFF8 specific
291  rtl_TextEncoding meTextEnc;
294  std::unique_ptr<ScDocumentImport> mxDocImport;
295 };
296 
298  mrBaseFilter( rFilter ),
299  mrExcelFilter( rFilter ),
300  mpOoxFilter( &rFilter ),
301  mpDoc(nullptr),
302  mpDocShell(nullptr)
303 {
304  // register at the filter, needed for virtual callbacks (even during construction)
306  initialize();
307 }
308 
310 {
311  finalize();
313 }
314 
316 {
317  return *mxDocImport;
318 }
319 
320 Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
321 {
322  Reference< XNameContainer > xStylesNC;
323  try
324  {
325  Reference< XStyleFamiliesSupplier > xFamiliesSup( mxDoc, UNO_QUERY_THROW );
326  Reference< XNameAccess > xFamiliesNA( xFamiliesSup->getStyleFamilies(), UNO_SET_THROW );
327  xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY );
328  }
329  catch( Exception& )
330  {
331  }
332  OSL_ENSURE( xStylesNC.is(), "WorkbookGlobals::getStyleFamily - cannot access style family" );
333  return xStylesNC;
334 }
335 
336 Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
337 {
338  Reference< XStyle > xStyle;
339  try
340  {
341  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
342  xStyle.set( xStylesNC->getByName( rStyleName ), UNO_QUERY );
343  }
344  catch( Exception& )
345  {
346  }
347  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
348  return xStyle;
349 }
350 
351 namespace {
352 
353 WorkbookHelper::RangeDataRet lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType, bool bHidden )
354 {
355  bool bDone = false;
357  if ( nUnoType & NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria;
358  if ( nUnoType & NamedRangeFlag::PRINT_AREA ) nNewType |= ScRangeData::Type::PrintArea;
359  if ( nUnoType & NamedRangeFlag::COLUMN_HEADER ) nNewType |= ScRangeData::Type::ColHeader;
360  if ( nUnoType & NamedRangeFlag::ROW_HEADER ) nNewType |= ScRangeData::Type::RowHeader;
361  ScTokenArray aTokenArray(rDoc);
362  (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
363  ScRangeData* pNew = new ScRangeData( rDoc, rName, aTokenArray, ScAddress(), nNewType );
364  pNew->GuessPosition();
365  if ( nIndex )
366  pNew->SetIndex( nIndex );
367  // create but not insert hidden FILTER_CRITERIA named ranges to ScRangeName
368  if ( bHidden && nNewType == ScRangeData::Type::Criteria )
369  {
370  return WorkbookHelper::RangeDataRet(pNew, true);
371  }
372  if ( pNames->insert(pNew) )
373  bDone = true;
374  if (!bDone)
375  {
376  delete pNew;
377  throw RuntimeException();
378  }
379  return WorkbookHelper::RangeDataRet(pNew, false);
380 }
381 
382 OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
383 {
384  OUString aNewName = rSuggestedName;
385  sal_Int32 nIndex = 0;
386  while(pRangeName->findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName)))
387  aNewName = rSuggestedName + OUStringChar('_') + OUString::number( nIndex++ );
388 
389  return aNewName;
390 }
391 
392 }
393 
395  OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden )
396 {
397  // create the name and insert it into the Calc document
398  WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
399  if( !orName.isEmpty() )
400  {
401  ScDocument& rDoc = getScDocument();
402  ScRangeName* pNames = rDoc.GetRangeName();
403  // find an unused name
404  orName = findUnusedName( pNames, orName );
405  // create the named range
406  aScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags, bHidden );
407  }
408  return aScRangeData;
409 }
410 
412  OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden )
413 {
414  // create the name and insert it into the Calc document
415  WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
416  if( !orName.isEmpty() )
417  {
418  ScDocument& rDoc = getScDocument();
419  ScRangeName* pNames = rDoc.GetRangeName( nTab );
420  if(!pNames)
421  throw RuntimeException("invalid sheet index used");
422  // find an unused name
423  orName = findUnusedName( pNames, orName );
424  // create the named range
425  aScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags, bHidden );
426  }
427  return aScRangeData;
428 }
429 
430 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr )
431 {
432  // validate cell range
433  ScRange aDestRange = rRangeAddr;
434  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
435 
436  // create database range and insert it into the Calc document
437  Reference< XDatabaseRange > xDatabaseRange;
438  if( bValidRange && !orName.isEmpty() ) try
439  {
440  // find an unused name
441  PropertySet aDocProps( mxDoc );
442  Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
443  orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
444  // create the database range
445  CellRangeAddress aApiRange( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row(),
446  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() );
447  xDatabaseRanges->addNewByName( orName, aApiRange );
448  xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
449  }
450  catch( Exception& )
451  {
452  }
453  OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
454  return xDatabaseRange;
455 }
456 
457 Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr )
458 {
459  // validate cell range
460  ScRange aDestRange = rRangeAddr;
461  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
462 
463  // create database range and insert it into the Calc document
464  Reference< XDatabaseRange > xDatabaseRange;
465  if( bValidRange ) try
466  {
467  ScDocument& rDoc = getScDocument();
468  if( rDoc.GetTableCount() <= aDestRange.aStart.Tab() )
469  throw css::lang::IndexOutOfBoundsException();
470  std::unique_ptr<ScDBData> pNewDBData(new ScDBData( STR_DB_LOCAL_NONAME, aDestRange.aStart.Tab(),
471  aDestRange.aStart.Col(), aDestRange.aStart.Row(),
472  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() ));
473  rDoc.SetAnonymousDBData( aDestRange.aStart.Tab() , std::move(pNewDBData) );
474  ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
475  xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aDestRange.aStart.Tab()));
476  }
477  catch( Exception& )
478  {
479  }
480  OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
481  return xDatabaseRange;
482 }
483 
485 {
486  ScDBCollection* pDBCollection = getScDocument().GetDBCollection();
487  if (!pDBCollection)
488  return nullptr;
489  return pDBCollection->getNamedDBs().findByIndex( nIndex );
490 }
491 
492 Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
493 {
494  Reference< XStyle > xStyle;
495  try
496  {
497  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
498  xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
499  orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ) );
500  }
501  catch( Exception& )
502  {
503  }
504  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
505  return xStyle;
506 }
507 
509 {
510  if( bInternal )
512  else
513  mxChartConverter.reset( new ExcelChartConverter( *this ) );
514 }
515 
516 // BIFF specific --------------------------------------------------------------
517 
518 // private --------------------------------------------------------------------
519 
521 {
522  maCellStyles = "CellStyles";
523  maPageStyles = "PageStyles";
524  maCellStyleServ = "com.sun.star.style.CellStyle";
525  maPageStyleServ = "com.sun.star.style.PageStyle";
526  mnCurrSheet = -1;
527  mbGeneratorKnownGood = false;
528  meTextEnc = osl_getThreadTextEncoding();
529 
530  // the spreadsheet document
531  mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
532  OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
533 
534  if (mxDoc)
535  {
536  ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
537  if (pModel)
538  mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
539  if (mpDocShell)
541  }
542 
543  if (!mpDoc)
544  throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
545 
546  Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
547  Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
548  const OUString aGenerator( xDocProps->getGenerator());
549 
550  if (aGenerator.startsWithIgnoreAsciiCase("Microsoft"))
551  {
552  mbGeneratorKnownGood = true;
553  ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
555  mpDoc->SetCalcConfig(aCalcConfig);
556  }
557  else if (aGenerator.startsWithIgnoreAsciiCase("LibreOffice"))
558  {
559  mbGeneratorKnownGood = true;
560  }
561 
562  mxDocImport.reset(new ScDocumentImport(*mpDoc));
563 
564  mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
565  mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
566  mxViewSettings.reset( new ViewSettings( *this ) );
567  mxWorksheets.reset( new WorksheetBuffer( *this ) );
568  mxTheme = std::make_shared<ThemeBuffer>( *this );
569  mxStyles.reset( new StylesBuffer( *this ) );
570  mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
571  mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
572  mxDefNames.reset( new DefinedNamesBuffer( *this ) );
573  mxTables.reset( new TableBuffer( *this ) );
574  mxScenarios.reset( new ScenarioBuffer( *this ) );
575  mxConnections.reset( new ConnectionsBuffer( *this ) );
576  mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
577  mxPivotTables.reset( new PivotTableBuffer( *this ) );
578 
579  mxUnitConverter.reset( new UnitConverter( *this ) );
580  mxAddrConverter.reset( new AddressConverter( *this ) );
581  mxChartConverter.reset( new ExcelChartConverter( *this ) );
582  mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
583 
584  // initialise edit engine
585  ScDocument& rDoc = getScDocument();
586  mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
587  mxEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
588  mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
589  mxEditEngine->SetUpdateMode( false );
590  mxEditEngine->EnableUndo( false );
591  mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
592 
593  // set some document properties needed during import
594  if( mrBaseFilter.isImportFilter() )
595  {
596  // enable editing read-only documents (e.g. from read-only files)
598  // #i76026# disable Undo while loading the document
599  mpDoc->EnableUndo(false);
600  // #i79826# disable calculating automatic row height while loading the document
602  // disable automatic update of linked sheets and DDE links
603  mpDoc->EnableExecuteLink(false);
604 
605  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_LOAD_DOC) ) );
607 
608  //prevent unnecessary broadcasts and "half way listeners" as
609  //is done in ScDocShell::BeforeXMLLoading() for ods
611  }
612  else if( mrBaseFilter.isExportFilter() )
613  {
614  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_SAVE_DOC) ) );
615  }
616 }
617 
619 {
620  // set some document properties needed after import
621  if( !mrBaseFilter.isImportFilter() )
622  return;
623 
624  // #i74668# do not insert default sheets
625  mpDocShell->SetEmpty(false);
626  // enable automatic update of linked sheets and DDE links
627  mpDoc->EnableExecuteLink(true);
628  // #i79826# enable updating automatic row height after loading the document
630 
631  // #i76026# enable Undo after loading the document
632  mpDoc->EnableUndo(true);
633 
634  // disable editing read-only documents (e.g. from read-only files)
635  mpDoc->EnableChangeReadOnly(false);
636  // #111099# open forms in alive mode (has no effect, if no controls in document)
637  ScDrawLayer* pModel = mpDoc->GetDrawLayer();
638  if (pModel)
639  pModel->SetOpenInDesignMode(false);
640 }
641 
642 
644 {
645 }
646 
648 {
649  WorkbookGlobalsRef xBookGlob = std::make_shared<WorkbookGlobals>( rFilter );
650  if( !xBookGlob->isValid() )
651  xBookGlob.reset();
652  return xBookGlob;
653 }
654 
655 // filter ---------------------------------------------------------------------
656 
657 FilterBase& WorkbookHelper::getBaseFilter() const
658 {
659  return mrBookGlob.getBaseFilter();
660 }
661 
663 {
664  return mrBookGlob.getProgressBar();
665 }
666 
668 {
670 }
671 
673 {
675 }
676 
678 {
679  mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
680 }
681 
683 {
685 }
686 
688 {
689  // workbook settings, document and sheet view settings
692 
693  // Import the VBA project (after finalizing workbook settings which
694  // contains the workbook code name). Do it before processing formulas in
695  // order to correctly resolve VBA custom function names.
697  if( xVbaPrjStrg && xVbaPrjStrg->isStorage() )
698  getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
699 
700  // need to import formulas before scenarios
702 
703  // Insert all pivot tables. Must be done after loading all sheets and
704  // formulas, because data pilots expect existing source data on
705  // creation.
707 
708  /* Insert scenarios after all sheet processing is done, because new hidden
709  sheets are created for scenarios which would confuse code that relies
710  on certain sheet indexes. Must be done after pivot tables too. */
712 
713  /* Set 'Default' page style to automatic page numbering (default is manual
714  number 1). Otherwise hidden sheets (e.g. for scenarios) which have
715  'Default' page style will break automatic page numbering for following
716  sheets. Automatic numbering is set by passing the value 0. */
717  PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
718  aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
719 
720  // Has any string ref syntax been imported?
721  // If not, we need to take action
722  ScCalcConfig aCalcConfig = getScDocument().GetCalcConfig();
723 
724  if ( !aCalcConfig.mbHasStringRefSyntax )
725  {
727  getScDocument().SetCalcConfig(aCalcConfig);
728  }
729 
730  // set selected sheet and positionleft/positiontop for OLE objects
731  Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY);
732  if (!xViewDataSupplier.is())
733  return;
734 
735  Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
736  if (!(xIndexAccess.is() && xIndexAccess->getCount() > 0))
737  return;
738 
739  Sequence< PropertyValue > aSeq;
740  if (!(xIndexAccess->getByIndex(0) >>= aSeq))
741  return;
742 
743  OUString sTabName;
744  Reference< XNameAccess > xSheetsNC;
745  for (const auto& rProp : std::as_const(aSeq))
746  {
747  OUString sName(rProp.Name);
748  if (sName == SC_ACTIVETABLE)
749  {
750  if(rProp.Value >>= sTabName)
751  {
752  SCTAB nTab(0);
753  if (getScDocument().GetTable(sTabName, nTab))
755  }
756  }
757  else if (sName == SC_TABLES)
758  {
759  rProp.Value >>= xSheetsNC;
760  }
761  }
762  if (!(xSheetsNC.is() && xSheetsNC->hasByName(sTabName)))
763  return;
764 
765  Sequence<PropertyValue> aProperties;
766  Any aAny = xSheetsNC->getByName(sTabName);
767  if ( !(aAny >>= aProperties) )
768  return;
769 
770  for (const auto& rProp : std::as_const(aProperties))
771  {
772  OUString sName(rProp.Name);
773  if (sName == SC_POSITIONLEFT)
774  {
775  SCCOL nPosLeft = *o3tl::doAccess<SCCOL>(rProp.Value);
776  getScDocument().SetPosLeft(nPosLeft);
777  }
778  else if (sName == SC_POSITIONTOP)
779  {
780  SCROW nPosTop = *o3tl::doAccess<SCROW>(rProp.Value);
781  getScDocument().SetPosTop(nPosTop);
782  }
783  }
784 }
785 
786 // document model -------------------------------------------------------------
787 
789 {
790  return mrBookGlob.getScDocument();
791 }
792 
794 {
795  return mrBookGlob.getScDocument();
796 }
797 
799 {
800  return mrBookGlob.getDocImport();
801 }
802 
804 {
805  return mrBookGlob.getDocImport();
806 }
807 
809 {
810  return mrBookGlob.getEditEngine();
811 }
812 
813 const Reference< XSpreadsheetDocument > & WorkbookHelper::getDocument() const
814 {
815  return mrBookGlob.getDocument();
816 }
817 
818 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
819 {
820  Reference< XSpreadsheet > xSheet;
821  try
822  {
823  Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
824  xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
825  }
826  catch( Exception& )
827  {
828  }
829  return xSheet;
830 }
831 
832 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
833 {
834  Reference< XSpreadsheet > xSheet;
835  try
836  {
837  Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
838  xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
839  }
840  catch( Exception& )
841  {
842  }
843  return xSheet;
844 }
845 
846 Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
847 {
848  Reference< XCellRange > xRange;
849  try
850  {
851  Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
852  xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
853  }
854  catch( Exception& )
855  {
856  }
857  return xRange;
858 }
859 
860 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
861 {
862  return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );
863 }
864 
865 Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
866 {
867  return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
868 }
869 
870 WorkbookHelper::RangeDataRet WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden ) const
871 {
872  return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags, bHidden );
873 }
874 
875 WorkbookHelper::RangeDataRet WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden ) const
876 {
877  return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab, bHidden );
878 }
879 
880 Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr ) const
881 {
882  return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
883 }
884 
885 Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr ) const
886 {
887  return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
888 }
889 
891 {
892  return mrBookGlob.findDatabaseRangeByIndex( nIndex );
893 }
894 
895 Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
896 {
897  return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
898 }
899 
900 // buffers --------------------------------------------------------------------
901 
903 {
904  return mrBookGlob.getFormulaBuffer();
905 }
906 
908 {
910 }
911 
913 {
914  return mrBookGlob.getViewSettings();
915 }
916 
918 {
919  return mrBookGlob.getWorksheets();
920 }
921 
923 {
924  return mrBookGlob.getTheme();
925 }
926 
928 {
929  return mrBookGlob.getStyles();
930 }
931 
933 {
934  return mrBookGlob.getSharedStrings();
935 }
936 
938 {
939  return mrBookGlob.getExternalLinks();
940 }
941 
943 {
944  return mrBookGlob.getDefinedNames();
945 }
946 
948 {
949  return mrBookGlob.getTables();
950 }
951 
953 {
954  return mrBookGlob.getScenarios();
955 }
956 
958 {
959  return mrBookGlob.getConnections();
960 }
961 
963 {
964  return mrBookGlob.getPivotCaches();
965 }
966 
968 {
969  return mrBookGlob.getPivotTables();
970 }
971 
972 // converters -----------------------------------------------------------------
973 
975 {
976  return mrBookGlob.getFormulaParser();
977 }
978 
980 {
982 }
983 
985 {
986  return mrBookGlob.getUnitConverter();
987 }
988 
990 {
992 }
993 
995 {
996  return mrBookGlob.getChartConverter();
997 }
998 
1000 {
1002 }
1003 
1005 {
1007 }
1008 
1009 // OOXML/BIFF12 specific ------------------------------------------------------
1010 
1011 XmlFilterBase& WorkbookHelper::getOoxFilter() const
1012 {
1013  return mrBookGlob.getOoxFilter();
1014 }
1015 
1017 {
1018  return getOoxFilter().importFragment( rxHandler );
1019 }
1020 
1022 {
1023  return getOoxFilter().importFragment(rxHandler, rParser);
1024 }
1025 
1026 // BIFF specific --------------------------------------------------------------
1027 
1028 rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1029 {
1030  return mrBookGlob.getTextEncoding();
1031 }
1032 
1033 } // namespace oox
1034 
1035 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void importModulesAndForms(StorageBase &rVbaPrjStrg, const GraphicHelper &rGraphicHelper)
rtl_TextEncoding meTextEnc
Base OOXML/BIFF12 filter object.
StylesBfrPtr mxStyles
Formatting theme from theme substream.
void registerWorkbookGlobals(WorkbookGlobals &rBookGlob)
Definition: excelfilter.cxx:63
#define SC_POSITIONLEFT
SharedStringsBuffer & getSharedStrings() const
Returns the shared strings read from the shared strings substream.
void setCurrentSheetIndex(SCTAB nSheet)
Sets the index of the current Calc sheet, if filter currently processes a sheet.
void useInternalChartDataTable(bool bInternal)
Helper to switch chart data table - specifically for xlsx imports.
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
::std::unique_ptr< DefinedNamesBuffer > DefNamesBfrPtr
FormulaParserPtr mxFmlaParser
All pivot tables in the document.
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:814
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
ScAddress aStart
Definition: address.hxx:499
ScDocumentImport & getDocImport()
ScDBData * findByIndex(sal_uInt16 nIndex)
Definition: dbdata.cxx:1160
const StorageRef & getVbaProjectStorage() const
Returns the VBA project storage.
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
SCROW Row() const
Definition: address.hxx:261
oox::drawingml::chart::ChartConverter * getChartConverter() const
Returns the chart object converter.
const Reference< XSpreadsheetDocument > & getDocument() const
Returns a reference to the source/target spreadsheet document model.
Stores information about all sheets in a spreadsheet document.
#define SC_ACTIVETABLE
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
::std::unique_ptr< SharedStringsBuffer > SharedStrBfrPtr
::std::unique_ptr< UnitConverter > UnitConvPtr
bool isGeneratorKnownGood() const
Returns true when reading a file generated by a known good generator.
css::uno::Reference< css::style::XStyle > getStyleObject(const OUString &rStyleName, bool bPageStyle) const
Returns the specified cell or page style from the Calc document.
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
Definition: document.cxx:318
FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
bool validateCellRange(ScRange &orRange, bool bAllowOverflow, bool bTrackOverflow)
Checks the passed cell range, may try to fit it to current sheet limits.
void finalizeImport()
Inserts all pivot tables into the sheet.
Collects all strings from the shared strings substream.
ExternalLinkBuffer & getExternalLinks() const
Returns the external links read from the external links substream.
#define STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:12
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
rtl_TextEncoding getTextEncoding() const
Returns the text encoding used to import/export byte strings.
WorksheetBfrPtr mxWorksheets
Workbook and sheet view settings.
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
PivotTableBuffer & getPivotTables()
Returns the collection of pivot tables.
PivotCacheBfrPtr mxPivotCaches
All external data connections.
EditEngineDefaulterPtr mxEditEngine
Page/print settings converter.
WorkbookHelper::RangeDataRet createLocalNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden)
Creates and returns a defined name on the-fly in the correct Calc sheet.
ViewSettingsPtr mxViewSettings
Global workbook settings.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr
Helper class that provides functions to convert values from and to different units.
bool importFragment(const rtl::Reference< FragmentHandler > &rxHandler)
bool isValid() const
Returns true, if this helper refers to a valid document.
WorkbookGlobals & mrBookGlob
ScAddress aEnd
Definition: address.hxx:500
Reference< XDatabaseRange > createDatabaseRangeObject(OUString &orName, const ScRange &rRangeAddr)
Creates and returns a database range on-the-fly in the Calc document.
ScDocument * mpDoc
BIFF byte string text encoding.
css::uno::Reference< css::table::XCellRange > getCellRangeFromDoc(const ScRange &rRange) const
Returns the XCellRange interface for the passed cell range address.
rtl_TextEncoding getTextEncoding() const
Returns the text encoding used to import/export byte strings.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
std::shared_ptr< StorageBase > StorageRef
Accessor class to ScDocument.
void SetOpenInDesignMode(bool _bOpenDesignMode)
EEControlBits
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
DefNamesBfrPtr mxDefNames
All external links.
#define SC_TABLES
void initialize()
Initializes some basic members and sets needed document properties.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
PageSettConvPtr mxPageSettConverter
Chart object converter.
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...
::std::unique_ptr< SegmentProgressBar > ProgressBarPtr
Reference< XDatabaseRange > createUnnamedDatabaseRangeObject(const ScRange &rRangeAddr)
Creates and returns an unnamed database range on-the-fly in the Calc document.
Reference< XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle)
Creates and returns a com.sun.star.style.Style object for cells or pages.
FormulaParser & getFormulaParser() const
Returns a shared import formula parser.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
PivotTableBfrPtr mxPivotTables
All pivot caches in the document.
OUString maCellStyleServ
Style family name for page styles.
PropertiesInfo aProperties
css::uno::Reference< css::style::XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle) const
Creates and returns a com.sun.star.style.Style object for cells or pages.
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:313
Reference< XSpreadsheetDocument > mxDoc
Service name for a page style.
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex) const
Finds the (already existing) database range of the given formula token index.
const WorkbookGlobals & operator=(const WorkbookGlobals &)=delete
void SetEmpty(bool bSet)
Definition: docsh2.cxx:89
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
sal_Int16 getCurrentSheetIndex() const
Returns the index of the current Calc sheet, if filter currently processes a sheet.
SCTAB Tab() const
Definition: address.hxx:270
SC_DLLPUBLIC void GuessPosition()
Definition: rangenam.cxx:205
ScDocumentImport & getDocImport()
static OUString insertByUnusedName(const css::uno::Reference< css::container::XNameContainer > &rxNameContainer, const OUString &rSuggestedName, sal_Unicode cSeparator, const css::uno::Any &rObject)
const char * sName
void useInternalChartDataTable(bool bInternal)
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2145
::std::unique_ptr< StylesBuffer > StylesBfrPtr
::std::unique_ptr< FormulaBuffer > FormulaBufferPtr
UnitConvPtr mxUnitConverter
Import formula parser.
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:859
Reference< XStyle > getStyleObject(const OUString &rStyleName, bool bPageStyle) const
Returns the specified cell or page style from the Calc document.
::oox::ole::VbaProject & getVbaProject() const
FormulaParser * createFormulaParser()
Returns an unshared import formula parser.
void finalizeWorkbookImport()
Final conversion after importing the workbook.
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1058
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:681
PageSettingsConverter & getPageSettingsConverter() const
Returns the page and print settings converter.
bool mbGeneratorKnownGood
Current sheet index in Calc document.
void EnableExecuteLink(bool bVal)
Definition: document.hxx:1543
RangeDataRet createNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden) const
Creates and returns a defined name on-the-fly in the Calc document.
AddressConvPtr mxAddrConverter
General unit converter.
void setCurrentSheetIndex(SCTAB nSheet)
Sets the index of the current Calc sheet, if filter currently processes a sheet.
const css::uno::Reference< css::sheet::XSpreadsheetDocument > & getDocument() const
Returns a reference to the source/target spreadsheet document model.
sal_Int16 SCCOL
Definition: types.hxx:21
::std::unique_ptr< FormulaParser > FormulaParserPtr
css::uno::Reference< css::container::XNameContainer > getCellStyleFamily() const
Returns the cell styles container from the Calc document.
std::unique_ptr< ScDocumentImport > mxDocImport
void EnableChangeReadOnly(bool bVal)
Definition: document.hxx:1545
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:451
ExternalLinkBuffer & getExternalLinks() const
Returns the external links read from the external links substream.
ExcelFilter & mrExcelFilter
Base filter object.
ExcelChartConvPtr mxChartConverter
Cell address and cell range address converter.
sal_Int16 getCurrentSheetIndex() const
Returns the index of the current Calc sheet, if filter currently processes a sheet.
::std::unique_ptr< ViewSettings > ViewSettingsPtr
FormulaParser * createFormulaParser() const
Returns an unshared import formula parser (import filter only!).
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
Definition: documen2.cxx:451
ScenarioBfrPtr mxScenarios
All tables (database ranges).
SC_DLLPUBLIC void UnlockAdjustHeight()
Definition: document.cxx:1789
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
::oox::core::XmlFilterBase & getOoxFilter() const
Returns the base OOXML/BIFF12 filter object.
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
::std::shared_ptr< ThemeBuffer > ThemeBfrRef
std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef
PageSettingsConverter & getPageSettingsConverter() const
Returns the page/print settings converter.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr
WorkbookSettPtr mxWorkbookSettings
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
Definition: tokenuno.cxx:364
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex)
Finds the (already existing) database range of the given formula token index.
ScEditEngineDefaulter & getEditEngine() const
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
StorageRef mxVbaPrjStrg
The progress bar.
SC_DLLPUBLIC void SetPosTop(SCROW nRow)
Definition: document.hxx:863
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:53
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
SCCOL Col() const
Definition: address.hxx:266
FormulaBufferPtr mxFormulaBuffer
Whether reading a file generated by Excel or Calc.
::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr
Reference< XNameContainer > getStyleFamily(bool bPageStyles) const
Returns the cell or page styles container from the Calc document.
::std::unique_ptr< TableBuffer > TableBfrPtr
::std::unique_ptr< AddressConverter > AddressConvPtr
std::pair< ScRangeData *, bool > RangeDataRet
Configuration options for formula interpreter.
Definition: calcconfig.hxx:43
FormulaBuffer & getFormulaBuffer() const
static WorkbookGlobalsRef constructGlobals(ExcelFilter &rFilter)
sal_Int32 SCROW
Definition: types.hxx:17
void unregisterWorkbookGlobals()
Definition: excelfilter.cxx:74
static OUString getUnusedName(const css::uno::Reference< css::container::XNameAccess > &rxNameAccess, const OUString &rSuggestedName, sal_Unicode cSeparator)
void SetIndex(sal_uInt16 nInd)
Definition: rangenam.hxx:115
bool operator()(const OUString &rName1, std::u16string_view rName2) const
OUString ScResId(std::string_view aId)
Definition: scdll.cxx:89
::std::unique_ptr< WorkbookSettings > WorkbookSettPtr
SharedStrBfrPtr mxSharedStrings
All cell style objects from styles substream.
oox::drawingml::chart::ChartConverter * getChartConverter() const
Returns the chart object converter.
#define SC_POSITIONTOP
void LockAdjustHeight()
Definition: document.hxx:1540
TableBfrPtr mxTables
All defined names.
Converter for cell addresses and cell ranges for OOXML and BIFF filters.
WorkbookHelper::RangeDataRet createNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden)
Creates and returns a defined name on-the-fly in the Calc document.
RangeDataRet createLocalNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden) const
Creates and returns a defined name on-the-fly in the sheet.
::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr
OUString maPageStyleServ
Service name for a cell style.
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2531
bool isGeneratorKnownGood() const
Returns true when reading a file generated by a known good generator.
void finalizeImport()
Creates all scenarios in the Calc document.
css::uno::Reference< css::sheet::XDatabaseRange > createDatabaseRangeObject(OUString &orName, const ScRange &rRangeAddr) const
Creates and returns a database range on-the-fly in the Calc document.
void finalizeImport()
Converts all imported document view settings.
ScEditEngineDefaulter & getEditEngine() const
static SC_DLLPUBLIC const CharClass * getCharClassPtr()
Definition: global.cxx:1010
SharedStringsBuffer & getSharedStrings() const
Returns the shared strings read from the shared strings substream.
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
OUString maPageStyles
Style family name for cell styles.
::std::unique_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr
Import formula parser for OOXML and BIFF filters.
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
Definition: documen2.cxx:446
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:315
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
void setVbaProjectStorage(const StorageRef &rxVbaPrjStrg)
Sets the VBA project storage used to import VBA source code and forms.
FormulaParser & getFormulaParser() const
Returns a shared import formula parser (import filter only!).
css::uno::Reference< css::sheet::XSpreadsheet > getSheetFromDoc(sal_Int32 nSheet) const
Returns a reference to the specified spreadsheet in the document model.
PivotTableBuffer & getPivotTables() const
Returns the collection of pivot tables.
ThemeBfrRef mxTheme
Sheet info buffer.
void finalize()
Finalizes the filter process (sets some needed document properties).
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1057
::std::unique_ptr< PageSettingsConverter > PageSettConvPtr
sal_Int16 mnCurrSheet
Storage containing the VBA project.
void setVbaProjectStorage(const StorageRef &rxVbaPrjStrg)
Sets the VBA project storage used to import VBA source code and forms.
::std::unique_ptr< PivotTableBuffer > PivotTableBfrPtr
void finalizeImport()
Converts the imported workbook settings.
SC_DLLPUBLIC void EnableUndo(bool bVal)
Definition: document.cxx:6496
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
css::uno::Reference< css::sheet::XDatabaseRange > createUnnamedDatabaseRangeObject(const ScRange &rRangeAddr) const
Creates and returns an unnamed database range on-the-fly in the Calc document.
WorkbookGlobals(const WorkbookGlobals &)=delete
ExtLinkBfrPtr mxExtLinks
All strings from shared strings substream.
SC_DLLPUBLIC void SetCalcConfig(const ScCalcConfig &rConfig)
Definition: document10.cxx:199
FilterBase & mrBaseFilter
Document model.
XmlFilterBase & getOoxFilter() const
Returns the base OOXML/BIFF12 filter object.
SC_DLLPUBLIC bool insert(ScRangeData *p, bool bReuseFreeIndex=true)
Insert object into set.
Definition: rangenam.cxx:814
ConnectionsBfrPtr mxConnections
All scenarios.
SC_DLLPUBLIC void SetPosLeft(SCCOL nCol)
Definition: document.hxx:861
DefinedNamesBuffer & getDefinedNames() const
Returns the defined names read from the workbook globals.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
::std::unique_ptr< ScenarioBuffer > ScenarioBfrPtr
sal_Int16 SCTAB
Definition: types.hxx:22
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
FormulaBuffer & getFormulaBuffer() const
ProgressBarPtr mxProgressBar
Base object for registration of this structure.
::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr
void SetStringRefSyntax(formula::FormulaGrammar::AddressConvention eConv)
Definition: calcconfig.cxx:165
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo