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

Generated by: LCOV version 1.10