LCOV - code coverage report
Current view: top level - sc/source/filter/oox - workbookhelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 320 394 81.2 %
Date: 2015-06-13 12:38:46 Functions: 97 111 87.4 %
Legend: Lines: hit not hit

          Line data    Source code
       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/document/XActionLockable.hpp>
      25             : #include <com/sun/star/sheet/XDatabaseRange.hpp>
      26             : #include <com/sun/star/sheet/XDatabaseRanges.hpp>
      27             : #include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp>
      28             : #include <com/sun/star/sheet/XNamedRange.hpp>
      29             : #include <com/sun/star/sheet/XNamedRanges.hpp>
      30             : #include <com/sun/star/sheet/XSpreadsheet.hpp>
      31             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      32             : #include <com/sun/star/sheet/NamedRangeFlag.hpp>
      33             : #include <com/sun/star/style/XStyle.hpp>
      34             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      35             : #include <com/sun/star/table/CellAddress.hpp>
      36             : #include <com/sun/star/container/XNamed.hpp>
      37             : #include <com/sun/star/document/XDocumentProperties.hpp>
      38             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      39             : #include <osl/thread.h>
      40             : #include <oox/helper/progressbar.hxx>
      41             : #include <oox/helper/propertyset.hxx>
      42             : #include <oox/ole/vbaproject.hxx>
      43             : #include <vcl/msgbox.hxx>
      44             : #include "addressconverter.hxx"
      45             : #include "biffinputstream.hxx"
      46             : #include "biffcodec.hxx"
      47             : #include "connectionsbuffer.hxx"
      48             : #include "defnamesbuffer.hxx"
      49             : #include "excelchartconverter.hxx"
      50             : #include "excelfilter.hxx"
      51             : #include "externallinkbuffer.hxx"
      52             : #include "formulaparser.hxx"
      53             : #include "pagesettings.hxx"
      54             : #include "pivotcachebuffer.hxx"
      55             : #include "pivottablebuffer.hxx"
      56             : #include "scenariobuffer.hxx"
      57             : #include "sharedstringsbuffer.hxx"
      58             : #include "stylesbuffer.hxx"
      59             : #include "tablebuffer.hxx"
      60             : #include "themebuffer.hxx"
      61             : #include "unitconverter.hxx"
      62             : #include "viewsettings.hxx"
      63             : #include "workbooksettings.hxx"
      64             : #include "worksheetbuffer.hxx"
      65             : #include "scmod.hxx"
      66             : #include "docsh.hxx"
      67             : #include "document.hxx"
      68             : #include "docuno.hxx"
      69             : #include "rangenam.hxx"
      70             : #include "tokenarray.hxx"
      71             : #include "tokenuno.hxx"
      72             : #include "convuno.hxx"
      73             : #include "dbdata.hxx"
      74             : #include "datauno.hxx"
      75             : #include "globalnames.hxx"
      76             : #include "documentimport.hxx"
      77             : #include "drwlayer.hxx"
      78             : #include "globstr.hrc"
      79             : 
      80             : #include "formulabuffer.hxx"
      81             : #include <vcl/mapmod.hxx>
      82             : #include "editutil.hxx"
      83             : #include <editeng/editstat.hxx>
      84             : 
      85             : #include <comphelper/processfactory.hxx>
      86             : #include <officecfg/Office/Calc.hxx>
      87             : 
      88             : #include <boost/noncopyable.hpp>
      89             : #include <boost/scoped_ptr.hpp>
      90             : 
      91             : namespace oox {
      92             : namespace xls {
      93             : 
      94             : using namespace ::com::sun::star::awt;
      95             : using namespace ::com::sun::star::container;
      96             : using namespace ::com::sun::star::document;
      97             : using namespace ::com::sun::star::lang;
      98             : using namespace ::com::sun::star::sheet;
      99             : using namespace ::com::sun::star::style;
     100             : using namespace ::com::sun::star::table;
     101             : using namespace ::com::sun::star::uno;
     102             : 
     103             : using ::oox::core::FilterBase;
     104             : using ::oox::core::FragmentHandler;
     105             : using ::oox::core::XmlFilterBase;
     106             : 
     107        7089 : bool IgnoreCaseCompare::operator()( const OUString& rName1, const OUString& rName2 ) const
     108             : {
     109             :     // there is no wrapper in OUString, TODO: compare with collator
     110             :     return ::rtl_ustr_compareIgnoreAsciiCase_WithLength(
     111        7089 :         rName1.getStr(), rName1.getLength(), rName2.getStr(), rName2.getLength() ) < 0;
     112             : }
     113             : 
     114             : class WorkbookGlobals : boost::noncopyable
     115             : {
     116             : public:
     117             :     explicit            WorkbookGlobals( ExcelFilter& rFilter );
     118             :                         ~WorkbookGlobals();
     119             : 
     120             :     /** Returns true, if this helper refers to a valid document. */
     121         145 :     inline bool         isValid() const { return mxDoc.is(); }
     122             : 
     123             :     // filter -----------------------------------------------------------------
     124             : 
     125             :     /** Returns the base filter object (base class of all filters). */
     126        6586 :     inline FilterBase&  getBaseFilter() const { return mrBaseFilter; }
     127             :     /** Returns the filter progress bar. */
     128         973 :     inline SegmentProgressBar& getProgressBar() const { return *mxProgressBar; }
     129             :     /** Returns the file type of the current filter. */
     130        7319 :     inline FilterType   getFilterType() const { return meFilterType; }
     131             :     /** Returns true, if the file is a multi-sheet document, or false if single-sheet. */
     132           0 :     inline bool         isWorkbookFile() const { return mbWorkbook; }
     133             :     /** Returns the VBA project storage. */
     134         145 :     inline StorageRef   getVbaProjectStorage() const { return mxVbaPrjStrg; }
     135             :     /** Returns the index of the current Calc sheet, if filter currently processes a sheet. */
     136         261 :     inline sal_Int16    getCurrentSheetIndex() const { return mnCurrSheet; }
     137             : 
     138             :     /** Sets the VBA project storage used to import VBA source code and forms. */
     139           1 :     inline void         setVbaProjectStorage( const StorageRef& rxVbaPrjStrg ) { mxVbaPrjStrg = rxVbaPrjStrg; }
     140             :     /** Sets the index of the current Calc sheet, if filter currently processes a sheet. */
     141         538 :     inline void         setCurrentSheetIndex( sal_Int16 nSheet ) { mnCurrSheet = nSheet; }
     142             : 
     143             :     // document model ---------------------------------------------------------
     144             : 
     145           4 :     inline ScEditEngineDefaulter& getEditEngine() const
     146             :     {
     147           4 :         return *mxEditEngine.get();
     148             :     }
     149             : 
     150        3707 :     ScDocument& getScDocument() { return *mpDoc; }
     151             : 
     152         145 :     ScDocShell& getDocShell() { return *mpDocShell; }
     153             : 
     154             :     ScDocumentImport& getDocImport();
     155             : 
     156             :     /** Returns a reference to the source/target spreadsheet document model. */
     157        2203 :     inline Reference< XSpreadsheetDocument > getDocument() const { return mxDoc; }
     158             :     /** Returns the cell or page styles container from the Calc document. */
     159             :     Reference< XNameContainer > getStyleFamily( bool bPageStyles ) const;
     160             :     /** Returns the specified cell or page style from the Calc document. */
     161             :     Reference< XStyle > getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
     162             :     /** Creates and returns a defined name on-the-fly in the Calc document. */
     163             :     ScRangeData* createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags );
     164             :     /** Creates and returns a defined name on the-fly in the correct Calc sheet. */
     165             :     ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab );
     166             :     /** Creates and returns a database range on-the-fly in the Calc document. */
     167             :     Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr );
     168             :     /** Creates and returns an unnamed database range on-the-fly in the Calc document. */
     169             :     Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr );
     170             :     /** Creates and returns a com.sun.star.style.Style object for cells or pages. */
     171             :     Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle );
     172             :     /** Helper to switch chart data table - specifically for xlsx imports */
     173             :     void useInternalChartDataTable( bool bInternal );
     174             : 
     175             :     // buffers ----------------------------------------------------------------
     176             : 
     177        3607 :     inline FormulaBuffer& getFormulaBuffer() const { return *mxFormulaBuffer; }
     178             :     /** Returns the global workbook settings object. */
     179         580 :     inline WorkbookSettings& getWorkbookSettings() const { return *mxWorkbookSettings; }
     180             :     /** Returns the workbook and sheet view settings object. */
     181         952 :     inline ViewSettings& getViewSettings() const { return *mxViewSettings; }
     182             :     /** Returns the worksheet buffer containing sheet names and properties. */
     183         937 :     inline WorksheetBuffer& getWorksheets() const { return *mxWorksheets; }
     184             :     /** Returns the office theme object read from the theme substorage. */
     185       10210 :     inline ThemeBuffer& getTheme() const { return *mxTheme; }
     186             :     /** Returns all cell formatting objects read from the styles substream. */
     187       14892 :     inline StylesBuffer& getStyles() const { return *mxStyles; }
     188             :     /** Returns the shared strings read from the shared strings substream. */
     189        1837 :     inline SharedStringsBuffer& getSharedStrings() const { return *mxSharedStrings; }
     190             :     /** Returns the external links read from the external links substream. */
     191         342 :     inline ExternalLinkBuffer& getExternalLinks() const { return *mxExtLinks; }
     192             :     /** Returns the defined names read from the workbook globals. */
     193         425 :     inline DefinedNamesBuffer& getDefinedNames() const { return *mxDefNames; }
     194             :     /** Returns the tables collection (equivalent to Calc's database ranges). */
     195         414 :     inline TableBuffer& getTables() const { return *mxTables; }
     196             :     /** Returns the scenarios collection. */
     197         145 :     inline ScenarioBuffer& getScenarios() const { return *mxScenarios; }
     198             :     /** Returns the collection of external data connections. */
     199           0 :     inline ConnectionsBuffer&  getConnections() const { return *mxConnections; }
     200             :     /** Returns the collection of pivot caches. */
     201           8 :     inline PivotCacheBuffer& getPivotCaches() const { return *mxPivotCaches; }
     202             :     /** Returns the collection of pivot tables. */
     203         149 :     inline PivotTableBuffer& getPivotTables() { return *mxPivotTables; }
     204             : 
     205             :     // converters -------------------------------------------------------------
     206             : 
     207             :     /** Returns a shared import formula parser. */
     208         307 :     inline FormulaParser& getFormulaParser() const { return *mxFmlaParser; }
     209             :     /** Returns an unshared import formula parser. */
     210         414 :     inline FormulaParser* createFormulaParser() { return new FormulaParser(*this); }
     211             :     /** Returns the measurement unit converter. */
     212        3760 :     inline UnitConverter& getUnitConverter() const { return *mxUnitConverter; }
     213             :     /** Returns the converter for string to cell address/range conversion. */
     214        5378 :     inline AddressConverter& getAddressConverter() const { return *mxAddrConverter; }
     215             :     /** Returns the chart object converter. */
     216         140 :     inline oox::drawingml::chart::ChartConverter* getChartConverter() const { return mxChartConverter.get(); }
     217             :     /** Returns the page/print settings converter. */
     218         269 :     inline PageSettingsConverter& getPageSettingsConverter() const { return *mxPageSettConverter; }
     219             : 
     220             :     // OOXML/BIFF12 specific --------------------------------------------------
     221             : 
     222             :     /** Returns the base OOXML/BIFF12 filter object. */
     223        2438 :     inline XmlFilterBase& getOoxFilter() const { return *mpOoxFilter; }
     224             : 
     225             :     // BIFF2-BIFF8 specific ---------------------------------------------------
     226             : 
     227             :     /** Returns the BIFF type in binary filter. */
     228         414 :     inline BiffType     getBiff() const { return meBiff; }
     229             :     /** Returns the text encoding used to import/export byte strings. */
     230           9 :     inline rtl_TextEncoding getTextEncoding() const { return meTextEnc; }
     231             :     /** Returns the codec helper that stores the encoder/decoder object. */
     232           0 :     inline BiffCodecHelper& getCodecHelper() { return *mxCodecHelper; }
     233             : 
     234             : private:
     235             :     /** Initializes some basic members and sets needed document properties. */
     236             :     void                initialize( bool bWorkbookFile );
     237             :     /** Finalizes the filter process (sets some needed document properties). */
     238             :     void                finalize();
     239             : 
     240             :     void recalcFormulaCells();
     241             : 
     242             : private:
     243             :     typedef ::std::unique_ptr< ScEditEngineDefaulter >    EditEngineDefaulterPtr;
     244             :     typedef ::std::unique_ptr< FormulaBuffer >          FormulaBufferPtr;
     245             :     typedef ::std::unique_ptr< SegmentProgressBar >     ProgressBarPtr;
     246             :     typedef ::std::unique_ptr< WorkbookSettings >       WorkbookSettPtr;
     247             :     typedef ::std::unique_ptr< ViewSettings >           ViewSettingsPtr;
     248             :     typedef ::std::unique_ptr< WorksheetBuffer >        WorksheetBfrPtr;
     249             :     typedef ::boost::shared_ptr< ThemeBuffer >          ThemeBfrRef;
     250             :     typedef ::std::unique_ptr< StylesBuffer >           StylesBfrPtr;
     251             :     typedef ::std::unique_ptr< SharedStringsBuffer >    SharedStrBfrPtr;
     252             :     typedef ::std::unique_ptr< ExternalLinkBuffer >     ExtLinkBfrPtr;
     253             :     typedef ::std::unique_ptr< DefinedNamesBuffer >     DefNamesBfrPtr;
     254             :     typedef ::std::unique_ptr< TableBuffer >            TableBfrPtr;
     255             :     typedef ::std::unique_ptr< ScenarioBuffer >         ScenarioBfrPtr;
     256             :     typedef ::std::unique_ptr< ConnectionsBuffer >      ConnectionsBfrPtr;
     257             :     typedef ::std::unique_ptr< PivotCacheBuffer >       PivotCacheBfrPtr;
     258             :     typedef ::std::unique_ptr< PivotTableBuffer >       PivotTableBfrPtr;
     259             :     typedef ::std::unique_ptr< FormulaParser >          FormulaParserPtr;
     260             :     typedef ::std::unique_ptr< UnitConverter >          UnitConvPtr;
     261             :     typedef ::std::unique_ptr< AddressConverter >       AddressConvPtr;
     262             :     typedef ::std::unique_ptr< oox::drawingml::chart::ChartConverter > ExcelChartConvPtr;
     263             :     typedef ::std::unique_ptr< PageSettingsConverter >  PageSettConvPtr;
     264             :     typedef ::std::unique_ptr< BiffCodecHelper >        BiffCodecHelperPtr;
     265             : 
     266             :     OUString            maCellStyles;           /// Style family name for cell styles.
     267             :     OUString            maPageStyles;           /// Style family name for page styles.
     268             :     OUString            maCellStyleServ;        /// Service name for a cell style.
     269             :     OUString            maPageStyleServ;        /// Service name for a page style.
     270             :     Reference< XSpreadsheetDocument > mxDoc;    /// Document model.
     271             :     FilterBase&         mrBaseFilter;           /// Base filter object.
     272             :     ExcelFilter&        mrExcelFilter;          /// Base object for registration of this structure.
     273             :     FilterType          meFilterType;           /// File type of the filter.
     274             :     ProgressBarPtr      mxProgressBar;          /// The progress bar.
     275             :     StorageRef          mxVbaPrjStrg;           /// Storage containing the VBA project.
     276             :     sal_Int16           mnCurrSheet;            /// Current sheet index in Calc document.
     277             :     bool                mbWorkbook;             /// True = multi-sheet file.
     278             : 
     279             :     // buffers
     280             :     FormulaBufferPtr    mxFormulaBuffer;
     281             :     WorkbookSettPtr     mxWorkbookSettings;     /// Global workbook settings.
     282             :     ViewSettingsPtr     mxViewSettings;         /// Workbook and sheet view settings.
     283             :     WorksheetBfrPtr     mxWorksheets;           /// Sheet info buffer.
     284             :     ThemeBfrRef         mxTheme;                /// Formatting theme from theme substream.
     285             :     StylesBfrPtr        mxStyles;               /// All cell style objects from styles substream.
     286             :     SharedStrBfrPtr     mxSharedStrings;        /// All strings from shared strings substream.
     287             :     ExtLinkBfrPtr       mxExtLinks;             /// All external links.
     288             :     DefNamesBfrPtr      mxDefNames;             /// All defined names.
     289             :     TableBfrPtr         mxTables;               /// All tables (database ranges).
     290             :     ScenarioBfrPtr      mxScenarios;            /// All scenarios.
     291             :     ConnectionsBfrPtr   mxConnections;          /// All external data connections.
     292             :     PivotCacheBfrPtr    mxPivotCaches;          /// All pivot caches in the document.
     293             :     PivotTableBfrPtr    mxPivotTables;          /// All pivot tables in the document.
     294             : 
     295             :     // converters
     296             :     FormulaParserPtr    mxFmlaParser;           /// Import formula parser.
     297             :     UnitConvPtr         mxUnitConverter;        /// General unit converter.
     298             :     AddressConvPtr      mxAddrConverter;        /// Cell address and cell range address converter.
     299             :     ExcelChartConvPtr   mxChartConverter;       /// Chart object converter.
     300             :     PageSettConvPtr     mxPageSettConverter;    /// Page/print settings converter.
     301             : 
     302             :     EditEngineDefaulterPtr mxEditEngine;
     303             : 
     304             :     // OOXML/BIFF12 specific
     305             :     XmlFilterBase*      mpOoxFilter;            /// Base OOXML/BIFF12 filter object.
     306             : 
     307             :     // BIFF2-BIFF8 specific
     308             :     BiffCodecHelperPtr  mxCodecHelper;          /// Encoder/decoder helper.
     309             :     BiffType            meBiff;                 /// BIFF version for BIFF import/export.
     310             :     rtl_TextEncoding    meTextEnc;              /// BIFF byte string text encoding.
     311             :     bool                mbHasCodePage;          /// True = CODEPAGE record exists in imported stream.
     312             :     ScDocument* mpDoc;
     313             :     ScDocShell* mpDocShell;
     314             :     boost::scoped_ptr<ScDocumentImport> mxDocImport;
     315             : };
     316             : 
     317         145 : WorkbookGlobals::WorkbookGlobals( ExcelFilter& rFilter ) :
     318             :     mrBaseFilter( rFilter ),
     319             :     mrExcelFilter( rFilter ),
     320             :     meFilterType( FILTER_OOXML ),
     321             :     mpOoxFilter( &rFilter ),
     322             :     meBiff( BIFF_UNKNOWN ),
     323             :     mpDoc(NULL),
     324         145 :     mpDocShell(NULL)
     325             : {
     326             :     // register at the filter, needed for virtual callbacks (even during construction)
     327         145 :     mrExcelFilter.registerWorkbookGlobals( *this );
     328         145 :     initialize( true );
     329         145 : }
     330             : 
     331         290 : WorkbookGlobals::~WorkbookGlobals()
     332             : {
     333         145 :     finalize();
     334         145 :     mrExcelFilter.unregisterWorkbookGlobals();
     335         145 : }
     336             : 
     337        5008 : ScDocumentImport& WorkbookGlobals::getDocImport()
     338             : {
     339        5008 :     return *mxDocImport;
     340             : }
     341             : 
     342         559 : Reference< XNameContainer > WorkbookGlobals::getStyleFamily( bool bPageStyles ) const
     343             : {
     344         559 :     Reference< XNameContainer > xStylesNC;
     345             :     try
     346             :     {
     347         559 :         Reference< XStyleFamiliesSupplier > xFamiliesSup( mxDoc, UNO_QUERY_THROW );
     348        1118 :         Reference< XNameAccess > xFamiliesNA( xFamiliesSup->getStyleFamilies(), UNO_QUERY_THROW );
     349        1118 :         xStylesNC.set( xFamiliesNA->getByName( bPageStyles ? maPageStyles : maCellStyles ), UNO_QUERY );
     350             :     }
     351           0 :     catch( Exception& )
     352             :     {
     353             :     }
     354             :     OSL_ENSURE( xStylesNC.is(), "WorkbookGlobals::getStyleFamily - cannot access style family" );
     355         559 :     return xStylesNC;
     356             : }
     357             : 
     358         145 : Reference< XStyle > WorkbookGlobals::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
     359             : {
     360         145 :     Reference< XStyle > xStyle;
     361             :     try
     362             :     {
     363         145 :         Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
     364         145 :         xStyle.set( xStylesNC->getByName( rStyleName ), UNO_QUERY );
     365             :     }
     366           0 :     catch( Exception& )
     367             :     {
     368             :     }
     369             :     OSL_ENSURE( xStyle.is(), "WorkbookGlobals::getStyleObject - cannot access style object" );
     370         145 :     return xStyle;
     371             : }
     372             : 
     373             : namespace {
     374             : 
     375          11 : ScRangeData* lcl_addNewByNameAndTokens( ScDocument& rDoc, ScRangeName* pNames, const OUString& rName, const Sequence<FormulaToken>& rTokens, sal_Int16 nIndex, sal_Int32 nUnoType )
     376             : {
     377          11 :     bool bDone = false;
     378          11 :     sal_uInt16 nNewType = RT_NAME;
     379          11 :     if ( nUnoType & NamedRangeFlag::FILTER_CRITERIA )    nNewType |= RT_CRITERIA;
     380          11 :     if ( nUnoType & NamedRangeFlag::PRINT_AREA )         nNewType |= RT_PRINTAREA;
     381          11 :     if ( nUnoType & NamedRangeFlag::COLUMN_HEADER )      nNewType |= RT_COLHEADER;
     382          11 :     if ( nUnoType & NamedRangeFlag::ROW_HEADER )         nNewType |= RT_ROWHEADER;
     383          11 :     ScTokenArray aTokenArray;
     384          11 :     (void)ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, rTokens );
     385          11 :     ScRangeData* pNew = new ScRangeData( &rDoc, rName, aTokenArray, ScAddress(), nNewType );
     386          11 :     pNew->GuessPosition();
     387          11 :     if ( nIndex )
     388          11 :         pNew->SetIndex( nIndex );
     389          11 :     if ( pNames->insert(pNew) )
     390          11 :         bDone = true;
     391          11 :     if (!bDone)
     392           0 :         throw RuntimeException();
     393          11 :     return pNew;
     394             : }
     395             : 
     396          11 : OUString findUnusedName( const ScRangeName* pRangeName, const OUString& rSuggestedName )
     397             : {
     398          11 :     OUString aNewName = rSuggestedName;
     399          11 :     sal_Int32 nIndex = 0;
     400          22 :     while(pRangeName->findByUpperName(ScGlobal::pCharClass->uppercase(aNewName)))
     401           0 :         aNewName = OUStringBuffer(rSuggestedName).append( '_' ).append( nIndex++ ).makeStringAndClear();
     402             : 
     403          11 :     return aNewName;
     404             : }
     405             : 
     406             : }
     407             : 
     408           6 : ScRangeData* WorkbookGlobals::createNamedRangeObject(
     409             :     OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags )
     410             : {
     411             :     // create the name and insert it into the Calc document
     412           6 :     ScRangeData* pScRangeData = NULL;
     413           6 :     if( !orName.isEmpty() )
     414             :     {
     415           6 :         ScDocument& rDoc =  getScDocument();
     416           6 :         ScRangeName* pNames = rDoc.GetRangeName();
     417             :         // find an unused name
     418           6 :         orName = findUnusedName( pNames, orName );
     419             :         // create the named range
     420           6 :         pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
     421             :     }
     422           6 :     return pScRangeData;
     423             : }
     424             : 
     425           5 : ScRangeData* WorkbookGlobals::createLocalNamedRangeObject(
     426             :     OUString& orName, const Sequence< FormulaToken >&  rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab )
     427             : {
     428             :     // create the name and insert it into the Calc document
     429           5 :     ScRangeData* pScRangeData = NULL;
     430           5 :     if( !orName.isEmpty() )
     431             :     {
     432           5 :         ScDocument& rDoc =  getScDocument();
     433           5 :         ScRangeName* pNames = rDoc.GetRangeName( nTab );
     434           5 :         if(!pNames)
     435           0 :             throw RuntimeException("invalid sheet index used");
     436             :         // find an unused name
     437           5 :         orName = findUnusedName( pNames, orName );
     438             :         // create the named range
     439           5 :         pScRangeData = lcl_addNewByNameAndTokens( rDoc, pNames, orName, rTokens, nIndex, nNameFlags );
     440             :     }
     441           5 :     return pScRangeData;
     442             : }
     443             : 
     444           0 : Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr )
     445             : {
     446             :     // validate cell range
     447           0 :     CellRangeAddress aDestRange = rRangeAddr;
     448           0 :     bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
     449             : 
     450             :     // create database range and insert it into the Calc document
     451           0 :     Reference< XDatabaseRange > xDatabaseRange;
     452           0 :     if( bValidRange && !orName.isEmpty() ) try
     453             :     {
     454             :         // find an unused name
     455           0 :         PropertySet aDocProps( mxDoc );
     456           0 :         Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
     457           0 :         orName = ContainerHelper::getUnusedName( xDatabaseRanges, orName, '_' );
     458             :         // create the database range
     459           0 :         xDatabaseRanges->addNewByName( orName, aDestRange );
     460           0 :         xDatabaseRange.set( xDatabaseRanges->getByName( orName ), UNO_QUERY );
     461             :     }
     462           0 :     catch( Exception& )
     463             :     {
     464             :     }
     465             :     OSL_ENSURE( xDatabaseRange.is(), "WorkbookGlobals::createDatabaseRangeObject - cannot create database range" );
     466           0 :     return xDatabaseRange;
     467             : }
     468             : 
     469           1 : Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr )
     470             : {
     471             :     // validate cell range
     472           1 :     CellRangeAddress aDestRange = rRangeAddr;
     473           1 :     bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true );
     474             : 
     475             :     // create database range and insert it into the Calc document
     476           1 :     Reference< XDatabaseRange > xDatabaseRange;
     477           1 :     if( bValidRange ) try
     478             :     {
     479           1 :         ScDocument& rDoc =  getScDocument();
     480           1 :         if( rDoc.GetTableCount() <= aDestRange.Sheet )
     481           0 :             throw ::com::sun::star::lang::IndexOutOfBoundsException();
     482           1 :         ScRange aScRange;
     483           1 :         ScUnoConversion::FillScRange(aScRange, aDestRange);
     484           1 :         ScDBData* pNewDBData = new ScDBData( STR_DB_LOCAL_NONAME, aScRange.aStart.Tab(),
     485           1 :                                        aScRange.aStart.Col(), aScRange.aStart.Row(),
     486           3 :                                        aScRange.aEnd.Col(), aScRange.aEnd.Row() );
     487           1 :         rDoc.SetAnonymousDBData( aScRange.aStart.Tab() , pNewDBData );
     488           1 :         ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
     489           1 :         xDatabaseRange.set(new ScDatabaseRangeObj(pDocSh, aScRange.aStart.Tab()));
     490             :     }
     491           0 :     catch( Exception& )
     492             :     {
     493             :     }
     494             :     OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" );
     495           1 :     return xDatabaseRange;
     496             : }
     497             : 
     498         269 : Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle )
     499             : {
     500         269 :     Reference< XStyle > xStyle;
     501             :     try
     502             :     {
     503         269 :         Reference< XNameContainer > xStylesNC( getStyleFamily( bPageStyle ), UNO_SET_THROW );
     504         269 :         xStyle.set( mrBaseFilter.getModelFactory()->createInstance( bPageStyle ? maPageStyleServ : maCellStyleServ ), UNO_QUERY_THROW );
     505         269 :         orStyleName = ContainerHelper::insertByUnusedName( xStylesNC, orStyleName, ' ', Any( xStyle ), false );
     506             :     }
     507           0 :     catch( Exception& )
     508             :     {
     509             :     }
     510             :     OSL_ENSURE( xStyle.is(), "WorkbookGlobals::createStyleObject - cannot create style" );
     511         269 :     return xStyle;
     512             : }
     513             : 
     514           0 : void WorkbookGlobals::useInternalChartDataTable( bool bInternal )
     515             : {
     516           0 :     if( bInternal )
     517           0 :         mxChartConverter.reset( new oox::drawingml::chart::ChartConverter() );
     518             :     else
     519           0 :         mxChartConverter.reset( new ExcelChartConverter( *this ) );
     520           0 : }
     521             : 
     522             : // BIFF specific --------------------------------------------------------------
     523             : 
     524             : // private --------------------------------------------------------------------
     525             : 
     526             : namespace {
     527             : 
     528         145 : formula::FormulaGrammar::AddressConvention getConvention(css::uno::Reference<XDocumentProperties> xDocProps)
     529             : {
     530         145 :     if (xDocProps->getGenerator().startsWithIgnoreAsciiCase("Microsoft"))
     531          84 :         return formula::FormulaGrammar::CONV_XL_A1;
     532             : 
     533          61 :     return formula::FormulaGrammar::CONV_OOO;
     534             : }
     535             : 
     536             : }
     537             : 
     538         145 : void WorkbookGlobals::initialize( bool bWorkbookFile )
     539             : {
     540         145 :     maCellStyles = "CellStyles";
     541         145 :     maPageStyles = "PageStyles";
     542         145 :     maCellStyleServ = "com.sun.star.style.CellStyle";
     543         145 :     maPageStyleServ = "com.sun.star.style.PageStyle";
     544         145 :     mnCurrSheet = -1;
     545         145 :     mbWorkbook = bWorkbookFile;
     546         145 :     meTextEnc = osl_getThreadTextEncoding();
     547         145 :     mbHasCodePage = false;
     548             : 
     549             :     // the spreadsheet document
     550         145 :     mxDoc.set( mrBaseFilter.getModel(), UNO_QUERY );
     551             :     OSL_ENSURE( mxDoc.is(), "WorkbookGlobals::initialize - no spreadsheet document" );
     552             : 
     553         145 :     if (mxDoc.get())
     554             :     {
     555         145 :         ScModelObj* pModel = dynamic_cast<ScModelObj*>(mxDoc.get());
     556         145 :         if (pModel)
     557         145 :             mpDocShell = static_cast<ScDocShell*>(pModel->GetEmbeddedObject());
     558         145 :         if (mpDocShell)
     559         145 :             mpDoc = &mpDocShell->GetDocument();
     560             :     }
     561             : 
     562         145 :     if (!mpDoc)
     563           0 :         throw RuntimeException("Workbookhelper::getScDocument(): Failed to access ScDocument from model");
     564             : 
     565         145 :     Reference< XDocumentPropertiesSupplier > xPropSupplier( mxDoc, UNO_QUERY);
     566         290 :     Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
     567         290 :     ScCalcConfig aCalcConfig = mpDoc->GetCalcConfig();
     568         145 :     aCalcConfig.meStringRefAddressSyntax = getConvention(xDocProps);
     569         145 :     mpDoc->SetCalcConfig(aCalcConfig);
     570             : 
     571         145 :     mxDocImport.reset(new ScDocumentImport(*mpDoc));
     572             : 
     573         145 :     mxFormulaBuffer.reset( new FormulaBuffer( *this ) );
     574         145 :     mxWorkbookSettings.reset( new WorkbookSettings( *this ) );
     575         145 :     mxViewSettings.reset( new ViewSettings( *this ) );
     576         145 :     mxWorksheets.reset( new WorksheetBuffer( *this ) );
     577         145 :     mxTheme.reset( new ThemeBuffer( *this ) );
     578         145 :     mxStyles.reset( new StylesBuffer( *this ) );
     579         145 :     mxSharedStrings.reset( new SharedStringsBuffer( *this ) );
     580         145 :     mxExtLinks.reset( new ExternalLinkBuffer( *this ) );
     581         145 :     mxDefNames.reset( new DefinedNamesBuffer( *this ) );
     582         145 :     mxTables.reset( new TableBuffer( *this ) );
     583         145 :     mxScenarios.reset( new ScenarioBuffer( *this ) );
     584         145 :     mxConnections.reset( new ConnectionsBuffer( *this ) );
     585         145 :     mxPivotCaches.reset( new PivotCacheBuffer( *this ) );
     586         145 :     mxPivotTables.reset( new PivotTableBuffer( *this ) );
     587             : 
     588         145 :     mxUnitConverter.reset( new UnitConverter( *this ) );
     589         145 :     mxAddrConverter.reset( new AddressConverter( *this ) );
     590         145 :     mxChartConverter.reset( new ExcelChartConverter( *this ) );
     591         145 :     mxPageSettConverter.reset( new PageSettingsConverter( *this ) );
     592             : 
     593             :     // initialise edit engine
     594         145 :     ScDocument& rDoc = getScDocument();
     595         145 :     mxEditEngine.reset( new ScEditEngineDefaulter( rDoc.GetEnginePool() ) );
     596         145 :     mxEditEngine->SetRefMapMode( MAP_100TH_MM );
     597         145 :     mxEditEngine->SetEditTextObjectPool( rDoc.GetEditPool() );
     598         145 :     mxEditEngine->SetUpdateMode( false );
     599         145 :     mxEditEngine->EnableUndo( false );
     600         145 :     mxEditEngine->SetControlWord( mxEditEngine->GetControlWord() & ~EEControlBits::ALLOWBIGOBJS );
     601             : 
     602             :     // set some document properties needed during import
     603         145 :     if( mrBaseFilter.isImportFilter() )
     604             :     {
     605             :         // enable editing read-only documents (e.g. from read-only files)
     606         145 :         mpDoc->EnableChangeReadOnly(true);
     607             :         // #i76026# disable Undo while loading the document
     608         145 :         mpDoc->EnableUndo(false);
     609             :         // #i79826# disable calculating automatic row height while loading the document
     610         145 :         mpDoc->EnableAdjustHeight(true);
     611             :         // disable automatic update of linked sheets and DDE links
     612         145 :         mpDoc->EnableExecuteLink(false);
     613             : 
     614         145 :         mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScGlobal::GetRscString(STR_LOAD_DOC) ) );
     615         145 :         mxFmlaParser.reset( createFormulaParser() );
     616             : 
     617             :         //prevent unnecessary broadcasts and "half way listeners" as
     618             :         //is done in ScDocShell::BeforeXMLLoading() for ods
     619         145 :         mpDoc->SetInsertingFromOtherDoc(true);
     620             :     }
     621           0 :     else if( mrBaseFilter.isExportFilter() )
     622             :     {
     623           0 :         mxProgressBar.reset( new SegmentProgressBar( mrBaseFilter.getStatusIndicator(), ScGlobal::GetRscString(STR_SAVE_DOC) ) );
     624             :     }
     625             :     // filter specific
     626         145 :     switch( getFilterType() )
     627             :     {
     628             :         case FILTER_BIFF:
     629           0 :             mxCodecHelper.reset( new BiffCodecHelper( *this ) );
     630           0 :         break;
     631             : 
     632             :         case FILTER_OOXML:
     633         145 :         break;
     634             : 
     635             :         case FILTER_UNKNOWN:
     636           0 :         break;
     637         145 :     }
     638         145 : }
     639             : 
     640         145 : void WorkbookGlobals::finalize()
     641             : {
     642             :     // set some document properties needed after import
     643         145 :     if( mrBaseFilter.isImportFilter() )
     644             :     {
     645             :         // #i74668# do not insert default sheets
     646         145 :         mpDocShell->SetEmpty(false);
     647             :         // enable automatic update of linked sheets and DDE links
     648         145 :         mpDoc->EnableExecuteLink(true);
     649             :         // #i79826# enable updating automatic row height after loading the document
     650         145 :         mpDoc->EnableAdjustHeight(true);
     651             : 
     652             :         // #i76026# enable Undo after loading the document
     653         145 :         mpDoc->EnableUndo(true);
     654             : 
     655             :         // disable editing read-only documents (e.g. from read-only files)
     656         145 :         mpDoc->EnableChangeReadOnly(false);
     657             :         // #111099# open forms in alive mode (has no effect, if no controls in document)
     658         145 :         ScDrawLayer* pModel = mpDoc->GetDrawLayer();
     659         145 :         if (pModel)
     660         145 :             pModel->SetOpenInDesignMode(false);
     661             : 
     662             :         //stop preventing establishment of listeners as is done in
     663             :         //ScDocShell::AfterXMLLoading() for ods
     664         145 :         mpDoc->SetInsertingFromOtherDoc(false);
     665         145 :         getDocImport().finalize();
     666             : 
     667         145 :         recalcFormulaCells();
     668             :     }
     669         145 : }
     670             : 
     671         145 : void WorkbookGlobals::recalcFormulaCells()
     672             : {
     673             :     // Recalculate formula cells.
     674         145 :     ScDocument& rDoc = getScDocument();
     675         145 :     ScDocShell& rDocSh = getDocShell();
     676         145 :     Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
     677             :     ScRecalcOptions nRecalcMode =
     678         145 :         static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
     679         145 :     bool bHardRecalc = false;
     680         145 :     if (nRecalcMode == RECALC_ASK)
     681             :     {
     682           0 :         if (rDoc.IsUserInteractionEnabled())
     683             :         {
     684             :             // Ask the user if full re-calculation is desired.
     685             :             ScopedVclPtrInstance<QueryBox> aBox(
     686           0 :                 ScDocShell::GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
     687           0 :                 ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
     688           0 :             aBox->SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
     689             : 
     690           0 :             sal_Int32 nRet = aBox->Execute();
     691           0 :             bHardRecalc = nRet == RET_YES;
     692             : 
     693           0 :             if (aBox->GetCheckBoxState())
     694             :             {
     695             :                 // Always perform selected action in the future.
     696           0 :                 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
     697           0 :                 officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
     698           0 :                 ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
     699           0 :                 aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
     700             :                 /* XXX  is this really supposed to set the ScModule options?
     701             :                  *      Not the ScDocShell options? */
     702           0 :                 SC_MOD()->SetFormulaOptions(aOpt);
     703             : 
     704           0 :                 batch->commit();
     705           0 :             }
     706             :         }
     707             :     }
     708         145 :     else if (nRecalcMode == RECALC_ALWAYS)
     709           0 :         bHardRecalc = true;
     710             : 
     711         145 :     if (bHardRecalc)
     712           0 :         rDocSh.DoHardRecalc(false);
     713             :     else
     714         145 :         rDoc.CalcFormulaTree(false, true, false);
     715         145 : }
     716             : 
     717       47024 : WorkbookHelper::~WorkbookHelper()
     718             : {
     719       47024 : }
     720             : 
     721         145 : /*static*/ WorkbookGlobalsRef WorkbookHelper::constructGlobals( ExcelFilter& rFilter )
     722             : {
     723         145 :     WorkbookGlobalsRef xBookGlob( new WorkbookGlobals( rFilter ) );
     724         145 :     if( !xBookGlob->isValid() )
     725           0 :         xBookGlob.reset();
     726         145 :     return xBookGlob;
     727             : }
     728             : 
     729             : // filter ---------------------------------------------------------------------
     730             : 
     731        6586 : FilterBase& WorkbookHelper::getBaseFilter() const
     732             : {
     733        6586 :     return mrBookGlob.getBaseFilter();
     734             : }
     735             : 
     736        7174 : FilterType WorkbookHelper::getFilterType() const
     737             : {
     738        7174 :     return mrBookGlob.getFilterType();
     739             : }
     740             : 
     741         973 : SegmentProgressBar& WorkbookHelper::getProgressBar() const
     742             : {
     743         973 :     return mrBookGlob.getProgressBar();
     744             : }
     745             : 
     746           0 : bool WorkbookHelper::isWorkbookFile() const
     747             : {
     748           0 :     return mrBookGlob.isWorkbookFile();
     749             : }
     750             : 
     751         261 : sal_Int16 WorkbookHelper::getCurrentSheetIndex() const
     752             : {
     753         261 :     return mrBookGlob.getCurrentSheetIndex();
     754             : }
     755             : 
     756           1 : void WorkbookHelper::setVbaProjectStorage( const StorageRef& rxVbaPrjStrg )
     757             : {
     758           1 :     mrBookGlob.setVbaProjectStorage( rxVbaPrjStrg );
     759           1 : }
     760             : 
     761         538 : void WorkbookHelper::setCurrentSheetIndex( sal_Int16 nSheet )
     762             : {
     763         538 :     mrBookGlob.setCurrentSheetIndex( nSheet );
     764         538 : }
     765             : 
     766         145 : void WorkbookHelper::finalizeWorkbookImport()
     767             : {
     768             :     // workbook settings, document and sheet view settings
     769         145 :     mrBookGlob.getWorkbookSettings().finalizeImport();
     770         145 :     mrBookGlob.getViewSettings().finalizeImport();
     771             : 
     772             :     // Import the VBA project (after finalizing workbook settings which
     773             :     // contains the workbook code name).  Do it before processing formulas in
     774             :     // order to correctly resolve VBA custom function names.
     775         145 :     StorageRef xVbaPrjStrg = mrBookGlob.getVbaProjectStorage();
     776         145 :     if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
     777           1 :         getBaseFilter().getVbaProject().importModulesAndForms( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() );
     778             : 
     779             :     // need to import formulas before scenarios
     780         145 :     mrBookGlob.getFormulaBuffer().finalizeImport();
     781             : 
     782             :     // Insert all pivot tables. Must be done after loading all sheets and
     783             :     // formulas, because data pilots expect existing source data on
     784             :     // creation.
     785         145 :     getPivotTables().finalizeImport();
     786             : 
     787             :     /*  Insert scenarios after all sheet processing is done, because new hidden
     788             :         sheets are created for scenarios which would confuse code that relies
     789             :         on certain sheet indexes. Must be done after pivot tables too. */
     790         145 :     mrBookGlob.getScenarios().finalizeImport();
     791             : 
     792             :     /*  Set 'Default' page style to automatic page numbering (default is manual
     793             :         number 1). Otherwise hidden sheets (e.g. for scenarios) which have
     794             :         'Default' page style will break automatic page numbering for following
     795             :         sheets. Automatic numbering is set by passing the value 0. */
     796         290 :     PropertySet aDefPageStyle( getStyleObject( "Default", true ) );
     797         290 :     aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 );
     798         145 : }
     799             : 
     800             : // document model -------------------------------------------------------------
     801             : 
     802        3153 : ScDocument& WorkbookHelper::getScDocument()
     803             : {
     804        3153 :     return mrBookGlob.getScDocument();
     805             : }
     806             : 
     807         252 : const ScDocument& WorkbookHelper::getScDocument() const
     808             : {
     809         252 :     return mrBookGlob.getScDocument();
     810             : }
     811             : 
     812        4863 : ScDocumentImport& WorkbookHelper::getDocImport()
     813             : {
     814        4863 :     return mrBookGlob.getDocImport();
     815             : }
     816             : 
     817           0 : const ScDocumentImport& WorkbookHelper::getDocImport() const
     818             : {
     819           0 :     return mrBookGlob.getDocImport();
     820             : }
     821             : 
     822           4 : ScEditEngineDefaulter& WorkbookHelper::getEditEngine() const
     823             : {
     824           4 :     return mrBookGlob.getEditEngine();
     825             : }
     826             : 
     827        2203 : Reference< XSpreadsheetDocument > WorkbookHelper::getDocument() const
     828             : {
     829        2203 :     return mrBookGlob.getDocument();
     830             : }
     831             : 
     832         422 : Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( sal_Int32 nSheet ) const
     833             : {
     834         422 :     Reference< XSpreadsheet > xSheet;
     835             :     try
     836             :     {
     837         422 :         Reference< XIndexAccess > xSheetsIA( getDocument()->getSheets(), UNO_QUERY_THROW );
     838         422 :         xSheet.set( xSheetsIA->getByIndex( nSheet ), UNO_QUERY_THROW );
     839             :     }
     840           0 :     catch( Exception& )
     841             :     {
     842             :     }
     843         422 :     return xSheet;
     844             : }
     845             : 
     846           0 : Reference< XSpreadsheet > WorkbookHelper::getSheetFromDoc( const OUString& rSheet ) const
     847             : {
     848           0 :     Reference< XSpreadsheet > xSheet;
     849             :     try
     850             :     {
     851           0 :         Reference< XNameAccess > xSheetsNA( getDocument()->getSheets(), UNO_QUERY_THROW );
     852           0 :         xSheet.set( xSheetsNA->getByName( rSheet ), UNO_QUERY );
     853             :     }
     854           0 :     catch( Exception& )
     855             :     {
     856             :     }
     857           0 :     return xSheet;
     858             : }
     859             : 
     860         149 : Reference< XCellRange > WorkbookHelper::getCellRangeFromDoc( const CellRangeAddress& rRange ) const
     861             : {
     862         149 :     Reference< XCellRange > xRange;
     863             :     try
     864             :     {
     865         149 :         Reference< XSpreadsheet > xSheet( getSheetFromDoc( rRange.Sheet ), UNO_SET_THROW );
     866         149 :         xRange = xSheet->getCellRangeByPosition( rRange.StartColumn, rRange.StartRow, rRange.EndColumn, rRange.EndRow );
     867             :     }
     868           0 :     catch( Exception& )
     869             :     {
     870             :     }
     871         149 :     return xRange;
     872             : }
     873             : 
     874         145 : Reference< XNameContainer > WorkbookHelper::getStyleFamily( bool bPageStyles ) const
     875             : {
     876         145 :     return mrBookGlob.getStyleFamily( bPageStyles );
     877             : }
     878             : 
     879         145 : Reference< XStyle > WorkbookHelper::getStyleObject( const OUString& rStyleName, bool bPageStyle ) const
     880             : {
     881         145 :     return mrBookGlob.getStyleObject( rStyleName, bPageStyle );
     882             : }
     883             : 
     884           6 : ScRangeData* WorkbookHelper::createNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags ) const
     885             : {
     886           6 :     return mrBookGlob.createNamedRangeObject( orName, rTokens, nIndex, nNameFlags );
     887             : }
     888             : 
     889           5 : ScRangeData* WorkbookHelper::createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const
     890             : {
     891           5 :     return mrBookGlob.createLocalNamedRangeObject( orName, rTokens, nIndex, nNameFlags, nTab );
     892             : }
     893             : 
     894           0 : Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const
     895             : {
     896           0 :     return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
     897             : }
     898             : 
     899           1 : Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
     900             : {
     901           1 :     return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
     902             : }
     903             : 
     904         269 : Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const
     905             : {
     906         269 :     return mrBookGlob.createStyleObject( orStyleName, bPageStyle );
     907             : }
     908             : 
     909             : // buffers --------------------------------------------------------------------
     910             : 
     911        3462 : FormulaBuffer& WorkbookHelper::getFormulaBuffer() const
     912             : {
     913        3462 :     return mrBookGlob.getFormulaBuffer();
     914             : }
     915             : 
     916         435 : WorkbookSettings& WorkbookHelper::getWorkbookSettings() const
     917             : {
     918         435 :     return mrBookGlob.getWorkbookSettings();
     919             : }
     920             : 
     921         807 : ViewSettings& WorkbookHelper::getViewSettings() const
     922             : {
     923         807 :     return mrBookGlob.getViewSettings();
     924             : }
     925             : 
     926         937 : WorksheetBuffer& WorkbookHelper::getWorksheets() const
     927             : {
     928         937 :     return mrBookGlob.getWorksheets();
     929             : }
     930             : 
     931       10210 : ThemeBuffer& WorkbookHelper::getTheme() const
     932             : {
     933       10210 :     return mrBookGlob.getTheme();
     934             : }
     935             : 
     936       14892 : StylesBuffer& WorkbookHelper::getStyles() const
     937             : {
     938       14892 :     return mrBookGlob.getStyles();
     939             : }
     940             : 
     941        1837 : SharedStringsBuffer& WorkbookHelper::getSharedStrings() const
     942             : {
     943        1837 :     return mrBookGlob.getSharedStrings();
     944             : }
     945             : 
     946         342 : ExternalLinkBuffer& WorkbookHelper::getExternalLinks() const
     947             : {
     948         342 :     return mrBookGlob.getExternalLinks();
     949             : }
     950             : 
     951         425 : DefinedNamesBuffer& WorkbookHelper::getDefinedNames() const
     952             : {
     953         425 :     return mrBookGlob.getDefinedNames();
     954             : }
     955             : 
     956         414 : TableBuffer& WorkbookHelper::getTables() const
     957             : {
     958         414 :     return mrBookGlob.getTables();
     959             : }
     960             : 
     961           0 : ScenarioBuffer& WorkbookHelper::getScenarios() const
     962             : {
     963           0 :     return mrBookGlob.getScenarios();
     964             : }
     965             : 
     966           0 : ConnectionsBuffer& WorkbookHelper::getConnections() const
     967             : {
     968           0 :     return mrBookGlob.getConnections();
     969             : }
     970             : 
     971           8 : PivotCacheBuffer& WorkbookHelper::getPivotCaches() const
     972             : {
     973           8 :     return mrBookGlob.getPivotCaches();
     974             : }
     975             : 
     976         149 : PivotTableBuffer& WorkbookHelper::getPivotTables() const
     977             : {
     978         149 :     return mrBookGlob.getPivotTables();
     979             : }
     980             : 
     981             : // converters -----------------------------------------------------------------
     982             : 
     983         307 : FormulaParser& WorkbookHelper::getFormulaParser() const
     984             : {
     985         307 :     return mrBookGlob.getFormulaParser();
     986             : }
     987             : 
     988         269 : FormulaParser* WorkbookHelper::createFormulaParser() const
     989             : {
     990         269 :     return mrBookGlob.createFormulaParser();
     991             : }
     992             : 
     993        3760 : UnitConverter& WorkbookHelper::getUnitConverter() const
     994             : {
     995        3760 :     return mrBookGlob.getUnitConverter();
     996             : }
     997             : 
     998        5377 : AddressConverter& WorkbookHelper::getAddressConverter() const
     999             : {
    1000        5377 :     return mrBookGlob.getAddressConverter();
    1001             : }
    1002             : 
    1003         140 : oox::drawingml::chart::ChartConverter* WorkbookHelper::getChartConverter() const
    1004             : {
    1005         140 :     return mrBookGlob.getChartConverter();
    1006             : }
    1007             : 
    1008           0 : void WorkbookHelper::useInternalChartDataTable( bool bInternal )
    1009             : {
    1010           0 :     mrBookGlob.useInternalChartDataTable( bInternal );
    1011           0 : }
    1012             : 
    1013         269 : PageSettingsConverter& WorkbookHelper::getPageSettingsConverter() const
    1014             : {
    1015         269 :     return mrBookGlob.getPageSettingsConverter();
    1016             : }
    1017             : 
    1018             : // OOXML/BIFF12 specific ------------------------------------------------------
    1019             : 
    1020        2438 : XmlFilterBase& WorkbookHelper::getOoxFilter() const
    1021             : {
    1022             :     OSL_ENSURE( mrBookGlob.getFilterType() == FILTER_OOXML, "WorkbookHelper::getOoxFilter - invalid call" );
    1023        2438 :     return mrBookGlob.getOoxFilter();
    1024             : }
    1025             : 
    1026         443 : bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler )
    1027             : {
    1028         443 :     return getOoxFilter().importFragment( rxHandler );
    1029             : }
    1030             : 
    1031         279 : bool WorkbookHelper::importOoxFragment( const rtl::Reference<FragmentHandler>& rxHandler, oox::core::FastParser& rParser )
    1032             : {
    1033         279 :     return getOoxFilter().importFragment(rxHandler, rParser);
    1034             : }
    1035             : 
    1036             : // BIFF specific --------------------------------------------------------------
    1037             : 
    1038         414 : BiffType WorkbookHelper::getBiff() const
    1039             : {
    1040         414 :     return mrBookGlob.getBiff();
    1041             : }
    1042             : 
    1043           9 : rtl_TextEncoding WorkbookHelper::getTextEncoding() const
    1044             : {
    1045           9 :     return mrBookGlob.getTextEncoding();
    1046             : }
    1047             : 
    1048           0 : BiffCodecHelper& WorkbookHelper::getCodecHelper() const
    1049             : {
    1050           0 :     return mrBookGlob.getCodecHelper();
    1051             : }
    1052             : 
    1053             : } // namespace xls
    1054          30 : } // namespace oox
    1055             : 
    1056             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11