LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xlroot.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 23 25 92.0 %
Date: 2015-06-13 12:38:46 Functions: 23 25 92.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_XLROOT_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_XLROOT_HXX
      22             : 
      23             : #include <com/sun/star/beans/NamedValue.hpp>
      24             : 
      25             : #include <i18nlangtag/lang.h>
      26             : #include <sot/storage.hxx>
      27             : #include "xlconst.hxx"
      28             : #include "xltools.hxx"
      29             : #include <documentimport.hxx>
      30             : #include <boost/shared_ptr.hpp>
      31             : 
      32             : namespace comphelper { class IDocPasswordVerifier; }
      33             : 
      34             : // Forward declarations of objects in public use ==============================
      35             : 
      36             : class DateTime;
      37             : 
      38             : struct XclAddress;
      39             : struct XclRange;
      40             : 
      41             : // Global data ================================================================
      42             : 
      43             : #ifdef DBG_UTIL
      44             : /** Counts the number of created root objects. */
      45             : struct XclDebugObjCounter
      46             : {
      47             :     sal_Int32           mnObjCnt;
      48             :     inline explicit     XclDebugObjCounter() : mnObjCnt( 0 ) {}
      49             :                         ~XclDebugObjCounter();
      50             : };
      51             : #endif
      52             : 
      53             : class SfxMedium;
      54             : class ScEditEngineDefaulter;
      55             : class ScHeaderEditEngine;
      56             : class EditEngine;
      57             : class ScExtDocOptions;
      58             : class XclFontPropSetHelper;
      59             : class XclChPropSetHelper;
      60             : class XclTracer;
      61             : 
      62             : struct RootData;//!
      63             : 
      64             : /** Stores global buffers and data needed elsewhere in the Excel filters. */
      65             : struct XclRootData
      66             : #ifdef DBG_UTIL
      67             :     : public XclDebugObjCounter
      68             : #endif
      69             : {
      70             :     typedef boost::shared_ptr< ScEditEngineDefaulter > ScEEDefaulterRef;
      71             :     typedef boost::shared_ptr< ScHeaderEditEngine >    ScHeaderEERef;
      72             :     typedef boost::shared_ptr< EditEngine >            EditEngineRef;
      73             :     typedef boost::shared_ptr< XclFontPropSetHelper >  XclFontPropSetHlpRef;
      74             :     typedef boost::shared_ptr< XclChPropSetHelper >    XclChPropSetHlpRef;
      75             :     typedef boost::shared_ptr< ScExtDocOptions >       ScExtDocOptRef;
      76             :     typedef boost::shared_ptr< XclTracer >             XclTracerRef;
      77             :     typedef boost::shared_ptr< RootData >              RootDataRef;
      78             : 
      79             :     XclBiff             meBiff;             /// Current BIFF version.
      80             :     XclOutput           meOutput;           /// Current Output format.
      81             :     SfxMedium&          mrMedium;           /// The medium to import from.
      82             :     tools::SvRef<SotStorage>       mxRootStrg;         /// The root OLE storage of imported/exported file.
      83             :     ScDocument&         mrDoc;              /// The source or destination document.
      84             :     ScDocumentImport    maDocImport;
      85             :     OUString            maDocUrl;           /// Document URL of imported/exported file.
      86             :     OUString            maBasePath;         /// Base path of imported/exported file (path of maDocUrl).
      87             :     OUString            maUserName;         /// Current user name.
      88             :     const OUString      maDefPassword;      /// The default password used for stream encryption.
      89             :     rtl_TextEncoding    meTextEnc;          /// Text encoding to import/export byte strings.
      90             :     LanguageType        meSysLang;          /// System language.
      91             :     LanguageType        meDocLang;          /// Document language (import: from file, export: from system).
      92             :     LanguageType        meUILang;           /// UI language (import: from file, export: from system).
      93             :     sal_Int16           mnDefApiScript;     /// Default script type for blank cells (API constant).
      94             :     ScAddress           maScMaxPos;         /// Highest Calc cell position.
      95             :     ScAddress           maXclMaxPos;        /// Highest Excel cell position.
      96             :     ScAddress           maMaxPos;           /// Highest position valid in Calc and Excel.
      97             : 
      98             :     ScEEDefaulterRef    mxEditEngine;       /// Edit engine for rich strings etc.
      99             :     ScHeaderEERef       mxHFEditEngine;     /// Edit engine for header/footer.
     100             :     EditEngineRef       mxDrawEditEng;      /// Edit engine for text boxes.
     101             : 
     102             :     XclFontPropSetHlpRef mxFontPropSetHlp;  /// Property set helper for fonts.
     103             :     XclChPropSetHlpRef  mxChPropSetHlp;     /// Property set helper for chart filter.
     104             : 
     105             :     ScExtDocOptRef      mxExtDocOpt;        /// Extended document options.
     106             :     XclTracerRef        mxTracer;           /// Filter tracer.
     107             :     RootDataRef         mxRD;               /// Old RootData struct. Will be removed.
     108             : 
     109             :     double              mfScreenPixelX;     /// Width of a screen pixel (1/100 mm).
     110             :     double              mfScreenPixelY;     /// Height of a screen pixel (1/100 mm).
     111             :     long                mnCharWidth;        /// Width of '0' in default font (twips).
     112             :     SCTAB               mnScTab;            /// Current Calc sheet index.
     113             :     const bool          mbExport;           /// false = Import, true = Export.
     114             : 
     115             :     explicit            XclRootData( XclBiff eBiff, SfxMedium& rMedium,
     116             :                             tools::SvRef<SotStorage> xRootStrg, ScDocument& rDoc,
     117             :                             rtl_TextEncoding eTextEnc, bool bExport );
     118             :     virtual             ~XclRootData();
     119             : };
     120             : 
     121             : class SfxObjectShell;
     122             : class ScModelObj;
     123             : class OutputDevice;
     124             : class SvNumberFormatter;
     125             : class SdrPage;
     126             : class ScStyleSheetPool;
     127             : class ScRangeName;
     128             : struct XclFontData;
     129             : 
     130             : /** Access to global data for a filter object (imported or exported document) from other classes. */
     131             : class XclRoot
     132             : {
     133             : public:
     134             :     explicit            XclRoot( XclRootData& rRootData );
     135             :                         XclRoot( const XclRoot& rRoot );
     136             : 
     137             :     virtual             ~XclRoot();
     138             : 
     139             :     XclRoot&            operator=( const XclRoot& rRoot );
     140             : 
     141             :     /** Returns this root instance - for code readability in derived classes. */
     142             :     inline const XclRoot& GetRoot() const { return *this; }
     143             :     /** Returns old RootData struct. Deprecated. */
     144        2422 :     inline RootData&    GetOldRoot() const { return *mrData.mxRD; }
     145             : 
     146             :     /** Returns the current BIFF version of the importer/exporter. */
     147       27011 :     inline XclBiff      GetBiff() const { return mrData.meBiff; }
     148             :     /** Returns the current output format of the importer/exporter. */
     149        1167 :     inline XclOutput    GetOutput() const { return mrData.meOutput; }
     150             :     /** Returns true, if currently a document is imported. */
     151         323 :     inline bool         IsImport() const { return !mrData.mbExport; }
     152             :     /** Returns true, if currently a document is exported. */
     153             :     inline bool         IsExport() const { return mrData.mbExport; }
     154             :     /** Returns the text encoding to import/export byte strings. */
     155        3611 :     inline rtl_TextEncoding GetTextEncoding() const { return mrData.meTextEnc; }
     156             :     /** Returns the system language, i.e. for number formats. */
     157          84 :     inline LanguageType GetSysLanguage() const { return mrData.meSysLang; }
     158             :     /** Returns the document language. */
     159          17 :     inline LanguageType GetDocLanguage() const { return mrData.meDocLang; }
     160             :     /** Returns the UI language. */
     161           0 :     inline LanguageType GetUILanguage() const { return mrData.meUILang; }
     162             :     /** Returns the default script type, e.g. for blank cells. */
     163      110623 :     inline sal_Int16    GetDefApiScript() const { return mrData.mnDefApiScript; }
     164             :     /** Returns the width of the '0' character (default font) for the current printer (twips). */
     165      110598 :     inline long         GetCharWidth() const { return mrData.mnCharWidth; }
     166             :     /** Returns the current Calc sheet index. */
     167         646 :     inline bool         IsInGlobals() const { return mrData.mnScTab == SCTAB_GLOBAL; }
     168             :     /** Returns the current Calc sheet index. */
     169      455676 :     inline SCTAB        GetCurrScTab() const { return mrData.mnScTab; }
     170             : 
     171             :     /** Calculates the width of the passed number of pixels in 1/100 mm. */
     172             :     sal_Int32           GetHmmFromPixelX( double fPixelX ) const;
     173             :     /** Calculates the height of the passed number of pixels in 1/100 mm. */
     174             :     sal_Int32           GetHmmFromPixelY( double fPixelY ) const;
     175             : 
     176             :     /** Returns the medium to import from. */
     177         136 :     inline SfxMedium&   GetMedium() const { return mrData.mrMedium; }
     178             :     /** Returns the document URL of the imported/exported file. */
     179         156 :     inline const OUString& GetDocUrl() const { return mrData.maDocUrl; }
     180             :     /** Returns the base path of the imported/exported file. */
     181         146 :     inline const OUString& GetBasePath() const { return mrData.maBasePath; }
     182             :     /** Returns the current user name. */
     183          17 :     inline const OUString& GetUserName() const { return mrData.maUserName; }
     184             : 
     185             :     /** Returns the default password used for stream encryption. */
     186           0 :     inline const OUString& GetDefaultPassword() const { return mrData.maDefPassword; }
     187             :     /** Requests and verifies a password from the medium or the user. */
     188             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
     189             :         RequestEncryptionData( ::comphelper::IDocPasswordVerifier& rVerifier ) const;
     190             : 
     191             :     /** Returns the OLE2 root storage of the imported/exported file.
     192             :         @return  Pointer to root storage or 0, if the file is a simple stream. */
     193         315 :     inline tools::SvRef<SotStorage> GetRootStorage() const { return mrData.mxRootStrg; }
     194             :     /** Returns true, if the document contains a VBA storage. */
     195             :     bool                HasVbaStorage() const;
     196             : 
     197             :     /** Tries to open a storage as child of the specified storage for reading or writing. */
     198             :     tools::SvRef<SotStorage>       OpenStorage( tools::SvRef<SotStorage> xStrg, const OUString& rStrgName ) const;
     199             :     /** Tries to open a storage as child of the root storage for reading or writing. */
     200             :     tools::SvRef<SotStorage>       OpenStorage( const OUString& rStrgName ) const;
     201             :     /** Tries to open a new stream in the specified storage for reading or writing. */
     202             :     tools::SvRef<SotStorageStream> OpenStream( tools::SvRef<SotStorage> xStrg, const OUString& rStrmName ) const;
     203             :     /** Tries to open a new stream in the root storage for reading or writing. */
     204             :     tools::SvRef<SotStorageStream> OpenStream( const OUString& rStrmName ) const;
     205             : 
     206             :     /** Returns the destination document (import) or source document (export). */
     207             :     ScDocument& GetDoc() const;
     208             :     /** Returns pointer to the destination document (import) or source document (export). */
     209             :     ScDocument* GetDocPtr() const;
     210             : 
     211             :     /** Returns the object shell of the Calc document. May be 0 (i.e. import from clipboard). */
     212             :     SfxObjectShell*     GetDocShell() const;
     213             :     /** Returns the object model of the Calc document. */
     214             :     ScModelObj*         GetDocModelObj() const;
     215             :     /** Returns pointer to the printer of the Calc document. */
     216             :     OutputDevice*       GetPrinter() const;
     217             :     /** Returns the style sheet pool of the Calc document. */
     218             :     ScStyleSheetPool&   GetStyleSheetPool() const;
     219             :     /** Returns the defined names container of the Calc document. */
     220             :     ScRangeName&        GetNamedRanges() const;
     221             :     /** Returns the drawing layer page of the passed sheet, if present. */
     222             :     SdrPage*            GetSdrPage( SCTAB nScTab ) const;
     223             : 
     224             :     /** Returns the number formatter of the Calc document. */
     225             :     SvNumberFormatter&  GetFormatter() const;
     226             :     /** Returns the null date of the current number formatter. */
     227             :     DateTime            GetNullDate() const;
     228             :     /** Returns the base year depending on the current null date (1900 or 1904). */
     229             :     sal_uInt16          GetBaseYear() const;
     230             :     /** Converts a date/time value to a floating-point value. */
     231             :     double              GetDoubleFromDateTime( const DateTime& rDateTime ) const;
     232             :     /** Converts a floating-point value to a date/time value. */
     233             :     DateTime            GetDateTimeFromDouble( double fValue ) const;
     234             : 
     235             :     /** Returns the edit engine for import/export of rich strings etc. */
     236             :     ScEditEngineDefaulter& GetEditEngine() const;
     237             :     /** Returns the edit engine for import/export of headers/footers. */
     238             :     ScHeaderEditEngine& GetHFEditEngine() const;
     239             :     /** Returns the edit engine for import/export of drawing text boxes. */
     240             :     EditEngine&         GetDrawEditEngine() const;
     241             : 
     242             :     /** Returns the property set helper for fonts. */
     243             :     XclFontPropSetHelper& GetFontPropSetHelper() const;
     244             :     /** Returns the property set helper for the chart filters. */
     245             :     XclChPropSetHelper& GetChartPropSetHelper() const;
     246             : 
     247             :     /** Returns the extended document options. */
     248             :     ScExtDocOptions&    GetExtDocOptions() const;
     249             :     /** Returns the filter tracer. */
     250             :     XclTracer&          GetTracer() const;
     251             : 
     252             :     /** Returns the highest possible cell address in a Calc document. */
     253         595 :     inline const ScAddress& GetScMaxPos() const { return mrData.maScMaxPos; }
     254             :     /** Returns the highest possible cell address in an Excel document (using current BIFF version). */
     255        1418 :     inline const ScAddress& GetXclMaxPos() const { return mrData.maXclMaxPos; }
     256             :     /** Returns the highest possible cell address valid in Calc and Excel (using current BIFF version). */
     257        3227 :     inline const ScAddress& GetMaxPos() const { return mrData.maMaxPos; }
     258             : 
     259             :     /** Sets the document language. */
     260          84 :     inline void         SetDocLanguage( LanguageType eLang ) { mrData.meDocLang = eLang; }
     261             :     /** Sets the UI language, i.e. if it has been read from a file. */
     262          84 :     inline void         SetUILanguage( LanguageType eLang ) { mrData.meUILang = eLang; }
     263             :     /** Sets the text encoding to import/export byte strings. */
     264             :     void                SetTextEncoding( rtl_TextEncoding eTextEnc );
     265             :     /** Sets the width of the '0' character (default font) for the current printer (twips).
     266             :         @param rFontData  The font used for the '0' character. */
     267             :     void                SetCharWidth( const XclFontData& rFontData );
     268             :     /** Sets the current Calc sheet index. */
     269         402 :     inline void         SetCurrScTab( SCTAB nScTab ) { mrData.mnScTab = nScTab; }
     270             :     /** Increases the current Calc sheet index by 1. */
     271         224 :     inline void         IncCurrScTab() { ++mrData.mnScTab; }
     272             : 
     273             : private:
     274             :     XclRootData& mrData;        /// Reference to the global data struct.
     275             : };
     276             : 
     277             : #endif
     278             : 
     279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11