LCOV - code coverage report
Current view: top level - sc/source/filter/excel - namebuff.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 105 0.0 %
Date: 2014-04-14 Functions: 0 23 0.0 %
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             : 
      21             : #include "namebuff.hxx"
      22             : 
      23             : #include "document.hxx"
      24             : #include "compiler.hxx"
      25             : #include "scextopt.hxx"
      26             : 
      27             : #include "root.hxx"
      28             : #include "tokstack.hxx"
      29             : #include "xltools.hxx"
      30             : #include "xiroot.hxx"
      31             : 
      32             : #include <string.h>
      33             : 
      34           0 : sal_uInt32 StringHashEntry::MakeHashCode( const OUString& r )
      35             : {
      36           0 :     sal_uInt32             n = 0;
      37           0 :     const sal_Unicode*     pAkt = r.getStr();
      38           0 :     sal_Unicode            cAkt = *pAkt;
      39             : 
      40           0 :     while( cAkt )
      41             :     {
      42           0 :         n *= 70;
      43           0 :         n += ( sal_uInt32 ) cAkt;
      44           0 :         pAkt++;
      45           0 :         cAkt = *pAkt;
      46             :     }
      47             : 
      48           0 :     return n;
      49             : }
      50             : 
      51             : 
      52           0 : NameBuffer::~NameBuffer()
      53             : {
      54           0 :     std::vector<StringHashEntry*>::iterator pIter;
      55           0 :     for ( pIter = maHashes.begin(); pIter != maHashes.end(); ++pIter )
      56           0 :         delete *pIter;
      57           0 : }
      58             : 
      59             : 
      60             : //void NameBuffer::operator <<( const SpString &rNewString )
      61           0 : void NameBuffer::operator <<( const OUString &rNewString )
      62             : {
      63             :     OSL_ENSURE( maHashes.size() + nBase < 0xFFFF,
      64             :         "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" );
      65             : 
      66           0 :     maHashes.push_back( new StringHashEntry( rNewString ) );
      67           0 : }
      68             : 
      69           0 : SharedFormulaBuffer::SharedFormulaBuffer( RootData* pRD ) : ExcRoot(pRD) {}
      70             : 
      71           0 : SharedFormulaBuffer::~SharedFormulaBuffer()
      72             : {
      73           0 :     Clear();
      74           0 : }
      75             : 
      76           0 : void SharedFormulaBuffer::Clear()
      77             : {
      78           0 :     TokenArraysType::iterator it = maTokenArrays.begin(), itEnd = maTokenArrays.end();
      79           0 :     for (; it != itEnd; ++it)
      80           0 :         delete it->second;
      81             : 
      82           0 :     maTokenArrays.clear();
      83           0 : }
      84             : 
      85           0 : void SharedFormulaBuffer::Store( const ScAddress& rPos, const ScTokenArray& rArray )
      86             : {
      87           0 :     ScTokenArray* pCode = rArray.Clone();
      88           0 :     pCode->GenHash();
      89           0 :     maTokenArrays.insert(TokenArraysType::value_type(rPos, pCode));
      90           0 : }
      91             : 
      92           0 : const ScTokenArray* SharedFormulaBuffer::Find( const ScAddress& rRefPos ) const
      93             : {
      94           0 :     TokenArraysType::const_iterator it = maTokenArrays.find(rRefPos);
      95           0 :     if (it == maTokenArrays.end())
      96           0 :         return NULL;
      97             : 
      98           0 :     return it->second;
      99             : }
     100             : 
     101           0 : sal_Int16 ExtSheetBuffer::Add( const OUString& rFPAN, const OUString& rTN, const bool bSWB )
     102             : {
     103           0 :     maEntries.push_back( Cont( rFPAN, rTN, bSWB ) );
     104             :     // return 1-based index of EXTERNSHEET
     105           0 :     return static_cast< sal_Int16 >( maEntries.size() );
     106             : }
     107             : 
     108             : 
     109           0 : bool ExtSheetBuffer::GetScTabIndex( sal_uInt16 nExcIndex, sal_uInt16& rScIndex )
     110             : {
     111             :     OSL_ENSURE( nExcIndex,
     112             :         "*ExtSheetBuffer::GetScTabIndex(): Sheet-Index == 0!" );
     113             : 
     114           0 :     if ( !nExcIndex || nExcIndex > maEntries.size() )
     115           0 :         return false;
     116             : 
     117           0 :     Cont*       pCur = &maEntries[ nExcIndex - 1 ];
     118           0 :     sal_uInt16&     rTabNum = pCur->nTabNum;
     119             : 
     120           0 :     if( rTabNum < 0xFFFD )
     121             :     {
     122           0 :         rScIndex = rTabNum;
     123           0 :         return true;
     124             :     }
     125             : 
     126           0 :     if( rTabNum == 0xFFFF )
     127             :     {// neue Tabelle erzeugen
     128             :         SCTAB   nNewTabNum;
     129           0 :         if( pCur->bSWB )
     130             :         {// Tabelle ist im selben Workbook!
     131           0 :             if( pExcRoot->pIR->GetDoc().GetTable( pCur->aTab, nNewTabNum ) )
     132             :             {
     133           0 :                 rScIndex = rTabNum = static_cast<sal_uInt16>(nNewTabNum);
     134           0 :                 return true;
     135             :             }
     136             :             else
     137           0 :                 rTabNum = 0xFFFD;
     138             :         }
     139           0 :         else if( pExcRoot->pIR->GetDocShell() )
     140             :         {// Tabelle ist 'echt' extern
     141           0 :             if( pExcRoot->pIR->GetExtDocOptions().GetDocSettings().mnLinkCnt == 0 )
     142             :             {
     143             :                 OUString      aURL( ScGlobal::GetAbsDocName( pCur->aFile,
     144           0 :                                     pExcRoot->pIR->GetDocShell() ) );
     145           0 :                 OUString      aTabName( ScGlobal::GetDocTabName( aURL, pCur->aTab ) );
     146           0 :                 if( pExcRoot->pIR->GetDoc().LinkExternalTab( nNewTabNum, aTabName, aURL, pCur->aTab ) )
     147             :                 {
     148           0 :                     rScIndex = rTabNum = static_cast<sal_uInt16>(nNewTabNum);
     149           0 :                     return true;
     150             :                 }
     151             :                 else
     152           0 :                     rTabNum = 0xFFFE;       // Tabelle einmal nicht angelegt -> wird
     153             :                                             //  wohl auch nicht mehr gehen...
     154             :             }
     155             :             else
     156           0 :                 rTabNum = 0xFFFE;
     157             : 
     158             :         }
     159             :     }
     160             : 
     161           0 :     return false;
     162             : }
     163             : 
     164             : 
     165           0 : bool ExtSheetBuffer::IsLink( const sal_uInt16 nExcIndex ) const
     166             : {
     167             :     OSL_ENSURE( nExcIndex > 0, "*ExtSheetBuffer::IsLink(): Index has to be >0!" );
     168             : 
     169           0 :     if (!nExcIndex || nExcIndex > maEntries.size() )
     170           0 :         return false;
     171             : 
     172           0 :     return maEntries[ nExcIndex -1 ].bLink;
     173             : }
     174             : 
     175             : 
     176           0 : bool ExtSheetBuffer::GetLink( const sal_uInt16 nExcIndex, OUString& rAppl, OUString& rDoc ) const
     177             : {
     178             :     OSL_ENSURE( nExcIndex > 0, "*ExtSheetBuffer::GetLink(): Index has to be >0!" );
     179             : 
     180           0 :     if (!nExcIndex || nExcIndex > maEntries.size() )
     181           0 :         return false;
     182             : 
     183           0 :     const Cont &rRet = maEntries[ nExcIndex -1 ];
     184             : 
     185           0 :     rAppl = rRet.aFile;
     186           0 :     rDoc = rRet.aTab;
     187             : 
     188           0 :     return true;
     189             : }
     190             : 
     191             : 
     192           0 : void ExtSheetBuffer::Reset( void )
     193             : {
     194           0 :     maEntries.clear();
     195           0 : }
     196             : 
     197             : 
     198           0 : bool ExtName::IsDDE( void ) const
     199             : {
     200           0 :     return ( nFlags & 0x0001 ) != 0;
     201             : }
     202             : 
     203             : 
     204           0 : bool ExtName::IsOLE( void ) const
     205             : {
     206           0 :     return ( nFlags & 0x0002 ) != 0;
     207             : }
     208             : 
     209             : 
     210           0 : ExtNameBuff::ExtNameBuff( const XclImpRoot& rRoot ) :
     211           0 :     XclImpRoot( rRoot )
     212             : {
     213           0 : }
     214             : 
     215             : 
     216           0 : void ExtNameBuff::AddDDE( const OUString& rName, sal_Int16 nRefIdx )
     217             : {
     218           0 :     ExtName aNew( rName, 0x0001 );
     219           0 :     maExtNames[ nRefIdx ].push_back( aNew );
     220           0 : }
     221             : 
     222             : 
     223           0 : void ExtNameBuff::AddOLE( const OUString& rName, sal_Int16 nRefIdx, sal_uInt32 nStorageId )
     224             : {
     225           0 :     ExtName aNew( rName, 0x0002 );
     226           0 :     aNew.nStorageId = nStorageId;
     227           0 :     maExtNames[ nRefIdx ].push_back( aNew );
     228           0 : }
     229             : 
     230             : 
     231           0 : void ExtNameBuff::AddName( const OUString& rName, sal_Int16 nRefIdx )
     232             : {
     233           0 :     ExtName aNew( GetScAddInName( rName ), 0x0004 );
     234           0 :     maExtNames[ nRefIdx ].push_back( aNew );
     235           0 : }
     236             : 
     237             : 
     238           0 : const ExtName* ExtNameBuff::GetNameByIndex( sal_Int16 nRefIdx, sal_uInt16 nNameIdx ) const
     239             : {
     240             :     OSL_ENSURE( nNameIdx > 0, "ExtNameBuff::GetNameByIndex() - invalid name index" );
     241           0 :     ExtNameMap::const_iterator aIt = maExtNames.find( nRefIdx );
     242           0 :     return ((aIt != maExtNames.end()) && (0 < nNameIdx) && (nNameIdx <= aIt->second.size())) ? &aIt->second[ nNameIdx - 1 ] : 0;
     243             : }
     244             : 
     245             : 
     246           0 : void ExtNameBuff::Reset( void )
     247             : {
     248           0 :     maExtNames.clear();
     249           0 : }
     250             : 
     251             : 
     252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10