1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/beans/NamedValue.hpp>
26 #include "compiler.hxx"
29 // Forward declarations of objects in public use ==============================
31 class XclExpRecordBase
;
34 typedef std::shared_ptr
< XclExpRecordBase
> XclExpRecordRef
;
35 typedef std::shared_ptr
< XclExpString
> XclExpStringRef
;
37 // Global data ================================================================
40 class XclExpAddressConverter
;
41 class XclExpFormulaCompiler
;
42 class XclExpProgressBar
;
45 class XclExpFontBuffer
;
46 class XclExpNumFmtBuffer
;
48 class XclExpLinkManager
;
49 class XclExpNameManager
;
50 class XclExpObjectManager
;
51 class XclExpFilterManager
;
52 class XclExpPivotTableManager
;
54 class XclExpXmlPivotTableManager
;
55 namespace sc
{ class CompileFormulaContext
; }
57 /** Stores global buffers and data needed for Excel export filter. */
58 struct XclExpRootData
: public XclRootData
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
;
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
;
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.
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
95 std::shared_ptr
<XclExpXmlPivotTableManager
> mxXmlPTableMgr
;
96 std::shared_ptr
<sc::CompileFormulaContext
> mpCompileFormulaCxt
;
98 ScCompiler::OpCodeMapPtr mxOpCodeMap
; /// mapping between op-codes and names
100 bool mbRelUrl
; /// true = Store URLs relative.
102 OStringBuffer maStringBuf
; /// buffer to avoid massive OUString allocations
104 explicit XclExpRootData( XclBiff eBiff
, SfxMedium
& rMedium
,
105 tools::SvRef
<SotStorage
> xRootStrg
, ScDocument
& rDoc
, rtl_TextEncoding eTextEnc
);
106 virtual ~XclExpRootData();
109 /** Access to global data from other classes. */
110 class XclExpRoot
: public XclRoot
113 explicit XclExpRoot( XclExpRootData
& rExpRootData
);
115 /** Returns this root instance - for code readability in derived classes. */
116 inline const XclExpRoot
& GetRoot() const { return *this; }
117 /** Returns true, if URLs should be stored relative to the document location. */
118 inline bool IsRelUrl() const { return mrExpData
.mbRelUrl
; }
119 sc::CompileFormulaContext
& GetCompileFormulaContext() const { return *mrExpData
.mpCompileFormulaCxt
; }
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;
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;
155 /** Clean and return the OStringBuffer */
156 inline OStringBuffer
& GetStringBuf() const { mrExpData
.maStringBuf
.setLength(0); return mrExpData
.maStringBuf
; }
158 XclExpXmlPivotTableManager
& GetXmlPivotTableManager();
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;
172 bool IsDocumentEncrypted() const;
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;
180 /** Returns the local or global link manager, depending on current context. */
181 XclExpRootData::XclExpLinkMgrRef
GetLocalLinkMgrRef() const;
184 XclExpRootData
& mrExpData
; /// Reference to the global export data struct.
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */