LCOV - code coverage report
Current view: top level - sc/source/filter/inc - workbookhelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 2 100.0 %
Date: 2015-06-13 12:38:46 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 INCLUDED_SC_SOURCE_FILTER_INC_WORKBOOKHELPER_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_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       39095 : class WorkbookHelper
     119             : {
     120             : public:
     121        7929 :     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             :     const ScDocumentImport& getDocImport() const;
     153             : 
     154             :     ScEditEngineDefaulter& getEditEngine() const;
     155             :     /** Returns a reference to the source/target spreadsheet document model. */
     156             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
     157             :                         getDocument() const;
     158             : 
     159             :     /** Returns a reference to the specified spreadsheet in the document model. */
     160             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
     161             :                         getSheetFromDoc( sal_Int32 nSheet ) const;
     162             :     /** Returns a reference to the specified spreadsheet in the document model. */
     163             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >
     164             :                         getSheetFromDoc( const OUString& rSheet ) const;
     165             : 
     166             :     /** Returns the XCellRange interface for the passed cell range address. */
     167             :     ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
     168             :                         getCellRangeFromDoc(
     169             :                             const ::com::sun::star::table::CellRangeAddress& rRange ) const;
     170             : 
     171             :     /** Returns the cell or page styles container from the Calc document. */
     172             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     173             :                         getStyleFamily( bool bPageStyles ) const;
     174             :     /** Returns the specified cell or page style from the Calc document. */
     175             :     ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >
     176             :                         getStyleObject( const OUString& rStyleName, bool bPageStyle ) const;
     177             : 
     178             :     /** Creates and returns a defined name on-the-fly in the Calc document.
     179             :         The name will not be buffered in the global defined names buffer.
     180             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     181             :     ScRangeData* createNamedRangeObject(
     182             :                             OUString& orName,
     183             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
     184             :                             sal_Int32 nIndex,
     185             :                             sal_Int32 nNameFlags = 0 ) const;
     186             : 
     187             :     /** Creates and returns a defined name on-the-fly in the sheet.
     188             :         The name will not be buffered in the global defined names buffer.
     189             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     190             :     ScRangeData* createLocalNamedRangeObject(
     191             :                             OUString& orName,
     192             :                             const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken>& rTokens,
     193             :                             sal_Int32 nIndex,
     194             :                             sal_Int32 nNameFlags = 0, sal_Int32 nTab = -1 ) const;
     195             : 
     196             :     /** Creates and returns a database range on-the-fly in the Calc document.
     197             :         The range will not be buffered in the global table buffer.
     198             :         @param orName  (in/out-parameter) Returns the resulting used name. */
     199             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >
     200             :                         createDatabaseRangeObject(
     201             :                             OUString& orName,
     202             :                             const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const;
     203             : 
     204             :     /** Creates and returns an unnamed database range on-the-fly in the Calc document.
     205             :         The range will not be buffered in the global table buffer. */
     206             :     ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >
     207             :                         createUnnamedDatabaseRangeObject(
     208             :                             const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const;
     209             : 
     210             :     /** Creates and returns a com.sun.star.style.Style object for cells or pages. */
     211             :     ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >
     212             :                         createStyleObject(
     213             :                             OUString& orStyleName,
     214             :                             bool bPageStyle ) const;
     215             : 
     216             :     // buffers ----------------------------------------------------------------
     217             : 
     218             :     FormulaBuffer&      getFormulaBuffer() const;
     219             :     /** Returns the global workbook settings object. */
     220             :     WorkbookSettings&   getWorkbookSettings() const;
     221             :     /** Returns the workbook and sheet view settings object. */
     222             :     ViewSettings&       getViewSettings() const;
     223             :     /** Returns the worksheet buffer containing sheet names and properties. */
     224             :     WorksheetBuffer&    getWorksheets() const;
     225             :     /** Returns the office theme object read from the theme substorage. */
     226             :     ThemeBuffer&        getTheme() const;
     227             :     /** Returns all cell formatting objects read from the styles substream. */
     228             :     StylesBuffer&       getStyles() const;
     229             :     /** Returns the shared strings read from the shared strings substream. */
     230             :     SharedStringsBuffer& getSharedStrings() const;
     231             :     /** Returns the external links read from the external links substream. */
     232             :     ExternalLinkBuffer& getExternalLinks() const;
     233             :     /** Returns the defined names read from the workbook globals. */
     234             :     DefinedNamesBuffer& getDefinedNames() const;
     235             :     /** Returns the tables collection (equivalent to Calc's database ranges). */
     236             :     TableBuffer&        getTables() const;
     237             :     /** Returns the scenarios collection. */
     238             :     ScenarioBuffer&     getScenarios() const;
     239             :     /** Returns the collection of external data connections. */
     240             :     ConnectionsBuffer&  getConnections() const;
     241             :     /** Returns the collection of pivot caches. */
     242             :     PivotCacheBuffer&   getPivotCaches() const;
     243             :     /** Returns the collection of pivot tables. */
     244             :     PivotTableBuffer&   getPivotTables() const;
     245             : 
     246             :     // converters -------------------------------------------------------------
     247             : 
     248             :     /** Returns a shared import formula parser (import filter only!). */
     249             :     FormulaParser&      getFormulaParser() const;
     250             :     /** Returns an unshared import formula parser (import filter only!). */
     251             :     FormulaParser*      createFormulaParser() const;
     252             :     /** Returns the measurement unit converter. */
     253             :     UnitConverter&      getUnitConverter() const;
     254             :     /** Returns the converter for string to cell address/range conversion. */
     255             :     AddressConverter&   getAddressConverter() const;
     256             :     /** Returns the chart object converter. */
     257             :     oox::drawingml::chart::ChartConverter* getChartConverter() const;
     258             :     /** Returns the page and print settings converter. */
     259             :     PageSettingsConverter& getPageSettingsConverter() const;
     260             : 
     261             :     // OOXML/BIFF12 specific (MUST NOT be called in BIFF filter) --------------
     262             : 
     263             :     /** Returns the base OOXML/BIFF12 filter object.
     264             :         Must not be called, if current filter is not the OOXML/BIFF12 filter. */
     265             :     ::oox::core::XmlFilterBase& getOoxFilter() const;
     266             : 
     267             :     /** Imports a fragment using the passed fragment handler, which contains
     268             :         the full path to the fragment stream. */
     269             :     bool importOoxFragment( const rtl::Reference<oox::core::FragmentHandler>& rxHandler );
     270             : 
     271             :     bool importOoxFragment( const rtl::Reference<oox::core::FragmentHandler>& rxHandler, oox::core::FastParser& rParser );
     272             : 
     273             :     // BIFF2-BIFF8 specific (MUST NOT be called in OOXML/BIFF12 filter) -------
     274             : 
     275             :     /** Returns the BIFF type in binary filter. */
     276             :     BiffType            getBiff() const;
     277             : 
     278             :     /** Returns the text encoding used to import/export byte strings. */
     279             :     rtl_TextEncoding    getTextEncoding() const;
     280             : 
     281             :     /** Returns the codec helper that stores the encoder/decoder object. */
     282             :     BiffCodecHelper&    getCodecHelper() const;
     283             : 
     284             : private:
     285             :     WorkbookGlobals&    mrBookGlob;
     286             : };
     287             : 
     288             : } // namespace xls
     289             : } // namespace oox
     290             : 
     291             : #endif
     292             : 
     293             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11