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>
77 #include <o3tl/string_view.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()( std::u16string_view rName1, std::u16string_view rName2 ) const
98 {
99  // TODO: compare with collator
100  return o3tl::compareToIgnoreAsciiCase(rName1, 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  WorkbookHelper::RangeDataRet createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden );
155  WorkbookHelper::RangeDataRet createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden );
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 WorkbookHelper::RangeDataRet lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType, bool bHidden )
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  // create but not insert hidden FILTER_CRITERIA named ranges to ScRangeName
369  if ( bHidden && nNewType == ScRangeData::Type::Criteria )
370  {
371  return WorkbookHelper::RangeDataRet(pNew, true);
372  }
373  if ( pNames->insert(pNew) )
374  bDone = true;
375  if (!bDone)
376  {
377  delete pNew;
378  throw RuntimeException();
379  }
380  return WorkbookHelper::RangeDataRet(pNew, false);
381 }
382 
383 OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
384 {
385  OUString aNewName = rSuggestedName;
386  sal_Int32 nIndex = 0;
387  while(pRangeName->findByUpperName(ScGlobal::getCharClass().uppercase(aNewName)))
388  aNewName = rSuggestedName + OUStringChar('_') + OUString::number( nIndex++ );
389 
390  return aNewName;
391 }
392 
393 }
394 
396  OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden )
397 {
398  // create the name and insert it into the Calc document
399  WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
400  if( !orName.isEmpty() )
401  {
402  ScDocument& rDoc = getScDocument();
403  ScRangeName* pNames = rDoc.GetRangeName();
404  // find an unused name
405  orName = findUnusedName( pNames, orName );
406  // create the named range
407  aScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags, bHidden );
408  }
409  return aScRangeData;
410 }
411 
413  OUString& orName, const Sequence< FormulaToken >& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden )
414 {
415  // create the name and insert it into the Calc document
416  WorkbookHelper::RangeDataRet aScRangeData(nullptr, false);
417  if( !orName.isEmpty() )
418  {
419  ScDocument& rDoc = getScDocument();
420  ScRangeName* pNames = rDoc.GetRangeName( nTab );
421  if(!pNames)
422  throw RuntimeException("invalid sheet index used");
423  // find an unused name
424  orName = findUnusedName( pNames, orName );
425  // create the named range
426  aScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags, bHidden );
427  }
428  return aScRangeData;
429 }
430 
431 Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr )
432 {
433  // validate cell range
434  ScRange aDestRange = rRangeAddr;
435  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
436 
437  // create database range and insert it into the Calc document
438  Reference< XDatabaseRange > xDatabaseRange;
439  if( bValidRange && !orName.isEmpty() ) try
440  {
441  // find an unused name
442  PropertySet aDocProps( mxDoc );
443  Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
444  orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
445  // create the database range
446  CellRangeAddress aApiRange( aDestRange.aStart.Tab(), aDestRange.aStart.Col(), aDestRange.aStart.Row(),
447  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() );
448  xDatabaseRanges->addNewByName( orName, aApiRange );
449  xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
450  }
451  catch( Exception& )
452  {
453  }
454  OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
455  return xDatabaseRange;
456 }
457 
458 Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr )
459 {
460  // validate cell range
461  ScRange aDestRange = rRangeAddr;
462  bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
463 
464  // create database range and insert it into the Calc document
465  Reference< XDatabaseRange > xDatabaseRange;
466  if( bValidRange ) try
467  {
468  ScDocument& rDoc = getScDocument();
469  if( rDoc.GetTableCount() <= aDestRange.aStart.Tab() )
470  throw css::lang::IndexOutOfBoundsException();
471  std::unique_ptr<ScDBData> pNewDBData(new ScDBData( STR_DB_LOCAL_NONAME, aDestRange.aStart.Tab(),
472  aDestRange.aStart.Col(), aDestRange.aStart.Row(),
473  aDestRange.aEnd.Col(), aDestRange.aEnd.Row() ));
474  rDoc.SetAnonymousDBData( aDestRange.aStart.Tab() , std::move(pNewDBData) );
475  ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
476  xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aDestRange.aStart.Tab()));
477  }
478  catch( Exception& )
479  {
480  }
481  OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
482  return xDatabaseRange;
483 }
484 
486 {
487  ScDBCollection* pDBCollection = getScDocument().GetDBCollection();
488  if (!pDBCollection)
489  return nullptr;
490  return pDBCollection->getNamedDBs().findByIndex( nIndex );
491 }
492 
493 Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
494 {
495  Reference< XStyle > xStyle;
496  try
497  {
498  Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
499  xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
500  orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ) );
501  }
502  catch( Exception& )
503  {
504  }
505  OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
506  return xStyle;
507 }
508 
510 {
511  if( bInternal )
513  else
514  mxChartConverter.reset( new ExcelChartConverter( *this ) );
515 }
516 
517 // BIFF specific --------------------------------------------------------------
518 
519 // private --------------------------------------------------------------------
520 
522 {
523  maCellStyles = "CellStyles";
524  maPageStyles = "PageStyles";
525  maCellStyleServ = "com.sun.star.style.CellStyle";
526  maPageStyleServ = "com.sun.star.style.PageStyle";
527  mnCurrSheet = -1;
528  mbGeneratorKnownGood = false;
529  meTextEnc = osl_getThreadTextEncoding();
530 
531  // the spreadsheet document
532  mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
533  OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
534 
535  if (mxDoc)
536  {
537  ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
538  if (pModel)
539  mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
540  if (mpDocShell)
542  }
543 
544  if (!mpDoc)
545  throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
546 
547  Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
548  Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
549  const OUString aGenerator( xDocProps->getGenerator());
550 
551  if (aGenerator.startsWithIgnoreAsciiCase("Microsoft"))
552  {
553  mbGeneratorKnownGood = true;
554  ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
556  mpDoc->SetCalcConfig(aCalcConfig);
557  }
558  else if (aGenerator.startsWithIgnoreAsciiCase("LibreOffice"))
559  {
560  mbGeneratorKnownGood = true;
561  }
562 
563  mxDocImport.reset(new ScDocumentImport(*mpDoc));
564 
565  mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
566  mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
567  mxViewSettings.reset( new ViewSettings( *this ) );
568  mxWorksheets.reset( new WorksheetBuffer( *this ) );
569  mxTheme = std::make_shared<ThemeBuffer>( *this );
570  mxStyles.reset( new StylesBuffer( *this ) );
571  mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
572  mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
573  mxDefNames.reset( new DefinedNamesBuffer( *this ) );
574  mxTables.reset( new TableBuffer( *this ) );
575  mxScenarios.reset( new ScenarioBuffer( *this ) );
576  mxConnections.reset( new ConnectionsBuffer( *this ) );
577  mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
578  mxPivotTables.reset( new PivotTableBuffer( *this ) );
579 
580  mxUnitConverter.reset( new UnitConverter( *this ) );
581  mxAddrConverter.reset( new AddressConverter( *this ) );
582  mxChartConverter.reset( new ExcelChartConverter( *this ) );
583  mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
584 
585  // initialise edit engine
586  ScDocument& rDoc = getScDocument();
587  mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
588  mxEditEngine->SetRefMapMode(MapMode(MapUnit::Map100thMM));
589  mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
590  mxEditEngine->SetUpdateLayout( false );
591  mxEditEngine->EnableUndo( false );
592  mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
593 
594  // set some document properties needed during import
595  if( mrBaseFilter.isImportFilter() )
596  {
597  // enable editing read-only documents (e.g. from read-only files)
599  // #i76026# disable Undo while loading the document
600  mpDoc->EnableUndo(false);
601  // #i79826# disable calculating automatic row height while loading the document
603  // disable automatic update of linked sheets and DDE links
604  mpDoc->EnableExecuteLink(false);
605 
606  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_LOAD_DOC) ) );
608 
609  //prevent unnecessary broadcasts and "half way listeners" as
610  //is done in ScDocShell::BeforeXMLLoading() for ods
612  }
613  else if( mrBaseFilter.isExportFilter() )
614  {
615  mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScResId(STR_SAVE_DOC) ) );
616  }
617 }
618 
620 {
621  // set some document properties needed after import
622  if( !mrBaseFilter.isImportFilter() )
623  return;
624 
625  // #i74668# do not insert default sheets
626  mpDocShell->SetEmpty(false);
627  // enable automatic update of linked sheets and DDE links
628  mpDoc->EnableExecuteLink(true);
629  // #i79826# enable updating automatic row height after loading the document
631 
632  // #i76026# enable Undo after loading the document
633  mpDoc->EnableUndo(true);
634 
635  // disable editing read-only documents (e.g. from read-only files)
636  mpDoc->EnableChangeReadOnly(false);
637  // #111099# open forms in alive mode (has no effect, if no controls in document)
638  ScDrawLayer* pModel = mpDoc->GetDrawLayer();
639  if (pModel)
640  pModel->SetOpenInDesignMode(false);
641 }
642 
643 
645 {
646 }
647 
649 {
650  WorkbookGlobalsRef xBookGlob = std::make_shared<WorkbookGlobals>( rFilter );
651  if( !xBookGlob->isValid() )
652  xBookGlob.reset();
653  return xBookGlob;
654 }
655 
656 // filter ---------------------------------------------------------------------
657 
658 FilterBase& WorkbookHelper::getBaseFilter() const
659 {
660  return mrBookGlob.getBaseFilter();
661 }
662 
664 {
665  return mrBookGlob.getProgressBar();
666 }
667 
669 {
671 }
672 
674 {
676 }
677 
679 {
680  mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
681 }
682 
684 {
686 }
687 
689 {
690  // workbook settings, document and sheet view settings
693 
694  // Import the VBA project (after finalizing workbook settings which
695  // contains the workbook code name). Do it before processing formulas in
696  // order to correctly resolve VBA custom function names.
698  if( xVbaPrjStrg && xVbaPrjStrg->isStorage() )
699  getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
700 
701  // need to import formulas before scenarios
703 
704  // Insert all pivot tables. Must be done after loading all sheets and
705  // formulas, because data pilots expect existing source data on
706  // creation.
708 
709  /* Insert scenarios after all sheet processing is done, because new hidden
710  sheets are created for scenarios which would confuse code that relies
711  on certain sheet indexes. Must be done after pivot tables too. */
713 
714  /* Set 'Default' page style to automatic page numbering (default is manual
715  number 1). Otherwise hidden sheets (e.g. for scenarios) which have
716  'Default' page style will break automatic page numbering for following
717  sheets. Automatic numbering is set by passing the value 0. */
718  PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
719  aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
720 
721  // Has any string ref syntax been imported?
722  // If not, we need to take action
723  ScCalcConfig aCalcConfig = getScDocument().GetCalcConfig();
724 
725  if ( !aCalcConfig.mbHasStringRefSyntax )
726  {
728  getScDocument().SetCalcConfig(aCalcConfig);
729  }
730 
731  // set selected sheet and positionleft/positiontop for OLE objects
732  Reference<XViewDataSupplier> xViewDataSupplier(getDocument(), UNO_QUERY);
733  if (!xViewDataSupplier.is())
734  return;
735 
736  Reference<XIndexAccess> xIndexAccess(xViewDataSupplier->getViewData());
737  if (!(xIndexAccess.is() && xIndexAccess->getCount() > 0))
738  return;
739 
740  Sequence< PropertyValue > aSeq;
741  if (!(xIndexAccess->getByIndex(0) >>= aSeq))
742  return;
743 
744  OUString sTabName;
745  Reference< XNameAccess > xSheetsNC;
746  for (const auto& rProp : std::as_const(aSeq))
747  {
748  OUString sName(rProp.Name);
749  if (sName == SC_ACTIVETABLE)
750  {
751  if(rProp.Value >>= sTabName)
752  {
753  SCTAB nTab(0);
754  if (getScDocument().GetTable(sTabName, nTab))
756  }
757  }
758  else if (sName == SC_TABLES)
759  {
760  rProp.Value >>= xSheetsNC;
761  }
762  }
763  if (!(xSheetsNC.is() && xSheetsNC->hasByName(sTabName)))
764  return;
765 
766  Sequence<PropertyValue> aProperties;
767  Any aAny = xSheetsNC->getByName(sTabName);
768  if ( !(aAny >>= aProperties) )
769  return;
770 
771  for (const auto& rProp : std::as_const(aProperties))
772  {
773  OUString sName(rProp.Name);
774  if (sName == SC_POSITIONLEFT)
775  {
776  SCCOL nPosLeft = *o3tl::doAccess<SCCOL>(rProp.Value);
777  getScDocument().SetPosLeft(nPosLeft);
778  }
779  else if (sName == SC_POSITIONTOP)
780  {
781  SCROW nPosTop = *o3tl::doAccess<SCROW>(rProp.Value);
782  getScDocument().SetPosTop(nPosTop);
783  }
784  }
785 }
786 
787 // document model -------------------------------------------------------------
788 
790 {
791  return mrBookGlob.getScDocument();
792 }
793 
795 {
796  return mrBookGlob.getScDocument();
797 }
798 
800 {
801  return mrBookGlob.getDocImport();
802 }
803 
805 {
806  return mrBookGlob.getDocImport();
807 }
808 
810 {
811  return mrBookGlob.getEditEngine();
812 }
813 
814 const Reference< XSpreadsheetDocument > & WorkbookHelper::getDocument() const
815 {
816  return mrBookGlob.getDocument();
817 }
818 
819 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
820 {
821  Reference< XSpreadsheet > xSheet;
822  try
823  {
824  Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
825  xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
826  }
827  catch( Exception& )
828  {
829  }
830  return xSheet;
831 }
832 
833 Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
834 {
835  Reference< XSpreadsheet > xSheet;
836  try
837  {
838  Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
839  xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
840  }
841  catch( Exception& )
842  {
843  }
844  return xSheet;
845 }
846 
847 Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const ScRange& rRange ) const
848 {
849  Reference< XCellRange > xRange;
850  try
851  {
852  Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.aStart.Tab() ), UNO_SET_THROW );
853  xRange = xSheet->getCellRangeByPosition( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() );
854  }
855  catch( Exception& )
856  {
857  }
858  return xRange;
859 }
860 
861 Reference< XNameContainer > WorkbookHelper::getCellStyleFamily() const
862 {
863  return mrBookGlob.getStyleFamily( false/*bPageStyles*/ );
864 }
865 
866 Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
867 {
868  return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
869 }
870 
871 WorkbookHelper::RangeDataRet WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden ) const
872 {
873  return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags, bHidden );
874 }
875 
876 WorkbookHelper::RangeDataRet WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden ) const
877 {
878  return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab, bHidden );
879 }
880 
881 Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const ScRange& rRangeAddr ) const
882 {
883  return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
884 }
885 
886 Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const ScRange& rRangeAddr ) const
887 {
888  return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
889 }
890 
892 {
893  return mrBookGlob.findDatabaseRangeByIndex( nIndex );
894 }
895 
896 Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
897 {
898  return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
899 }
900 
901 // buffers --------------------------------------------------------------------
902 
904 {
905  return mrBookGlob.getFormulaBuffer();
906 }
907 
909 {
911 }
912 
914 {
915  return mrBookGlob.getViewSettings();
916 }
917 
919 {
920  return mrBookGlob.getWorksheets();
921 }
922 
924 {
925  return mrBookGlob.getTheme();
926 }
927 
929 {
930  return mrBookGlob.getStyles();
931 }
932 
934 {
935  return mrBookGlob.getSharedStrings();
936 }
937 
939 {
940  return mrBookGlob.getExternalLinks();
941 }
942 
944 {
945  return mrBookGlob.getDefinedNames();
946 }
947 
949 {
950  return mrBookGlob.getTables();
951 }
952 
954 {
955  return mrBookGlob.getScenarios();
956 }
957 
959 {
960  return mrBookGlob.getConnections();
961 }
962 
964 {
965  return mrBookGlob.getPivotCaches();
966 }
967 
969 {
970  return mrBookGlob.getPivotTables();
971 }
972 
973 // converters -----------------------------------------------------------------
974 
976 {
977  return mrBookGlob.getFormulaParser();
978 }
979 
981 {
983 }
984 
986 {
987  return mrBookGlob.getUnitConverter();
988 }
989 
991 {
993 }
994 
996 {
997  return mrBookGlob.getChartConverter();
998 }
999 
1001 {
1003 }
1004 
1006 {
1008 }
1009 
1010 // OOXML/BIFF12 specific ------------------------------------------------------
1011 
1012 XmlFilterBase& WorkbookHelper::getOoxFilter() const
1013 {
1014  return mrBookGlob.getOoxFilter();
1015 }
1016 
1018 {
1019  return getOoxFilter().importFragment( rxHandler );
1020 }
1021 
1023 {
1024  return getOoxFilter().importFragment(rxHandler, rParser);
1025 }
1026 
1027 // BIFF specific --------------------------------------------------------------
1028 
1029 rtl_TextEncoding WorkbookHelper::getTextEncoding() const
1030 {
1031  return mrBookGlob.getTextEncoding();
1032 }
1033 
1034 } // namespace oox
1035 
1036 /* 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:58
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
bool operator()(std::u16string_view rName1, std::u16string_view rName2) const
FormulaParserPtr mxFmlaParser
All pivot tables in the document.
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:825
ThemeBuffer & getTheme() const
Returns the office theme object read from the theme substorage.
ScAddress aStart
Definition: address.hxx:497
ScDocumentImport & getDocImport()
ScDBData * findByIndex(sal_uInt16 nIndex)
Definition: dbdata.cxx:1189
const StorageRef & getVbaProjectStorage() const
Returns the VBA project storage.
ScenarioBuffer & getScenarios() const
Returns the scenarios collection.
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
SCROW Row() const
Definition: address.hxx:274
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.
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:320
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.
SC_DLLPUBLIC ScRangeName * GetRangeName(SCTAB nTab) const
Definition: documen3.cxx:168
rtl_TextEncoding getTextEncoding() const
Returns the text encoding used to import/export byte strings.
WorksheetBfrPtr mxWorksheets
Workbook and sheet view settings.
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
PivotTableBuffer & getPivotTables()
Returns the collection of pivot tables.
PivotCacheBfrPtr mxPivotCaches
All external data connections.
EditEngineDefaulterPtr mxEditEngine
Page/print settings converter.
WorkbookHelper::RangeDataRet createLocalNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden)
Creates and returns a defined name on the-fly in the correct Calc sheet.
ViewSettingsPtr mxViewSettings
Global workbook settings.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
::std::unique_ptr< PivotCacheBuffer > PivotCacheBfrPtr
Helper class that provides functions to convert values from and to different units.
bool importFragment(const rtl::Reference< FragmentHandler > &rxHandler)
bool isValid() const
Returns true, if this helper refers to a valid document.
WorkbookGlobals & mrBookGlob
ScAddress aEnd
Definition: address.hxx:498
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.
void initialize()
Initializes some basic members and sets needed document properties.
WorkbookSettings & getWorkbookSettings() const
Returns the global workbook settings object.
PageSettConvPtr mxPageSettConverter
Chart object converter.
bool importOoxFragment(const rtl::Reference< oox::core::FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
::std::unique_ptr< SegmentProgressBar > ProgressBarPtr
Reference< XDatabaseRange > createUnnamedDatabaseRangeObject(const ScRange &rRangeAddr)
Creates and returns an unnamed database range on-the-fly in the Calc document.
Reference< XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle)
Creates and returns a com.sun.star.style.Style object for cells or pages.
FormulaParser & getFormulaParser() const
Returns a shared import formula parser.
ViewSettings & getViewSettings() const
Returns the workbook and sheet view settings object.
StylesBuffer & getStyles() const
Returns all cell formatting objects read from the styles substream.
PivotTableBfrPtr mxPivotTables
All pivot caches in the document.
OUString maCellStyleServ
Style family name for page styles.
PropertiesInfo aProperties
css::uno::Reference< css::style::XStyle > createStyleObject(OUString &orStyleName, bool bPageStyle) const
Creates and returns a com.sun.star.style.Style object for cells or pages.
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:315
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:92
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:283
SC_DLLPUBLIC void GuessPosition()
Definition: rangenam.cxx:205
ScDocumentImport & getDocImport()
static OUString insertByUnusedName(const css::uno::Reference< css::container::XNameContainer > &rxNameContainer, const OUString &rSuggestedName, sal_Unicode cSeparator, const css::uno::Any &rObject)
const char * sName
void useInternalChartDataTable(bool bInternal)
void SetInsertingFromOtherDoc(bool bVal)
Definition: document.hxx:2216
::std::unique_ptr< StylesBuffer > StylesBfrPtr
::std::unique_ptr< FormulaBuffer > FormulaBufferPtr
UnitConvPtr mxUnitConverter
Import formula parser.
SC_DLLPUBLIC void SetVisibleTab(SCTAB nTab)
Definition: document.hxx:878
Reference< XStyle > getStyleObject(const OUString &rStyleName, bool bPageStyle) const
Returns the specified cell or page style from the Calc document.
::oox::ole::VbaProject & getVbaProject() const
FormulaParser * createFormulaParser()
Returns an unshared import formula parser.
void finalizeWorkbookImport()
Final conversion after importing the workbook.
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1081
SC_DLLPUBLIC ScRangeData * findByUpperName(const OUString &rName)
Definition: rangenam.cxx:704
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:1598
RangeDataRet createNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden) const
Creates and returns a defined name on-the-fly in the Calc document.
int compareToIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
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:1600
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1024
SfxObjectShell * GetEmbeddedObject() const
Definition: docuno.cxx:448
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:470
ScenarioBfrPtr mxScenarios
All tables (database ranges).
SC_DLLPUBLIC void UnlockAdjustHeight()
Definition: document.cxx:1802
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
::oox::core::XmlFilterBase & getOoxFilter() const
Returns the base OOXML/BIFF12 filter object.
SegmentProgressBar & getProgressBar() const
Returns the filter progress bar.
::std::shared_ptr< ThemeBuffer > ThemeBfrRef
std::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef
PageSettingsConverter & getPageSettingsConverter() const
Returns the page/print settings converter.
UnitConverter & getUnitConverter() const
Returns the measurement unit converter.
::std::unique_ptr< ConnectionsBuffer > ConnectionsBfrPtr
WorkbookSettPtr mxWorkbookSettings
static SC_DLLPUBLIC bool ConvertToTokenArray(ScDocument &rDoc, ScTokenArray &rTokenArray, const css::uno::Sequence< css::sheet::FormulaToken > &rSequence)
Definition: tokenuno.cxx:375
ScDBData * findDatabaseRangeByIndex(sal_uInt16 nIndex)
Finds the (already existing) database range of the given formula token index.
constexpr OUStringLiteral SC_POSITIONLEFT
ScEditEngineDefaulter & getEditEngine() const
TableBuffer & getTables() const
Returns the tables collection (equivalent to Calc's database ranges).
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:14
StorageRef mxVbaPrjStrg
The progress bar.
SC_DLLPUBLIC void SetPosTop(SCROW nRow)
Definition: document.hxx:882
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:53
PivotCacheBuffer & getPivotCaches() const
Returns the collection of pivot caches.
SCCOL Col() const
Definition: address.hxx:279
FormulaBufferPtr mxFormulaBuffer
Whether reading a file generated by Excel or Calc.
::std::unique_ptr< ExternalLinkBuffer > ExtLinkBfrPtr
Reference< XNameContainer > getStyleFamily(bool bPageStyles) const
Returns the cell or page styles container from the Calc document.
::std::unique_ptr< TableBuffer > TableBfrPtr
::std::unique_ptr< AddressConverter > AddressConvPtr
std::pair< ScRangeData *, bool > RangeDataRet
Configuration options for formula interpreter.
Definition: calcconfig.hxx:43
constexpr OUStringLiteral SC_TABLES
FormulaBuffer & getFormulaBuffer() const
static WorkbookGlobalsRef constructGlobals(ExcelFilter &rFilter)
sal_Int32 SCROW
Definition: types.hxx:17
void unregisterWorkbookGlobals()
Definition: excelfilter.cxx:69
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
::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.
void LockAdjustHeight()
Definition: document.hxx:1595
TableBfrPtr mxTables
All defined names.
Converter for cell addresses and cell ranges for OOXML and BIFF filters.
WorkbookHelper::RangeDataRet createNamedRangeObject(OUString &orName, const Sequence< FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, bool bHidden)
Creates and returns a defined name on-the-fly in the Calc document.
RangeDataRet createLocalNamedRangeObject(OUString &orName, const css::uno::Sequence< css::sheet::FormulaToken > &rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab, bool bHidden) const
Creates and returns a defined name on-the-fly in the sheet.
::std::unique_ptr< WorksheetBuffer > WorksheetBfrPtr
OUString maPageStyleServ
Service name for a cell style.
const ScCalcConfig & GetCalcConfig() const
Definition: document.hxx:2612
bool isGeneratorKnownGood() const
Returns true when reading a file generated by a known good generator.
void finalizeImport()
Creates all scenarios in the Calc document.
constexpr OUStringLiteral SC_POSITIONTOP
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.
constexpr OUStringLiteral SC_ACTIVETABLE
void finalizeImport()
Converts all imported document view settings.
ScEditEngineDefaulter & getEditEngine() const
SharedStringsBuffer & getSharedStrings() const
Returns the shared strings read from the shared strings substream.
Sequence< sal_Int8 > aSeq
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
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:465
ConnectionsBuffer & getConnections() const
Returns the collection of external data connections.
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:316
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:1080
::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:6572
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:203
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:802
ConnectionsBfrPtr mxConnections
All scenarios.
SC_DLLPUBLIC void SetPosLeft(SCCOL nCol)
Definition: document.hxx:880
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:163
WorksheetBuffer & getWorksheets() const
Returns the worksheet buffer containing sheet names and properties.
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo