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 .
21 #include "addincol.hxx"
22 #include "document.hxx"
23 #include "scextopt.hxx"
24 #include "xltracer.hxx"
25 #include "xihelper.hxx"
26 #include "xiformula.hxx"
29 #include "xistyle.hxx"
30 #include "xicontent.hxx"
31 #include "xiescher.hxx"
32 #include "xipivot.hxx"
37 #include "excimp8.hxx"
38 #include "documentimport.hxx"
40 // Global data ================================================================
42 XclImpRootData::XclImpRootData( XclBiff eBiff
, SfxMedium
& rMedium
,
43 tools::SvRef
<SotStorage
> xRootStrg
, ScDocument
& rDoc
, rtl_TextEncoding eTextEnc
) :
44 XclRootData( eBiff
, rMedium
, xRootStrg
, rDoc
, eTextEnc
, false ),
45 mxDocImport(new ScDocumentImport(rDoc
)),
46 mbHasCodePage( false ),
51 XclImpRootData::~XclImpRootData()
55 XclImpRoot::XclImpRoot( XclImpRootData
& rImpRootData
) :
56 XclRoot( rImpRootData
),
57 mrImpData( rImpRootData
)
59 mrImpData
.mxAddrConv
.reset( new XclImpAddressConverter( GetRoot() ) );
60 mrImpData
.mxFmlaComp
.reset( new XclImpFormulaCompiler( GetRoot() ) );
61 mrImpData
.mxPalette
.reset( new XclImpPalette( GetRoot() ) );
62 mrImpData
.mxFontBfr
.reset( new XclImpFontBuffer( GetRoot() ) );
63 mrImpData
.mxNumFmtBfr
.reset( new XclImpNumFmtBuffer( GetRoot() ) );
64 mrImpData
.mpXFBfr
.reset( new XclImpXFBuffer( GetRoot() ) );
65 mrImpData
.mxXFRangeBfr
.reset( new XclImpXFRangeBuffer( GetRoot() ) );
66 mrImpData
.mxTabInfo
.reset( new XclImpTabInfo
);
67 mrImpData
.mxNameMgr
.reset( new XclImpNameManager( GetRoot() ) );
68 mrImpData
.mxObjMgr
.reset( new XclImpObjectManager( GetRoot() ) );
70 if( GetBiff() == EXC_BIFF8
)
72 mrImpData
.mxLinkMgr
.reset( new XclImpLinkManager( GetRoot() ) );
73 mrImpData
.mxSst
.reset( new XclImpSst( GetRoot() ) );
74 mrImpData
.mxCondFmtMgr
.reset( new XclImpCondFormatManager( GetRoot() ) );
75 mrImpData
.mxValidMgr
.reset( new XclImpValidationManager( GetRoot() ) );
76 // TODO still in old RootData (deleted by RootData)
77 GetOldRoot().pAutoFilterBuffer
= new XclImpAutoFilterBuffer
;
78 mrImpData
.mxWebQueryBfr
.reset( new XclImpWebQueryBuffer( GetRoot() ) );
79 mrImpData
.mxPTableMgr
.reset( new XclImpPivotTableManager( GetRoot() ) );
80 mrImpData
.mxTabProtect
.reset( new XclImpSheetProtectBuffer( GetRoot() ) );
81 mrImpData
.mxDocProtect
.reset( new XclImpDocProtectBuffer( GetRoot() ) );
84 mrImpData
.mxPageSett
.reset( new XclImpPageSettings( GetRoot() ) );
85 mrImpData
.mxDocViewSett
.reset( new XclImpDocViewSettings( GetRoot() ) );
86 mrImpData
.mxTabViewSett
.reset( new XclImpTabViewSettings( GetRoot() ) );
89 void XclImpRoot::SetCodePage( sal_uInt16 nCodePage
)
91 SetTextEncoding( XclTools::GetTextEncoding( nCodePage
) );
92 mrImpData
.mbHasCodePage
= true;
95 void XclImpRoot::SetAppFontEncoding( rtl_TextEncoding eAppFontEnc
)
97 if( !mrImpData
.mbHasCodePage
)
98 SetTextEncoding( eAppFontEnc
);
101 void XclImpRoot::InitializeTable( SCTAB nScTab
)
103 if( GetBiff() <= EXC_BIFF4
)
105 GetPalette().Initialize();
106 GetFontBuffer().Initialize();
107 GetNumFmtBuffer().Initialize();
108 GetXFBuffer().Initialize();
110 GetXFRangeBuffer().Initialize();
111 GetPageSettings().Initialize();
112 GetTabViewSettings().Initialize();
113 // delete the automatically generated codename
114 GetDoc().SetCodeName( nScTab
, OUString() );
117 void XclImpRoot::FinalizeTable()
119 GetXFRangeBuffer().Finalize();
120 GetOldRoot().pColRowBuff
->Convert( GetCurrScTab() );
121 GetPageSettings().Finalize();
122 GetTabViewSettings().Finalize();
125 XclImpAddressConverter
& XclImpRoot::GetAddressConverter() const
127 return *mrImpData
.mxAddrConv
;
130 XclImpFormulaCompiler
& XclImpRoot::GetFormulaCompiler() const
132 return *mrImpData
.mxFmlaComp
;
135 ExcelToSc
& XclImpRoot::GetOldFmlaConverter() const
137 // TODO still in old RootData
138 return *GetOldRoot().pFmlaConverter
;
141 XclImpSst
& XclImpRoot::GetSst() const
143 assert(mrImpData
.mxSst
&& "XclImpRoot::GetSst - invalid call, wrong BIFF");
144 return *mrImpData
.mxSst
;
147 XclImpPalette
& XclImpRoot::GetPalette() const
149 return *mrImpData
.mxPalette
;
152 XclImpFontBuffer
& XclImpRoot::GetFontBuffer() const
154 return *mrImpData
.mxFontBfr
;
157 XclImpNumFmtBuffer
& XclImpRoot::GetNumFmtBuffer() const
159 return *mrImpData
.mxNumFmtBfr
;
162 XclImpXFBuffer
& XclImpRoot::GetXFBuffer() const
164 return *mrImpData
.mpXFBfr
;
167 XclImpXFRangeBuffer
& XclImpRoot::GetXFRangeBuffer() const
169 return *mrImpData
.mxXFRangeBfr
;
172 _ScRangeListTabs
& XclImpRoot::GetPrintAreaBuffer() const
174 // TODO still in old RootData
175 return *GetOldRoot().pPrintRanges
;
178 _ScRangeListTabs
& XclImpRoot::GetTitleAreaBuffer() const
180 // TODO still in old RootData
181 return *GetOldRoot().pPrintTitles
;
184 XclImpTabInfo
& XclImpRoot::GetTabInfo() const
186 return *mrImpData
.mxTabInfo
;
189 XclImpNameManager
& XclImpRoot::GetNameManager() const
191 return *mrImpData
.mxNameMgr
;
194 XclImpLinkManager
& XclImpRoot::GetLinkManager() const
196 assert(mrImpData
.mxLinkMgr
&& "XclImpRoot::GetLinkManager - invalid call, wrong BIFF");
197 return *mrImpData
.mxLinkMgr
;
200 XclImpObjectManager
& XclImpRoot::GetObjectManager() const
202 return *mrImpData
.mxObjMgr
;
205 XclImpSheetDrawing
& XclImpRoot::GetCurrSheetDrawing() const
207 OSL_ENSURE( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
208 return mrImpData
.mxObjMgr
->GetSheetDrawing( GetCurrScTab() );
211 XclImpCondFormatManager
& XclImpRoot::GetCondFormatManager() const
213 assert(mrImpData
.mxCondFmtMgr
&& "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF");
214 return *mrImpData
.mxCondFmtMgr
;
217 XclImpValidationManager
& XclImpRoot::GetValidationManager() const
219 assert(mrImpData
.mxValidMgr
&& "XclImpRoot::GetValidationManager - invalid call, wrong BIFF");
220 return *mrImpData
.mxValidMgr
;
223 XclImpAutoFilterBuffer
& XclImpRoot::GetFilterManager() const
225 // TODO still in old RootData
226 assert(GetOldRoot().pAutoFilterBuffer
&& "XclImpRoot::GetFilterManager - invalid call, wrong BIFF");
227 return *GetOldRoot().pAutoFilterBuffer
;
230 XclImpWebQueryBuffer
& XclImpRoot::GetWebQueryBuffer() const
232 assert(mrImpData
.mxWebQueryBfr
&& "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF");
233 return *mrImpData
.mxWebQueryBfr
;
236 XclImpPivotTableManager
& XclImpRoot::GetPivotTableManager() const
238 assert(mrImpData
.mxPTableMgr
&& "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF");
239 return *mrImpData
.mxPTableMgr
;
242 XclImpSheetProtectBuffer
& XclImpRoot::GetSheetProtectBuffer() const
244 assert(mrImpData
.mxTabProtect
&& "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF");
245 return *mrImpData
.mxTabProtect
;
248 XclImpDocProtectBuffer
& XclImpRoot::GetDocProtectBuffer() const
250 assert(mrImpData
.mxDocProtect
&& "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF");
251 return *mrImpData
.mxDocProtect
;
254 XclImpPageSettings
& XclImpRoot::GetPageSettings() const
256 return *mrImpData
.mxPageSett
;
259 XclImpDocViewSettings
& XclImpRoot::GetDocViewSettings() const
261 return *mrImpData
.mxDocViewSett
;
264 XclImpTabViewSettings
& XclImpRoot::GetTabViewSettings() const
266 return *mrImpData
.mxTabViewSett
;
269 OUString
XclImpRoot::GetScAddInName( const OUString
& rXclName
)
272 if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName
, aScName
) )
277 void XclImpRoot::ReadCodeName( XclImpStream
& rStrm
, bool bGlobals
)
279 if( mrImpData
.mbHasBasic
&& (GetBiff() == EXC_BIFF8
) )
281 OUString aName
= rStrm
.ReadUniString();
282 if( !aName
.isEmpty() )
286 GetExtDocOptions().GetDocSettings().maGlobCodeName
= aName
;
287 GetDoc().SetCodeName( aName
);
291 GetExtDocOptions().SetCodeName( GetCurrScTab(), aName
);
292 GetDoc().SetCodeName( GetCurrScTab(), aName
);
298 ScDocumentImport
& XclImpRoot::GetDocImport()
300 return *mrImpData
.mxDocImport
;
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */