LCOV - code coverage report
Current view: top level - sc/source/filter/inc - workbookhelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 2 0.0 %
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             : #ifndef OOX_XLS_WORKBOOKHELPER_HXX
      21             : #define OOX_XLS_WORKBOOKHELPER_HXX
      22             : 
      23             : #include <boost/shared_ptr.hpp>
      24             : #include <rtl/ref.hxx>
      25             : #include "oox/helper/storagebase.hxx"
      26             : #include "oox/drawingml/chart/chartconverter.hxx"
      27             : #include "biffhelper.hxx"
      28             : #include "rangenam.hxx"
      29             : 
      30             : namespace com { namespace sun { namespace star {
      31             :     namespace container { class XNameAccess; }
      32             :     namespace container { class XNameContainer; }
      33             :     namespace lang { class XMultiServiceFactory; }
      34             :     namespace sheet { class XDatabaseRange; }
      35             :     namespace sheet { class XNamedRange; }
      36             :     namespace sheet { class XSpreadsheet; }
      37             :     namespace sheet { class XSpreadsheetDocument; }
      38             :     namespace sheet { struct FormulaToken; }
      39             :     namespace style { class XStyle; }
      40             :     namespace table { struct CellAddress; }
      41             :     namespace table { struct CellRangeAddress; }
      42             :     namespace table { class XCell; }
      43             :     namespace table { class XCellRange; }
      44             : } } }
      45             : 
      46             : namespace oox {
      47             :     class AttributeList;
      48             :     class SegmentProgressBar;
      49             :     class ISegmentProgressBar;
      50             : }
      51             : 
      52             : namespace oox { namespace core {
      53             :     class FilterBase;
      54             :     class FragmentHandler;
      55             :     class XmlFilterBase;
      56             :     class FastParser;
      57             : } }
      58             : 
      59             : class ScDocument;
      60             : class ScDocShell;
      61             : class ScDocumentImport;
      62             : class ScEditEngineDefaulter;
      63             : 
      64             : namespace oox {
      65             : namespace xls {
      66             : 
      67             : class ExcelFilter;
      68             : 
      69             : /** An enumeration for all supported spreadsheet filter types. */
      70             : enum FilterType
      71             : {
      72             :     FILTER_OOXML,       /// MS Excel OOXML (Office Open XML) or BIFF12.
      73             :     FILTER_BIFF,        /// MS Excel BIFF2-BIFF8 (Binary Interchange File Format).
      74             :     FILTER_UNKNOWN      /// Unknown filter type.
      75             : };
      76             : 
      77             : /** Functor for case-insensitive string comparison, usable in maps etc. */
      78             : struct IgnoreCaseCompare
      79             : {
      80             :     bool operator()( const OUString& rName1, const OUString& rName2 ) const;
      81             : };
      82             : 
      83             : class AddressConverter;
      84             : class BiffCodecHelper;
      85             : class ConnectionsBuffer;
      86             : class DefinedNamesBuffer;
      87             : class ExcelChartConverter;
      88             : class ExternalLinkBuffer;
      89             : class FormulaParser;
      90             : class PageSettingsConverter;
      91             : class PivotCacheBuffer;
      92             : class PivotTableBuffer;
      93             : class ScenarioBuffer;
      94             : class SharedStringsBuffer;
      95             : class StylesBuffer;
      96             : class TableBuffer;
      97             : class ThemeBuffer;
      98             : class UnitConverter;
      99             : class ViewSettings;
     100             : class WorkbookSettings;
     101             : class WorksheetBuffer;
     102             : class FormulaBuffer;
     103             : 
     104             : class WorkbookGlobals;
     105             : typedef ::boost::shared_ptr< WorkbookGlobals > WorkbookGlobalsRef;
     106             : 
     107             : /** Helper class to provice access to global workbook data.
     108             : 
     109             :     All classes derived from this helper class will have access to a singleton
     110             :     object of type WorkbookGlobals containing global workbook settings,
     111             :     buffers, converters, etc. Nearly all classes in this filter implementation
     112             :     are derived directly or indirectly from this class.
     113             : 
     114             :     This class contains just a simple reference to the WorkbookGlobals object
     115             :     to prevent circular references, as the WorkbookGlobals object contains a
     116             :     lot of objects derived from this class.
     117             :  */
     118           0 : class WorkbookHelper
     119             : {
     120             : public:
     121           0 :     inline /*implicit*/ WorkbookHelper( WorkbookGlobals& rBookGlob ) : mrBookGlob( rBookGlob ) {}
     122             :     virtual             ~WorkbookHelper();
     123             : 
     124             :     static WorkbookGlobalsRef constructGlobals( ExcelFilter& rFilter );
     125             : 
     126             :     // filter -----------------------------------------------------------------
     127             : 
     128             :     /** Returns the base filter object (base class of all filters). */
     129             :     ::oox::core::FilterBase& getBaseFilter() const;
     130             :     /** Returns the file type of the current filter. */
     131             :     FilterType          getFilterType() const;
     132             :     /** Returns the filter progress bar. */
     133             :     SegmentProgressBar& getProgressBar() const;
     134             :     /** Returns true, if the file is a multi-sheet document, or false if single-sheet. */
     135             :     bool                isWorkbookFile() const;
     136             :     /** Returns the index of the current Calc sheet, if filter currently processes a sheet. */
     137             :     sal_Int16           getCurrentSheetIndex() const;
     138             : 
     139             :     /** Sets the VBA project storage used to import VBA source code and forms. */
     140             :     void                setVbaProjectStorage( const StorageRef& rxVbaPrjStrg );
     141             :     /** Sets the index of the current Calc sheet, if filter currently processes a sheet. */
     142             :     void                setCurrentSheetIndex( sal_Int16 nSheet );
     143             :     /** Final conversion after importing the workbook. */
     144             :     void                finalizeWorkbookImport();
     145             :     void                useInternalChartDataTable( bool bInternal );
     146             : 
     147             :     // document model ---------------------------------------------------------
     148             :     ScDocument& getScDocument();
     149             :     const ScDocument& getScDocument() const;
     150             : 
     151             :     ScDocumentImport& getDocImport();
     152             : 
     153             :     ScEditEngineDefaulter& getEditEngine() const;
     154             :     /** Returns a reference to the source/target spreadsheet document model. */
     155             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
     156             :                         getDocument() const;
     157             : 
     158             :     /** Returns a reference to the specified spreadsheet in the document model. */
     159             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
     160             :                         getSheetFromDoc( sal_Int32 nSheet ) const;
     161             :     /** Returns a reference to the specified spreadsheet in the document model. */
     162             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
     163             :                         getSheetFromDoc( const OUString& rSheet ) const;
     164             : 
     165             :     /** Returns the XCellRange interface for the passed cell range address. */
     166             :     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
     167             :                         getCellRangeFromDoc(
     168             :                             const ::com::sun::star::table::CellRangeAddress& rRange ) const;
     169             : 
     170             :     /** Returns the cell or page styles container from the Calc document. */
     171             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     172             :                         getStyleFamily( bool bPageStyles ) const;
     173             :     /** Returns the specified cell or page style from the Calc document. */
     174             :     ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >
     175             :                         getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
     176             : 
     177             :     /** Creates and returns a defined name on-the-fly in the Calc document.
     178             :         The name will not be buffered in the global defined names buffer.
     179             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     180             :     ScRangeData* createNamedRangeObject(
     181             :                             OUString& orName,
     182             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
     183             :                             sal_Int32 nIndex,
     184             :                             sal_Int32 nNameFlags = 0 ) const;
     185             : 
     186             :     /** Creates and returns a defined name on-the-fly in the sheet.
     187             :         The name will not be buffered in the global defined names buffer.
     188             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     189             :     ScRangeData* createLocalNamedRangeObject(
     190             :                             OUString& orName,
     191             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
     192             :                             sal_Int32 nIndex,
     193             :                             sal_Int32 nNameFlags = 0, sal_Int32 nTab = -1 ) const;
     194             : 
     195             :     /** Creates and returns a database range on-the-fly in the Calc document.
     196             :         The range will not be buffered in the global table buffer.
     197             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     198             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >
     199             :                         createDatabaseRangeObject(
     200             :                             OUString& orName,
     201             :                             const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const;
     202             : 
     203             :     /** Creates and returns an unnamed database range on-the-fly in the Calc document.
     204             :         The range will not be buffered in the global table buffer. */
     205             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >
     206             :                         createUnnamedDatabaseRangeObject(
     207             :                             const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const;
     208             : 
     209             :     /** Creates and returns a com.sun.star.style.Style object for cells or pages. */
     210             :     ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >
     211             :                         createStyleObject(
     212             :                             OUString& orStyleName,
     213             :                             bool bPageStyle ) const;
     214             : 
     215             :     // buffers ----------------------------------------------------------------
     216             : 
     217             :     FormulaBuffer&      getFormulaBuffer() const;
     218             :     /** Returns the global workbook settings object. */
     219             :     WorkbookSettings&   getWorkbookSettings() const;
     220             :     /** Returns the workbook and sheet view settings object. */
     221             :     ViewSettings&       getViewSettings() const;
     222             :     /** Returns the worksheet buffer containing sheet names and properties. */
     223             :     WorksheetBuffer&    getWorksheets() const;
     224             :     /** Returns the office theme object read from the theme substorage. */
     225             :     ThemeBuffer&        getTheme() const;
     226             :     /** Returns all cell formatting objects read from the styles substream. */
     227             :     StylesBuffer&       getStyles() const;
     228             :     /** Returns the shared strings read from the shared strings substream. */
     229             :     SharedStringsBuffer& getSharedStrings() const;
     230             :     /** Returns the external links read from the external links substream. */
     231             :     ExternalLinkBuffer& getExternalLinks() const;
     232             :     /** Returns the defined names read from the workbook globals. */
     233             :     DefinedNamesBuffer& getDefinedNames() const;
     234             :     /** Returns the tables collection (equivalent to Calc's database ranges). */
     235             :     TableBuffer&        getTables() const;
     236             :     /** Returns the scenarios collection. */
     237             :     ScenarioBuffer&     getScenarios() const;
     238             :     /** Returns the collection of external data connections. */
     239             :     ConnectionsBuffer&  getConnections() const;
     240             :     /** Returns the collection of pivot caches. */
     241             :     PivotCacheBuffer&   getPivotCaches() const;
     242             :     /** Returns the collection of pivot tables. */
     243             :     PivotTableBuffer&   getPivotTables() const;
     244             : 
     245             :     // converters -------------------------------------------------------------
     246             : 
     247             :     /** Returns the import formula parser (import filter only!). */
     248             :     FormulaParser&      getFormulaParser() const;
     249             :     /** Returns the measurement unit converter. */
     250             :     UnitConverter&      getUnitConverter() const;
     251             :     /** Returns the converter for string to cell address/range conversion. */
     252             :     AddressConverter&   getAddressConverter() const;
     253             :     /** Returns the chart object converter. */
     254             :     oox::drawingml::chart::ChartConverter* getChartConverter() const;
     255             :     /** Returns the page and print settings converter. */
     256             :     PageSettingsConverter& getPageSettingsConverter() const;
     257             : 
     258             :     // OOXML/BIFF12 specific (MUST NOT be called in BIFF filter) --------------
     259             : 
     260             :     /** Returns the base OOXML/BIFF12 filter object.
     261             :         Must not be called, if current filter is not the OOXML/BIFF12 filter. */
     262             :     ::oox::core::XmlFilterBase& getOoxFilter() const;
     263             : 
     264             :     /** Imports a fragment using the passed fragment handler, which contains
     265             :         the full path to the fragment stream. */
     266             :     bool importOoxFragment( const rtl::Reference<oox::core::FragmentHandler>& rxHandler );
     267             : 
     268             :     bool importOoxFragment( const rtl::Reference<oox::core::FragmentHandler>& rxHandler, oox::core::FastParser& rParser );
     269             : 
     270             : 
     271             :     // BIFF2-BIFF8 specific (MUST NOT be called in OOXML/BIFF12 filter) -------
     272             : 
     273             :     /** Returns the BIFF type in binary filter. */
     274             :     BiffType            getBiff() const;
     275             : 
     276             :     /** Returns the text encoding used to import/export byte strings. */
     277             :     rtl_TextEncoding    getTextEncoding() const;
     278             : 
     279             :     /** Returns the codec helper that stores the encoder/decoder object. */
     280             :     BiffCodecHelper&    getCodecHelper() const;
     281             : 
     282             : private:
     283             :     WorkbookGlobals&    mrBookGlob;
     284             : };
     285             : 
     286             : } // namespace xls
     287             : } // namespace oox
     288             : 
     289             : #endif
     290             : 
     291             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10