LibreOffice Module sc (master) 1
xiroot.cxx
Go to the documentation of this file.
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#include <xiroot.hxx>
21#include <addincol.hxx>
22#include <colrowst.hxx>
23#include <document.hxx>
24#include <formel.hxx>
25#include <scextopt.hxx>
26#include <xihelper.hxx>
27#include <xiformula.hxx>
28#include <xilink.hxx>
29#include <xiname.hxx>
30#include <xistyle.hxx>
31#include <xicontent.hxx>
32#include <xiescher.hxx>
33#include <xipivot.hxx>
34#include <xipage.hxx>
35#include <xiview.hxx>
36
37#include <root.hxx>
38#include <excimp8.hxx>
39#include <documentimport.hxx>
40#include <sot/storage.hxx>
41
42// Global data ================================================================
43
45 const tools::SvRef<SotStorage>& xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ) :
46 XclRootData( eBiff, rMedium, xRootStrg, rDoc, eTextEnc, false ),
47 mxDocImport(std::make_shared<ScDocumentImport>(rDoc)),
48 mbHasCodePage( false ),
49 mbHasBasic( false )
50{
51}
52
54{
55}
56
58 XclRoot( rImpRootData ),
59 mrImpData( rImpRootData )
60{
61 mrImpData.mxAddrConv = std::make_shared<XclImpAddressConverter>( GetRoot() );
62 mrImpData.mxFmlaComp = std::make_shared<XclImpFormulaCompiler>( GetRoot() );
63 mrImpData.mxPalette = std::make_shared<XclImpPalette>( GetRoot() );
64 mrImpData.mxFontBfr = std::make_shared<XclImpFontBuffer>( GetRoot() );
65 mrImpData.mxNumFmtBfr = std::make_shared<XclImpNumFmtBuffer>( GetRoot() );
66 mrImpData.mpXFBfr = std::make_shared<XclImpXFBuffer>( GetRoot() );
67 mrImpData.mxXFRangeBfr = std::make_shared<XclImpXFRangeBuffer>( GetRoot() );
68 mrImpData.mxTabInfo = std::make_shared<XclImpTabInfo>();
69 mrImpData.mxNameMgr = std::make_shared<XclImpNameManager>( GetRoot() );
70 mrImpData.mxObjMgr = std::make_shared<XclImpObjectManager>( GetRoot() );
71
72 if( GetBiff() == EXC_BIFF8 )
73 {
74 mrImpData.mxLinkMgr = std::make_shared<XclImpLinkManager>( GetRoot() );
75 mrImpData.mxSst = std::make_shared<XclImpSst>( GetRoot() );
76 mrImpData.mxCondFmtMgr = std::make_shared<XclImpCondFormatManager>( GetRoot() );
77 mrImpData.mxValidMgr = std::make_shared<XclImpValidationManager>( GetRoot() );
78 // TODO still in old RootData (deleted by RootData)
80 mrImpData.mxWebQueryBfr = std::make_shared<XclImpWebQueryBuffer>( GetRoot() );
81 mrImpData.mxPTableMgr = std::make_shared<XclImpPivotTableManager>( GetRoot() );
82 mrImpData.mxTabProtect = std::make_shared<XclImpSheetProtectBuffer>( GetRoot() );
83 mrImpData.mxDocProtect = std::make_shared<XclImpDocProtectBuffer>( GetRoot() );
84 }
85
86 mrImpData.mxPageSett = std::make_shared<XclImpPageSettings>( GetRoot() );
87 mrImpData.mxDocViewSett = std::make_shared<XclImpDocViewSettings>( GetRoot() );
88 mrImpData.mxTabViewSett = std::make_shared<XclImpTabViewSettings>( GetRoot() );
89 mrImpData.mpPrintRanges = std::make_unique<ScRangeListTabs>( GetRoot() );
90 mrImpData.mpPrintTitles = std::make_unique<ScRangeListTabs>( GetRoot() );
91}
92
93void XclImpRoot::SetCodePage( sal_uInt16 nCodePage )
94{
97}
98
100{
101 if( GetBiff() <= EXC_BIFF4 )
102 {
107 }
111 // delete the automatically generated codename
112 GetDoc().SetCodeName( nScTab, OUString() );
113}
114
116{
121}
122
124{
125 return *mrImpData.mxAddrConv;
126}
127
129{
130 return *mrImpData.mxFmlaComp;
131}
132
134{
135 // TODO still in old RootData
136 return *GetOldRoot().pFmlaConverter;
137}
138
140{
141 assert(mrImpData.mxSst && "XclImpRoot::GetSst - invalid call, wrong BIFF");
142 return *mrImpData.mxSst;
143}
144
146{
147 return *mrImpData.mxPalette;
148}
149
151{
152 return *mrImpData.mxFontBfr;
153}
154
156{
157 return *mrImpData.mxNumFmtBfr;
158}
159
161{
162 return *mrImpData.mpXFBfr;
163}
164
166{
167 return *mrImpData.mxXFRangeBfr;
168}
169
171{
172 return *mrImpData.mpPrintRanges;
173}
174
176{
177 return *mrImpData.mpPrintTitles;
178}
179
181{
182 return *mrImpData.mxTabInfo;
183}
184
186{
187 return *mrImpData.mxNameMgr;
188}
189
191{
192 assert(mrImpData.mxLinkMgr && "XclImpRoot::GetLinkManager - invalid call, wrong BIFF");
193 return *mrImpData.mxLinkMgr;
194}
195
197{
198 return *mrImpData.mxObjMgr;
199}
200
202{
203 OSL_ENSURE( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
204 return mrImpData.mxObjMgr->GetSheetDrawing( GetCurrScTab() );
205}
206
208{
209 assert(mrImpData.mxCondFmtMgr && "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF");
210 return *mrImpData.mxCondFmtMgr;
211}
212
214{
215 assert(mrImpData.mxValidMgr && "XclImpRoot::GetValidationManager - invalid call, wrong BIFF");
216 return *mrImpData.mxValidMgr;
217}
218
220{
221 // TODO still in old RootData
222 assert(GetOldRoot().pAutoFilterBuffer && "XclImpRoot::GetFilterManager - invalid call, wrong BIFF");
224}
225
227{
228 assert(mrImpData.mxWebQueryBfr && "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF");
229 return *mrImpData.mxWebQueryBfr;
230}
231
233{
234 assert(mrImpData.mxPTableMgr && "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF");
235 return *mrImpData.mxPTableMgr;
236}
237
239{
240 assert(mrImpData.mxTabProtect && "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF");
241 return *mrImpData.mxTabProtect;
242}
243
245{
246 assert(mrImpData.mxDocProtect && "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF");
247 return *mrImpData.mxDocProtect;
248}
249
251{
252 return *mrImpData.mxPageSett;
253}
254
256{
257 return *mrImpData.mxDocViewSett;
258}
259
261{
262 return *mrImpData.mxTabViewSett;
263}
264
265OUString XclImpRoot::GetScAddInName( const OUString& rXclName )
266{
267 OUString aScName;
268 if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName, aScName ) )
269 return aScName;
270 return rXclName;
271}
272
273void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals )
274{
275 if( !(mrImpData.mbHasBasic && (GetBiff() == EXC_BIFF8)) )
276 return;
277
278 OUString aName = rStrm.ReadUniString();
279 if( aName.isEmpty() )
280 return;
281
282 if( bGlobals )
283 {
286 }
287 else
288 {
291 }
292}
293
295{
296 return *mrImpData.mxDocImport;
297}
298
299/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Accessor class to ScDocument.
void SetCodeName(const OUString &r)
Definition: document.hxx:610
const ScExtDocSettings & GetDocSettings() const
Definition: scextopt.cxx:170
void SetCodeName(SCTAB nTab, const OUString &rCodeName)
Appends a codename for a sheet.
Definition: scextopt.cxx:206
static SC_DLLPUBLIC ScUnoAddInCollection * GetAddInCollection()
Definition: global.cxx:283
Provides functions to convert Excel cell addresses to Calc cell addresses.
Definition: xihelper.hxx:42
void Convert(SCTAB nScTab)
Inserts all column and row settings of the specified sheet, except the hidden flags.
Definition: colrowst.cxx:178
Imports and collects all conditional formatting of a sheet.
Definition: xicontent.hxx:148
Contains document view settings (WINDOW1 record).
Definition: xiview.hxx:29
Stores the data of all fonts occurred in an Excel file.
Definition: xistyle.hxx:153
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:547
The formula compiler to create Calc token arrays from Excel token arrays.
Definition: xiformula.hxx:33
This is the central class for the import of all internal/external links.
Definition: xilink.hxx:185
This buffer contains all internal defined names of the document.
Definition: xiname.hxx:82
Stores all user defined number formats occurred in the file.
Definition: xistyle.hxx:205
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:637
Stores all drawing and OLE objects and additional data related to these objects.
Definition: xiescher.hxx:1151
Contains all page (print) settings for a single sheet.
Definition: xipage.hxx:30
void Initialize()
Initializes the object to be used for a new sheet.
Definition: xipage.cxx:47
void Finalize()
Creates a page stylesheet from current settings and sets it at current sheet.
Definition: xipage.cxx:231
Stores the default colors for the current BIFF version and the contents of a PALETTE record.
Definition: xistyle.hxx:45
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:152
The main class for pivot table import.
Definition: xipivot.hxx:372
ScRangeListTabs & GetPrintAreaBuffer() const
Returns the buffer that contains all print areas in the document.
Definition: xiroot.cxx:170
ExcelToSc & GetOldFmlaConverter() const
Returns the old formula converter.
Definition: xiroot.cxx:133
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xiroot.cxx:123
XclImpXFBuffer & GetXFBuffer() const
Returns the cell formatting attributes buffer.
Definition: xiroot.cxx:160
XclImpWebQueryBuffer & GetWebQueryBuffer() const
Returns the web query buffer.
Definition: xiroot.cxx:226
void ReadCodeName(XclImpStream &rStrm, bool bGlobals)
Reads the CODENAME record and inserts the codename into the document.
Definition: xiroot.cxx:273
void FinalizeTable()
Is called when import filter stops importing a single sheet (all BIFF versions).
Definition: xiroot.cxx:115
ScRangeListTabs & GetTitleAreaBuffer() const
Returns the buffer that contains all print titles in the document.
Definition: xiroot.cxx:175
XclImpLinkManager & GetLinkManager() const
Returns the link manager.
Definition: xiroot.cxx:190
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
Definition: xiroot.cxx:165
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:294
XclImpCondFormatManager & GetCondFormatManager() const
Returns the conditional formatting manager.
Definition: xiroot.cxx:207
XclImpFontBuffer & GetFontBuffer() const
Returns the font buffer.
Definition: xiroot.cxx:150
XclImpDocProtectBuffer & GetDocProtectBuffer() const
Returns the document protection options.
Definition: xiroot.cxx:244
XclImpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xiroot.cxx:185
XclImpValidationManager & GetValidationManager() const
Definition: xiroot.cxx:213
static OUString GetScAddInName(const OUString &rXclName)
Returns the Calc add-in function name for an Excel function name.
Definition: xiroot.cxx:265
XclImpAutoFilterBuffer & GetFilterManager() const
Returns the filter manager.
Definition: xiroot.cxx:219
XclImpRoot(XclImpRootData &rImpRootData)
Definition: xiroot.cxx:57
XclImpFormulaCompiler & GetFormulaCompiler() const
Returns the formula converter.
Definition: xiroot.cxx:128
XclImpDocViewSettings & GetDocViewSettings() const
Returns the view settings of the entire document.
Definition: xiroot.cxx:255
XclImpPalette & GetPalette() const
Returns the color buffer.
Definition: xiroot.cxx:145
XclImpSst & GetSst() const
Returns the shared string table.
Definition: xiroot.cxx:139
void InitializeTable(SCTAB nScTab)
Is called when import filter starts importing a single sheet (all BIFF versions).
Definition: xiroot.cxx:99
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:134
XclImpPageSettings & GetPageSettings() const
Returns the page settings of the current sheet.
Definition: xiroot.cxx:250
XclImpSheetDrawing & GetCurrSheetDrawing() const
Returns the drawing container of the current sheet.
Definition: xiroot.cxx:201
XclImpTabInfo & GetTabInfo() const
Returns the buffer that contains the sheet creation order.
Definition: xiroot.cxx:180
XclImpSheetProtectBuffer & GetSheetProtectBuffer() const
Returns the sheet protection options of the current sheet.
Definition: xiroot.cxx:238
XclImpObjectManager & GetObjectManager() const
Returns the drawing object manager.
Definition: xiroot.cxx:196
XclImpTabViewSettings & GetTabViewSettings() const
Returns the view settings of the current sheet.
Definition: xiroot.cxx:260
void SetCodePage(sal_uInt16 nCodePage)
Sets a code page read from a CODEPAGE record for byte string import.
Definition: xiroot.cxx:93
XclImpPivotTableManager & GetPivotTableManager() const
Returns the pivot table manager.
Definition: xiroot.cxx:232
XclImpRootData & mrImpData
Definition: xiroot.hxx:216
XclImpNumFmtBuffer & GetNumFmtBuffer() const
Returns the number format buffer.
Definition: xiroot.cxx:155
Drawing manager of a single sheet.
Definition: xiescher.hxx:1117
The SST (shared string table) contains all strings used in a BIFF8 file.
Definition: xicontent.hxx:56
This class is used to import record oriented streams.
Definition: xistream.hxx:278
A buffer containing information about names and creation order of sheets.
Definition: xilink.hxx:62
Contains all view settings for a single sheet.
Definition: xiview.hxx:59
void Finalize()
Sets the view settings at the current sheet or the extended sheet options object.
Definition: xiview.cxx:212
void Initialize()
Initializes the object to be used for a new sheet.
Definition: xiview.cxx:96
Imports validation data.
Definition: xicontent.hxx:169
Contains all XF records occurred in the file.
Definition: xistyle.hxx:479
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:1565
Contains the XF indexes for every used cell in a single sheet.
Definition: xistyle.hxx:608
void Finalize()
Applies styles and cell merging to the current sheet in the document.
Definition: xistyle.cxx:1985
void Initialize()
Clears all buffered data, used to set up for a new sheet.
Definition: xistyle.cxx:1888
Access to global data for a filter object (imported or exported document) from other classes.
Definition: xlroot.hxx:128
ScExtDocOptions & GetExtDocOptions() const
Returns the extended document options.
Definition: xlroot.cxx:429
void SetTextEncoding(rtl_TextEncoding eTextEnc)
Sets the text encoding to import/export byte strings.
Definition: xlroot.cxx:201
bool IsInGlobals() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:160
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
static rtl_TextEncoding GetTextEncoding(sal_uInt16 nCodePage)
Returns a text encoding from an Excel code page.
Definition: xltools.cxx:430
OUString aName
void SvStream & rStrm
std::shared_ptr< T > make_shared(Args &&... args)
std::unique_ptr< XclImpAutoFilterBuffer > pAutoFilterBuffer
Definition: root.hxx:53
XclImpColRowSettings * pColRowBuff
Definition: root.hxx:50
ExcelToSc * pFmlaConverter
Definition: root.hxx:49
OUString maGlobCodeName
Global codename (VBA module name).
Definition: scextopt.hxx:29
Stores global buffers and data needed for Excel import filter.
Definition: xiroot.hxx:64
XclImpDocProtectRef mxDocProtect
Sheet protection options for current sheet.
Definition: xiroot.hxx:112
XclImpXFBfrRef mpXFBfr
All number formats in the file.
Definition: xiroot.hxx:95
XclImpSstRef mxSst
The formula compiler.
Definition: xiroot.hxx:91
XclImpAddrConvRef mxAddrConv
Definition: xiroot.hxx:88
std::shared_ptr< ScDocumentImport > mxDocImport
Document protection options.
Definition: xiroot.hxx:114
std::unique_ptr< ScRangeListTabs > mpPrintRanges
Definition: xiroot.hxx:116
XclImpTabProtectRef mxTabProtect
View settings for current sheet.
Definition: xiroot.hxx:111
XclImpLinkMgrRef mxLinkMgr
Internal defined names.
Definition: xiroot.hxx:100
bool mbHasCodePage
Definition: xiroot.hxx:119
XclImpDocViewSettRef mxDocViewSett
Page settings for current sheet.
Definition: xiroot.hxx:109
virtual ~XclImpRootData() override
Definition: xiroot.cxx:53
XclImpRootData(XclBiff eBiff, SfxMedium &rMedium, const tools::SvRef< SotStorage > &xRootStrg, ScDocument &rDoc, rtl_TextEncoding eTextEnc)
true = document contains VB project.
Definition: xiroot.cxx:44
XclImpNameMgrRef mxNameMgr
Sheet creation order list.
Definition: xiroot.hxx:99
XclImpFontBfrRef mxFontBfr
The color buffer.
Definition: xiroot.hxx:93
XclImpWebQueryBfrRef mxWebQueryBfr
Data validation.
Definition: xiroot.hxx:105
XclImpFmlaCompRef mxFmlaComp
The address converter.
Definition: xiroot.hxx:89
std::unique_ptr< ScRangeListTabs > mpPrintTitles
Definition: xiroot.hxx:117
XclImpPaletteRef mxPalette
The shared string table.
Definition: xiroot.hxx:92
XclImpNumFmtBfrRef mxNumFmtBfr
All fonts in the file.
Definition: xiroot.hxx:94
bool mbHasBasic
true = CODEPAGE record exists.
Definition: xiroot.hxx:120
XclImpTabInfoRef mxTabInfo
Buffer of XF index ranges in a sheet.
Definition: xiroot.hxx:98
XclImpCondFmtMgrRef mxCondFmtMgr
All drawing objects.
Definition: xiroot.hxx:103
XclImpPTableMgrRef mxPTableMgr
All web queries.
Definition: xiroot.hxx:106
XclImpTabViewSettRef mxTabViewSett
View settings for entire document.
Definition: xiroot.hxx:110
XclImpXFRangeBfrRef mxXFRangeBfr
All XF record data in the file.
Definition: xiroot.hxx:96
XclImpObjectMgrRef mxObjMgr
Manager for internal/external links.
Definition: xiroot.hxx:102
XclImpValidationMgrRef mxValidMgr
Conditional formatting.
Definition: xiroot.hxx:104
XclImpPageSettRef mxPageSett
All pivot tables and pivot caches.
Definition: xiroot.hxx:108
Stores global buffers and data needed elsewhere in the Excel filters.
Definition: xlroot.hxx:65
sal_Int16 SCTAB
Definition: types.hxx:22
XclBiff
An enumeration for all Excel file format types (BIFF types).
Definition: xlconst.hxx:30
@ EXC_BIFF4
MS Excel 3.0.
Definition: xlconst.hxx:33
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35