LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - tokenuno.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 144 243 59.3 %
Date: 2014-04-11 Functions: 15 24 62.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             : 
      21             : #include "tokenuno.hxx"
      22             : 
      23             : #include <sal/macros.h>
      24             : 
      25             : #include <com/sun/star/sheet/ComplexReference.hpp>
      26             : #include <com/sun/star/sheet/ExternalReference.hpp>
      27             : #include <com/sun/star/sheet/ReferenceFlags.hpp>
      28             : #include <com/sun/star/sheet/AddressConvention.hpp>
      29             : #include <com/sun/star/sheet/NameToken.hpp>
      30             : #include <com/sun/star/table/CellAddress.hpp>
      31             : 
      32             : #include <svl/itemprop.hxx>
      33             : #include <vcl/svapp.hxx>
      34             : 
      35             : #include "miscuno.hxx"
      36             : #include "convuno.hxx"
      37             : #include "unonames.hxx"
      38             : #include "token.hxx"
      39             : #include "compiler.hxx"
      40             : #include "tokenarray.hxx"
      41             : #include "docsh.hxx"
      42             : #include "rangeseq.hxx"
      43             : #include "externalrefmgr.hxx"
      44             : 
      45             : using namespace ::formula;
      46             : using namespace ::com::sun::star;
      47             : 
      48           5 : static const SfxItemPropertyMapEntry* lcl_GetFormulaParserMap()
      49             : {
      50             :     static const SfxItemPropertyMapEntry aFormulaParserMap_Impl[] =
      51             :     {
      52           5 :         {OUString(SC_UNO_COMPILEFAP),           0,  getBooleanCppuType(),                   0, 0 },
      53           5 :         {OUString(SC_UNO_COMPILEENGLISH),       0,  getBooleanCppuType(),                   0, 0 },
      54           5 :         {OUString(SC_UNO_IGNORELEADING),        0,  getBooleanCppuType(),                   0, 0 },
      55           5 :         {OUString(SC_UNO_FORMULACONVENTION),    0,  getCppuType(&sheet::AddressConvention::UNSPECIFIED), 0, 0 },
      56           5 :         {OUString(SC_UNO_OPCODEMAP),            0,  getCppuType((uno::Sequence< sheet::FormulaOpCodeMapEntry >*)0), 0, 0 },
      57             :         { OUString(), 0, css::uno::Type(), 0, 0 }
      58          35 :     };
      59           5 :     return aFormulaParserMap_Impl;
      60             : }
      61             : 
      62           0 : SC_SIMPLE_SERVICE_INFO( ScFormulaParserObj, "ScFormulaParserObj", SC_SERVICENAME_FORMULAPARS )
      63             : 
      64          67 : ScFormulaParserObj::ScFormulaParserObj(ScDocShell* pDocSh) :
      65             :     mpDocShell( pDocSh ),
      66             :     mnConv( sheet::AddressConvention::UNSPECIFIED ),
      67             :     mbEnglish( false ),
      68             :     mbIgnoreSpaces( true ),
      69          67 :     mbCompileFAP( false )
      70             : {
      71          67 :     mpDocShell->GetDocument()->AddUnoObject(*this);
      72          67 : }
      73             : 
      74         201 : ScFormulaParserObj::~ScFormulaParserObj()
      75             : {
      76          67 :     if (mpDocShell)
      77          66 :         mpDocShell->GetDocument()->RemoveUnoObject(*this);
      78         134 : }
      79             : 
      80        2796 : void ScFormulaParserObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
      81             : {
      82        2796 :     if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
      83           1 :         mpDocShell = NULL;
      84        2796 : }
      85             : 
      86             : // XFormulaParser
      87             : 
      88          97 : void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const
      89             : {
      90             :     static const formula::FormulaGrammar::AddressConvention aConvMap[] = {
      91             :         formula::FormulaGrammar::CONV_OOO,        // <- AddressConvention::OOO
      92             :         formula::FormulaGrammar::CONV_XL_A1,      // <- AddressConvention::XL_A1
      93             :         formula::FormulaGrammar::CONV_XL_R1C1,    // <- AddressConvention::XL_R1C1
      94             :         formula::FormulaGrammar::CONV_XL_OOX,     // <- AddressConvention::XL_OOX
      95             :         formula::FormulaGrammar::CONV_LOTUS_A1    // <- AddressConvention::LOTUS_A1
      96             :     };
      97             :     static const sal_Int16 nConvMapCount = sizeof(aConvMap)/sizeof(aConvMap[0]);
      98             : 
      99             :     // If mxOpCodeMap is not empty it overrides mbEnglish, and vice versa. We
     100             :     // don't need to initialize things twice.
     101          97 :     if (mxOpCodeMap.get())
     102          54 :         rCompiler.SetFormulaLanguage( mxOpCodeMap );
     103             :     else
     104             :     {
     105             :         sal_Int32 nFormulaLanguage = mbEnglish ?
     106             :             sheet::FormulaLanguage::ENGLISH :
     107          43 :             sheet::FormulaLanguage::NATIVE;
     108          43 :         ScCompiler::OpCodeMapPtr xMap = rCompiler.GetOpCodeMap( nFormulaLanguage);
     109          43 :         rCompiler.SetFormulaLanguage( xMap);
     110             :     }
     111             : 
     112          97 :     formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_UNSPECIFIED;
     113          97 :     if (mnConv >= 0 && mnConv < nConvMapCount)
     114          96 :         eConv = aConvMap[mnConv];
     115             : 
     116          97 :     rCompiler.SetRefConvention( eConv );
     117             : 
     118          97 :     rCompiler.SetCompileForFAP(mbCompileFAP);
     119             : 
     120          97 :     rCompiler.SetExternalLinks( maExternalLinks);
     121          97 : }
     122             : 
     123          76 : uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula(
     124             :     const OUString& aFormula, const table::CellAddress& rReferencePos )
     125             :         throw (uno::RuntimeException, std::exception)
     126             : {
     127          76 :     SolarMutexGuard aGuard;
     128          76 :     uno::Sequence<sheet::FormulaToken> aRet;
     129             : 
     130          76 :     if (mpDocShell)
     131             :     {
     132          76 :         ScDocument* pDoc = mpDocShell->GetDocument();
     133          76 :         ScExternalRefManager::ApiGuard aExtRefGuard(pDoc);
     134             : 
     135          76 :         ScAddress aRefPos( ScAddress::UNINITIALIZED );
     136          76 :         ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
     137         152 :         ScCompiler aCompiler( pDoc, aRefPos);
     138          76 :         aCompiler.SetGrammar(pDoc->GetGrammar());
     139          76 :         SetCompilerFlags( aCompiler );
     140             : 
     141          76 :         ScTokenArray* pCode = aCompiler.CompileString( aFormula );
     142          76 :         (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aRet, *pCode );
     143         152 :         delete pCode;
     144             :     }
     145             : 
     146          76 :     return aRet;
     147             : }
     148             : 
     149          21 : OUString SAL_CALL ScFormulaParserObj::printFormula(
     150             :         const uno::Sequence<sheet::FormulaToken>& aTokens, const table::CellAddress& rReferencePos )
     151             :                                 throw (uno::RuntimeException, std::exception)
     152             : {
     153          21 :     SolarMutexGuard aGuard;
     154          21 :     OUString aRet;
     155             : 
     156          21 :     if (mpDocShell)
     157             :     {
     158          21 :         ScDocument* pDoc = mpDocShell->GetDocument();
     159          21 :         ScTokenArray aCode;
     160          21 :         (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aCode, aTokens );
     161          21 :         ScAddress aRefPos( ScAddress::UNINITIALIZED );
     162          21 :         ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
     163          42 :         ScCompiler aCompiler( pDoc, aRefPos, aCode);
     164          21 :         aCompiler.SetGrammar(pDoc->GetGrammar());
     165          21 :         SetCompilerFlags( aCompiler );
     166             : 
     167          42 :         OUStringBuffer aBuffer;
     168          21 :         aCompiler.CreateStringFromTokenArray( aBuffer );
     169          42 :         aRet = aBuffer.makeStringAndClear();
     170             :     }
     171             : 
     172          21 :     return aRet;
     173             : }
     174             : 
     175             : // XPropertySet
     176             : 
     177          44 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFormulaParserObj::getPropertySetInfo()
     178             :                                                         throw(uno::RuntimeException, std::exception)
     179             : {
     180          44 :     SolarMutexGuard aGuard;
     181          44 :     static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( lcl_GetFormulaParserMap() ));
     182          44 :     return aRef;
     183             : }
     184             : 
     185         229 : void SAL_CALL ScFormulaParserObj::setPropertyValue(
     186             :                         const OUString& aPropertyName, const uno::Any& aValue )
     187             :                 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
     188             :                         lang::IllegalArgumentException, lang::WrappedTargetException,
     189             :                         uno::RuntimeException, std::exception)
     190             : {
     191         229 :     SolarMutexGuard aGuard;
     192         458 :     OUString aString(aPropertyName);
     193         229 :     if ( aString.equalsAscii( SC_UNO_COMPILEFAP ) )
     194             :     {
     195           0 :         aValue >>= mbCompileFAP;
     196             :     }
     197         229 :     else if ( aString.equalsAscii( SC_UNO_COMPILEENGLISH ) )
     198             :     {
     199          44 :         bool bOldEnglish = mbEnglish;
     200          44 :         if (aValue >>= mbEnglish)
     201             :         {
     202             :             // Need to recreate the symbol map to change English property
     203             :             // because the map is const. So for performance reasons set
     204             :             // CompileEnglish _before_ OpCodeMap!
     205          44 :             if (mxOpCodeMap.get() && mbEnglish != bOldEnglish)
     206             :             {
     207           0 :                 ScDocument* pDoc = mpDocShell->GetDocument();
     208           0 :                 ScCompiler aCompiler( pDoc, ScAddress());
     209           0 :                 aCompiler.SetGrammar(pDoc->GetGrammar());
     210           0 :                 mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish);
     211             :             }
     212             :         }
     213             :         else
     214           0 :             throw lang::IllegalArgumentException();
     215             :     }
     216         185 :     else if ( aString.equalsAscii( SC_UNO_FORMULACONVENTION ) )
     217             :     {
     218          86 :         aValue >>= mnConv;
     219             :     }
     220          99 :     else if ( aString.equalsAscii( SC_UNO_IGNORELEADING ) )
     221             :     {
     222          44 :         aValue >>= mbIgnoreSpaces;
     223             :     }
     224          55 :     else if ( aString.equalsAscii( SC_UNO_OPCODEMAP ) )
     225             :     {
     226          44 :         if (aValue >>= maOpCodeMapping)
     227             :         {
     228          44 :             ScDocument* pDoc = mpDocShell->GetDocument();
     229          44 :             ScCompiler aCompiler( pDoc, ScAddress());
     230          44 :             aCompiler.SetGrammar(pDoc->GetGrammar());
     231          44 :             mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish);
     232             :         }
     233             :         else
     234           0 :             throw lang::IllegalArgumentException();
     235             :     }
     236          11 :     else if ( aString.equalsAscii( SC_UNO_EXTERNALLINKS ) )
     237             :     {
     238          11 :         if (!(aValue >>= maExternalLinks))
     239           0 :             throw lang::IllegalArgumentException();
     240             :     }
     241             :     else
     242         229 :         throw beans::UnknownPropertyException();
     243         229 : }
     244             : 
     245           0 : uno::Any SAL_CALL ScFormulaParserObj::getPropertyValue( const OUString& aPropertyName )
     246             :                 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
     247             :                         uno::RuntimeException, std::exception)
     248             : {
     249           0 :     SolarMutexGuard aGuard;
     250           0 :     uno::Any aRet;
     251           0 :     OUString aString(aPropertyName);
     252           0 :     if ( aString.equalsAscii( SC_UNO_COMPILEFAP ) )
     253             :     {
     254           0 :         aRet <<= mbCompileFAP;
     255             :     }
     256           0 :     else if ( aString.equalsAscii( SC_UNO_COMPILEENGLISH ) )
     257             :     {
     258           0 :         aRet <<= mbEnglish;
     259             :     }
     260           0 :     else if ( aString.equalsAscii( SC_UNO_FORMULACONVENTION ) )
     261             :     {
     262           0 :         aRet <<= mnConv;
     263             :     }
     264           0 :     else if ( aString.equalsAscii( SC_UNO_IGNORELEADING ) )
     265             :     {
     266           0 :         aRet <<= mbIgnoreSpaces;
     267             :     }
     268           0 :     else if ( aString.equalsAscii( SC_UNO_OPCODEMAP ) )
     269             :     {
     270           0 :         aRet <<= maOpCodeMapping;
     271             :     }
     272           0 :     else if ( aString.equalsAscii( SC_UNO_EXTERNALLINKS ) )
     273             :     {
     274           0 :         aRet <<= maExternalLinks;
     275             :     }
     276             :     else
     277           0 :         throw beans::UnknownPropertyException();
     278           0 :     return aRet;
     279             : }
     280             : 
     281           0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFormulaParserObj )
     282             : 
     283           0 : static void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
     284             : {
     285           0 :     rAPI.Column         = 0;
     286           0 :     rAPI.Row            = 0;
     287           0 :     rAPI.Sheet          = 0;
     288           0 :     rAPI.RelativeColumn = 0;
     289           0 :     rAPI.RelativeRow    = 0;
     290           0 :     rAPI.RelativeSheet  = 0;
     291             : 
     292           0 :     sal_Int32 nFlags = 0;
     293           0 :     if ( rRef.IsColRel() )
     294             :     {
     295           0 :         nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
     296           0 :         rAPI.RelativeColumn = rRef.Col();
     297             :     }
     298             :     else
     299           0 :         rAPI.Column = rRef.Col();
     300             : 
     301           0 :     if ( rRef.IsRowRel() )
     302             :     {
     303           0 :         nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
     304           0 :         rAPI.RelativeRow = rRef.Row();
     305             :     }
     306             :     else
     307           0 :         rAPI.Row = rRef.Row();
     308             : 
     309           0 :     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     310           0 :     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     311           0 :     if ( rRef.IsFlag3D() )     nFlags |= sheet::ReferenceFlags::SHEET_3D;
     312           0 :     if ( rRef.IsRelName() )    nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
     313           0 :     rAPI.Flags = nFlags;
     314           0 : }
     315             : 
     316         117 : static void lcl_SingleRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
     317             : {
     318         117 :     sal_Int32 nFlags = 0;
     319         117 :     if ( rRef.IsColRel() )
     320             :     {
     321           0 :         nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
     322           0 :         rAPI.RelativeColumn = rRef.Col();
     323           0 :         rAPI.Column = 0;
     324             :     }
     325             :     else
     326             :     {
     327         117 :         rAPI.RelativeColumn = 0;
     328         117 :         rAPI.Column = rRef.Col();
     329             :     }
     330             : 
     331         117 :     if ( rRef.IsRowRel() )
     332             :     {
     333           0 :         nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
     334           0 :         rAPI.RelativeRow = rRef.Row();
     335           0 :         rAPI.Row = 0;
     336             :     }
     337             :     else
     338             :     {
     339         117 :         rAPI.RelativeRow = 0;
     340         117 :         rAPI.Row = rRef.Row();
     341             :     }
     342             : 
     343         117 :     if ( rRef.IsTabRel() )
     344             :     {
     345           0 :         nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
     346           0 :         rAPI.RelativeSheet = rRef.Tab();
     347           0 :         rAPI.Sheet = 0;
     348             :     }
     349             :     else
     350             :     {
     351         117 :         rAPI.RelativeSheet = 0;
     352         117 :         rAPI.Sheet = rRef.Tab();
     353             :     }
     354             : 
     355         117 :     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     356         117 :     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     357         117 :     if ( rRef.IsTabDeleted() ) nFlags |= sheet::ReferenceFlags::SHEET_DELETED;
     358         117 :     if ( rRef.IsFlag3D() )     nFlags |= sheet::ReferenceFlags::SHEET_3D;
     359         117 :     if ( rRef.IsRelName() )    nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
     360         117 :     rAPI.Flags = nFlags;
     361         117 : }
     362             : 
     363          87 : bool ScTokenConversion::ConvertToTokenArray( ScDocument& rDoc,
     364             :         ScTokenArray& rTokenArray, const uno::Sequence<sheet::FormulaToken>& rSequence )
     365             : {
     366          87 :     return !rTokenArray.Fill(rSequence,rDoc.GetExternalRefManager());
     367             : }
     368             : 
     369          88 : bool ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc,
     370             :         uno::Sequence<sheet::FormulaToken>& rSequence, const ScTokenArray& rTokenArray )
     371             : {
     372          88 :     bool bError = false;
     373             : 
     374          88 :     sal_Int32 nLen = static_cast<sal_Int32>(rTokenArray.GetLen());
     375          88 :     formula::FormulaToken** pTokens = rTokenArray.GetArray();
     376          88 :     if ( pTokens )
     377             :     {
     378          88 :         rSequence.realloc(nLen);
     379         176 :         for (sal_Int32 nPos=0; nPos<nLen; nPos++)
     380             :         {
     381          88 :             const formula::FormulaToken& rToken = *pTokens[nPos];
     382          88 :             sheet::FormulaToken& rAPI = rSequence[nPos];
     383             : 
     384          88 :             OpCode eOpCode = rToken.GetOpCode();
     385             :             // eOpCode may be changed in the following switch/case
     386          88 :             switch ( rToken.GetType() )
     387             :             {
     388             :                 case svByte:
     389             :                     // Only the count of spaces is stored as "long". Parameter count is ignored.
     390           0 :                     if ( eOpCode == ocSpaces )
     391           0 :                         rAPI.Data <<= (sal_Int32) rToken.GetByte();
     392             :                     else
     393           0 :                         rAPI.Data.clear();      // no data
     394           0 :                     break;
     395             :                 case formula::svDouble:
     396           5 :                     rAPI.Data <<= rToken.GetDouble();
     397           5 :                     break;
     398             :                 case formula::svString:
     399           0 :                     rAPI.Data <<= rToken.GetString().getString();
     400           0 :                     break;
     401             :                 case svExternal:
     402             :                     // Function name is stored as string.
     403             :                     // Byte (parameter count) is ignored.
     404           0 :                     rAPI.Data <<= OUString( rToken.GetExternal() );
     405           0 :                     break;
     406             :                 case svSingleRef:
     407             :                     {
     408          41 :                         sheet::SingleReference aSingleRef;
     409          41 :                         lcl_SingleRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() );
     410          41 :                         rAPI.Data <<= aSingleRef;
     411             :                     }
     412          41 :                     break;
     413             :                 case formula::svDoubleRef:
     414             :                     {
     415          38 :                         sheet::ComplexReference aCompRef;
     416          38 :                         lcl_SingleRefToApi( aCompRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() );
     417          38 :                         lcl_SingleRefToApi( aCompRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() );
     418          38 :                         rAPI.Data <<= aCompRef;
     419             :                     }
     420          38 :                     break;
     421             :                 case svIndex:
     422             :                     {
     423           2 :                         sheet::NameToken aNameToken;
     424           2 :                         aNameToken.Index = static_cast<sal_Int32>( rToken.GetIndex() );
     425           2 :                         aNameToken.Global = static_cast<sal_Bool>( rToken.IsGlobal() );
     426           2 :                         rAPI.Data <<= aNameToken;
     427             :                     }
     428           2 :                     break;
     429             :                 case svMatrix:
     430           2 :                     if (!ScRangeToSequence::FillMixedArray( rAPI.Data, static_cast<const ScToken&>(rToken).GetMatrix(), true))
     431           0 :                         rAPI.Data.clear();
     432           2 :                     break;
     433             :                 case svExternalSingleRef:
     434             :                     {
     435           0 :                         sheet::SingleReference aSingleRef;
     436           0 :                         lcl_ExternalRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() );
     437             :                         size_t nCacheId;
     438             :                         rDoc.GetExternalRefManager()->getCacheTable(
     439           0 :                             rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId);
     440           0 :                         aSingleRef.Sheet = static_cast< sal_Int32 >( nCacheId );
     441           0 :                         sheet::ExternalReference aExtRef;
     442           0 :                         aExtRef.Index = rToken.GetIndex();
     443           0 :                         aExtRef.Reference <<= aSingleRef;
     444           0 :                         rAPI.Data <<= aExtRef;
     445           0 :                         eOpCode = ocPush;
     446             :                     }
     447           0 :                     break;
     448             :                 case svExternalDoubleRef:
     449             :                     {
     450           0 :                         sheet::ComplexReference aComplRef;
     451           0 :                         lcl_ExternalRefToApi( aComplRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() );
     452           0 :                         lcl_ExternalRefToApi( aComplRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() );
     453             :                         size_t nCacheId;
     454             :                         rDoc.GetExternalRefManager()->getCacheTable(
     455           0 :                             rToken.GetIndex(), rToken.GetString().getString(), false, &nCacheId);
     456           0 :                         aComplRef.Reference1.Sheet = static_cast< sal_Int32 >( nCacheId );
     457             :                         // NOTE: This assumes that cached sheets are in consecutive order!
     458             :                         aComplRef.Reference2.Sheet =
     459           0 :                             aComplRef.Reference1.Sheet +
     460           0 :                             (static_cast<const ScToken&>(rToken).GetSingleRef2().Tab() - static_cast<const ScToken&>(rToken).GetSingleRef().Tab());
     461           0 :                         sheet::ExternalReference aExtRef;
     462           0 :                         aExtRef.Index = rToken.GetIndex();
     463           0 :                         aExtRef.Reference <<= aComplRef;
     464           0 :                         rAPI.Data <<= aExtRef;
     465           0 :                         eOpCode = ocPush;
     466             :                     }
     467           0 :                     break;
     468             :                 case svExternalName:
     469             :                     {
     470           0 :                         sheet::ExternalReference aExtRef;
     471           0 :                         aExtRef.Index = rToken.GetIndex();
     472           0 :                         aExtRef.Reference <<= rToken.GetString().getString();
     473           0 :                         rAPI.Data <<= aExtRef;
     474           0 :                         eOpCode = ocPush;
     475             :                     }
     476           0 :                     break;
     477             :                 default:
     478             :                     OSL_TRACE( "ScTokenConversion::ConvertToTokenSequence: unhandled token type SvStackVar %d", rToken.GetType());
     479             :                 case svSep:     // occurs with ocSep, ocOpen, ocClose, ocArray*
     480             :                 case svJump:    // occurs with ocIf, ocChose
     481             :                 case svMissing: // occurs with ocMissing
     482           0 :                     rAPI.Data.clear();      // no data
     483             :             }
     484          88 :             rAPI.OpCode = static_cast<sal_Int32>(eOpCode);      //! assuming equal values for the moment
     485             :         }
     486             :     }
     487             :     else
     488           0 :         rSequence.realloc(0);
     489             : 
     490          88 :     return !bError;
     491             : }
     492             : 
     493             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     494          59 : ScFormulaOpCodeMapperObj::ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler)
     495          59 : : formula::FormulaOpCodeMapperObj(_pCompiler)
     496             : {
     497          59 : }
     498             : SAL_WNODEPRECATED_DECLARATIONS_POP
     499             : 
     500             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10