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/XIndexContainer.hpp>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <com/sun/star/sheet/XDatabaseRanges.hpp>
27 #include <com/sun/star/sheet/XSpreadsheet.hpp>
28 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
29 #include <com/sun/star/sheet/NamedRangeFlag.hpp>
30 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
31 #include <com/sun/star/document/XDocumentProperties.hpp>
32 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
33 #include <com/sun/star/document/XViewDataSupplier.hpp>
34 #include <o3tl/any.hxx>
35 #include <osl/thread.h>
36 #include <osl/diagnose.h>
39 #include <oox/ole/vbaproject.hxx>
40 #include <oox/token/properties.hxx>
41 #include <addressconverter.hxx>
42 #include <connectionsbuffer.hxx>
43 #include <defnamesbuffer.hxx>
44 #include <excelchartconverter.hxx>
45 #include <excelfilter.hxx>
46 #include <externallinkbuffer.hxx>
47 #include <formulaparser.hxx>
48 #include <pagesettings.hxx>
49 #include <pivotcachebuffer.hxx>
50 #include <pivottablebuffer.hxx>
51 #include <scenariobuffer.hxx>
52 #include <sharedstringsbuffer.hxx>
53 #include <stylesbuffer.hxx>
54 #include <tablebuffer.hxx>
55 #include <themebuffer.hxx>
56 #include <unitconverter.hxx>
57 #include <viewsettings.hxx>
58 #include <workbooksettings.hxx>
59 #include <worksheetbuffer.hxx>
60 #include <docsh.hxx>
61 #include <document.hxx>
62 #include <docuno.hxx>
63 #include <rangenam.hxx>
64 #include <tokenarray.hxx>
65 #include <tokenuno.hxx>
66 #include <dbdata.hxx>
67 #include <datauno.hxx>
68 #include <globalnames.hxx>
69 #include <documentimport.hxx>
70 #include <drwlayer.hxx>
71 #include <globstr.hrc>
72 #include <scresid.hxx>
73 
74 #include <formulabuffer.hxx>
75 #include <editutil.hxx>
76 #include <editeng/editstat.hxx>
77 #include <unotools/charclass.hxx>
79 
80 #include <memory>
81 
82 namespace oox::xls {
83 
84 using namespace ::com::sun::star::container;
85 using namespace ::com::sun::star::document;
86 using namespace ::com::sun::star::lang;
87 using namespace ::com::sun::star::sheet;
88 using namespace ::com::sun::star::style;
89 using namespace ::com::sun::star::table;
90 using namespace ::com::sun::star::uno;
91 using namespace ::com::sun::star::beans;
92 
93 using ::oox::core::FilterBase;
94 using ::oox::core::FragmentHandler;
95 using ::oox::core::XmlFilterBase;
96 
97 bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
98 {
99  // TODO: compare with collator
100  return rName1.compareToIgnoreAsciiCase(rName2 ) < 0;
101 }
102 
104 {
105 public:
106  // noncopyable ------------------------------------------------------------
107 
108  WorkbookGlobals(const WorkbookGlobals&) = delete;
109  const WorkbookGlobals& operator=(const WorkbookGlobals&) = delete;
110 
111  explicit WorkbookGlobals( ExcelFilter& rFilter );
113 
115  bool isValid() const { return mxDoc.is(); }
116 
117  // filter -----------------------------------------------------------------
118 
120  FilterBase& getBaseFilter() const { return mrBaseFilter; }
124  const StorageRef& getVbaProjectStorage() const { return mxVbaPrjStrg; }
126  sal_Int16 getCurrentSheetIndex() const { return mnCurrSheet; }
129 
131  void setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
133  void setCurrentSheetIndex( SCTAB nSheet ) { mnCurrSheet = nSheet; }
134 
135  // document model ---------------------------------------------------------
136 
138  {
139  return *mxEditEngine;
140  }
141 
143 
145 
147  const Reference< XSpreadsheetDocument >& getDocument() const { return mxDoc; }
149  Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const;
151  Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
153  ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags );
155  ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab );
157  Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr );
159  Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr );
161  ScDBData* findDatabaseRangeByIndex( sal_uInt16 nIndex );
163  Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
165  void useInternalChartDataTable( bool bInternal );
166 
167  // buffers ----------------------------------------------------------------
168 
177  ThemeBuffer& getTheme() const { return *mxTheme; }
179  StylesBuffer& getStyles() const { return *mxStyles; }
187  TableBuffer& getTables() const { return *mxTables; }
196 
197  // converters -------------------------------------------------------------
198 
211 
212  // OOXML/BIFF12 specific --------------------------------------------------
213 
215  XmlFilterBase& getOoxFilter() const { return *mpOoxFilter; }
216 
217  // BIFF2-BIFF8 specific ---------------------------------------------------
218 
220  rtl_TextEncoding getTextEncoding() const { return meTextEnc; }
221 
222 private:
224  void initialize();
226  void finalize();
227 
228 private:
229  typedef ::std::unique_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr;
230  typedef ::std::unique_ptr< FormulaBuffer > FormulaBufferPtr;
231  typedef ::std::unique_ptr< SegmentProgressBar > ProgressBarPtr;
232  typedef ::std::unique_ptr< WorkbookSettings > WorkbookSettPtr;
233  typedef ::std::unique_ptr< ViewSettings > ViewSettingsPtr;
234  typedef ::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr;
235  typedef ::std::shared_ptr< ThemeBuffer > ThemeBfrRef;
236  typedef ::std::unique_ptr< StylesBuffer > StylesBfrPtr;
237  typedef ::std::unique_ptr< SharedStringsBuffer > SharedStrBfrPtr;
238  typedef ::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr;
239  typedef ::std::unique_ptr< DefinedNamesBuffer > DefNamesBfrPtr;
240  typedef ::std::unique_ptr< TableBuffer > TableBfrPtr;
241  typedef ::std::unique_ptr< ScenarioBuffer > ScenarioBfrPtr;
242  typedef ::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr;
243  typedef ::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr;
244  typedef ::std::unique_ptr< PivotTableBuffer > PivotTableBfrPtr;
245  typedef ::std::unique_ptr< FormulaParser > FormulaParserPtr;
246  typedef ::std::unique_ptr< UnitConverter > UnitConvPtr;
247  typedef ::std::unique_ptr< AddressConverter > AddressConvPtr;
248  typedef ::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr;
249  typedef ::std::unique_ptr< PageSettingsConverter > PageSettConvPtr;
250 
251  OUString maCellStyles;
252  OUString maPageStyles;
253  OUString maCellStyleServ;
254  OUString maPageStyleServ;
255  Reference< XSpreadsheetDocument > mxDoc;
256  FilterBase& mrBaseFilter;
258  ProgressBarPtr mxProgressBar;
260  sal_Int16 mnCurrSheet;
262 
263  // buffers
264  FormulaBufferPtr mxFormulaBuffer;
265  WorkbookSettPtr mxWorkbookSettings;
266  ViewSettingsPtr mxViewSettings;
267  WorksheetBfrPtr mxWorksheets;
268  ThemeBfrRef mxTheme;
269  StylesBfrPtr mxStyles;
270  SharedStrBfrPtr mxSharedStrings;
271  ExtLinkBfrPtr mxExtLinks;
272  DefNamesBfrPtr mxDefNames;
273  TableBfrPtr mxTables;
274  ScenarioBfrPtr mxScenarios;
275  ConnectionsBfrPtr mxConnections;
276  PivotCacheBfrPtr mxPivotCaches;
277  PivotTableBfrPtr mxPivotTables;
278 
279  // converters
280  FormulaParserPtr mxFmlaParser;
281  UnitConvPtr mxUnitConverter;
282  AddressConvPtr mxAddrConverter;
283  ExcelChartConvPtr mxChartConverter;
284  PageSettConvPtr mxPageSettConverter;
285 
286  EditEngineDefaulterPtr mxEditEngine;
287 
288  // OOXML/BIFF12 specific
289  XmlFilterBase* mpOoxFilter;
290 
291  // BIFF2-BIFF8 specific
292  rtl_TextEncoding meTextEnc;
295  std::unique_ptr<ScDocumentImport> mxDocImport;
296 };
297 
299  mrBaseFilter( rFilter ),
300  mrExcelFilter( rFilter ),
301  mpOoxFilter( &rFilter ),
302  mpDoc(nullptr),
303  mpDocShell(nullptr)
304 {
305  // register at the filter, needed for virtual callbacks (even during construction)
307  initialize();
308 }
309 
311 {
312  finalize();
314 }
315 
317 {
318  return *mxDocImport;
319 }
320 
321 Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
322 {
323  Reference< XNameContainer > xStylesNC;
324  try
325  {
326  Reference< XStyleFamiliesSupplier > xFamiliesSup( mxDoc, UNO_QUERY_THROW );
327  Reference< XNameAccess > xFamiliesNA( xFamiliesSup->getStyleFamilies(), UNO_SET_THROW );
328  xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY );
329  }
330  catch( Exception& )
331  {
332  }
333  OSL_ENSURE( xStylesNC.is(), "WorkbookGlobals::getStyleFamily - cannot access style family" );
334  return xStylesNC;
335 }
336 
337 Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
338 {
339  Reference< XStyle > xStyle;
340  try
341  {
342  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
343  xStyle.set( xStylesNC->getByName( rStyleName ), UNO_QUERY );
344  }
345  catch( Exception& )
346  {
347  }
348  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
349  return xStyle;
350 }
351 
352 namespace {
353 
354 ScRangeData* lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
355 {
356  bool bDone = false;
358  if ( nUnoType & NamedRangeFlag::FILTER_CRITERIA ) nNewType |= ScRangeData::Type::Criteria;
359  if ( nUnoType & NamedRangeFlag::PRINT_AREA ) nNewType |= ScRangeData::Type::PrintArea;
360  if ( nUnoType & NamedRangeFlag::COLUMN_HEADER ) nNewType |= ScRangeData::Type::ColHeader;
361  if ( nUnoType & NamedRangeFlag::ROW_HEADER ) nNewType |= ScRangeData::Type::RowHeader;
362  ScTokenArray aTokenArray(&rDoc);
363  (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
364  ScRangeData* pNew = new ScRangeData( &rDoc, rName, aTokenArray, ScAddress(), nNewType );
365  pNew->GuessPosition();
366  if ( nIndex )
367  pNew->SetIndex( nIndex );
368  if ( pNames->insert(pNew) )
369  bDone = true;
370  if (!bDone)
371  throw RuntimeException();
372  return pNew;
373 }
374 
375 OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
376 {
377  OUString aNewName = rSuggestedName;
378  sal_Int32 nIndex = 0;
379  while(pRangeName->findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName)))
380  aNewName = rSuggestedName + OUStringChar('_') + OUString::number( nIndex++ );
381 
382  return aNewName;
383 }
384 
385 }
386 
388  OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags )
389 {
390  // create the name and insert it into the Calc document
391  ScRangeData* pScRangeData = nullptr;
392  if( !orName.isEmpty() )
393  {
394  ScDocument& rDoc = getScDocument();
395  ScRangeName* pNames = rDoc.GetRangeName();
396  // find an unused name
397  orName = findUnusedName( pNames, orName );
398  // create the named range
399  pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
400  }
401  return pScRangeData;
402 }
403 
405  OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab )
406 {
407  // create the name and insert it into the Calc document
408  ScRangeData* pScRangeData = nullptr;
409  if( !orName.isEmpty() )
410  {
411  ScDocument& rDoc = getScDocument();
412  ScRangeName* pNames = rDoc.GetRangeName( nTab );
413  if(!pNames)
414  throw RuntimeException("invalid sheet index used");
415  // find an unused name
416  orName = findUnusedName( pNames, orName );
417  // create the named range
418  pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
419  }
420  return pScRangeData;
421 }
422 
423 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr )
424 {
425  // validate cell range
426  ScRange aDestRange = rRangeAddr;
427  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
428 
429  // create database range and insert it into the Calc document
430  Reference< XDatabaseRange > xDatabaseRange;
431  if( bValidRange && !orName.isEmpty() ) try
432  {
433  // find an unused name
434  PropertySet aDocProps( mxDoc );
435  Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
436  orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
437  // create the database range
438  CellRangeAddress aApiRange( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row(),
439  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() );
440  xDatabaseRanges->addNewByName( orName, aApiRange );
441  xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
442  }
443  catch( Exception& )
444  {
445  }
446  OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
447  return xDatabaseRange;
448 }
449 
450 Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr )
451 {
452  // validate cell range
453  ScRange aDestRange = rRangeAddr;
454  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
455 
456  // create database range and insert it into the Calc document
457  Reference< XDatabaseRange > xDatabaseRange;
458  if( bValidRange ) try
459  {
460  ScDocument& rDoc = getScDocument();
461  if( rDoc.GetTableCount() <= aDestRange.aStart.Tab() )
462  throw css::lang::IndexOutOfBoundsException();
463  std::unique_ptr<ScDBData> pNewDBData(new ScDBData( STR_DB_LOCAL_NONAME, aDestRange.aStart.Tab(),
464  aDestRange.aStart.Col(), aDestRange.aStart.Row(),
465  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() ));
466  rDoc.SetAnonymousDBData( aDestRange.aStart.Tab() , std::move(pNewDBData) );
467  ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
468  xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aDestRange.aStart.Tab()));
469  }
470  catch( Exception& )
471  {
472  }
473  OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
474  return xDatabaseRange;
475 }
476 
478 {
479  ScDBCollection* pDBCollection = getScDocument().GetDBCollection();
480  if (!pDBCollection)
481  return nullptr;
482  return pDBCollection->getNamedDBs().findByIndex( nIndex );
483 }
484 
485 Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
486 {
487  Reference< XStyle > xStyle;
488  try
489  {
490  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
491  xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
492  orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ) );
493  }
494  catch( Exception& )
495  {
496  }
497  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
498  return xStyle;
499 }
500 
502 {
503  if( bInternal )
505  else
506  mxChartConverter.reset( new ExcelChartConverter( *this ) );
507 }
508 
509 // BIFF specific --------------------------------------------------------------
510 
511 // private --------------------------------------------------------------------
512 
514 {
515  maCellStyles = "CellStyles";
516  maPageStyles = "PageStyles";
517  maCellStyleServ = "com.sun.star.style.CellStyle";
518  maPageStyleServ = "com.sun.star.style.PageStyle";
519  mnCurrSheet = -1;
520  mbGeneratorKnownGood = false;
521  meTextEnc = osl_getThreadTextEncoding();
522 
523  // the spreadsheet document
524  mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
525  OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
526 
527  if (mxDoc)
528  {
529  ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
530  if (pModel)
531  mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
532  if (mpDocShell)
534  }
535 
536  if (!mpDoc)
537  throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
538 
539  Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
540  Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
541  const OUString aGenerator( xDocProps->getGenerator());
542 
543  if (aGenerator.startsWithIgnoreAsciiCase("Microsoft"))
544  {
545  mbGeneratorKnownGood = true;
546  ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
548  mpDoc->SetCalcConfig(aCalcConfig);
549  }
550  else if (aGenerator.startsWithIgnoreAsciiCase("LibreOffice"))
551  {
552  mbGeneratorKnownGood = true;
553  }
554 
555  mxDocImport.reset(new ScDocumentImport(*mpDoc));
556 
557  mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
558  mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
559  mxViewSettings.reset( new ViewSettings( *this ) );
560  mxWorksheets.reset( new WorksheetBuffer( *this ) );
561  mxTheme = std::make_shared<ThemeBuffer>( *this );
562  mxStyles.reset( new StylesBuffer( *this ) );
563  mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
564  mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
565  mxDefNames.reset( new DefinedNamesBuffer( *this ) );
566  mxTables.reset( new TableBuffer( *this ) );
567  mxScenarios.reset( new ScenarioBuffer( *this ) );
568  mxConnections.reset( new ConnectionsBuffer( *this ) );
569  mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
570  mxPivotTables.reset( new PivotTableBuffer( *this ) );
571 
572  mxUnitConverter.reset( new UnitConverter( *this ) );
573  mxAddrConverter.reset( new AddressConverter( *this ) );
574  mxChartConverter.reset( new ExcelChartConverter( *this ) );
575  mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
576 
577  // initialise edit engine
578  ScDocument& rDoc = getScDocument();
579  mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
580  mxEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
581  mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
582  mxEditEngine->SetUpdateMode( false );
583  mxEditEngine->EnableUndo( false );
584  mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
585 
586  // set some document properties needed during import
587  if( mrBaseFilter.isImportFilter() )
588  {
589  // enable editing read-only documents (e.g. from read-only files)
591  // #i76026# disable Undo while loading the document
592  mpDoc->EnableUndo(false);
593  // #i79826# disable calculating automatic row height while loading the document
595  // disable automatic update of linked sheets and DDE links
596  mpDoc->EnableExecuteLink(false);
597 
598  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_LOAD_DOC) ) );
600 
601  //prevent unnecessary broadcasts and "half way listeners" as
602  //is done in ScDocShell::BeforeXMLLoading() for ods
604  }
605  else if( mrBaseFilter.isExportFilter() )
606  {
607  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_SAVE_DOC) ) );
608  }
609 }
610 
612 {
613  // set some document properties needed after import
614  if( mrBaseFilter.isImportFilter() )
615  {
616  // #i74668# do not insert default sheets
617  mpDocShell->SetEmpty(false);
618  // enable automatic update of linked sheets and DDE links
619  mpDoc->EnableExecuteLink(true);
620  // #i79826# enable updating automatic row height after loading the document
622 
623  // #i76026# enable Undo after loading the document
624  mpDoc->EnableUndo(true);
625 
626  // disable editing read-only documents (e.g. from read-only files)
627  mpDoc->EnableChangeReadOnly(false);
628  // #111099# open forms in alive mode (has no effect, if no controls in document)
629  ScDrawLayer* pModel = mpDoc->GetDrawLayer();
630  if (pModel)
631  pModel->SetOpenInDesignMode(false);
632 
633  }
634 }
635 
636 
638 {
639 }
640 
642 {
643  WorkbookGlobalsRef xBookGlob = std::make_shared<WorkbookGlobals>( rFilter );
644  if( !xBookGlob->isValid() )
645  xBookGlob.reset();
646  return xBookGlob;
647 }
648 
649 // filter ---------------------------------------------------------------------
650 
651 FilterBase& WorkbookHelper::getBaseFilter() const
652 {
653  return mrBookGlob.getBaseFilter();
654 }
655 
657 {
658  return mrBookGlob.getProgressBar();
659 }
660 
662 {
664 }
665 
667 {
669 }
670 
672 {
673  mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
674 }
675 
677 {
679 }
680 
682 {
683  // workbook settings, document and sheet view settings
686 
687  // Import the VBA project (after finalizing workbook settings which
688  // contains the workbook code name). Do it before processing formulas in
689  // order to correctly resolve VBA custom function names.
691  if( xVbaPrjStrg && xVbaPrjStrg->isStorage() )
692  getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
693 
694  // need to import formulas before scenarios
696 
697  // Insert all pivot tables. Must be done after loading all sheets and
698  // formulas, because data pilots expect existing source data on
699  // creation.
701 
702  /* Insert scenarios after all sheet processing is done, because new hidden
703  sheets are created for scenarios which would confuse code that relies
704  on certain sheet indexes. Must be done after pivot tables too. */
706 
707  /* Set 'Default' page style to automatic page numbering (default is manual
708  number 1). Otherwise hidden sheets (e.g. for scenarios) which have
709  'Default' page style will break automatic page numbering for following
710  sheets. Automatic numbering is set by passing the value 0. */
711  PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
712  aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
713 
714  // Has any string ref syntax been imported?
715  // If not, we need to take action
716  ScCalcConfig aCalcConfig = getScDocument().GetCalcConfig();
717 
718  if ( !aCalcConfig.mbHasStringRefSyntax )
719  {
721  getScDocument().SetCalcConfig(aCalcConfig);
722  }
723 
724  // set selected sheet and positionleft/positiontop for OLE objects
725  Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY);
726  if (xViewDataSupplier.is())
727  {
728  Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
729  if (xIndexAccess.is() && xIndexAccess->getCount() > 0)
730  {
731  Sequence< PropertyValue > aSeq;
732  if (xIndexAccess->getByIndex(0) >>= aSeq)
733  {
734  OUString sTabName;
735  Reference< XNameAccess > xSheetsNC;
736  for (const auto& rProp : std::as_const(aSeq))
737  {
738  OUString sName(rProp.Name);
739  if (sName == SC_ACTIVETABLE)
740  {
741  if(rProp.Value >>= sTabName)
742  {
743  SCTAB nTab(0);
744  if (getScDocument().GetTable(sTabName, nTab))
746  }
747  }
748  else if (sName == SC_TABLES)
749  {
750  rProp.Value >>= xSheetsNC;
751  }
752  }
753  if (xSheetsNC.is() && xSheetsNC->hasByName(sTabName))
754  {
755  Sequence<PropertyValue> aProperties;
756  Any aAny = xSheetsNC->getByName(sTabName);
757  if ( aAny >>= aProperties )
758  {
759  for (const auto& rProp : std::as_const(aProperties))
760  {
761  OUString sName(rProp.Name);
762  if (sName == SC_POSITIONLEFT)
763  {
764  SCCOL nPosLeft = *o3tl::doAccess<SCCOL>(rProp.Value);
765  getScDocument().SetPosLeft(nPosLeft);
766  }
767  else if (sName == SC_POSITIONTOP)
768  {
769  SCROW nPosTop = *o3tl::doAccess<SCROW>(rProp.Value);
770  getScDocument().SetPosTop(nPosTop);
771  }
772  }
773  }
774  }
775  }
776  }
777  }
778 }
779 
780 // document model -------------------------------------------------------------
781 
783 {
784  return mrBookGlob.getScDocument();
785 }
786 
788 {
789  return mrBookGlob.getScDocument();
790 }
791 
793 {
794  return mrBookGlob.getDocImport();
795 }
796 
798 {
799  return mrBookGlob.getDocImport();
800 }
801 
803 {
804  return mrBookGlob.getEditEngine();
805 }
806 
807 const Reference< XSpreadsheetDocument > & WorkbookHelper::getDocument() const
808 {
809  return mrBookGlob.getDocument();
810 }
811 
812 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
813 {
814  Reference< XSpreadsheet > xSheet;
815  try
816  {
817  Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
818  xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
819  }
820  catch( Exception& )
821  {
822  }
823  return xSheet;
824 }
825 
826 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
827 {
828  Reference< XSpreadsheet > xSheet;
829  try
830  {
831  Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
832  xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
833  }
834  catch( Exception& )
835  {
836  }
837  return xSheet;
838 }
839 
840 Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
841 {
842  Reference< XCellRange > xRange;
843  try
844  {
845  Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
846  xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
847  }
848  catch( Exception& )
849  {
850  }
851  return xRange;
852 }
853 
854 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
855 {
856  return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );
857 }
858 
859 Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
860 {
861  return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
862 }
863 
864 ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
865 {
866  return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags );
867 }
868 
869 ScRangeData* WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
870 {
871  return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
872 }
873 
874 Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr ) const
875 {
876  return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
877 }
878 
879 Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr ) const
880 {
881  return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
882 }
883 
885 {
886  return mrBookGlob.findDatabaseRangeByIndex( nIndex );
887 }
888 
889 Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
890 {
891  return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
892 }
893 
894 // buffers --------------------------------------------------------------------
895 
897 {
898  return mrBookGlob.getFormulaBuffer();
899 }
900 
902 {
904 }
905 
907 {
908  return mrBookGlob.getViewSettings();
909 }
910 
912 {
913  return mrBookGlob.getWorksheets();
914 }
915 
917 {
918  return mrBookGlob.getTheme();
919 }
920 
922 {
923  return mrBookGlob.getStyles();
924 }
925 
927 {
928  return mrBookGlob.getSharedStrings();
929 }
930 
932 {
933  return mrBookGlob.getExternalLinks();
934 }
935 
937 {
938  return mrBookGlob.getDefinedNames();
939 }
940 
942 {
943  return mrBookGlob.getTables();
944 }
945 
947 {
948  return mrBookGlob.getScenarios();
949 }
950 
952 {
953  return mrBookGlob.getConnections();
954 }
955 
957 {
958  return mrBookGlob.getPivotCaches();
959 }
960 
962 {
963  return mrBookGlob.getPivotTables();
964 }
965 
966 // converters -----------------------------------------------------------------
967 
969 {
970  return mrBookGlob.getFormulaParser();
971 }
972 
974 {
976 }
977 
979 {
980  return mrBookGlob.getUnitConverter();
981 }
982 
984 {
986 }
987 
989 {
990  return mrBookGlob.getChartConverter();
991 }
992 
994 {
996 }
997 
999 {
1001 }
1002 
1003 // OOXML/BIFF12 specific ------------------------------------------------------
1004 
1005 XmlFilterBase& WorkbookHelper::getOoxFilter() const
1006 {
1007  return mrBookGlob.getOoxFilter();
1008 }
1009 
1011 {
1012  return getOoxFilter().importFragment( rxHandler );
1013 }
1014 
1016 {
1017  return getOoxFilter().importFragment(rxHandler, rParser);
1018 }
1019 
1020 // BIFF specific --------------------------------------------------------------
1021 
1022 rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1023 {
1024  return mrBookGlob.getTextEncoding();
1025 }
1026 
1027 } // namespace oox
1028 
1029 /* 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:816
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
ScAddress aStart
Definition: address.hxx:500
ScDocumentImport & getDocImport()
ScDBData * findByIndex(sal_uInt16 nIndex)
Definition: dbdata.cxx:1138
const StorageRef & getVbaProjectStorage() const
Returns the VBA project storage.
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
SCROW Row() const
Definition: address.hxx:262
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:319
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:13
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.
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:501
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.
ScRangeData * createLocalNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab)
Creates and returns a defined name on the-fly in the correct Calc sheet.
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:314
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:86
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:271
SC_DLLPUBLIC void GuessPosition()
Definition: rangenam.cxx:208
ScRangeData * createNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags)
Creates and returns a defined name on-the-fly in the Calc document.
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:2133
::std::unique_ptr< StylesBuffer > StylesBfrPtr
bool operator()(const OUString &rName1, const OUString &rName2) const
::std::unique_ptr< FormulaBuffer > FormulaBufferPtr
UnitConvPtr mxUnitConverter
Import formula parser.
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:860
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
ScRangeData * createLocalNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab) const
Creates and returns a defined name on-the-fly in the sheet.
FormulaParser * createFormulaParser()
Returns an unshared import formula parser.
void finalizeWorkbookImport()
Final conversion after importing the workbook.
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1059
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:682
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:1539
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:22
::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:1541
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:455
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:449
ScenarioBfrPtr mxScenarios
All tables (database ranges).
SC_DLLPUBLIC void UnlockAdjustHeight()
Definition: document.cxx:1815
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.
OUString ScResId(const char *pId)
Definition: scdll.cxx:95
::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:348
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex)
Finds the (already existing) database range of the given formula token index.
ScRangeData * createNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags) const
Creates and returns a defined name on-the-fly in the Calc document.
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:864
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:53
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
SCCOL Col() const
Definition: address.hxx:267
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
Configuration options for formula interpreter.
Definition: calcconfig.hxx:43
FormulaBuffer & getFormulaBuffer() const
static WorkbookGlobalsRef constructGlobals(ExcelFilter &rFilter)
sal_Int32 SCROW
Definition: types.hxx:18
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:116
::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:1536
TableBfrPtr mxTables
All defined names.
Converter for cell addresses and cell ranges for OOXML and BIFF filters.
::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr
OUString maPageStyleServ
Service name for a cell style.
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2523
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:1016
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:444
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:1058
::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:6473
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:200
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:810
ConnectionsBfrPtr mxConnections
All scenarios.
SC_DLLPUBLIC void SetPosLeft(SCCOL nCol)
Definition: document.hxx:862
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:23
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:170
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo