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  ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags );
154  ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab );
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 ScRangeData* lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
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  if ( pNames->insert(pNew) )
368  bDone = true;
369  if (!bDone)
370  throw RuntimeException();
371  return pNew;
372 }
373 
374 OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
375 {
376  OUString aNewName = rSuggestedName;
377  sal_Int32 nIndex = 0;
378  while(pRangeName->findByUpperName(ScGlobal::getCharClassPtr()->uppercase(aNewName)))
379  aNewName = rSuggestedName + OUStringChar('_') + OUString::number( nIndex++ );
380 
381  return aNewName;
382 }
383 
384 }
385 
387  OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags )
388 {
389  // create the name and insert it into the Calc document
390  ScRangeData* pScRangeData = nullptr;
391  if( !orName.isEmpty() )
392  {
393  ScDocument& rDoc = getScDocument();
394  ScRangeName* pNames = rDoc.GetRangeName();
395  // find an unused name
396  orName = findUnusedName( pNames, orName );
397  // create the named range
398  pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
399  }
400  return pScRangeData;
401 }
402 
404  OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab )
405 {
406  // create the name and insert it into the Calc document
407  ScRangeData* pScRangeData = nullptr;
408  if( !orName.isEmpty() )
409  {
410  ScDocument& rDoc = getScDocument();
411  ScRangeName* pNames = rDoc.GetRangeName( nTab );
412  if(!pNames)
413  throw RuntimeException("invalid sheet index used");
414  // find an unused name
415  orName = findUnusedName( pNames, orName );
416  // create the named range
417  pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
418  }
419  return pScRangeData;
420 }
421 
422 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr )
423 {
424  // validate cell range
425  ScRange aDestRange = rRangeAddr;
426  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
427 
428  // create database range and insert it into the Calc document
429  Reference< XDatabaseRange > xDatabaseRange;
430  if( bValidRange && !orName.isEmpty() ) try
431  {
432  // find an unused name
433  PropertySet aDocProps( mxDoc );
434  Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
435  orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
436  // create the database range
437  CellRangeAddress aApiRange( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row(),
438  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() );
439  xDatabaseRanges->addNewByName( orName, aApiRange );
440  xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
441  }
442  catch( Exception& )
443  {
444  }
445  OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
446  return xDatabaseRange;
447 }
448 
449 Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr )
450 {
451  // validate cell range
452  ScRange aDestRange = rRangeAddr;
453  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
454 
455  // create database range and insert it into the Calc document
456  Reference< XDatabaseRange > xDatabaseRange;
457  if( bValidRange ) try
458  {
459  ScDocument& rDoc = getScDocument();
460  if( rDoc.GetTableCount() <= aDestRange.aStart.Tab() )
461  throw css::lang::IndexOutOfBoundsException();
462  std::unique_ptr<ScDBData> pNewDBData(new ScDBData( STR_DB_LOCAL_NONAME, aDestRange.aStart.Tab(),
463  aDestRange.aStart.Col(), aDestRange.aStart.Row(),
464  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() ));
465  rDoc.SetAnonymousDBData( aDestRange.aStart.Tab() , std::move(pNewDBData) );
466  ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
467  xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aDestRange.aStart.Tab()));
468  }
469  catch( Exception& )
470  {
471  }
472  OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
473  return xDatabaseRange;
474 }
475 
477 {
478  ScDBCollection* pDBCollection = getScDocument().GetDBCollection();
479  if (!pDBCollection)
480  return nullptr;
481  return pDBCollection->getNamedDBs().findByIndex( nIndex );
482 }
483 
484 Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
485 {
486  Reference< XStyle > xStyle;
487  try
488  {
489  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
490  xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
491  orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ) );
492  }
493  catch( Exception& )
494  {
495  }
496  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
497  return xStyle;
498 }
499 
501 {
502  if( bInternal )
504  else
505  mxChartConverter.reset( new ExcelChartConverter( *this ) );
506 }
507 
508 // BIFF specific --------------------------------------------------------------
509 
510 // private --------------------------------------------------------------------
511 
513 {
514  maCellStyles = "CellStyles";
515  maPageStyles = "PageStyles";
516  maCellStyleServ = "com.sun.star.style.CellStyle";
517  maPageStyleServ = "com.sun.star.style.PageStyle";
518  mnCurrSheet = -1;
519  mbGeneratorKnownGood = false;
520  meTextEnc = osl_getThreadTextEncoding();
521 
522  // the spreadsheet document
523  mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
524  OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
525 
526  if (mxDoc)
527  {
528  ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
529  if (pModel)
530  mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
531  if (mpDocShell)
533  }
534 
535  if (!mpDoc)
536  throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
537 
538  Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
539  Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
540  const OUString aGenerator( xDocProps->getGenerator());
541 
542  if (aGenerator.startsWithIgnoreAsciiCase("Microsoft"))
543  {
544  mbGeneratorKnownGood = true;
545  ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
547  mpDoc->SetCalcConfig(aCalcConfig);
548  }
549  else if (aGenerator.startsWithIgnoreAsciiCase("LibreOffice"))
550  {
551  mbGeneratorKnownGood = true;
552  }
553 
554  mxDocImport.reset(new ScDocumentImport(*mpDoc));
555 
556  mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
557  mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
558  mxViewSettings.reset( new ViewSettings( *this ) );
559  mxWorksheets.reset( new WorksheetBuffer( *this ) );
560  mxTheme = std::make_shared<ThemeBuffer>( *this );
561  mxStyles.reset( new StylesBuffer( *this ) );
562  mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
563  mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
564  mxDefNames.reset( new DefinedNamesBuffer( *this ) );
565  mxTables.reset( new TableBuffer( *this ) );
566  mxScenarios.reset( new ScenarioBuffer( *this ) );
567  mxConnections.reset( new ConnectionsBuffer( *this ) );
568  mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
569  mxPivotTables.reset( new PivotTableBuffer( *this ) );
570 
571  mxUnitConverter.reset( new UnitConverter( *this ) );
572  mxAddrConverter.reset( new AddressConverter( *this ) );
573  mxChartConverter.reset( new ExcelChartConverter( *this ) );
574  mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
575 
576  // initialise edit engine
577  ScDocument& rDoc = getScDocument();
578  mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
579  mxEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
580  mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
581  mxEditEngine->SetUpdateMode( false );
582  mxEditEngine->EnableUndo( false );
583  mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
584 
585  // set some document properties needed during import
586  if( mrBaseFilter.isImportFilter() )
587  {
588  // enable editing read-only documents (e.g. from read-only files)
590  // #i76026# disable Undo while loading the document
591  mpDoc->EnableUndo(false);
592  // #i79826# disable calculating automatic row height while loading the document
594  // disable automatic update of linked sheets and DDE links
595  mpDoc->EnableExecuteLink(false);
596 
597  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_LOAD_DOC) ) );
599 
600  //prevent unnecessary broadcasts and "half way listeners" as
601  //is done in ScDocShell::BeforeXMLLoading() for ods
603  }
604  else if( mrBaseFilter.isExportFilter() )
605  {
606  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_SAVE_DOC) ) );
607  }
608 }
609 
611 {
612  // set some document properties needed after import
613  if( !mrBaseFilter.isImportFilter() )
614  return;
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 
636 {
637 }
638 
640 {
641  WorkbookGlobalsRef xBookGlob = std::make_shared<WorkbookGlobals>( rFilter );
642  if( !xBookGlob->isValid() )
643  xBookGlob.reset();
644  return xBookGlob;
645 }
646 
647 // filter ---------------------------------------------------------------------
648 
649 FilterBase& WorkbookHelper::getBaseFilter() const
650 {
651  return mrBookGlob.getBaseFilter();
652 }
653 
655 {
656  return mrBookGlob.getProgressBar();
657 }
658 
660 {
662 }
663 
665 {
667 }
668 
670 {
671  mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
672 }
673 
675 {
677 }
678 
680 {
681  // workbook settings, document and sheet view settings
684 
685  // Import the VBA project (after finalizing workbook settings which
686  // contains the workbook code name). Do it before processing formulas in
687  // order to correctly resolve VBA custom function names.
689  if( xVbaPrjStrg && xVbaPrjStrg->isStorage() )
690  getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
691 
692  // need to import formulas before scenarios
694 
695  // Insert all pivot tables. Must be done after loading all sheets and
696  // formulas, because data pilots expect existing source data on
697  // creation.
699 
700  /* Insert scenarios after all sheet processing is done, because new hidden
701  sheets are created for scenarios which would confuse code that relies
702  on certain sheet indexes. Must be done after pivot tables too. */
704 
705  /* Set 'Default' page style to automatic page numbering (default is manual
706  number 1). Otherwise hidden sheets (e.g. for scenarios) which have
707  'Default' page style will break automatic page numbering for following
708  sheets. Automatic numbering is set by passing the value 0. */
709  PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
710  aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
711 
712  // Has any string ref syntax been imported?
713  // If not, we need to take action
714  ScCalcConfig aCalcConfig = getScDocument().GetCalcConfig();
715 
716  if ( !aCalcConfig.mbHasStringRefSyntax )
717  {
719  getScDocument().SetCalcConfig(aCalcConfig);
720  }
721 
722  // set selected sheet and positionleft/positiontop for OLE objects
723  Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY);
724  if (!xViewDataSupplier.is())
725  return;
726 
727  Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
728  if (!(xIndexAccess.is() && xIndexAccess->getCount() > 0))
729  return;
730 
731  Sequence< PropertyValue > aSeq;
732  if (!(xIndexAccess->getByIndex(0) >>= aSeq))
733  return;
734 
735  OUString sTabName;
736  Reference< XNameAccess > xSheetsNC;
737  for (const auto& rProp : std::as_const(aSeq))
738  {
739  OUString sName(rProp.Name);
740  if (sName == SC_ACTIVETABLE)
741  {
742  if(rProp.Value >>= sTabName)
743  {
744  SCTAB nTab(0);
745  if (getScDocument().GetTable(sTabName, nTab))
747  }
748  }
749  else if (sName == SC_TABLES)
750  {
751  rProp.Value >>= xSheetsNC;
752  }
753  }
754  if (!(xSheetsNC.is() && xSheetsNC->hasByName(sTabName)))
755  return;
756 
757  Sequence<PropertyValue> aProperties;
758  Any aAny = xSheetsNC->getByName(sTabName);
759  if ( !(aAny >>= aProperties) )
760  return;
761 
762  for (const auto& rProp : std::as_const(aProperties))
763  {
764  OUString sName(rProp.Name);
765  if (sName == SC_POSITIONLEFT)
766  {
767  SCCOL nPosLeft = *o3tl::doAccess<SCCOL>(rProp.Value);
768  getScDocument().SetPosLeft(nPosLeft);
769  }
770  else if (sName == SC_POSITIONTOP)
771  {
772  SCROW nPosTop = *o3tl::doAccess<SCROW>(rProp.Value);
773  getScDocument().SetPosTop(nPosTop);
774  }
775  }
776 }
777 
778 // document model -------------------------------------------------------------
779 
781 {
782  return mrBookGlob.getScDocument();
783 }
784 
786 {
787  return mrBookGlob.getScDocument();
788 }
789 
791 {
792  return mrBookGlob.getDocImport();
793 }
794 
796 {
797  return mrBookGlob.getDocImport();
798 }
799 
801 {
802  return mrBookGlob.getEditEngine();
803 }
804 
805 const Reference< XSpreadsheetDocument > & WorkbookHelper::getDocument() const
806 {
807  return mrBookGlob.getDocument();
808 }
809 
810 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
811 {
812  Reference< XSpreadsheet > xSheet;
813  try
814  {
815  Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
816  xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
817  }
818  catch( Exception& )
819  {
820  }
821  return xSheet;
822 }
823 
824 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
825 {
826  Reference< XSpreadsheet > xSheet;
827  try
828  {
829  Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
830  xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
831  }
832  catch( Exception& )
833  {
834  }
835  return xSheet;
836 }
837 
838 Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
839 {
840  Reference< XCellRange > xRange;
841  try
842  {
843  Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
844  xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
845  }
846  catch( Exception& )
847  {
848  }
849  return xRange;
850 }
851 
852 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
853 {
854  return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );
855 }
856 
857 Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
858 {
859  return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
860 }
861 
862 ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
863 {
864  return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags );
865 }
866 
867 ScRangeData* WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
868 {
869  return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
870 }
871 
872 Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr ) const
873 {
874  return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
875 }
876 
877 Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr ) const
878 {
879  return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
880 }
881 
883 {
884  return mrBookGlob.findDatabaseRangeByIndex( nIndex );
885 }
886 
887 Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
888 {
889  return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
890 }
891 
892 // buffers --------------------------------------------------------------------
893 
895 {
896  return mrBookGlob.getFormulaBuffer();
897 }
898 
900 {
902 }
903 
905 {
906  return mrBookGlob.getViewSettings();
907 }
908 
910 {
911  return mrBookGlob.getWorksheets();
912 }
913 
915 {
916  return mrBookGlob.getTheme();
917 }
918 
920 {
921  return mrBookGlob.getStyles();
922 }
923 
925 {
926  return mrBookGlob.getSharedStrings();
927 }
928 
930 {
931  return mrBookGlob.getExternalLinks();
932 }
933 
935 {
936  return mrBookGlob.getDefinedNames();
937 }
938 
940 {
941  return mrBookGlob.getTables();
942 }
943 
945 {
946  return mrBookGlob.getScenarios();
947 }
948 
950 {
951  return mrBookGlob.getConnections();
952 }
953 
955 {
956  return mrBookGlob.getPivotCaches();
957 }
958 
960 {
961  return mrBookGlob.getPivotTables();
962 }
963 
964 // converters -----------------------------------------------------------------
965 
967 {
968  return mrBookGlob.getFormulaParser();
969 }
970 
972 {
974 }
975 
977 {
978  return mrBookGlob.getUnitConverter();
979 }
980 
982 {
984 }
985 
987 {
988  return mrBookGlob.getChartConverter();
989 }
990 
992 {
994 }
995 
997 {
999 }
1000 
1001 // OOXML/BIFF12 specific ------------------------------------------------------
1002 
1003 XmlFilterBase& WorkbookHelper::getOoxFilter() const
1004 {
1005  return mrBookGlob.getOoxFilter();
1006 }
1007 
1009 {
1010  return getOoxFilter().importFragment( rxHandler );
1011 }
1012 
1014 {
1015  return getOoxFilter().importFragment(rxHandler, rParser);
1016 }
1017 
1018 // BIFF specific --------------------------------------------------------------
1019 
1020 rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1021 {
1022  return mrBookGlob.getTextEncoding();
1023 }
1024 
1025 } // namespace oox
1026 
1027 /* 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:813
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:1140
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.
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.
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: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
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:2136
::std::unique_ptr< StylesBuffer > StylesBfrPtr
::std::unique_ptr< FormulaBuffer > FormulaBufferPtr
UnitConvPtr mxUnitConverter
Import formula parser.
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:858
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:1057
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:679
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:1541
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:1543
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:450
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:1807
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:89
::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.
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:862
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
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
::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:1538
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:2526
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:1009
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:314
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:1056
::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:6457
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:807
ConnectionsBfrPtr mxConnections
All scenarios.
SC_DLLPUBLIC void SetPosLeft(SCCOL nCol)
Definition: document.hxx:860
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