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 <boost/shared_ptr.hpp>
28 :
29 : // Forward declarations of objects in public use ==============================
30 :
31 : class XclExpRecordBase;
32 : class XclExpString;
33 :
34 : typedef boost::shared_ptr< XclExpRecordBase > XclExpRecordRef;
35 : typedef boost::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 boost::shared_ptr< XclExpTabInfo > XclExpTabInfoRef;
61 : typedef boost::shared_ptr< XclExpAddressConverter > XclExpAddrConvRef;
62 : typedef boost::shared_ptr< XclExpFormulaCompiler > XclExpFmlaCompRef;
63 : typedef boost::shared_ptr< XclExpProgressBar > XclExpProgressRef;
64 :
65 : typedef boost::shared_ptr< XclExpSst > XclExpSstRef;
66 : typedef boost::shared_ptr< XclExpPalette > XclExpPaletteRef;
67 : typedef boost::shared_ptr< XclExpFontBuffer > XclExpFontBfrRef;
68 : typedef boost::shared_ptr< XclExpNumFmtBuffer > XclExpNumFmtBfrRef;
69 : typedef boost::shared_ptr< XclExpXFBuffer > XclExpXFBfrRef;
70 : typedef boost::shared_ptr< XclExpNameManager > XclExpNameMgrRef;
71 : typedef boost::shared_ptr< XclExpLinkManager > XclExpLinkMgrRef;
72 : typedef boost::shared_ptr< XclExpObjectManager > XclExpObjectMgrRef;
73 : typedef boost::shared_ptr< XclExpFilterManager > XclExpFilterMgrRef;
74 : typedef boost::shared_ptr< XclExpPivotTableManager > XclExpPTableMgrRef;
75 : typedef boost::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 : boost::shared_ptr<XclExpXmlPivotTableManager> mxXmlPTableMgr;
96 : boost::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 : explicit XclExpRootData( XclBiff eBiff, SfxMedium& rMedium,
103 : SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc );
104 : virtual ~XclExpRootData();
105 : };
106 :
107 : /** Access to global data from other classes. */
108 193802 : class XclExpRoot : public XclRoot
109 : {
110 : public:
111 : explicit XclExpRoot( XclExpRootData& rExpRootData );
112 :
113 : /** Returns this root instance - for code readability in derived classes. */
114 209784 : inline const XclExpRoot& GetRoot() const { return *this; }
115 : /** Returns true, if URLs should be stored relative to the document location. */
116 0 : inline bool IsRelUrl() const { return mrExpData.mbRelUrl; }
117 1120 : sc::CompileFormulaContext& GetCompileFormulaContext() const { return *mrExpData.mpCompileFormulaCxt; }
118 :
119 : /** Returns the buffer for Calc->Excel sheet index conversion. */
120 : XclExpTabInfo& GetTabInfo() const;
121 : /** Returns the address converter. */
122 : XclExpAddressConverter& GetAddressConverter() const;
123 : /** Returns the formula compiler to produce formula token arrays. */
124 : XclExpFormulaCompiler& GetFormulaCompiler() const;
125 : /** Returns the export progress bar. */
126 : XclExpProgressBar& GetProgressBar() const;
127 :
128 : /** Returns the shared string table. */
129 : XclExpSst& GetSst() const;
130 : /** Returns the color buffer. */
131 : XclExpPalette& GetPalette() const;
132 : /** Returns the font buffer. */
133 : XclExpFontBuffer& GetFontBuffer() const;
134 : /** Returns the number format buffer. */
135 : XclExpNumFmtBuffer& GetNumFmtBuffer() const;
136 : /** Returns the cell formatting attributes buffer. */
137 : XclExpXFBuffer& GetXFBuffer() const;
138 : /** Returns the global link manager for defined names. */
139 : XclExpLinkManager& GetGlobalLinkManager() const;
140 : /** Returns the local link manager for the current sheet. */
141 : XclExpLinkManager& GetLocalLinkManager() const;
142 : /** Returns the buffer that contains internal defined names. */
143 : XclExpNameManager& GetNameManager() const;
144 : /** Returns the drawing object manager. */
145 : XclExpObjectManager& GetObjectManager() const;
146 : /** Returns the filter manager. */
147 : XclExpFilterManager& GetFilterManager() const;
148 : /** Returns the pivot table manager. */
149 : XclExpPivotTableManager& GetPivotTableManager() const;
150 : /** Returns the differential formatting list */
151 : XclExpDxfs& GetDxfs() const;
152 :
153 : XclExpXmlPivotTableManager& GetXmlPivotTableManager();
154 :
155 : /** Is called when export filter starts to create the Excel document (all BIFF versions). */
156 : void InitializeConvert();
157 : /** Is called when export filter starts to create the workbook global data (>=BIFF5). */
158 : void InitializeGlobals();
159 : /** Is called when export filter starts to create data for a single sheet (all BIFF versions). */
160 : void InitializeTable( SCTAB nScTab );
161 : /** Is called before export filter starts to write the records to the stream. */
162 : void InitializeSave();
163 : /** Returns the reference to a record (or record list) representing a root object.
164 : @param nRecId Identifier that specifies which record is returned. */
165 : XclExpRecordRef CreateRecord( sal_uInt16 nRecId ) const;
166 :
167 : bool IsDocumentEncrypted() const;
168 :
169 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateEncryptionData( const OUString& aPass ) const;
170 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetEncryptionData() const;
171 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GenerateDefaultEncryptionData() const;
172 :
173 : private:
174 :
175 : /** Returns the local or global link manager, depending on current context. */
176 : XclExpRootData::XclExpLinkMgrRef GetLocalLinkMgrRef() const;
177 :
178 : private:
179 : XclExpRootData& mrExpData; /// Reference to the global export data struct.
180 : };
181 :
182 : #endif
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|