Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / xeroot.hxx
blob34d44d7523770c14f9ad086802d0cd5a62478037
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_XEROOT_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_XEROOT_HXX
23 #include "xlroot.hxx"
24 #include <compiler.hxx>
25 #include <memory>
27 // Forward declarations of objects in public use ==============================
29 namespace com { namespace sun { namespace star { namespace beans { struct NamedValue; } } } }
31 class XclExpRecordBase;
32 class XclExpString;
34 typedef std::shared_ptr< XclExpRecordBase > XclExpRecordRef;
35 typedef std::shared_ptr< XclExpString > XclExpStringRef;
37 // Global data ================================================================
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 class XclExpTablesManager;
56 namespace sc { class CompileFormulaContext; }
58 /** Stores global buffers and data needed for Excel export filter. */
59 struct XclExpRootData : public XclRootData
61 typedef std::shared_ptr< XclExpTabInfo > XclExpTabInfoRef;
62 typedef std::shared_ptr< XclExpAddressConverter > XclExpAddrConvRef;
63 typedef std::shared_ptr< XclExpFormulaCompiler > XclExpFmlaCompRef;
64 typedef std::shared_ptr< XclExpProgressBar > XclExpProgressRef;
66 typedef std::shared_ptr< XclExpSst > XclExpSstRef;
67 typedef std::shared_ptr< XclExpPalette > XclExpPaletteRef;
68 typedef std::shared_ptr< XclExpFontBuffer > XclExpFontBfrRef;
69 typedef std::shared_ptr< XclExpNumFmtBuffer > XclExpNumFmtBfrRef;
70 typedef std::shared_ptr< XclExpXFBuffer > XclExpXFBfrRef;
71 typedef std::shared_ptr< XclExpNameManager > XclExpNameMgrRef;
72 typedef std::shared_ptr< XclExpLinkManager > XclExpLinkMgrRef;
73 typedef std::shared_ptr< XclExpObjectManager > XclExpObjectMgrRef;
74 typedef std::shared_ptr< XclExpFilterManager > XclExpFilterMgrRef;
75 typedef std::shared_ptr< XclExpPivotTableManager > XclExpPTableMgrRef;
76 typedef std::shared_ptr< XclExpDxfs > XclExpDxfsRef;
78 XclExpTabInfoRef mxTabInfo; /// Calc->Excel sheet index conversion.
79 XclExpAddrConvRef mxAddrConv; /// The address converter.
80 XclExpFmlaCompRef mxFmlaComp; /// The formula compiler.
81 XclExpProgressRef mxProgress; /// The export progress bar.
83 XclExpSstRef mxSst; /// The shared string table.
84 XclExpPaletteRef mxPalette; /// The color buffer.
85 XclExpFontBfrRef mxFontBfr; /// All fonts in the file.
86 XclExpNumFmtBfrRef mxNumFmtBfr; /// All number formats in the file.
87 XclExpXFBfrRef mxXFBfr; /// All XF records in the file.
88 XclExpNameMgrRef mxNameMgr; /// Internal defined names.
89 XclExpLinkMgrRef mxGlobLinkMgr; /// Global link manager for defined names.
90 XclExpLinkMgrRef mxLocLinkMgr; /// Local link manager for a sheet.
91 XclExpObjectMgrRef mxObjMgr; /// All drawing objects.
92 XclExpFilterMgrRef mxFilterMgr; /// Manager for filtered areas in all sheets.
93 XclExpPTableMgrRef mxPTableMgr; /// All pivot tables and pivot caches.
94 XclExpDxfsRef mxDxfs; /// All delta formatting entries
96 std::shared_ptr<XclExpXmlPivotTableManager> mxXmlPTableMgr;
97 std::shared_ptr<XclExpTablesManager> mxTablesMgr;
98 std::shared_ptr<sc::CompileFormulaContext> mpCompileFormulaCxt;
100 ScCompiler::OpCodeMapPtr mxOpCodeMap; /// mapping between op-codes and names
102 bool mbRelUrl; /// true = Store URLs relative.
104 OStringBuffer maStringBuf; /// buffer to avoid massive OUString allocations
106 explicit XclExpRootData( XclBiff eBiff, SfxMedium& rMedium,
107 const tools::SvRef<SotStorage>& xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc );
108 virtual ~XclExpRootData() override;
111 /** Access to global data from other classes. */
112 class XclExpRoot : public XclRoot
114 public:
115 explicit XclExpRoot( XclExpRootData& rExpRootData );
117 /** Returns this root instance - for code readability in derived classes. */
118 const XclExpRoot& GetRoot() const { return *this; }
119 /** Returns true, if URLs should be stored relative to the document location. */
120 bool IsRelUrl() const { return mrExpData.mbRelUrl; }
121 sc::CompileFormulaContext& GetCompileFormulaContext() const { return *mrExpData.mpCompileFormulaCxt; }
123 /** Returns the buffer for Calc->Excel sheet index conversion. */
124 XclExpTabInfo& GetTabInfo() const;
125 /** Returns the address converter. */
126 XclExpAddressConverter& GetAddressConverter() const;
127 /** Returns the formula compiler to produce formula token arrays. */
128 XclExpFormulaCompiler& GetFormulaCompiler() const;
129 /** Returns the export progress bar. */
130 XclExpProgressBar& GetProgressBar() const;
132 /** Returns the shared string table. */
133 XclExpSst& GetSst() const;
134 /** Returns the color buffer. */
135 XclExpPalette& GetPalette() const;
136 /** Returns the font buffer. */
137 XclExpFontBuffer& GetFontBuffer() const;
138 /** Returns the number format buffer. */
139 XclExpNumFmtBuffer& GetNumFmtBuffer() const;
140 /** Returns the cell formatting attributes buffer. */
141 XclExpXFBuffer& GetXFBuffer() const;
142 /** Returns the global link manager for defined names. */
143 XclExpLinkManager& GetGlobalLinkManager() const;
144 /** Returns the local link manager for the current sheet. */
145 XclExpLinkManager& GetLocalLinkManager() const;
146 /** Returns the buffer that contains internal defined names. */
147 XclExpNameManager& GetNameManager() const;
148 /** Returns the drawing object manager. */
149 XclExpObjectManager& GetObjectManager() const;
150 /** Returns the filter manager. */
151 XclExpFilterManager& GetFilterManager() const;
152 /** Returns the pivot table manager. */
153 XclExpPivotTableManager& GetPivotTableManager() const;
154 /** Returns the differential formatting list */
155 XclExpDxfs& GetDxfs() const;
157 /** Clean and return the OStringBuffer */
158 OStringBuffer& GetStringBuf() const { mrExpData.maStringBuf.setLength(0); return mrExpData.maStringBuf; }
160 XclExpXmlPivotTableManager& GetXmlPivotTableManager();
162 XclExpTablesManager& GetTablesManager();
164 /** Is called when export filter starts to create the Excel document (all BIFF versions). */
165 void InitializeConvert();
166 /** Is called when export filter starts to create the workbook global data (>=BIFF5). */
167 void InitializeGlobals();
168 /** Is called when export filter starts to create data for a single sheet (all BIFF versions). */
169 void InitializeTable( SCTAB nScTab );
170 /** Is called before export filter starts to write the records to the stream. */
171 void InitializeSave();
172 /** Returns the reference to a record (or record list) representing a root object.
173 @param nRecId Identifier that specifies which record is returned. */
174 XclExpRecordRef CreateRecord( sal_uInt16 nRecId ) const;
176 bool IsDocumentEncrypted() const;
178 static css::uno::Sequence< css::beans::NamedValue > GenerateEncryptionData( const OUString& aPass );
179 css::uno::Sequence< css::beans::NamedValue > GetEncryptionData() const;
180 static css::uno::Sequence< css::beans::NamedValue > GenerateDefaultEncryptionData();
182 private:
184 /** Returns the local or global link manager, depending on current context. */
185 XclExpRootData::XclExpLinkMgrRef const & GetLocalLinkMgrRef() const;
187 private:
188 XclExpRootData& mrExpData; /// Reference to the global export data struct.
191 #endif
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */