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