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 .
25 // Forward declarations of objects in public use ==============================
30 typedef std::shared_ptr
< XclImpString
> XclImpStringRef
;
32 // Global data ================================================================
34 class XclImpAddressConverter
;
35 class XclImpFormulaCompiler
;
38 class XclImpFontBuffer
;
39 class XclImpNumFmtBuffer
;
41 class XclImpXFRangeBuffer
;
43 class XclImpNameManager
;
44 class XclImpLinkManager
;
45 class XclImpObjectManager
;
46 class XclImpSheetDrawing
;
47 class XclImpCondFormatManager
;
48 class XclImpValidationManager
;
49 class XclImpAutoFilterBuffer
;
50 class XclImpWebQueryBuffer
;
51 class XclImpPivotTableManager
;
52 class XclImpPageSettings
;
53 class XclImpDocViewSettings
;
54 class XclImpTabViewSettings
;
55 class XclImpSheetProtectBuffer
;
56 class XclImpDocProtectBuffer
;
58 class ScRangeListTabs
;
60 class ScDocumentImport
;
62 /** Stores global buffers and data needed for Excel import filter. */
63 struct XclImpRootData
: public XclRootData
65 typedef std::shared_ptr
< XclImpAddressConverter
> XclImpAddrConvRef
;
66 typedef std::shared_ptr
< XclImpFormulaCompiler
> XclImpFmlaCompRef
;
68 typedef std::shared_ptr
< XclImpSst
> XclImpSstRef
;
69 typedef std::shared_ptr
< XclImpPalette
> XclImpPaletteRef
;
70 typedef std::shared_ptr
< XclImpFontBuffer
> XclImpFontBfrRef
;
71 typedef std::shared_ptr
< XclImpNumFmtBuffer
> XclImpNumFmtBfrRef
;
72 typedef std::shared_ptr
< XclImpXFBuffer
> XclImpXFBfrRef
;
73 typedef std::shared_ptr
< XclImpXFRangeBuffer
> XclImpXFRangeBfrRef
;
74 typedef std::shared_ptr
< XclImpTabInfo
> XclImpTabInfoRef
;
75 typedef std::shared_ptr
< XclImpNameManager
> XclImpNameMgrRef
;
76 typedef std::shared_ptr
< XclImpLinkManager
> XclImpLinkMgrRef
;
77 typedef std::shared_ptr
< XclImpObjectManager
> XclImpObjectMgrRef
;
78 typedef std::shared_ptr
< XclImpCondFormatManager
> XclImpCondFmtMgrRef
;
79 typedef std::shared_ptr
< XclImpValidationManager
> XclImpValidationMgrRef
;
80 typedef std::shared_ptr
< XclImpWebQueryBuffer
> XclImpWebQueryBfrRef
;
81 typedef std::shared_ptr
< XclImpPivotTableManager
> XclImpPTableMgrRef
;
82 typedef std::shared_ptr
< XclImpPageSettings
> XclImpPageSettRef
;
83 typedef std::shared_ptr
< XclImpDocViewSettings
> XclImpDocViewSettRef
;
84 typedef std::shared_ptr
< XclImpTabViewSettings
> XclImpTabViewSettRef
;
85 typedef std::shared_ptr
< XclImpSheetProtectBuffer
> XclImpTabProtectRef
;
86 typedef std::shared_ptr
< XclImpDocProtectBuffer
> XclImpDocProtectRef
;
88 XclImpAddrConvRef mxAddrConv
; /// The address converter.
89 XclImpFmlaCompRef mxFmlaComp
; /// The formula compiler.
91 XclImpSstRef mxSst
; /// The shared string table.
92 XclImpPaletteRef mxPalette
; /// The color buffer.
93 XclImpFontBfrRef mxFontBfr
; /// All fonts in the file.
94 XclImpNumFmtBfrRef mxNumFmtBfr
; /// All number formats in the file.
95 XclImpXFBfrRef mpXFBfr
; /// All XF record data in the file.
96 XclImpXFRangeBfrRef mxXFRangeBfr
; /// Buffer of XF index ranges in a sheet.
98 XclImpTabInfoRef mxTabInfo
; /// Sheet creation order list.
99 XclImpNameMgrRef mxNameMgr
; /// Internal defined names.
100 XclImpLinkMgrRef mxLinkMgr
; /// Manager for internal/external links.
102 XclImpObjectMgrRef mxObjMgr
; /// All drawing objects.
103 XclImpCondFmtMgrRef mxCondFmtMgr
; /// Conditional formatting.
104 XclImpValidationMgrRef mxValidMgr
; /// Data validation
105 XclImpWebQueryBfrRef mxWebQueryBfr
; /// All web queries.
106 XclImpPTableMgrRef mxPTableMgr
; /// All pivot tables and pivot caches.
108 XclImpPageSettRef mxPageSett
; /// Page settings for current sheet.
109 XclImpDocViewSettRef mxDocViewSett
; /// View settings for entire document.
110 XclImpTabViewSettRef mxTabViewSett
; /// View settings for current sheet.
111 XclImpTabProtectRef mxTabProtect
; /// Sheet protection options for current sheet.
112 XclImpDocProtectRef mxDocProtect
; /// Document protection options.
114 std::shared_ptr
<ScDocumentImport
> mxDocImport
;
116 std::unique_ptr
<ScRangeListTabs
> mpPrintRanges
;
117 std::unique_ptr
<ScRangeListTabs
> mpPrintTitles
;
119 bool mbHasCodePage
; /// true = CODEPAGE record exists.
120 bool mbHasBasic
; /// true = document contains VB project.
122 explicit XclImpRootData( XclBiff eBiff
, SfxMedium
& rMedium
,
123 const rtl::Reference
<SotStorage
>& xRootStrg
, ScDocument
& rDoc
, rtl_TextEncoding eTextEnc
);
124 virtual ~XclImpRootData() override
;
127 /** Access to global data from other classes. */
128 class XclImpRoot
: public XclRoot
131 explicit XclImpRoot( XclImpRootData
& rImpRootData
);
133 /** Returns this root instance - for code readability in derived classes. */
134 const XclImpRoot
& GetRoot() const { return *this; }
135 XclImpRoot
& GetRoot() { return *this; }
137 /** Sets a code page read from a CODEPAGE record for byte string import. */
138 void SetCodePage( sal_uInt16 nCodePage
);
140 /** Is called when import filter starts importing a single sheet (all BIFF versions). */
141 void InitializeTable( SCTAB nScTab
);
142 /** Is called when import filter stops importing a single sheet (all BIFF versions). */
143 void FinalizeTable();
145 /** Returns the address converter. */
146 XclImpAddressConverter
& GetAddressConverter() const;
147 /** Returns the formula converter. */
148 XclImpFormulaCompiler
& GetFormulaCompiler() const;
149 /** Returns the old formula converter. */
150 ExcelToSc
& GetOldFmlaConverter() const;
152 /** Returns the shared string table. */
153 XclImpSst
& GetSst() const;
154 /** Returns the color buffer. */
155 XclImpPalette
& GetPalette() const;
156 /** Returns the font buffer. */
157 XclImpFontBuffer
& GetFontBuffer() const;
158 /** Returns the number format buffer. */
159 XclImpNumFmtBuffer
& GetNumFmtBuffer() const;
160 /** Returns the cell formatting attributes buffer. */
161 XclImpXFBuffer
& GetXFBuffer() const;
162 /** Returns the buffer of XF index ranges for a sheet. */
163 XclImpXFRangeBuffer
& GetXFRangeBuffer() const;
165 /** Returns the buffer that contains all print areas in the document. */
166 ScRangeListTabs
& GetPrintAreaBuffer() const;
167 /** Returns the buffer that contains all print titles in the document. */
168 ScRangeListTabs
& GetTitleAreaBuffer() const;
170 /** Returns the buffer that contains the sheet creation order. */
171 XclImpTabInfo
& GetTabInfo() const;
172 /** Returns the buffer that contains internal defined names. */
173 XclImpNameManager
& GetNameManager() const;
174 /** Returns the link manager. */
175 XclImpLinkManager
& GetLinkManager() const;
177 /** Returns the drawing object manager. */
178 XclImpObjectManager
& GetObjectManager() const;
179 /** Returns the drawing container of the current sheet. */
180 XclImpSheetDrawing
& GetCurrSheetDrawing() const;
181 /** Returns the conditional formatting manager. */
182 XclImpCondFormatManager
& GetCondFormatManager() const;
184 XclImpValidationManager
& GetValidationManager() const;
185 /** Returns the filter manager. */
186 XclImpAutoFilterBuffer
& GetFilterManager() const;
187 /** Returns the web query buffer. */
188 XclImpWebQueryBuffer
& GetWebQueryBuffer() const;
189 /** Returns the pivot table manager. */
190 XclImpPivotTableManager
& GetPivotTableManager() const;
191 /** Returns the sheet protection options of the current sheet. */
192 XclImpSheetProtectBuffer
& GetSheetProtectBuffer() const;
193 /** Returns the document protection options. */
194 XclImpDocProtectBuffer
& GetDocProtectBuffer() const;
196 /** Returns the page settings of the current sheet. */
197 XclImpPageSettings
& GetPageSettings() const;
198 /** Returns the view settings of the entire document. */
199 XclImpDocViewSettings
& GetDocViewSettings() const;
200 /** Returns the view settings of the current sheet. */
201 XclImpTabViewSettings
& GetTabViewSettings() const;
203 /** Returns the Calc add-in function name for an Excel function name. */
204 static OUString
GetScAddInName( const OUString
& rXclName
);
206 /** Returns true, if the document contains a VB project. */
207 bool HasBasic() const { return mrImpData
.mbHasBasic
; }
208 /** Called to indicate that the document contains a VB project. */
209 void SetHasBasic() { mrImpData
.mbHasBasic
= true; }
210 /** Reads the CODENAME record and inserts the codename into the document. */
211 void ReadCodeName( XclImpStream
& rStrm
, bool bGlobals
);
213 ScDocumentImport
& GetDocImport();
216 XclImpRootData
& mrImpData
; /// Reference to the global import data struct.
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */