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

Generated by: LCOV version 1.11