1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xiroot.cxx,v $
10 * $Revision: 1.24.88.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "addincol.hxx"
35 #include "xltracer.hxx"
36 #include "xihelper.hxx"
37 #include "xiformula.hxx"
40 #include "xistyle.hxx"
41 #include "xicontent.hxx"
42 #include "xiescher.hxx"
43 #include "xipivot.hxx"
48 #include "excimp8.hxx"
50 // Global data ================================================================
52 XclImpRootData::XclImpRootData( XclBiff eBiff
, SfxMedium
& rMedium
,
53 SotStorageRef xRootStrg
, ScDocument
& rDoc
, rtl_TextEncoding eTextEnc
) :
54 XclRootData( eBiff
, rMedium
, xRootStrg
, rDoc
, eTextEnc
, false ),
55 mbPassQueried( false ),
56 mbHasCodePage( false )
60 XclImpRootData::~XclImpRootData()
64 // ----------------------------------------------------------------------------
66 XclImpRoot::XclImpRoot( XclImpRootData
& rImpRootData
) :
67 XclRoot( rImpRootData
),
68 mrImpData( rImpRootData
)
70 mrImpData
.mxAddrConv
.reset( new XclImpAddressConverter( GetRoot() ) );
71 mrImpData
.mxFmlaComp
.reset( new XclImpFormulaCompiler( GetRoot() ) );
72 mrImpData
.mxPalette
.reset( new XclImpPalette( GetRoot() ) );
73 mrImpData
.mxFontBfr
.reset( new XclImpFontBuffer( GetRoot() ) );
74 mrImpData
.mxNumFmtBfr
.reset( new XclImpNumFmtBuffer( GetRoot() ) );
75 mrImpData
.mpXFBfr
.reset( new XclImpXFBuffer( GetRoot() ) );
76 mrImpData
.mxXFRangeBfr
.reset( new XclImpXFRangeBuffer( GetRoot() ) );
77 mrImpData
.mxTabInfo
.reset( new XclImpTabInfo
);
78 mrImpData
.mxNameMgr
.reset( new XclImpNameManager( GetRoot() ) );
79 mrImpData
.mxObjMgr
.reset( new XclImpObjectManager( GetRoot() ) );
81 if( GetBiff() == EXC_BIFF8
)
83 mrImpData
.mxLinkMgr
.reset( new XclImpLinkManager( GetRoot() ) );
84 mrImpData
.mxSst
.reset( new XclImpSst( GetRoot() ) );
85 mrImpData
.mxCondFmtMgr
.reset( new XclImpCondFormatManager( GetRoot() ) );
86 // TODO still in old RootData (deleted by RootData)
87 GetOldRoot().pAutoFilterBuffer
= new XclImpAutoFilterBuffer
;
88 mrImpData
.mxWebQueryBfr
.reset( new XclImpWebQueryBuffer( GetRoot() ) );
89 mrImpData
.mxPTableMgr
.reset( new XclImpPivotTableManager( GetRoot() ) );
90 mrImpData
.mxTabProtect
.reset( new XclImpSheetProtectBuffer( GetRoot() ) );
91 mrImpData
.mxDocProtect
.reset( new XclImpDocProtectBuffer( GetRoot() ) );
94 mrImpData
.mxPageSett
.reset( new XclImpPageSettings( GetRoot() ) );
95 mrImpData
.mxDocViewSett
.reset( new XclImpDocViewSettings( GetRoot() ) );
96 mrImpData
.mxTabViewSett
.reset( new XclImpTabViewSettings( GetRoot() ) );
99 void XclImpRoot::SetCodePage( sal_uInt16 nCodePage
)
101 SetTextEncoding( XclTools::GetTextEncoding( nCodePage
) );
102 mrImpData
.mbHasCodePage
= true;
105 void XclImpRoot::SetAppFontEncoding( rtl_TextEncoding eAppFontEnc
)
107 if( !mrImpData
.mbHasCodePage
)
108 SetTextEncoding( eAppFontEnc
);
111 void XclImpRoot::InitializeTable( SCTAB
/*nScTab*/ )
113 if( GetBiff() <= EXC_BIFF4
)
115 GetPalette().Initialize();
116 GetFontBuffer().Initialize();
117 GetNumFmtBuffer().Initialize();
118 GetXFBuffer().Initialize();
120 GetXFRangeBuffer().Initialize();
121 GetPageSettings().Initialize();
122 GetTabViewSettings().Initialize();
125 void XclImpRoot::FinalizeTable()
127 GetXFRangeBuffer().Finalize();
128 GetOldRoot().pColRowBuff
->Convert( GetCurrScTab() );
129 GetPageSettings().Finalize();
130 GetTabViewSettings().Finalize();
133 XclImpAddressConverter
& XclImpRoot::GetAddressConverter() const
135 return *mrImpData
.mxAddrConv
;
138 XclImpFormulaCompiler
& XclImpRoot::GetFormulaCompiler() const
140 return *mrImpData
.mxFmlaComp
;
143 ExcelToSc
& XclImpRoot::GetOldFmlaConverter() const
145 // TODO still in old RootData
146 return *GetOldRoot().pFmlaConverter
;
149 XclImpSst
& XclImpRoot::GetSst() const
151 DBG_ASSERT( mrImpData
.mxSst
.is(), "XclImpRoot::GetSst - invalid call, wrong BIFF" );
152 return *mrImpData
.mxSst
;
155 XclImpPalette
& XclImpRoot::GetPalette() const
157 return *mrImpData
.mxPalette
;
160 XclImpFontBuffer
& XclImpRoot::GetFontBuffer() const
162 return *mrImpData
.mxFontBfr
;
165 XclImpNumFmtBuffer
& XclImpRoot::GetNumFmtBuffer() const
167 return *mrImpData
.mxNumFmtBfr
;
170 XclImpXFBuffer
& XclImpRoot::GetXFBuffer() const
172 return *mrImpData
.mpXFBfr
;
175 XclImpXFRangeBuffer
& XclImpRoot::GetXFRangeBuffer() const
177 return *mrImpData
.mxXFRangeBfr
;
180 _ScRangeListTabs
& XclImpRoot::GetPrintAreaBuffer() const
182 // TODO still in old RootData
183 return *GetOldRoot().pPrintRanges
;
186 _ScRangeListTabs
& XclImpRoot::GetTitleAreaBuffer() const
188 // TODO still in old RootData
189 return *GetOldRoot().pPrintTitles
;
192 XclImpTabInfo
& XclImpRoot::GetTabInfo() const
194 return *mrImpData
.mxTabInfo
;
197 XclImpNameManager
& XclImpRoot::GetNameManager() const
199 return *mrImpData
.mxNameMgr
;
202 XclImpLinkManager
& XclImpRoot::GetLinkManager() const
204 DBG_ASSERT( mrImpData
.mxLinkMgr
.is(), "XclImpRoot::GetLinkManager - invalid call, wrong BIFF" );
205 return *mrImpData
.mxLinkMgr
;
208 XclImpObjectManager
& XclImpRoot::GetObjectManager() const
210 return *mrImpData
.mxObjMgr
;
213 XclImpCondFormatManager
& XclImpRoot::GetCondFormatManager() const
215 DBG_ASSERT( mrImpData
.mxCondFmtMgr
.is(), "XclImpRoot::GetCondFormatManager - invalid call, wrong BIFF" );
216 return *mrImpData
.mxCondFmtMgr
;
219 XclImpAutoFilterBuffer
& XclImpRoot::GetFilterManager() const
221 // TODO still in old RootData
222 DBG_ASSERT( GetOldRoot().pAutoFilterBuffer
, "XclImpRoot::GetFilterManager - invalid call, wrong BIFF" );
223 return *GetOldRoot().pAutoFilterBuffer
;
226 XclImpWebQueryBuffer
& XclImpRoot::GetWebQueryBuffer() const
228 DBG_ASSERT( mrImpData
.mxWebQueryBfr
.is(), "XclImpRoot::GetWebQueryBuffer - invalid call, wrong BIFF" );
229 return *mrImpData
.mxWebQueryBfr
;
232 XclImpPivotTableManager
& XclImpRoot::GetPivotTableManager() const
234 DBG_ASSERT( mrImpData
.mxPTableMgr
.is(), "XclImpRoot::GetPivotTableManager - invalid call, wrong BIFF" );
235 return *mrImpData
.mxPTableMgr
;
238 XclImpSheetProtectBuffer
& XclImpRoot::GetSheetProtectBuffer() const
240 DBG_ASSERT( mrImpData
.mxTabProtect
.is(), "XclImpRoot::GetSheetProtectBuffer - invalid call, wrong BIFF" );
241 return *mrImpData
.mxTabProtect
;
244 XclImpDocProtectBuffer
& XclImpRoot::GetDocProtectBuffer() const
246 DBG_ASSERT( mrImpData
.mxDocProtect
.is(), "XclImpRoot::GetDocProtectBuffer - invalid call, wrong BIFF" );
247 return *mrImpData
.mxDocProtect
;
250 XclImpPageSettings
& XclImpRoot::GetPageSettings() const
252 return *mrImpData
.mxPageSett
;
255 XclImpDocViewSettings
& XclImpRoot::GetDocViewSettings() const
257 return *mrImpData
.mxDocViewSett
;
260 XclImpTabViewSettings
& XclImpRoot::GetTabViewSettings() const
262 return *mrImpData
.mxTabViewSett
;
265 String
XclImpRoot::GetScAddInName( const String
& rXclName
) const
268 if( ScGlobal::GetAddInCollection()->GetCalcName( rXclName
, aScName
) )
273 const String
& XclImpRoot::QueryPassword() const
275 if( !mrImpData
.mbPassQueried
)
277 mrImpData
.maPassw
= ScfApiHelper::QueryPasswordForMedium( GetMedium() );
278 // set to true, even if dialog has been cancelled (never ask twice)
279 mrImpData
.mbPassQueried
= true;
281 return mrImpData
.maPassw
;
284 // ============================================================================