LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / source / filter / excel / xiroot.cxx
blobaf04654de2cda3756c9fab9b573437c38473a7fb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
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>
37 #include <root.hxx>
38 #include <excimp8.hxx>
39 #include <documentimport.hxx>
41 // Global data ================================================================
43 XclImpRootData::XclImpRootData( XclBiff eBiff, SfxMedium& rMedium,
44 const tools::SvRef<SotStorage>& xRootStrg, ScDocument& rDoc, rtl_TextEncoding eTextEnc ) :
45 XclRootData( eBiff, rMedium, xRootStrg, rDoc, eTextEnc, false ),
46 mxDocImport(std::make_shared<ScDocumentImport>(rDoc)),
47 mbHasCodePage( false ),
48 mbHasBasic( false )
52 XclImpRootData::~XclImpRootData()
56 XclImpRoot::XclImpRoot( XclImpRootData& rImpRootData ) :
57 XclRoot( rImpRootData ),
58 mrImpData( rImpRootData )
60 mrImpData.mxAddrConv = std::make_shared<XclImpAddressConverter>( GetRoot() );
61 mrImpData.mxFmlaComp = std::make_shared<XclImpFormulaCompiler>( GetRoot() );
62 mrImpData.mxPalette = std::make_shared<XclImpPalette>( GetRoot() );
63 mrImpData.mxFontBfr = std::make_shared<XclImpFontBuffer>( GetRoot() );
64 mrImpData.mxNumFmtBfr = std::make_shared<XclImpNumFmtBuffer>( GetRoot() );
65 mrImpData.mpXFBfr = std::make_shared<XclImpXFBuffer>( GetRoot() );
66 mrImpData.mxXFRangeBfr = std::make_shared<XclImpXFRangeBuffer>( GetRoot() );
67 mrImpData.mxTabInfo = std::make_shared<XclImpTabInfo>();
68 mrImpData.mxNameMgr = std::make_shared<XclImpNameManager>( GetRoot() );
69 mrImpData.mxObjMgr = std::make_shared<XclImpObjectManager>( GetRoot() );
71 if( GetBiff() == EXC_BIFF8 )
73 mrImpData.mxLinkMgr = std::make_shared<XclImpLinkManager>( GetRoot() );
74 mrImpData.mxSst = std::make_shared<XclImpSst>( GetRoot() );
75 mrImpData.mxCondFmtMgr = std::make_shared<XclImpCondFormatManager>( GetRoot() );
76 mrImpData.mxValidMgr = std::make_shared<XclImpValidationManager>( GetRoot() );
77 // TODO still in old RootData (deleted by RootData)
78 GetOldRoot().pAutoFilterBuffer.reset( new XclImpAutoFilterBuffer );
79 mrImpData.mxWebQueryBfr = std::make_shared<XclImpWebQueryBuffer>( GetRoot() );
80 mrImpData.mxPTableMgr = std::make_shared<XclImpPivotTableManager>( GetRoot() );
81 mrImpData.mxTabProtect = std::make_shared<XclImpSheetProtectBuffer>( GetRoot() );
82 mrImpData.mxDocProtect = std::make_shared<XclImpDocProtectBuffer>( GetRoot() );
85 mrImpData.mxPageSett = std::make_shared<XclImpPageSettings>( GetRoot() );
86 mrImpData.mxDocViewSett = std::make_shared<XclImpDocViewSettings>( GetRoot() );
87 mrImpData.mxTabViewSett = std::make_shared<XclImpTabViewSettings>( GetRoot() );
88 mrImpData.mpPrintRanges = std::make_unique<ScRangeListTabs>( GetRoot() );
89 mrImpData.mpPrintTitles = std::make_unique<ScRangeListTabs>( GetRoot() );
92 void XclImpRoot::SetCodePage( sal_uInt16 nCodePage )
94 SetTextEncoding( XclTools::GetTextEncoding( nCodePage ) );
95 mrImpData.mbHasCodePage = true;
98 void XclImpRoot::InitializeTable( SCTAB nScTab )
100 if( GetBiff() <= EXC_BIFF4 )
102 GetPalette().Initialize();
103 GetFontBuffer().Initialize();
104 GetNumFmtBuffer().Initialize();
105 GetXFBuffer().Initialize();
107 GetXFRangeBuffer().Initialize();
108 GetPageSettings().Initialize();
109 GetTabViewSettings().Initialize();
110 // delete the automatically generated codename
111 GetDoc().SetCodeName( nScTab, OUString() );
114 void XclImpRoot::FinalizeTable()
116 GetXFRangeBuffer().Finalize();
117 GetOldRoot().pColRowBuff->Convert( GetCurrScTab() );
118 GetPageSettings().Finalize();
119 GetTabViewSettings().Finalize();
122 XclImpAddressConverter& XclImpRoot::GetAddressConverter() const
124 return *mrImpData.mxAddrConv;
127 XclImpFormulaCompiler& XclImpRoot::GetFormulaCompiler() const
129 return *mrImpData.mxFmlaComp;
132 ExcelToSc& XclImpRoot::GetOldFmlaConverter() const
134 // TODO still in old RootData
135 return *GetOldRoot().pFmlaConverter;
138 XclImpSst& XclImpRoot::GetSst() const
140 assert(mrImpData.mxSst && "XclImpRoot::GetSst - invalid call, wrong BIFF");
141 return *mrImpData.mxSst;
144 XclImpPalette& XclImpRoot::GetPalette() const
146 return *mrImpData.mxPalette;
149 XclImpFontBuffer& XclImpRoot::GetFontBuffer() const
151 return *mrImpData.mxFontBfr;
154 XclImpNumFmtBuffer& XclImpRoot::GetNumFmtBuffer() const
156 return *mrImpData.mxNumFmtBfr;
159 XclImpXFBuffer& XclImpRoot::GetXFBuffer() const
161 return *mrImpData.mpXFBfr;
164 XclImpXFRangeBuffer& XclImpRoot::GetXFRangeBuffer() const
166 return *mrImpData.mxXFRangeBfr;
169 ScRangeListTabs& XclImpRoot::GetPrintAreaBuffer() const
171 return *mrImpData.mpPrintRanges;
174 ScRangeListTabs& XclImpRoot::GetTitleAreaBuffer() const
176 return *mrImpData.mpPrintTitles;
179 XclImpTabInfo& XclImpRoot::GetTabInfo() const
181 return *mrImpData.mxTabInfo;
184 XclImpNameManager& XclImpRoot::GetNameManager() const
186 return *mrImpData.mxNameMgr;
189 XclImpLinkManager& XclImpRoot::GetLinkManager() const
191 assert(mrImpData.mxLinkMgr && "XclImpRoot::GetLinkManager - invalid call, wrong BIFF");
192 return *mrImpData.mxLinkMgr;
195 XclImpObjectManager& XclImpRoot::GetObjectManager() const
197 return *mrImpData.mxObjMgr;
200 XclImpSheetDrawing& XclImpRoot::GetCurrSheetDrawing() const
202 OSL_ENSURE( !IsInGlobals(), "XclImpRoot::GetCurrSheetDrawing - must not be called from workbook globals" );
203 return mrImpData.mxObjMgr->GetSheetDrawing( GetCurrScTab() );
206 XclImpCondFormatManager& XclImpRoot::GetCondFormatManager() const
208 assert(mrImpData.mxCondFmtMgr && "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF");
209 return *mrImpData.mxCondFmtMgr;
212 XclImpValidationManager& XclImpRoot::GetValidationManager() const
214 assert(mrImpData.mxValidMgr && "XclImpRoot::GetValidationManager - invalid call, wrong BIFF");
215 return *mrImpData.mxValidMgr;
218 XclImpAutoFilterBuffer& XclImpRoot::GetFilterManager() const
220 // TODO still in old RootData
221 assert(GetOldRoot().pAutoFilterBuffer && "XclImpRoot::GetFilterManager - invalid call, wrong BIFF");
222 return *GetOldRoot().pAutoFilterBuffer;
225 XclImpWebQueryBuffer& XclImpRoot::GetWebQueryBuffer() const
227 assert(mrImpData.mxWebQueryBfr && "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF");
228 return *mrImpData.mxWebQueryBfr;
231 XclImpPivotTableManager& XclImpRoot::GetPivotTableManager() const
233 assert(mrImpData.mxPTableMgr && "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF");
234 return *mrImpData.mxPTableMgr;
237 XclImpSheetProtectBuffer& XclImpRoot::GetSheetProtectBuffer() const
239 assert(mrImpData.mxTabProtect && "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF");
240 return *mrImpData.mxTabProtect;
243 XclImpDocProtectBuffer& XclImpRoot::GetDocProtectBuffer() const
245 assert(mrImpData.mxDocProtect && "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF");
246 return *mrImpData.mxDocProtect;
249 XclImpPageSettings& XclImpRoot::GetPageSettings() const
251 return *mrImpData.mxPageSett;
254 XclImpDocViewSettings& XclImpRoot::GetDocViewSettings() const
256 return *mrImpData.mxDocViewSett;
259 XclImpTabViewSettings& XclImpRoot::GetTabViewSettings() const
261 return *mrImpData.mxTabViewSett;
264 OUString XclImpRoot::GetScAddInName( const OUString& rXclName )
266 OUString aScName;
267 if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName, aScName ) )
268 return aScName;
269 return rXclName;
272 void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals )
274 if( !(mrImpData.mbHasBasic && (GetBiff() == EXC_BIFF8)) )
275 return;
277 OUString aName = rStrm.ReadUniString();
278 if( aName.isEmpty() )
279 return;
281 if( bGlobals )
283 GetExtDocOptions().GetDocSettings().maGlobCodeName = aName;
284 GetDoc().SetCodeName( aName );
286 else
288 GetExtDocOptions().SetCodeName( GetCurrScTab(), aName );
289 GetDoc().SetCodeName( GetCurrScTab(), aName );
293 ScDocumentImport& XclImpRoot::GetDocImport()
295 return *mrImpData.mxDocImport;
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */