Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "xiroot.hxx"
30 : : #include "addincol.hxx"
31 : : #include "document.hxx"
32 : : #include "scextopt.hxx"
33 : : #include "xltracer.hxx"
34 : : #include "xihelper.hxx"
35 : : #include "xiformula.hxx"
36 : : #include "xilink.hxx"
37 : : #include "xiname.hxx"
38 : : #include "xistyle.hxx"
39 : : #include "xicontent.hxx"
40 : : #include "xiescher.hxx"
41 : : #include "xipivot.hxx"
42 : : #include "xipage.hxx"
43 : : #include "xiview.hxx"
44 : :
45 : : #include "root.hxx"
46 : : #include "excimp8.hxx"
47 : :
48 : : // Global data ================================================================
49 : :
50 : 55 : XclImpRootData::XclImpRootData( XclBiff eBiff, SfxMedium& rMedium,
51 : : SotStorageRef xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ) :
52 : : XclRootData( eBiff, rMedium, xRootStrg, rDoc, eTextEnc, false ),
53 : : mbHasCodePage( false ),
54 [ + - ][ + - ]: 55 : mbHasBasic( false )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
55 : : {
56 : 55 : }
57 : :
58 [ + - ][ + - ]: 55 : XclImpRootData::~XclImpRootData()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
59 : : {
60 [ - + ]: 55 : }
61 : :
62 : : // ----------------------------------------------------------------------------
63 : :
64 : 55 : XclImpRoot::XclImpRoot( XclImpRootData& rImpRootData ) :
65 : : XclRoot( rImpRootData ),
66 : 55 : mrImpData( rImpRootData )
67 : : {
68 [ + - ][ + - ]: 55 : mrImpData.mxAddrConv.reset( new XclImpAddressConverter( GetRoot() ) );
[ + - ]
69 [ + - ][ + - ]: 55 : mrImpData.mxFmlaComp.reset( new XclImpFormulaCompiler( GetRoot() ) );
[ + - ]
70 [ + - ][ + - ]: 55 : mrImpData.mxPalette.reset( new XclImpPalette( GetRoot() ) );
[ + - ]
71 [ + - ][ + - ]: 55 : mrImpData.mxFontBfr.reset( new XclImpFontBuffer( GetRoot() ) );
[ + - ]
72 [ + - ][ + - ]: 55 : mrImpData.mxNumFmtBfr.reset( new XclImpNumFmtBuffer( GetRoot() ) );
[ + - ]
73 [ + - ][ + - ]: 55 : mrImpData.mpXFBfr.reset( new XclImpXFBuffer( GetRoot() ) );
[ + - ]
74 [ + - ][ + - ]: 55 : mrImpData.mxXFRangeBfr.reset( new XclImpXFRangeBuffer( GetRoot() ) );
[ + - ]
75 [ + - ][ + - ]: 55 : mrImpData.mxTabInfo.reset( new XclImpTabInfo );
[ + - ]
76 [ + - ][ + - ]: 55 : mrImpData.mxNameMgr.reset( new XclImpNameManager( GetRoot() ) );
[ + - ]
77 [ + - ][ + - ]: 55 : mrImpData.mxObjMgr.reset( new XclImpObjectManager( GetRoot() ) );
[ + - ]
78 : :
79 [ + - ]: 55 : if( GetBiff() == EXC_BIFF8 )
80 : : {
81 [ + - ][ + - ]: 55 : mrImpData.mxLinkMgr.reset( new XclImpLinkManager( GetRoot() ) );
[ + - ]
82 [ + - ][ + - ]: 55 : mrImpData.mxSst.reset( new XclImpSst( GetRoot() ) );
[ + - ]
83 [ + - ][ + - ]: 55 : mrImpData.mxCondFmtMgr.reset( new XclImpCondFormatManager( GetRoot() ) );
[ + - ]
84 [ + - ][ + - ]: 55 : mrImpData.mxValidMgr.reset( new XclImpValidationManager( GetRoot() ) );
[ + - ]
85 : : // TODO still in old RootData (deleted by RootData)
86 [ + - ][ + - ]: 55 : GetOldRoot().pAutoFilterBuffer = new XclImpAutoFilterBuffer;
[ + - ]
87 [ + - ][ + - ]: 55 : mrImpData.mxWebQueryBfr.reset( new XclImpWebQueryBuffer( GetRoot() ) );
[ + - ]
88 [ + - ][ + - ]: 55 : mrImpData.mxPTableMgr.reset( new XclImpPivotTableManager( GetRoot() ) );
[ + - ]
89 [ + - ][ + - ]: 55 : mrImpData.mxTabProtect.reset( new XclImpSheetProtectBuffer( GetRoot() ) );
[ + - ]
90 [ + - ][ + - ]: 55 : mrImpData.mxDocProtect.reset( new XclImpDocProtectBuffer( GetRoot() ) );
[ + - ]
91 : : }
92 : :
93 [ + - ][ + - ]: 55 : mrImpData.mxPageSett.reset( new XclImpPageSettings( GetRoot() ) );
[ + - ]
94 [ + - ][ + - ]: 55 : mrImpData.mxDocViewSett.reset( new XclImpDocViewSettings( GetRoot() ) );
[ + - ]
95 [ + - ][ + - ]: 55 : mrImpData.mxTabViewSett.reset( new XclImpTabViewSettings( GetRoot() ) );
[ + - ]
96 : 55 : }
97 : :
98 : 49 : void XclImpRoot::SetCodePage( sal_uInt16 nCodePage )
99 : : {
100 : 49 : SetTextEncoding( XclTools::GetTextEncoding( nCodePage ) );
101 : 49 : mrImpData.mbHasCodePage = true;
102 : 49 : }
103 : :
104 : 49 : void XclImpRoot::SetAppFontEncoding( rtl_TextEncoding eAppFontEnc )
105 : : {
106 [ - + ]: 49 : if( !mrImpData.mbHasCodePage )
107 : 0 : SetTextEncoding( eAppFontEnc );
108 : 49 : }
109 : :
110 : 165 : void XclImpRoot::InitializeTable( SCTAB nScTab )
111 : : {
112 [ - + ]: 165 : if( GetBiff() <= EXC_BIFF4 )
113 : : {
114 : 0 : GetPalette().Initialize();
115 : 0 : GetFontBuffer().Initialize();
116 : 0 : GetNumFmtBuffer().Initialize();
117 : 0 : GetXFBuffer().Initialize();
118 : : }
119 : 165 : GetXFRangeBuffer().Initialize();
120 : 165 : GetPageSettings().Initialize();
121 : 165 : GetTabViewSettings().Initialize();
122 : : // delete the automatically generated codename
123 [ + - ]: 165 : GetDoc().SetCodeName( nScTab, String::EmptyString() );
124 : 165 : }
125 : :
126 : 165 : void XclImpRoot::FinalizeTable()
127 : : {
128 : 165 : GetXFRangeBuffer().Finalize();
129 : 165 : GetOldRoot().pColRowBuff->Convert( GetCurrScTab() );
130 : 165 : GetPageSettings().Finalize();
131 : 165 : GetTabViewSettings().Finalize();
132 : 165 : }
133 : :
134 : 10695 : XclImpAddressConverter& XclImpRoot::GetAddressConverter() const
135 : : {
136 : 10695 : return *mrImpData.mxAddrConv;
137 : : }
138 : :
139 : 21 : XclImpFormulaCompiler& XclImpRoot::GetFormulaCompiler() const
140 : : {
141 : 21 : return *mrImpData.mxFmlaComp;
142 : : }
143 : :
144 : 156 : ExcelToSc& XclImpRoot::GetOldFmlaConverter() const
145 : : {
146 : : // TODO still in old RootData
147 : 156 : return *GetOldRoot().pFmlaConverter;
148 : : }
149 : :
150 : 2155 : XclImpSst& XclImpRoot::GetSst() const
151 : : {
152 : : OSL_ENSURE( mrImpData.mxSst, "XclImpRoot::GetSst - invalid call, wrong BIFF" );
153 : 2155 : return *mrImpData.mxSst;
154 : : }
155 : :
156 : 1569 : XclImpPalette& XclImpRoot::GetPalette() const
157 : : {
158 : 1569 : return *mrImpData.mxPalette;
159 : : }
160 : :
161 : 3274 : XclImpFontBuffer& XclImpRoot::GetFontBuffer() const
162 : : {
163 : 3274 : return *mrImpData.mxFontBfr;
164 : : }
165 : :
166 : 212 : XclImpNumFmtBuffer& XclImpRoot::GetNumFmtBuffer() const
167 : : {
168 : 212 : return *mrImpData.mxNumFmtBfr;
169 : : }
170 : :
171 : 13652 : XclImpXFBuffer& XclImpRoot::GetXFBuffer() const
172 : : {
173 : 13652 : return *mrImpData.mpXFBfr;
174 : : }
175 : :
176 : 10902 : XclImpXFRangeBuffer& XclImpRoot::GetXFRangeBuffer() const
177 : : {
178 : 10902 : return *mrImpData.mxXFRangeBfr;
179 : : }
180 : :
181 : 0 : _ScRangeListTabs& XclImpRoot::GetPrintAreaBuffer() const
182 : : {
183 : : // TODO still in old RootData
184 : 0 : return *GetOldRoot().pPrintRanges;
185 : : }
186 : :
187 : 0 : _ScRangeListTabs& XclImpRoot::GetTitleAreaBuffer() const
188 : : {
189 : : // TODO still in old RootData
190 : 0 : return *GetOldRoot().pPrintTitles;
191 : : }
192 : :
193 : 223 : XclImpTabInfo& XclImpRoot::GetTabInfo() const
194 : : {
195 : 223 : return *mrImpData.mxTabInfo;
196 : : }
197 : :
198 : 103 : XclImpNameManager& XclImpRoot::GetNameManager() const
199 : : {
200 : 103 : return *mrImpData.mxNameMgr;
201 : : }
202 : :
203 : 110 : XclImpLinkManager& XclImpRoot::GetLinkManager() const
204 : : {
205 : : OSL_ENSURE( mrImpData.mxLinkMgr, "XclImpRoot::GetLinkManager - invalid call, wrong BIFF" );
206 : 110 : return *mrImpData.mxLinkMgr;
207 : : }
208 : :
209 : 307 : XclImpObjectManager& XclImpRoot::GetObjectManager() const
210 : : {
211 : 307 : return *mrImpData.mxObjMgr;
212 : : }
213 : :
214 : 92 : XclImpSheetDrawing& XclImpRoot::GetCurrSheetDrawing() const
215 : : {
216 : : OSL_ENSURE( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
217 : 92 : return mrImpData.mxObjMgr->GetSheetDrawing( GetCurrScTab() );
218 : : }
219 : :
220 : 220 : XclImpCondFormatManager& XclImpRoot::GetCondFormatManager() const
221 : : {
222 : : OSL_ENSURE( mrImpData.mxCondFmtMgr, "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF" );
223 : 220 : return *mrImpData.mxCondFmtMgr;
224 : : }
225 : :
226 : 220 : XclImpValidationManager& XclImpRoot::GetValidationManager() const
227 : : {
228 : : OSL_ENSURE( mrImpData.mxValidMgr, "XclImpRoot::GetValidationManager - invalid call, wrong BIFF" );
229 : 220 : return *mrImpData.mxValidMgr;
230 : : }
231 : :
232 : 183 : XclImpAutoFilterBuffer& XclImpRoot::GetFilterManager() const
233 : : {
234 : : // TODO still in old RootData
235 : : OSL_ENSURE( GetOldRoot().pAutoFilterBuffer, "XclImpRoot::GetFilterManager - invalid call, wrong BIFF" );
236 : 183 : return *GetOldRoot().pAutoFilterBuffer;
237 : : }
238 : :
239 : 110 : XclImpWebQueryBuffer& XclImpRoot::GetWebQueryBuffer() const
240 : : {
241 : : OSL_ENSURE( mrImpData.mxWebQueryBfr, "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF" );
242 : 110 : return *mrImpData.mxWebQueryBfr;
243 : : }
244 : :
245 : 168 : XclImpPivotTableManager& XclImpRoot::GetPivotTableManager() const
246 : : {
247 : : OSL_ENSURE( mrImpData.mxPTableMgr, "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF" );
248 : 168 : return *mrImpData.mxPTableMgr;
249 : : }
250 : :
251 : 184 : XclImpSheetProtectBuffer& XclImpRoot::GetSheetProtectBuffer() const
252 : : {
253 : : OSL_ENSURE( mrImpData.mxTabProtect, "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF" );
254 : 184 : return *mrImpData.mxTabProtect;
255 : : }
256 : :
257 : 139 : XclImpDocProtectBuffer& XclImpRoot::GetDocProtectBuffer() const
258 : : {
259 : : OSL_ENSURE( mrImpData.mxDocProtect, "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF" );
260 : 139 : return *mrImpData.mxDocProtect;
261 : : }
262 : :
263 : 556 : XclImpPageSettings& XclImpRoot::GetPageSettings() const
264 : : {
265 : 556 : return *mrImpData.mxPageSett;
266 : : }
267 : :
268 : 269 : XclImpDocViewSettings& XclImpRoot::GetDocViewSettings() const
269 : : {
270 : 269 : return *mrImpData.mxDocViewSett;
271 : : }
272 : :
273 : 391 : XclImpTabViewSettings& XclImpRoot::GetTabViewSettings() const
274 : : {
275 : 391 : return *mrImpData.mxTabViewSett;
276 : : }
277 : :
278 : 0 : String XclImpRoot::GetScAddInName( const String& rXclName ) const
279 : : {
280 : 0 : ::rtl::OUString aScName;
281 [ # # ][ # # ]: 0 : if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName, aScName ) )
[ # # ][ # # ]
282 [ # # ]: 0 : return aScName;
283 [ # # ]: 0 : return rXclName;
284 : : }
285 : :
286 : 55 : void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals )
287 : : {
288 [ + - ][ + - ]: 55 : if( mrImpData.mbHasBasic && (GetBiff() == EXC_BIFF8) )
[ + - ]
289 : : {
290 [ + - ]: 55 : String aName = rStrm.ReadUniString();
291 [ + - ]: 55 : if( aName.Len() > 0 )
292 : : {
293 [ + + ]: 55 : if( bGlobals )
294 : : {
295 [ + - ][ + - ]: 13 : GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
[ + - ]
296 [ + - ]: 13 : GetDoc().SetCodeName( aName );
297 : : }
298 : : else
299 : : {
300 [ + - ][ + - ]: 42 : GetExtDocOptions().SetCodeName( GetCurrScTab(), aName );
301 [ + - ][ + - ]: 42 : GetDoc().SetCodeName( GetCurrScTab(), aName );
302 : : }
303 [ + - ]: 55 : }
304 : : }
305 [ + - ][ + - ]: 79 : }
306 : :
307 : : // ============================================================================
308 : :
309 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|