LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/excel - xiroot.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 110 124 88.7 %
Date: 2012-12-27 Functions: 34 38 89.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10