LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xeroot.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 5 80.0 %
Date: 2015-06-13 12:38:46 Functions: 5 7 71.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             : #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XEROOT_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_XEROOT_HXX
      22             : 
      23             : #include <com/sun/star/beans/NamedValue.hpp>
      24             : 
      25             : #include "xlroot.hxx"
      26             : #include "compiler.hxx"
      27             : #include <memory>
      28             : 
      29             : // Forward declarations of objects in public use ==============================
      30             : 
      31             : class XclExpRecordBase;
      32             : class XclExpString;
      33             : 
      34             : typedef std::shared_ptr< XclExpRecordBase >  XclExpRecordRef;
      35             : typedef std::shared_ptr< XclExpString >      XclExpStringRef;
      36             : 
      37             : // Global data ================================================================
      38             : 
      39             : class XclExpTabInfo;
      40             : class XclExpAddressConverter;
      41             : class XclExpFormulaCompiler;
      42             : class XclExpProgressBar;
      43             : class XclExpSst;
      44             : class XclExpPalette;
      45             : class XclExpFontBuffer;
      46             : class XclExpNumFmtBuffer;
      47             : class XclExpXFBuffer;
      48             : class XclExpLinkManager;
      49             : class XclExpNameManager;
      50             : class XclExpObjectManager;
      51             : class XclExpFilterManager;
      52             : class XclExpPivotTableManager;
      53             : class XclExpDxfs;
      54             : class XclExpXmlPivotTableManager;
      55             : namespace sc { class CompileFormulaContext; }
      56             : 
      57             : /** Stores global buffers and data needed for Excel export filter. */
      58             : struct XclExpRootData : public XclRootData
      59             : {
      60             :     typedef std::shared_ptr< XclExpTabInfo >             XclExpTabInfoRef;
      61             :     typedef std::shared_ptr< XclExpAddressConverter >    XclExpAddrConvRef;
      62             :     typedef std::shared_ptr< XclExpFormulaCompiler >     XclExpFmlaCompRef;
      63             :     typedef std::shared_ptr< XclExpProgressBar >         XclExpProgressRef;
      64             : 
      65             :     typedef std::shared_ptr< XclExpSst >                 XclExpSstRef;
      66             :     typedef std::shared_ptr< XclExpPalette >             XclExpPaletteRef;
      67             :     typedef std::shared_ptr< XclExpFontBuffer >          XclExpFontBfrRef;
      68             :     typedef std::shared_ptr< XclExpNumFmtBuffer >        XclExpNumFmtBfrRef;
      69             :     typedef std::shared_ptr< XclExpXFBuffer >            XclExpXFBfrRef;
      70             :     typedef std::shared_ptr< XclExpNameManager >         XclExpNameMgrRef;
      71             :     typedef std::shared_ptr< XclExpLinkManager >         XclExpLinkMgrRef;
      72             :     typedef std::shared_ptr< XclExpObjectManager >       XclExpObjectMgrRef;
      73             :     typedef std::shared_ptr< XclExpFilterManager >       XclExpFilterMgrRef;
      74             :     typedef std::shared_ptr< XclExpPivotTableManager >   XclExpPTableMgrRef;
      75             :     typedef std::shared_ptr< XclExpDxfs >                XclExpDxfsRef;
      76             : 
      77             :     XclExpTabInfoRef    mxTabInfo;          /// Calc->Excel sheet index conversion.
      78             :     XclExpAddrConvRef   mxAddrConv;         /// The address converter.
      79             :     XclExpFmlaCompRef   mxFmlaComp;         /// The formula compiler.
      80             :     XclExpProgressRef   mxProgress;         /// The export progress bar.
      81             : 
      82             :     XclExpSstRef        mxSst;              /// The shared string table.
      83             :     XclExpPaletteRef    mxPalette;          /// The color buffer.
      84             :     XclExpFontBfrRef    mxFontBfr;          /// All fonts in the file.
      85             :     XclExpNumFmtBfrRef  mxNumFmtBfr;        /// All number formats in the file.
      86             :     XclExpXFBfrRef      mxXFBfr;            /// All XF records in the file.
      87             :     XclExpNameMgrRef    mxNameMgr;          /// Internal defined names.
      88             :     XclExpLinkMgrRef    mxGlobLinkMgr;      /// Global link manager for defined names.
      89             :     XclExpLinkMgrRef    mxLocLinkMgr;       /// Local link manager for a sheet.
      90             :     XclExpObjectMgrRef  mxObjMgr;           /// All drawing objects.
      91             :     XclExpFilterMgrRef  mxFilterMgr;        /// Manager for filtered areas in all sheets.
      92             :     XclExpPTableMgrRef  mxPTableMgr;        /// All pivot tables and pivot caches.
      93             :     XclExpDxfsRef       mxDxfs;             /// All delta formatting entries
      94             : 
      95             :     std::shared_ptr<XclExpXmlPivotTableManager> mxXmlPTableMgr;
      96             :     std::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
      97             : 
      98             :     ScCompiler::OpCodeMapPtr  mxOpCodeMap;  /// mapping between op-codes and names
      99             : 
     100             :     bool                mbRelUrl;           /// true = Store URLs relative.
     101             : 
     102             :     OStringBuffer       maStringBuf;        /// buffer to avoid massive OUString allocations
     103             : 
     104             :     explicit            XclExpRootData( XclBiff eBiff, SfxMedium& rMedium,
     105             :                             tools::SvRef<SotStorage> xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc );
     106             :     virtual             ~XclExpRootData();
     107             : };
     108             : 
     109             : /** Access to global data from other classes. */
     110      236565 : class XclExpRoot : public XclRoot
     111             : {
     112             : public:
     113             :     explicit            XclExpRoot( XclExpRootData& rExpRootData );
     114             : 
     115             :     /** Returns this root instance - for code readability in derived classes. */
     116      239725 :     inline const XclExpRoot& GetRoot() const { return *this; }
     117             :     /** Returns true, if URLs should be stored relative to the document location. */
     118           0 :     inline bool         IsRelUrl() const { return mrExpData.mbRelUrl; }
     119         560 :     sc::CompileFormulaContext& GetCompileFormulaContext() const { return *mrExpData.mpCompileFormulaCxt; }
     120             : 
     121             :     /** Returns the buffer for Calc->Excel sheet index conversion. */
     122             :     XclExpTabInfo&      GetTabInfo() const;
     123             :     /** Returns the address converter. */
     124             :     XclExpAddressConverter& GetAddressConverter() const;
     125             :     /** Returns the formula compiler to produce formula token arrays. */
     126             :     XclExpFormulaCompiler& GetFormulaCompiler() const;
     127             :     /** Returns the export progress bar. */
     128             :     XclExpProgressBar&  GetProgressBar() const;
     129             : 
     130             :     /** Returns the shared string table. */
     131             :     XclExpSst&          GetSst() const;
     132             :     /** Returns the color buffer. */
     133             :     XclExpPalette&      GetPalette() const;
     134             :     /** Returns the font buffer. */
     135             :     XclExpFontBuffer&   GetFontBuffer() const;
     136             :     /** Returns the number format buffer. */
     137             :     XclExpNumFmtBuffer& GetNumFmtBuffer() const;
     138             :     /** Returns the cell formatting attributes buffer. */
     139             :     XclExpXFBuffer&     GetXFBuffer() const;
     140             :     /** Returns the global link manager for defined names. */
     141             :     XclExpLinkManager&  GetGlobalLinkManager() const;
     142             :     /** Returns the local link manager for the current sheet. */
     143             :     XclExpLinkManager&  GetLocalLinkManager() const;
     144             :     /** Returns the buffer that contains internal defined names. */
     145             :     XclExpNameManager&  GetNameManager() const;
     146             :     /** Returns the drawing object manager. */
     147             :     XclExpObjectManager& GetObjectManager() const;
     148             :     /** Returns the filter manager. */
     149             :     XclExpFilterManager& GetFilterManager() const;
     150             :     /** Returns the pivot table manager. */
     151             :     XclExpPivotTableManager& GetPivotTableManager() const;
     152             :     /** Returns the differential formatting list */
     153             :     XclExpDxfs&          GetDxfs() const;
     154             : 
     155             :     /** Clean and return the OStringBuffer */
     156        2095 :     inline OStringBuffer&   GetStringBuf() const { mrExpData.maStringBuf.setLength(0); return mrExpData.maStringBuf; }
     157             : 
     158             :     XclExpXmlPivotTableManager& GetXmlPivotTableManager();
     159             : 
     160             :     /** Is called when export filter starts to create the Excel document (all BIFF versions). */
     161             :     void                InitializeConvert();
     162             :     /** Is called when export filter starts to create the workbook global data (>=BIFF5). */
     163             :     void                InitializeGlobals();
     164             :     /** Is called when export filter starts to create data for a single sheet (all BIFF versions). */
     165             :     void                InitializeTable( SCTAB nScTab );
     166             :     /** Is called before export filter starts to write the records to the stream. */
     167             :     void                InitializeSave();
     168             :     /** Returns the reference to a record (or record list) representing a root object.
     169             :         @param nRecId  Identifier that specifies which record is returned. */
     170             :     XclExpRecordRef     CreateRecord( sal_uInt16 nRecId ) const;
     171             : 
     172             :     bool                IsDocumentEncrypted() const;
     173             : 
     174             :     static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateEncryptionData( const OUString& aPass );
     175             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetEncryptionData() const;
     176             :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateDefaultEncryptionData() const;
     177             : 
     178             : private:
     179             : 
     180             :     /** Returns the local or global link manager, depending on current context. */
     181             :     XclExpRootData::XclExpLinkMgrRef GetLocalLinkMgrRef() const;
     182             : 
     183             : private:
     184             :     XclExpRootData& mrExpData;      /// Reference to the global export data struct.
     185             : };
     186             : 
     187             : #endif
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11