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 : #include "xiroot.hxx"
21 : #include "addincol.hxx"
22 : #include "document.hxx"
23 : #include "scextopt.hxx"
24 : #include "xltracer.hxx"
25 : #include "xihelper.hxx"
26 : #include "xiformula.hxx"
27 : #include "xilink.hxx"
28 : #include "xiname.hxx"
29 : #include "xistyle.hxx"
30 : #include "xicontent.hxx"
31 : #include "xiescher.hxx"
32 : #include "xipivot.hxx"
33 : #include "xipage.hxx"
34 : #include "xiview.hxx"
35 :
36 : #include "root.hxx"
37 : #include "excimp8.hxx"
38 : #include "documentimport.hxx"
39 :
40 : // Global data ================================================================
41 :
42 0 : XclImpRootData::XclImpRootData( XclBiff eBiff, SfxMedium& rMedium,
43 : SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ) :
44 : XclRootData( eBiff, rMedium, xRootStrg, rDoc, eTextEnc, false ),
45 0 : mxDocImport(new ScDocumentImport(rDoc)),
46 : mbHasCodePage( false ),
47 0 : mbHasBasic( false )
48 : {
49 0 : }
50 :
51 0 : XclImpRootData::~XclImpRootData()
52 : {
53 0 : }
54 :
55 0 : XclImpRoot::XclImpRoot( XclImpRootData& rImpRootData ) :
56 : XclRoot( rImpRootData ),
57 0 : mrImpData( rImpRootData )
58 : {
59 0 : mrImpData.mxAddrConv.reset( new XclImpAddressConverter( GetRoot() ) );
60 0 : mrImpData.mxFmlaComp.reset( new XclImpFormulaCompiler( GetRoot() ) );
61 0 : mrImpData.mxPalette.reset( new XclImpPalette( GetRoot() ) );
62 0 : mrImpData.mxFontBfr.reset( new XclImpFontBuffer( GetRoot() ) );
63 0 : mrImpData.mxNumFmtBfr.reset( new XclImpNumFmtBuffer( GetRoot() ) );
64 0 : mrImpData.mpXFBfr.reset( new XclImpXFBuffer( GetRoot() ) );
65 0 : mrImpData.mxXFRangeBfr.reset( new XclImpXFRangeBuffer( GetRoot() ) );
66 0 : mrImpData.mxTabInfo.reset( new XclImpTabInfo );
67 0 : mrImpData.mxNameMgr.reset( new XclImpNameManager( GetRoot() ) );
68 0 : mrImpData.mxObjMgr.reset( new XclImpObjectManager( GetRoot() ) );
69 :
70 0 : if( GetBiff() == EXC_BIFF8 )
71 : {
72 0 : mrImpData.mxLinkMgr.reset( new XclImpLinkManager( GetRoot() ) );
73 0 : mrImpData.mxSst.reset( new XclImpSst( GetRoot() ) );
74 0 : mrImpData.mxCondFmtMgr.reset( new XclImpCondFormatManager( GetRoot() ) );
75 0 : mrImpData.mxValidMgr.reset( new XclImpValidationManager( GetRoot() ) );
76 : // TODO still in old RootData (deleted by RootData)
77 0 : GetOldRoot().pAutoFilterBuffer = new XclImpAutoFilterBuffer;
78 0 : mrImpData.mxWebQueryBfr.reset( new XclImpWebQueryBuffer( GetRoot() ) );
79 0 : mrImpData.mxPTableMgr.reset( new XclImpPivotTableManager( GetRoot() ) );
80 0 : mrImpData.mxTabProtect.reset( new XclImpSheetProtectBuffer( GetRoot() ) );
81 0 : mrImpData.mxDocProtect.reset( new XclImpDocProtectBuffer( GetRoot() ) );
82 : }
83 :
84 0 : mrImpData.mxPageSett.reset( new XclImpPageSettings( GetRoot() ) );
85 0 : mrImpData.mxDocViewSett.reset( new XclImpDocViewSettings( GetRoot() ) );
86 0 : mrImpData.mxTabViewSett.reset( new XclImpTabViewSettings( GetRoot() ) );
87 0 : }
88 :
89 0 : void XclImpRoot::SetCodePage( sal_uInt16 nCodePage )
90 : {
91 0 : SetTextEncoding( XclTools::GetTextEncoding( nCodePage ) );
92 0 : mrImpData.mbHasCodePage = true;
93 0 : }
94 :
95 0 : void XclImpRoot::SetAppFontEncoding( rtl_TextEncoding eAppFontEnc )
96 : {
97 0 : if( !mrImpData.mbHasCodePage )
98 0 : SetTextEncoding( eAppFontEnc );
99 0 : }
100 :
101 0 : void XclImpRoot::InitializeTable( SCTAB nScTab )
102 : {
103 0 : if( GetBiff() <= EXC_BIFF4 )
104 : {
105 0 : GetPalette().Initialize();
106 0 : GetFontBuffer().Initialize();
107 0 : GetNumFmtBuffer().Initialize();
108 0 : GetXFBuffer().Initialize();
109 : }
110 0 : GetXFRangeBuffer().Initialize();
111 0 : GetPageSettings().Initialize();
112 0 : GetTabViewSettings().Initialize();
113 : // delete the automatically generated codename
114 0 : GetDoc().SetCodeName( nScTab, OUString() );
115 0 : }
116 :
117 0 : void XclImpRoot::FinalizeTable()
118 : {
119 0 : GetXFRangeBuffer().Finalize();
120 0 : GetOldRoot().pColRowBuff->Convert( GetCurrScTab() );
121 0 : GetPageSettings().Finalize();
122 0 : GetTabViewSettings().Finalize();
123 0 : }
124 :
125 0 : XclImpAddressConverter& XclImpRoot::GetAddressConverter() const
126 : {
127 0 : return *mrImpData.mxAddrConv;
128 : }
129 :
130 0 : XclImpFormulaCompiler& XclImpRoot::GetFormulaCompiler() const
131 : {
132 0 : return *mrImpData.mxFmlaComp;
133 : }
134 :
135 0 : ExcelToSc& XclImpRoot::GetOldFmlaConverter() const
136 : {
137 : // TODO still in old RootData
138 0 : return *GetOldRoot().pFmlaConverter;
139 : }
140 :
141 0 : XclImpSst& XclImpRoot::GetSst() const
142 : {
143 : OSL_ENSURE( mrImpData.mxSst, "XclImpRoot::GetSst - invalid call, wrong BIFF" );
144 0 : return *mrImpData.mxSst;
145 : }
146 :
147 0 : XclImpPalette& XclImpRoot::GetPalette() const
148 : {
149 0 : return *mrImpData.mxPalette;
150 : }
151 :
152 0 : XclImpFontBuffer& XclImpRoot::GetFontBuffer() const
153 : {
154 0 : return *mrImpData.mxFontBfr;
155 : }
156 :
157 0 : XclImpNumFmtBuffer& XclImpRoot::GetNumFmtBuffer() const
158 : {
159 0 : return *mrImpData.mxNumFmtBfr;
160 : }
161 :
162 0 : XclImpXFBuffer& XclImpRoot::GetXFBuffer() const
163 : {
164 0 : return *mrImpData.mpXFBfr;
165 : }
166 :
167 0 : XclImpXFRangeBuffer& XclImpRoot::GetXFRangeBuffer() const
168 : {
169 0 : return *mrImpData.mxXFRangeBfr;
170 : }
171 :
172 0 : _ScRangeListTabs& XclImpRoot::GetPrintAreaBuffer() const
173 : {
174 : // TODO still in old RootData
175 0 : return *GetOldRoot().pPrintRanges;
176 : }
177 :
178 0 : _ScRangeListTabs& XclImpRoot::GetTitleAreaBuffer() const
179 : {
180 : // TODO still in old RootData
181 0 : return *GetOldRoot().pPrintTitles;
182 : }
183 :
184 0 : XclImpTabInfo& XclImpRoot::GetTabInfo() const
185 : {
186 0 : return *mrImpData.mxTabInfo;
187 : }
188 :
189 0 : XclImpNameManager& XclImpRoot::GetNameManager() const
190 : {
191 0 : return *mrImpData.mxNameMgr;
192 : }
193 :
194 0 : XclImpLinkManager& XclImpRoot::GetLinkManager() const
195 : {
196 : OSL_ENSURE( mrImpData.mxLinkMgr, "XclImpRoot::GetLinkManager - invalid call, wrong BIFF" );
197 0 : return *mrImpData.mxLinkMgr;
198 : }
199 :
200 0 : XclImpObjectManager& XclImpRoot::GetObjectManager() const
201 : {
202 0 : return *mrImpData.mxObjMgr;
203 : }
204 :
205 0 : XclImpSheetDrawing& XclImpRoot::GetCurrSheetDrawing() const
206 : {
207 : OSL_ENSURE( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
208 0 : return mrImpData.mxObjMgr->GetSheetDrawing( GetCurrScTab() );
209 : }
210 :
211 0 : XclImpCondFormatManager& XclImpRoot::GetCondFormatManager() const
212 : {
213 : OSL_ENSURE( mrImpData.mxCondFmtMgr, "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF" );
214 0 : return *mrImpData.mxCondFmtMgr;
215 : }
216 :
217 0 : XclImpValidationManager& XclImpRoot::GetValidationManager() const
218 : {
219 : OSL_ENSURE( mrImpData.mxValidMgr, "XclImpRoot::GetValidationManager - invalid call, wrong BIFF" );
220 0 : return *mrImpData.mxValidMgr;
221 : }
222 :
223 0 : XclImpAutoFilterBuffer& XclImpRoot::GetFilterManager() const
224 : {
225 : // TODO still in old RootData
226 : OSL_ENSURE( GetOldRoot().pAutoFilterBuffer, "XclImpRoot::GetFilterManager - invalid call, wrong BIFF" );
227 0 : return *GetOldRoot().pAutoFilterBuffer;
228 : }
229 :
230 0 : XclImpWebQueryBuffer& XclImpRoot::GetWebQueryBuffer() const
231 : {
232 : OSL_ENSURE( mrImpData.mxWebQueryBfr, "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF" );
233 0 : return *mrImpData.mxWebQueryBfr;
234 : }
235 :
236 0 : XclImpPivotTableManager& XclImpRoot::GetPivotTableManager() const
237 : {
238 : OSL_ENSURE( mrImpData.mxPTableMgr, "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF" );
239 0 : return *mrImpData.mxPTableMgr;
240 : }
241 :
242 0 : XclImpSheetProtectBuffer& XclImpRoot::GetSheetProtectBuffer() const
243 : {
244 : OSL_ENSURE( mrImpData.mxTabProtect, "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF" );
245 0 : return *mrImpData.mxTabProtect;
246 : }
247 :
248 0 : XclImpDocProtectBuffer& XclImpRoot::GetDocProtectBuffer() const
249 : {
250 : OSL_ENSURE( mrImpData.mxDocProtect, "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF" );
251 0 : return *mrImpData.mxDocProtect;
252 : }
253 :
254 0 : XclImpPageSettings& XclImpRoot::GetPageSettings() const
255 : {
256 0 : return *mrImpData.mxPageSett;
257 : }
258 :
259 0 : XclImpDocViewSettings& XclImpRoot::GetDocViewSettings() const
260 : {
261 0 : return *mrImpData.mxDocViewSett;
262 : }
263 :
264 0 : XclImpTabViewSettings& XclImpRoot::GetTabViewSettings() const
265 : {
266 0 : return *mrImpData.mxTabViewSett;
267 : }
268 :
269 0 : OUString XclImpRoot::GetScAddInName( const OUString& rXclName ) const
270 : {
271 0 : OUString aScName;
272 0 : if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName, aScName ) )
273 0 : return aScName;
274 0 : return rXclName;
275 : }
276 :
277 0 : void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals )
278 : {
279 0 : if( mrImpData.mbHasBasic && (GetBiff() == EXC_BIFF8) )
280 : {
281 0 : OUString aName = rStrm.ReadUniString();
282 0 : if( !aName.isEmpty() )
283 : {
284 0 : if( bGlobals )
285 : {
286 0 : GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
287 0 : GetDoc().SetCodeName( aName );
288 : }
289 : else
290 : {
291 0 : GetExtDocOptions().SetCodeName( GetCurrScTab(), aName );
292 0 : GetDoc().SetCodeName( GetCurrScTab(), aName );
293 : }
294 0 : }
295 : }
296 0 : }
297 :
298 0 : ScDocumentImport& XclImpRoot::GetDocImport()
299 : {
300 0 : return *mrImpData.mxDocImport;
301 0 : }
302 :
303 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|