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 : : #include "excform.hxx"
30 : :
31 : : #include "cell.hxx"
32 : : #include "document.hxx"
33 : : #include "rangenam.hxx"
34 : : #include "xltracer.hxx"
35 : : #include "xistream.hxx"
36 : : #include "xihelper.hxx"
37 : : #include "xilink.hxx"
38 : : #include "xiname.hxx"
39 : :
40 : : #include "externalrefmgr.hxx"
41 : :
42 : : #include <vector>
43 : : #include <cstring>
44 : :
45 : : using ::rtl::OUString;
46 : : using ::rtl::OUStringBuffer;
47 : : using ::std::vector;
48 : :
49 : : namespace {
50 : :
51 : : /**
52 : : * Extract a file path from OLE link path. An OLE link path is expected to
53 : : * be in the following format:
54 : : *
55 : : * Excel.Sheet.8 \3 [file path]
56 : : */
57 : 0 : bool extractFilePath(const OUString& rUrl, OUString& rPath)
58 : : {
59 : 0 : const char* prefix = "Excel.Sheet.8\3";
60 : 0 : size_t nPrefixLen = ::std::strlen(prefix);
61 : :
62 : 0 : sal_Int32 n = rUrl.getLength();
63 [ # # ]: 0 : if (n <= static_cast<sal_Int32>(nPrefixLen))
64 : : // needs to have the specified prefix.
65 : 0 : return false;
66 : :
67 : 0 : OUStringBuffer aBuf;
68 : 0 : const sal_Unicode* p = rUrl.getStr();
69 [ # # ]: 0 : for (size_t i = 0; i < static_cast<size_t>(n); ++i, ++p)
70 : : {
71 [ # # ]: 0 : if (i < nPrefixLen)
72 : : {
73 : 0 : sal_Unicode pc = static_cast<sal_Unicode>(*prefix++);
74 [ # # ]: 0 : if (pc != *p)
75 : 0 : return false;
76 : :
77 : 0 : continue;
78 : : }
79 [ # # ]: 0 : aBuf.append(*p);
80 : : }
81 : :
82 [ # # ]: 0 : rPath = aBuf.makeStringAndClear();
83 : 0 : return true;
84 : : }
85 : :
86 : : }
87 : :
88 : 2763 : ExcelToSc8::ExternalTabInfo::ExternalTabInfo() :
89 : 2763 : mnFileId(0), mbExternal(false)
90 : : {
91 : 2763 : }
92 : :
93 : : // ============================================================================
94 : :
95 : 55 : ExcelToSc8::ExcelToSc8( const XclImpRoot& rRoot ) :
96 : : ExcelToSc( rRoot ),
97 [ + - ]: 55 : rLinkMan( rRoot.GetLinkManager() )
98 : : {
99 : 55 : }
100 : :
101 : :
102 : 55 : ExcelToSc8::~ExcelToSc8()
103 : : {
104 [ - + ]: 110 : }
105 : :
106 : 0 : bool ExcelToSc8::GetExternalFileIdFromXti( sal_uInt16 nIxti, sal_uInt16& rFileId ) const
107 : : {
108 [ # # ]: 0 : const String* pFileUrl = rLinkMan.GetSupbookUrl(nIxti);
109 [ # # ][ # # ]: 0 : if (!pFileUrl || pFileUrl->Len() == 0 || !GetDocShell())
[ # # ][ # # ]
[ # # ]
110 : 0 : return false;
111 : :
112 [ # # ][ # # ]: 0 : String aFileUrl = ScGlobal::GetAbsDocName(*pFileUrl, GetDocShell());
113 [ # # ]: 0 : ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
114 [ # # ][ # # ]: 0 : rFileId = pRefMgr->getExternalFileId(aFileUrl);
115 : :
116 [ # # ]: 0 : return true;
117 : : }
118 : :
119 : 2763 : bool ExcelToSc8::Read3DTabReference( sal_uInt16 nIxti, SCTAB& rFirstTab, SCTAB& rLastTab, ExternalTabInfo& rExtInfo )
120 : : {
121 : 2763 : rFirstTab = rLastTab = 0;
122 : 2763 : rExtInfo.mbExternal = !rLinkMan.IsSelfRef(nIxti);
123 : 2763 : bool bSuccess = rLinkMan.GetScTabRange(rFirstTab, rLastTab, nIxti);
124 [ - + ]: 2763 : if (!bSuccess)
125 : 0 : return false;
126 : :
127 [ + - ]: 2763 : if (!rExtInfo.mbExternal)
128 : : // This is internal reference. Stop here.
129 : 2763 : return true;
130 : :
131 : 0 : rExtInfo.maTabName = rLinkMan.GetSupbookTabName(nIxti, rFirstTab);
132 : 2763 : return GetExternalFileIdFromXti(nIxti, rExtInfo.mnFileId);
133 : : }
134 : :
135 : 0 : bool ExcelToSc8::HandleOleLink(sal_uInt16 nXtiIndex, const XclImpExtName& rExtName, ExternalTabInfo& rExtInfo)
136 : : {
137 [ # # ]: 0 : const String* pUrl = rLinkMan.GetSupbookUrl(nXtiIndex);
138 [ # # ]: 0 : if (!pUrl)
139 : 0 : return false;
140 : :
141 : 0 : OUString aPath;
142 [ # # ][ # # ]: 0 : if (!extractFilePath(*pUrl, aPath))
[ # # ]
143 : : // file path extraction failed.
144 : 0 : return false;
145 : :
146 [ # # ][ # # ]: 0 : OUString aFileUrl = ScGlobal::GetAbsDocName(aPath, GetDocShell());
[ # # ][ # # ]
[ # # ][ # # ]
147 [ # # ]: 0 : return rExtName.CreateOleData(GetDoc(), aFileUrl, rExtInfo.mnFileId, rExtInfo.maTabName, rExtInfo.maRange);
148 : : }
149 : :
150 : : // if bAllowArrays is false stream seeks to first byte after <nFormulaLen>
151 : : // otherwise it will seek to the first byte past additional content after <nFormulaLen>
152 : 1866 : ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT )
153 : : {
154 : : sal_uInt8 nOp, nLen, nByte;
155 : : sal_uInt16 nUINT16;
156 : : double fDouble;
157 [ + - ]: 1866 : String aString;
158 : 1866 : sal_Bool bError = false;
159 : 1866 : sal_Bool bArrayFormula = false;
160 : 1866 : TokenId nMerk0;
161 : 1866 : const sal_Bool bRangeName = eFT == FT_RangeName;
162 : 1866 : const sal_Bool bSharedFormula = eFT == FT_SharedFormula;
163 [ - + ][ + + ]: 1866 : const sal_Bool bRNorSF = bRangeName || bSharedFormula;
164 : :
165 : : ScSingleRefData aSRD;
166 : : ScComplexRefData aCRD;
167 [ + - ]: 1866 : ExtensionTypeVec aExtensions;
168 : :
169 [ - + ]: 1866 : if( eStatus != ConvOK )
170 : : {
171 [ # # ]: 0 : aIn.Ignore( nFormulaLen );
172 : 0 : return eStatus;
173 : : }
174 : :
175 [ - + ]: 1866 : if( nFormulaLen == 0 )
176 : : {
177 [ # # ][ # # ]: 0 : aPool.Store( CREATE_STRING( "-/-" ) );
[ # # ]
178 [ # # ]: 0 : aPool >> aStack;
179 [ # # ]: 0 : rpTokArray = aPool[ aStack.Get() ];
180 : 0 : return ConvOK;
181 : : }
182 : :
183 [ + - ]: 1866 : sal_Size nEndPos = aIn.GetRecPos() + nFormulaLen;
184 : :
185 [ + - ][ + + ]: 33690 : while( (aIn.GetRecPos() < nEndPos) && !bError )
[ + + ][ + + ]
186 : : {
187 [ + - ]: 31824 : aIn >> nOp;
188 : :
189 : : // always reset flags
190 : 31824 : aSRD.InitFlags();
191 : 31824 : aCRD.InitFlags();
192 : :
193 [ + + + + : 31824 : switch( nOp ) // book page:
+ - - - -
+ - - - -
- - - + -
+ - + - +
+ + + + +
+ + + + +
- - - - -
- - - - -
+ + + ]
194 : : { // SDK4 SDK5
195 : : case 0x01: // Array Formula [325 ]
196 : : // Array Formula or Shared Formula [ 277]
197 : : case 0x02: // Data Table [325 277]
198 [ + - ]: 48 : aIn.Ignore( 4 );
199 : :
200 : 48 : bArrayFormula = sal_True;
201 : 48 : break;
202 : : case 0x03: // Addition [312 264]
203 : 6540 : aStack >> nMerk0;
204 [ + - ][ + - ]: 6540 : aPool << aStack << ocAdd << nMerk0;
[ + - ]
205 [ + - ]: 6540 : aPool >> aStack;
206 : 6540 : break;
207 : : case 0x04: // Subtraction [313 264]
208 : : // SECOND-TOP minus TOP
209 : 63 : aStack >> nMerk0;
210 [ + - ][ + - ]: 63 : aPool << aStack << ocSub << nMerk0;
[ + - ]
211 [ + - ]: 63 : aPool >> aStack;
212 : 63 : break;
213 : : case 0x05: // Multiplication [313 264]
214 : 18 : aStack >> nMerk0;
215 [ + - ][ + - ]: 18 : aPool << aStack << ocMul << nMerk0;
[ + - ]
216 [ + - ]: 18 : aPool >> aStack;
217 : 18 : break;
218 : : case 0x06: // Division [313 264]
219 : : // divide TOP by SECOND-TOP
220 : 60 : aStack >> nMerk0;
221 [ + - ][ + - ]: 60 : aPool << aStack << ocDiv << nMerk0;
[ + - ]
222 [ + - ]: 60 : aPool >> aStack;
223 : 60 : break;
224 : : case 0x07: // Exponentiation [313 265]
225 : : // raise SECOND-TOP to power of TOP
226 : 0 : aStack >> nMerk0;
227 [ # # ][ # # ]: 0 : aPool << aStack << ocPow << nMerk0;
[ # # ]
228 [ # # ]: 0 : aPool >> aStack;
229 : 0 : break;
230 : : case 0x08: // Concatenation [313 265]
231 : : // append TOP to SECOND-TOP
232 : 0 : aStack >> nMerk0;
233 [ # # ][ # # ]: 0 : aPool << aStack << ocAmpersand << nMerk0;
[ # # ]
234 [ # # ]: 0 : aPool >> aStack;
235 : 0 : break;
236 : : case 0x09: // Less Than [313 265]
237 : : // SECOND-TOP < TOP
238 : 0 : aStack >> nMerk0;
239 [ # # ][ # # ]: 0 : aPool << aStack << ocLess << nMerk0;
[ # # ]
240 [ # # ]: 0 : aPool >> aStack;
241 : 0 : break;
242 : : case 0x0A: // Less Than or Equal [313 265]
243 : : // SECOND-TOP <= TOP
244 : 0 : aStack >> nMerk0;
245 [ # # ][ # # ]: 0 : aPool << aStack << ocLessEqual << nMerk0;
[ # # ]
246 [ # # ]: 0 : aPool >> aStack;
247 : 0 : break;
248 : : case 0x0B: // Equal [313 265]
249 : : // SECOND-TOP == TOP
250 : 3 : aStack >> nMerk0;
251 [ + - ][ + - ]: 3 : aPool << aStack << ocEqual << nMerk0;
[ + - ]
252 [ + - ]: 3 : aPool >> aStack;
253 : 3 : break;
254 : : case 0x0C: // Greater Than or Equal [313 265]
255 : : // SECOND-TOP >= TOP
256 : 0 : aStack >> nMerk0;
257 [ # # ][ # # ]: 0 : aPool << aStack << ocGreaterEqual << nMerk0;
[ # # ]
258 [ # # ]: 0 : aPool >> aStack;
259 : 0 : break;
260 : : case 0x0D: // Greater Than [313 265]
261 : : // SECOND-TOP > TOP
262 : 0 : aStack >> nMerk0;
263 [ # # ][ # # ]: 0 : aPool << aStack << ocGreater << nMerk0;
[ # # ]
264 [ # # ]: 0 : aPool >> aStack;
265 : 0 : break;
266 : : case 0x0E: // Not Equal [313 265]
267 : : // SECOND-TOP != TOP
268 : 0 : aStack >> nMerk0;
269 [ # # ][ # # ]: 0 : aPool << aStack << ocNotEqual << nMerk0;
[ # # ]
270 [ # # ]: 0 : aPool >> aStack;
271 : 0 : break;
272 : : case 0x0F: // Intersection [314 265]
273 : 0 : aStack >> nMerk0;
274 [ # # ][ # # ]: 0 : aPool << aStack << ocIntersect << nMerk0;
[ # # ]
275 [ # # ]: 0 : aPool >> aStack;
276 : 0 : break;
277 : : case 0x10: // Union [314 265]
278 : : // ocSep instead of 'ocUnion'
279 : 0 : aStack >> nMerk0;
280 [ # # ][ # # ]: 0 : aPool << aStack << ocSep << nMerk0;
[ # # ]
281 : : // doesn't fit exactly, but is more Excel-like
282 [ # # ]: 0 : aPool >> aStack;
283 : 0 : break;
284 : : case 0x11: // Range [314 265]
285 : 0 : aStack >> nMerk0;
286 [ # # ][ # # ]: 0 : aPool << aStack << ocRange << nMerk0;
[ # # ]
287 [ # # ]: 0 : aPool >> aStack;
288 : 0 : break;
289 : : case 0x12: // Unary Plus [312 264]
290 [ # # ][ # # ]: 0 : aPool << ocAdd << aStack;
291 [ # # ]: 0 : aPool >> aStack;
292 : 0 : break;
293 : : case 0x13: // Unary Minus [312 264]
294 [ + - ][ + - ]: 3 : aPool << ocNegSub << aStack;
295 [ + - ]: 3 : aPool >> aStack;
296 : 3 : break;
297 : : case 0x14: // Percent Sign [312 264]
298 [ # # ][ # # ]: 0 : aPool << aStack << ocPercentSign;
299 [ # # ]: 0 : aPool >> aStack;
300 : 0 : break;
301 : : case 0x15: // Parenthesis [326 278]
302 [ + - ][ + - ]: 60 : aPool << ocOpen << aStack << ocClose;
[ + - ]
303 [ + - ]: 60 : aPool >> aStack;
304 : 60 : break;
305 : : case 0x16: // Missing Argument [314 266]
306 [ # # ]: 0 : aPool << ocMissing;
307 [ # # ]: 0 : aPool >> aStack;
308 [ # # ][ # # ]: 0 : GetTracer().TraceFormulaMissingArg();
309 : 0 : break;
310 : : case 0x17: // String Constant [314 266]
311 [ + - ]: 8073 : aIn >> nLen; // und?
312 [ + - ][ + - ]: 8073 : aString = aIn.ReadUniString( nLen ); // reads Grbit even if nLen==0
[ + - ]
313 : :
314 [ + - ]: 8073 : aStack << aPool.Store( aString );
315 : 8073 : break;
316 : : case 0x18: // natural language formula
317 : : {
318 : : sal_uInt8 nEptg;
319 : : sal_uInt16 nCol, nRow;
320 [ # # ]: 0 : aIn >> nEptg;
321 [ # # # # : 0 : switch( nEptg )
# # # ]
322 : : { // name size ext type
323 : : case 0x01: // Lel 4 - err
324 [ # # ]: 0 : aIn.Ignore( 4 );
325 [ # # ]: 0 : aPool << ocBad;
326 [ # # ]: 0 : aPool >> aStack;
327 : 0 : break;
328 : : case 0x02: // Rw 4 - ref
329 : : case 0x03: // Col 4 - ref
330 : : case 0x06: // RwV 4 - val
331 : : case 0x07: // ColV 4 - val
332 [ # # ][ # # ]: 0 : aIn >> nRow >> nCol;
333 : :
334 : 0 : aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
335 : :
336 [ # # ][ # # ]: 0 : if( nEptg == 0x02 || nEptg == 0x06 )
337 : 0 : aSRD.SetRowRel( sal_True );
338 : : else
339 : 0 : aSRD.SetColRel( sal_True );
340 : :
341 [ # # ]: 0 : aSRD.CalcRelFromAbs( aEingPos );
342 : :
343 [ # # ]: 0 : aStack << aPool.StoreNlf( aSRD );
344 : 0 : break;
345 : : case 0x0A: // Radical 13 - ref
346 [ # # ][ # # ]: 0 : aIn >> nRow >> nCol;
347 [ # # ]: 0 : aIn.Ignore( 9 );
348 : :
349 : 0 : aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
350 : :
351 : 0 : aSRD.SetColRel( sal_True );
352 : :
353 [ # # ]: 0 : aSRD.CalcRelFromAbs( aEingPos );
354 : :
355 [ # # ]: 0 : aStack << aPool.StoreNlf( aSRD );
356 : 0 : break;
357 : : case 0x0B: // RadicalS 13 x ref
358 [ # # ]: 0 : aIn.Ignore( 13 );
359 [ # # ]: 0 : aExtensions.push_back( EXTENSION_NLR );
360 [ # # ]: 0 : aPool << ocBad;
361 [ # # ]: 0 : aPool >> aStack;
362 : 0 : break;
363 : : case 0x0C: // RwS 4 x ref
364 : : case 0x0D: // ColS 4 x ref
365 : : case 0x0E: // RwSV 4 x val
366 : : case 0x0F: // ColSV 4 x val
367 [ # # ]: 0 : aIn.Ignore( 4 );
368 [ # # ]: 0 : aExtensions.push_back( EXTENSION_NLR );
369 [ # # ]: 0 : aPool << ocBad;
370 [ # # ]: 0 : aPool >> aStack;
371 : 0 : break;
372 : : case 0x10: // RadicalLel 4 - err
373 : : case 0x1D: // SxName 4 - val
374 [ # # ]: 0 : aIn.Ignore( 4 );
375 [ # # ]: 0 : aPool << ocBad;
376 [ # # ]: 0 : aPool >> aStack;
377 : 0 : break;
378 : : default:
379 [ # # ]: 0 : aPool << ocBad;
380 [ # # ]: 0 : aPool >> aStack;
381 : : }
382 : : }
383 : 0 : break;
384 : : case 0x19: // Special Attribute [327 279]
385 : : {
386 : : sal_uInt16 nData, nFakt;
387 : : sal_uInt8 nOpt;
388 : :
389 [ + - ][ + - ]: 12 : aIn >> nOpt >> nData;
390 : 12 : nFakt = 2;
391 : :
392 [ - + ]: 12 : if( nOpt & 0x04 )
393 : : {// nFakt -> skip bytes or words AttrChoose
394 : 0 : nData++;
395 [ # # ]: 0 : aIn.Ignore( nData * nFakt );
396 : : }
397 [ + + ]: 12 : else if( nOpt & 0x10 ) // AttrSum
398 [ + - ]: 3 : DoMulArgs( ocSum, 1 );
399 : : }
400 : 12 : break;
401 : : case 0x1C: // Error Value [314 266]
402 : : {
403 [ + - ]: 9 : aIn >> nByte;
404 : :
405 : : DefTokenId eOc;
406 [ + + - ]: 9 : switch( nByte )
407 : : {
408 : : case EXC_ERR_NULL:
409 : : case EXC_ERR_DIV0:
410 : : case EXC_ERR_VALUE:
411 : : case EXC_ERR_REF:
412 : : case EXC_ERR_NAME:
413 : 3 : case EXC_ERR_NUM: eOc = ocStop; break;
414 : 6 : case EXC_ERR_NA: eOc = ocNotAvail; break;
415 : 0 : default: eOc = ocNoName;
416 : : }
417 [ + - ]: 9 : aPool << eOc;
418 [ + + ]: 9 : if( eOc != ocStop )
419 [ + - ][ + - ]: 6 : aPool << ocOpen << ocClose;
420 [ + - ]: 9 : aPool >> aStack;
421 : : }
422 : 9 : break;
423 : : case 0x1D: // Boolean [315 266]
424 [ + - ]: 6 : aIn >> nByte;
425 [ + + ]: 6 : if( nByte == 0 )
426 [ + - ][ + - ]: 3 : aPool << ocFalse << ocOpen << ocClose;
[ + - ]
427 : : else
428 [ + - ][ + - ]: 3 : aPool << ocTrue << ocOpen << ocClose;
[ + - ]
429 [ + - ]: 6 : aPool >> aStack;
430 : 6 : break;
431 : : case 0x1E: // Integer [315 266]
432 [ + - ]: 39 : aIn >> nUINT16;
433 [ + - ]: 39 : aStack << aPool.Store( ( double ) nUINT16 );
434 : 39 : break;
435 : : case 0x1F: // Number [315 266]
436 [ + - ]: 15 : aIn >> fDouble;
437 [ + - ]: 15 : aStack << aPool.Store( fDouble );
438 : 15 : break;
439 : : case 0x40:
440 : : case 0x60:
441 : : case 0x20: // Array Constant [317 268]
442 [ + - ][ + - ]: 3 : aIn >> nByte >> nUINT16;
443 [ + - ]: 3 : aIn.Ignore( 4 );
444 [ + - ]: 3 : if( bAllowArrays )
445 : : {
446 [ + - ]: 3 : aStack << aPool.StoreMatrix();
447 [ + - ]: 3 : aExtensions.push_back( EXTENSION_ARRAY );
448 : : }
449 : : else
450 : : {
451 [ # # ]: 0 : aPool << ocBad;
452 [ # # ]: 0 : aPool >> aStack;
453 : : }
454 : 3 : break;
455 : : case 0x41:
456 : : case 0x61:
457 : : case 0x21: // Function, Fixed Number of Arguments [333 282]
458 : : {
459 : : sal_uInt16 nXclFunc;
460 [ + - ]: 8064 : aIn >> nXclFunc;
461 [ + - ][ + - ]: 8064 : if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
462 [ + - ]: 8064 : DoMulArgs( pFuncInfo->meOpCode, pFuncInfo->mnMaxParamCount );
463 : : else
464 [ # # ]: 0 : DoMulArgs( ocNoName, 0 );
465 : : }
466 : 8064 : break;
467 : : case 0x42:
468 : : case 0x62:
469 : : case 0x22: // Function, Variable Number of Arg. [333 283]
470 : : {
471 : : sal_uInt16 nXclFunc;
472 : : sal_uInt8 nParamCount;
473 [ + - ][ + - ]: 66 : aIn >> nParamCount >> nXclFunc;
474 : 66 : nParamCount &= 0x7F;
475 [ + - ][ + - ]: 66 : if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
476 [ + - ]: 66 : DoMulArgs( pFuncInfo->meOpCode, nParamCount );
477 : : else
478 [ # # ]: 0 : DoMulArgs( ocNoName, 0 );
479 : : }
480 : 66 : break;
481 : : case 0x43:
482 : : case 0x63:
483 : : case 0x23: // Name [318 269]
484 : : {
485 [ + - ]: 48 : aIn >> nUINT16;
486 [ + - ]: 48 : aIn.Ignore( 2 );
487 [ + - ][ + - ]: 48 : const XclImpName* pName = GetNameManager().GetName( nUINT16 );
488 [ + + ]: 48 : if (pName)
489 : : {
490 [ + - ][ + + ]: 45 : if (pName->IsMacro())
491 : : // user-defined macro name.
492 [ + - ]: 3 : aStack << aPool.Store(ocMacro, pName->GetXclName());
493 : : else
494 [ + - ]: 42 : aStack << aPool.StoreName(nUINT16, pName->IsGlobal());
495 : : }
496 : : }
497 : 48 : break;
498 : : case 0x44:
499 : : case 0x64:
500 : : case 0x24: // Cell Reference [319 270]
501 : : case 0x4A:
502 : : case 0x6A:
503 : : case 0x2A: // Deleted Cell Reference [323 273]
504 : : {
505 : : sal_uInt16 nCol, nRow;
506 : :
507 [ + - ][ + - ]: 3501 : aIn >> nRow >> nCol;
508 : :
509 : 3501 : aSRD.nCol = static_cast<SCCOL>(nCol);
510 : 3501 : aSRD.nRow = nRow & 0x3FFF;
511 : 3501 : aSRD.nRelTab = 0;
512 : 3501 : aSRD.SetTabRel( sal_True );
513 : 3501 : aSRD.SetFlag3D( bRangeName );
514 : :
515 [ + - ]: 3501 : ExcRelToScRel8( nRow, nCol, aSRD, bRangeName );
516 : :
517 [ - + ]: 3501 : switch ( nOp )
518 : : {
519 : : case 0x4A:
520 : : case 0x6A:
521 : : case 0x2A: // Deleted Cell Reference [323 273]
522 : : // no information which part is deleted, set both
523 : 0 : aSRD.SetColDeleted( sal_True );
524 : 0 : aSRD.SetRowDeleted( sal_True );
525 : : }
526 : :
527 [ + - ]: 3501 : aStack << aPool.Store( aSRD );
528 : : }
529 : 3501 : break;
530 : : case 0x45:
531 : : case 0x65:
532 : : case 0x25: // Area Reference [320 270]
533 : : case 0x4B:
534 : : case 0x6B:
535 : : case 0x2B: // Deleted Area Refernce [323 273]
536 : : {
537 : : sal_uInt16 nRowFirst, nRowLast;
538 : : sal_uInt16 nColFirst, nColLast;
539 : 2427 : ScSingleRefData &rSRef1 = aCRD.Ref1;
540 : 2427 : ScSingleRefData &rSRef2 = aCRD.Ref2;
541 : :
542 [ + - ][ + - ]: 2427 : aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
[ + - ][ + - ]
543 : :
544 : 2427 : rSRef1.nRelTab = rSRef2.nRelTab = 0;
545 : 2427 : rSRef1.SetTabRel( sal_True );
546 : 2427 : rSRef2.SetTabRel( sal_True );
547 : 2427 : rSRef1.SetFlag3D( bRangeName );
548 : 2427 : rSRef2.SetFlag3D( bRangeName );
549 : :
550 [ + - ]: 2427 : ExcRelToScRel8( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
551 [ + - ]: 2427 : ExcRelToScRel8( nRowLast, nColLast, aCRD.Ref2, bRangeName );
552 : :
553 [ - + ]: 2427 : if( IsComplColRange( nColFirst, nColLast ) )
554 [ # # ]: 0 : SetComplCol( aCRD );
555 [ - + ]: 2427 : else if( IsComplRowRange( nRowFirst, nRowLast ) )
556 [ # # ]: 0 : SetComplRow( aCRD );
557 : :
558 [ - + ]: 2427 : switch ( nOp )
559 : : {
560 : : case 0x4B:
561 : : case 0x6B:
562 : : case 0x2B: // Deleted Area Refernce [323 273]
563 : : // no information which part is deleted, set all
564 : 0 : rSRef1.SetColDeleted( sal_True );
565 : 0 : rSRef1.SetRowDeleted( sal_True );
566 : 0 : rSRef2.SetColDeleted( sal_True );
567 : 0 : rSRef2.SetRowDeleted( sal_True );
568 : : }
569 : :
570 [ + - ]: 2427 : aStack << aPool.Store( aCRD );
571 : : }
572 : 2427 : break;
573 : : case 0x46:
574 : : case 0x66:
575 : : case 0x26: // Constant Reference Subexpression [321 271]
576 [ # # ]: 0 : aExtensions.push_back( EXTENSION_MEMAREA );
577 [ # # ]: 0 : aIn.Ignore( 6 ); // There isn't any more
578 : 0 : break;
579 : : case 0x47:
580 : : case 0x67:
581 : : case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
582 [ # # ]: 0 : aIn.Ignore( 6 ); // There isn't any more
583 : 0 : break;
584 : : case 0x48:
585 : : case 0x68:
586 : : case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
587 [ # # ]: 0 : aIn.Ignore( 6 ); // There isn't any more
588 : 0 : break;
589 : : case 0x49:
590 : : case 0x69:
591 : : case 0x29: // Variable Reference Subexpression [331 281]
592 [ # # ]: 0 : aIn.Ignore( 2 ); // There isn't any more
593 : 0 : break;
594 : : case 0x4C:
595 : : case 0x6C:
596 : : case 0x2C: // Cell Reference Within a Name [323 ]
597 : : // Cell Reference Within a Shared Formula[ 273]
598 : : {
599 : : sal_uInt16 nRow, nCol;
600 : :
601 [ # # ][ # # ]: 0 : aIn >> nRow >> nCol;
602 : :
603 : 0 : aSRD.nRelTab = 0;
604 : 0 : aSRD.SetTabRel( sal_True );
605 : 0 : aSRD.SetFlag3D( bRangeName );
606 : :
607 [ # # ]: 0 : ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
608 : :
609 [ # # ]: 0 : aStack << aPool.Store( aSRD );
610 : : }
611 : 0 : break;
612 : : case 0x4D:
613 : : case 0x6D:
614 : : case 0x2D: // Area Reference Within a Name [324 ]
615 : : { // Area Reference Within a Shared Formula[ 274]
616 : : sal_uInt16 nRowFirst, nRowLast;
617 : : sal_uInt16 nColFirst, nColLast;
618 : :
619 : 0 : aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
620 : 0 : aCRD.Ref1.SetTabRel( sal_True );
621 : 0 : aCRD.Ref2.SetTabRel( sal_True );
622 : 0 : aCRD.Ref1.SetFlag3D( bRangeName );
623 : 0 : aCRD.Ref2.SetFlag3D( bRangeName );
624 : :
625 [ # # ][ # # ]: 0 : aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
[ # # ][ # # ]
626 : :
627 [ # # ]: 0 : ExcRelToScRel8( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
628 [ # # ]: 0 : ExcRelToScRel8( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
629 : :
630 [ # # ]: 0 : if( IsComplColRange( nColFirst, nColLast ) )
631 [ # # ]: 0 : SetComplCol( aCRD );
632 [ # # ]: 0 : else if( IsComplRowRange( nRowFirst, nRowLast ) )
633 [ # # ]: 0 : SetComplRow( aCRD );
634 : :
635 [ # # ]: 0 : aStack << aPool.Store( aCRD );
636 : : }
637 : 0 : break;
638 : : case 0x4E:
639 : : case 0x6E:
640 : : case 0x2E: // Reference Subexpression Within a Name [332 282]
641 [ # # ]: 0 : aIn.Ignore( 2 ); // There isn't any more
642 : 0 : break;
643 : : case 0x4F:
644 : : case 0x6F:
645 : : case 0x2F: // Incomplete Reference Subexpression... [332 282]
646 [ # # ]: 0 : aIn.Ignore( 2 ); // There isn't any more
647 : 0 : break;
648 : : case 0x58:
649 : : case 0x78:
650 : : case 0x38: // Command-Equivalent Function [333 ]
651 [ # # ]: 0 : aString.AssignAscii( "COMM_EQU_FUNC" );
652 [ # # ]: 0 : aIn >> nByte;
653 [ # # ][ # # ]: 0 : aString += String::CreateFromInt32( nByte );
[ # # ]
654 [ # # ]: 0 : aIn >> nByte;
655 [ # # ]: 0 : aStack << aPool.Store( aString );
656 [ # # ]: 0 : DoMulArgs( ocPush, nByte + 1 );
657 : 0 : break;
658 : : case 0x59:
659 : : case 0x79:
660 : : case 0x39: // Name or External Name [ 275]
661 : : {
662 : : sal_uInt16 nXtiIndex, nNameIdx;
663 [ # # ][ # # ]: 0 : aIn >> nXtiIndex >> nNameIdx;
664 [ # # ]: 0 : aIn.Ignore( 2 );
665 : :
666 [ # # ][ # # ]: 0 : if( rLinkMan.IsSelfRef( nXtiIndex ) )
667 : : {
668 : : // internal defined name with explicit sheet, i.e.: =Sheet1!AnyName
669 [ # # ][ # # ]: 0 : const XclImpName* pName = GetNameManager().GetName( nNameIdx );
670 [ # # ]: 0 : if (pName)
671 : : {
672 [ # # ]: 0 : if (pName->GetScRangeData())
673 [ # # ]: 0 : aStack << aPool.StoreName( nNameIdx, pName->IsGlobal());
674 : : else
675 [ # # ]: 0 : aStack << aPool.Store(ocMacro, pName->GetXclName());
676 : : }
677 : : }
678 [ # # ][ # # ]: 0 : else if( const XclImpExtName* pExtName = rLinkMan.GetExternName( nXtiIndex, nNameIdx ) )
679 : : {
680 [ # # # # : 0 : switch( pExtName->GetType() )
# # ]
681 : : {
682 : : case xlExtName:
683 : : {
684 : : /* FIXME: enable this code for #i4385# once
685 : : * external name reference can be stored in ODF,
686 : : * which remains to be done for #i3740#. Until then
687 : : * create a #NAME? token. */
688 : : #if 1
689 : : sal_uInt16 nFileId;
690 [ # # ][ # # ]: 0 : if (!GetExternalFileIdFromXti(nXtiIndex, nFileId) || !pExtName->HasFormulaTokens())
[ # # ][ # # ]
[ # # ]
691 : : {
692 [ # # ]: 0 : aStack << aPool.Store(ocNoName, pExtName->GetName());
693 : : break;
694 : : }
695 : :
696 [ # # ]: 0 : aStack << aPool.StoreExtName(nFileId, pExtName->GetName());
697 [ # # ]: 0 : pExtName->CreateExtNameData(GetDoc(), nFileId);
698 : : #else
699 : : aStack << aPool.Store( ocNoName, pExtName->GetName() );
700 : : #endif
701 : : }
702 : 0 : break;
703 : :
704 : : case xlExtAddIn:
705 : : {
706 [ # # ]: 0 : aStack << aPool.Store( ocExternal, pExtName->GetName() );
707 : : }
708 : 0 : break;
709 : :
710 : : case xlExtDDE:
711 : : {
712 [ # # ][ # # ]: 0 : String aApplic, aTopic;
713 [ # # ][ # # ]: 0 : if( rLinkMan.GetLinkData( aApplic, aTopic, nXtiIndex ) )
714 : : {
715 [ # # ]: 0 : TokenId nPar1 = aPool.Store( aApplic );
716 [ # # ]: 0 : TokenId nPar2 = aPool.Store( aTopic );
717 [ # # ]: 0 : nMerk0 = aPool.Store( pExtName->GetName() );
718 [ # # ][ # # ]: 0 : aPool << ocDde << ocOpen << nPar1 << ocSep << nPar2 << ocSep
[ # # ][ # # ]
[ # # ][ # # ]
719 [ # # ][ # # ]: 0 : << nMerk0 << ocClose;
720 [ # # ]: 0 : aPool >> aStack;
721 [ # # ]: 0 : pExtName->CreateDdeData( GetDoc(), aApplic, aTopic );
722 [ # # ][ # # ]: 0 : }
723 : : }
724 : 0 : break;
725 : :
726 : : case xlExtEuroConvert:
727 : : {
728 [ # # ][ # # ]: 0 : aStack << aPool.Store( ocEuroConvert, String() );
[ # # ]
729 : : }
730 : 0 : break;
731 : : case xlExtOLE:
732 : : {
733 : 0 : ExternalTabInfo aExtInfo;
734 [ # # ][ # # ]: 0 : if (HandleOleLink(nXtiIndex, *pExtName, aExtInfo))
735 : : {
736 [ # # ]: 0 : if (aExtInfo.maRange.aStart == aExtInfo.maRange.aEnd)
737 : : {
738 : : // single cell
739 : 0 : aSRD.InitAddress(aExtInfo.maRange.aStart);
740 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aSRD);
[ # # ]
741 : : }
742 : : else
743 : : {
744 : : // range
745 : 0 : aCRD.InitRange(aExtInfo.maRange);
746 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aCRD);
[ # # ]
747 : : }
748 : : }
749 : : else
750 [ # # ]: 0 : aStack << aPool.Store(ocNoName, pExtName->GetName());
751 : : }
752 : 0 : break;
753 : : default:
754 : : {
755 [ # # ]: 0 : aPool << ocBad;
756 [ # # ]: 0 : aPool >> aStack;
757 : : }
758 : : }
759 : : }
760 : : else
761 : : {
762 [ # # ]: 0 : aPool << ocBad;
763 [ # # ]: 0 : aPool >> aStack;
764 : : }
765 : : }
766 : 0 : break;
767 : : case 0x5A:
768 : : case 0x7A:
769 : : case 0x3A: // 3-D Cell Reference [ 275]
770 : : case 0x5C:
771 : : case 0x7C:
772 : : case 0x3C: // Deleted 3-D Cell Reference [ 277]
773 : : {
774 : : sal_uInt16 nIxti, nRw, nGrbitCol;
775 : : SCTAB nTabFirst, nTabLast;
776 : :
777 [ + - ][ + - ]: 33 : aIn >> nIxti >> nRw >> nGrbitCol;
[ + - ]
778 : :
779 : 33 : ExternalTabInfo aExtInfo;
780 [ - + ][ + - ]: 33 : if (!Read3DTabReference(nIxti, nTabFirst, nTabLast, aExtInfo))
781 : : {
782 [ # # ]: 0 : aPool << ocBad;
783 [ # # ]: 0 : aPool >> aStack;
784 : : break;
785 : : }
786 : :
787 : 33 : aSRD.nTab = nTabFirst;
788 : 33 : aSRD.SetFlag3D( sal_True );
789 : 33 : aSRD.SetTabRel( false );
790 : :
791 [ + - ]: 33 : ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
792 : :
793 [ - + ]: 33 : switch ( nOp )
794 : : {
795 : : case 0x5C:
796 : : case 0x7C:
797 : : case 0x3C: // Deleted 3-D Cell Reference [ 277]
798 : : // no information which part is deleted, set both
799 : 0 : aSRD.SetColDeleted( sal_True );
800 : 0 : aSRD.SetRowDeleted( sal_True );
801 : : }
802 : :
803 [ - + ]: 33 : if (aExtInfo.mbExternal)
804 : : {
805 : : // nTabFirst and nTabLast are the indices of the refernced
806 : : // sheets in the SUPBOOK record, hence do not represent
807 : : // the actual indices of the original sheets since the
808 : : // SUPBOOK record only stores referenced sheets and skips
809 : : // the ones that are not referenced.
810 : :
811 [ # # ]: 0 : if (nTabLast != nTabFirst)
812 : : {
813 : 0 : aCRD.Ref1 = aCRD.Ref2 = aSRD;
814 : 0 : aCRD.Ref2.nTab = nTabLast;
815 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aCRD);
[ # # ]
816 : : }
817 : : else
818 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aSRD);
[ # # ]
819 : : }
820 : : else
821 : : {
822 [ - + ]: 33 : if ( !ValidTab(nTabFirst))
823 : 0 : aSRD.SetTabDeleted( sal_True );
824 : :
825 [ - + ]: 33 : if( nTabLast != nTabFirst )
826 : : {
827 : 0 : aCRD.Ref1 = aCRD.Ref2 = aSRD;
828 : 0 : aCRD.Ref2.nTab = nTabLast;
829 : 0 : aCRD.Ref2.SetTabDeleted( !ValidTab(nTabLast) );
830 [ # # ]: 0 : aStack << aPool.Store( aCRD );
831 : : }
832 : : else
833 [ + - ]: 33 : aStack << aPool.Store( aSRD );
834 [ + - ]: 33 : }
835 : : }
836 : 33 : break;
837 : : case 0x5B:
838 : : case 0x7B:
839 : : case 0x3B: // 3-D Area Reference [ 276]
840 : : case 0x5D:
841 : : case 0x7D:
842 : : case 0x3D: // Deleted 3-D Area Reference [ 277]
843 : : {
844 : : sal_uInt16 nIxti, nRw1, nGrbitCol1, nRw2, nGrbitCol2;
845 : : SCTAB nTabFirst, nTabLast;
846 [ + - ][ + - ]: 2730 : aIn >> nIxti >> nRw1 >> nRw2 >> nGrbitCol1 >> nGrbitCol2;
[ + - ][ + - ]
[ + - ]
847 : :
848 : 2730 : ExternalTabInfo aExtInfo;
849 [ - + ][ + - ]: 2730 : if (!Read3DTabReference(nIxti, nTabFirst, nTabLast, aExtInfo))
850 : : {
851 [ # # ]: 0 : aPool << ocBad;
852 [ # # ]: 0 : aPool >> aStack;
853 : : break;
854 : : }
855 : 2730 : ScSingleRefData &rR1 = aCRD.Ref1;
856 : 2730 : ScSingleRefData &rR2 = aCRD.Ref2;
857 : :
858 : :
859 : 2730 : rR1.nTab = nTabFirst;
860 : 2730 : rR2.nTab = nTabLast;
861 : 2730 : rR1.SetFlag3D( sal_True );
862 : 2730 : rR1.SetTabRel( false );
863 : 2730 : rR2.SetFlag3D( nTabFirst != nTabLast );
864 : 2730 : rR2.SetTabRel( false );
865 : :
866 [ + - ]: 2730 : ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
867 [ + - ]: 2730 : ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
868 : :
869 [ - + ]: 2730 : if( IsComplColRange( nGrbitCol1, nGrbitCol2 ) )
870 [ # # ]: 0 : SetComplCol( aCRD );
871 [ - + ]: 2730 : else if( IsComplRowRange( nRw1, nRw2 ) )
872 [ # # ]: 0 : SetComplRow( aCRD );
873 : :
874 [ - + ]: 2730 : switch ( nOp )
875 : : {
876 : : case 0x5D:
877 : : case 0x7D:
878 : : case 0x3D: // Deleted 3-D Area Reference [ 277]
879 : : // no information which part is deleted, set all
880 : 0 : rR1.SetColDeleted( sal_True );
881 : 0 : rR1.SetRowDeleted( sal_True );
882 : 0 : rR2.SetColDeleted( sal_True );
883 : 0 : rR2.SetRowDeleted( sal_True );
884 : : }
885 : :
886 [ - + ]: 2730 : if (aExtInfo.mbExternal)
887 : : {
888 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aCRD);
[ # # ]
889 : : }
890 : : else
891 : : {
892 [ - + ]: 2730 : if ( !ValidTab(nTabFirst) )
893 : 0 : rR1.SetTabDeleted( sal_True );
894 [ - + ]: 2730 : if ( !ValidTab(nTabLast) )
895 : 0 : rR2.SetTabDeleted( sal_True );
896 : :
897 [ + - ]: 2730 : aStack << aPool.Store( aCRD );
898 [ + - ]: 2730 : }
899 : : }
900 : 2730 : break;
901 : 3 : default: bError = sal_True;
902 : : }
903 : 31824 : bError |= !aIn.IsValid();
904 : : }
905 : :
906 : : ConvErr eRet;
907 : :
908 [ + + ]: 1866 : if( bError )
909 : : {
910 [ + - ]: 3 : aPool << ocBad;
911 [ + - ]: 3 : aPool >> aStack;
912 [ + - ]: 3 : rpTokArray = aPool[ aStack.Get() ];
913 : 3 : eRet = ConvErrNi;
914 : : }
915 [ + - ][ - + ]: 1863 : else if( aIn.GetRecPos() != nEndPos )
916 : : {
917 [ # # ]: 0 : aPool << ocBad;
918 [ # # ]: 0 : aPool >> aStack;
919 [ # # ]: 0 : rpTokArray = aPool[ aStack.Get() ];
920 : 0 : eRet = ConvErrCount;
921 : : }
922 [ + + ]: 1863 : else if( bArrayFormula )
923 : : {
924 : 48 : rpTokArray = NULL;
925 : 48 : eRet = ConvOK;
926 : : }
927 : : else
928 : : {
929 [ + - ]: 1815 : rpTokArray = aPool[ aStack.Get() ];
930 : 1815 : eRet = ConvOK;
931 : : }
932 : :
933 [ + - ]: 1866 : aIn.Seek( nEndPos );
934 : :
935 [ + + ]: 1866 : if( eRet == ConvOK)
936 [ + - ]: 1863 : ReadExtensions( aExtensions, aIn );
937 : :
938 [ + - ]: 1866 : return eRet;
939 : : }
940 : :
941 : :
942 : : // stream seeks to first byte after <nFormulaLen>
943 : 0 : ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen,
944 : : SCsTAB nTab, const FORMULA_TYPE eFT )
945 : : {
946 : : sal_uInt8 nOp, nLen;
947 : 0 : sal_Bool bError = false;
948 : 0 : const sal_Bool bRangeName = eFT == FT_RangeName;
949 : 0 : const sal_Bool bSharedFormula = eFT == FT_SharedFormula;
950 [ # # ][ # # ]: 0 : const sal_Bool bRNorSF = bRangeName || bSharedFormula;
951 : :
952 : : ScSingleRefData aSRD;
953 : : ScComplexRefData aCRD;
954 : :
955 : 0 : bExternName = false;
956 : :
957 [ # # ]: 0 : if( eStatus != ConvOK )
958 : : {
959 [ # # ]: 0 : aIn.Ignore( nFormulaLen );
960 : 0 : return eStatus;
961 : : }
962 : :
963 [ # # ]: 0 : if( nFormulaLen == 0 )
964 : 0 : return ConvOK;
965 : :
966 [ # # ]: 0 : sal_Size nEndPos = aIn.GetRecPos() + nFormulaLen;
967 : :
968 [ # # ][ # # ]: 0 : while( (aIn.GetRecPos() < nEndPos) && !bError )
[ # # ][ # # ]
969 : : {
970 [ # # ]: 0 : aIn >> nOp;
971 : :
972 : : // always reset flags
973 : 0 : aSRD.InitFlags();
974 : 0 : aCRD.InitFlags();
975 : :
976 [ # # # # : 0 : switch( nOp ) // book page:
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
977 : : { // SDK4 SDK5
978 : : case 0x01: // Array Formula [325 ]
979 : : // Array Formula or Shared Formula [ 277]
980 [ # # ]: 0 : aIn.Ignore( 4 );
981 : 0 : break;
982 : : case 0x02: // Data Table [325 277]
983 [ # # ]: 0 : aIn.Ignore( 4 );
984 : 0 : break;
985 : : case 0x03: // Addition [312 264]
986 : : case 0x04: // Subtraction [313 264]
987 : : case 0x05: // Multiplication [313 264]
988 : : case 0x06: // Division [313 264]
989 : : case 0x07: // Exponetiation [313 265]
990 : : case 0x08: // Concatenation [313 265]
991 : : case 0x09: // Less Than [313 265]
992 : : case 0x0A: // Less Than or Equal [313 265]
993 : : case 0x0B: // Equal [313 265]
994 : : case 0x0C: // Greater Than or Equal [313 265]
995 : : case 0x0D: // Greater Than [313 265]
996 : : case 0x0E: // Not Equal [313 265]
997 : : case 0x0F: // Intersection [314 265]
998 : : case 0x10: // Union [314 265]
999 : : case 0x11: // Range [314 265]
1000 : : case 0x12: // Unary Plus [312 264]
1001 : : case 0x13: // Unary Minus [312 264]
1002 : : case 0x14: // Percent Sign [312 264]
1003 : : case 0x15: // Parenthesis [326 278]
1004 : : case 0x16: // Missing Argument [314 266]
1005 : 0 : break;
1006 : : case 0x17: // String Constant [314 266]
1007 [ # # ]: 0 : aIn >> nLen; // und?
1008 : :
1009 [ # # ]: 0 : aIn.IgnoreUniString( nLen ); // reads Grbit even if nLen==0
1010 : 0 : break;
1011 : : case 0x19: // Special Attribute [327 279]
1012 : : {
1013 : : sal_uInt16 nData, nFakt;
1014 : : sal_uInt8 nOpt;
1015 : :
1016 [ # # ][ # # ]: 0 : aIn >> nOpt >> nData;
1017 : 0 : nFakt = 2;
1018 : :
1019 [ # # ]: 0 : if( nOpt & 0x04 )
1020 : : {// nFakt -> skip bytes or words AttrChoose
1021 : 0 : nData++;
1022 [ # # ]: 0 : aIn.Ignore( nData * nFakt );
1023 : : }
1024 : : }
1025 : 0 : break;
1026 : : case 0x1C: // Error Value [314 266]
1027 : : case 0x1D: // Boolean [315 266]
1028 [ # # ]: 0 : aIn.Ignore( 1 );
1029 : 0 : break;
1030 : : case 0x1E: // Integer [315 266]
1031 [ # # ]: 0 : aIn.Ignore( 2 );
1032 : 0 : break;
1033 : : case 0x1F: // Number [315 266]
1034 [ # # ]: 0 : aIn.Ignore( 8 );
1035 : 0 : break;
1036 : : case 0x40:
1037 : : case 0x60:
1038 : : case 0x20: // Array Constant [317 268]
1039 [ # # ]: 0 : aIn.Ignore( 7 );
1040 : 0 : break;
1041 : : case 0x41:
1042 : : case 0x61:
1043 : : case 0x21: // Function, Fixed Number of Arguments [333 282]
1044 [ # # ]: 0 : aIn.Ignore( 2 );
1045 : 0 : break;
1046 : : case 0x42:
1047 : : case 0x62:
1048 : : case 0x22: // Function, Variable Number of Arg. [333 283]
1049 [ # # ]: 0 : aIn.Ignore( 3 );
1050 : 0 : break;
1051 : : case 0x43:
1052 : : case 0x63:
1053 : : case 0x23: // Name [318 269]
1054 [ # # ]: 0 : aIn.Ignore( 4 );
1055 : 0 : break;
1056 : : case 0x44:
1057 : : case 0x64:
1058 : : case 0x24: // Cell Reference [319 270]
1059 : : {
1060 : : sal_uInt16 nCol, nRow;
1061 : :
1062 [ # # ][ # # ]: 0 : aIn >> nRow >> nCol;
1063 : :
1064 : 0 : aSRD.nCol = static_cast<SCCOL>(nCol);
1065 : 0 : aSRD.nRow = nRow & 0x3FFF;
1066 : 0 : aSRD.nRelTab = 0;
1067 : 0 : aSRD.SetTabRel( sal_True );
1068 : 0 : aSRD.SetFlag3D( bRangeName );
1069 : :
1070 [ # # ]: 0 : ExcRelToScRel8( nRow, nCol, aSRD, bRangeName );
1071 : :
1072 [ # # ]: 0 : rRangeList.Append( aSRD, nTab );
1073 : : }
1074 : 0 : break;
1075 : : case 0x45:
1076 : : case 0x65:
1077 : : case 0x25: // Area Reference [320 270]
1078 : : {
1079 : : sal_uInt16 nRowFirst, nRowLast;
1080 : : sal_uInt16 nColFirst, nColLast;
1081 : 0 : ScSingleRefData &rSRef1 = aCRD.Ref1;
1082 : 0 : ScSingleRefData &rSRef2 = aCRD.Ref2;
1083 : :
1084 [ # # ][ # # ]: 0 : aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
[ # # ][ # # ]
1085 : :
1086 : 0 : rSRef1.nRelTab = rSRef2.nRelTab = 0;
1087 : 0 : rSRef1.SetTabRel( sal_True );
1088 : 0 : rSRef2.SetTabRel( sal_True );
1089 : 0 : rSRef1.SetFlag3D( bRangeName );
1090 : 0 : rSRef2.SetFlag3D( bRangeName );
1091 : :
1092 [ # # ]: 0 : ExcRelToScRel8( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
1093 [ # # ]: 0 : ExcRelToScRel8( nRowLast, nColLast, aCRD.Ref2, bRangeName );
1094 : :
1095 [ # # ]: 0 : if( IsComplColRange( nColFirst, nColLast ) )
1096 [ # # ]: 0 : SetComplCol( aCRD );
1097 [ # # ]: 0 : else if( IsComplRowRange( nRowFirst, nRowLast ) )
1098 [ # # ]: 0 : SetComplRow( aCRD );
1099 : :
1100 [ # # ]: 0 : rRangeList.Append( aCRD, nTab );
1101 : : }
1102 : 0 : break;
1103 : : case 0x46:
1104 : : case 0x66:
1105 : : case 0x26: // Constant Reference Subexpression [321 271]
1106 : : case 0x47:
1107 : : case 0x67:
1108 : : case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
1109 : : case 0x48:
1110 : : case 0x68:
1111 : : case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
1112 [ # # ]: 0 : aIn.Ignore( 6 ); // There isn't any more
1113 : 0 : break;
1114 : : case 0x49:
1115 : : case 0x69:
1116 : : case 0x29: // Variable Reference Subexpression [331 281]
1117 [ # # ]: 0 : aIn.Ignore( 2 ); // There isn't any more
1118 : 0 : break;
1119 : : case 0x4A:
1120 : : case 0x6A:
1121 : : case 0x2A: // Deleted Cell Reference [323 273]
1122 [ # # ]: 0 : aIn.Ignore( 3 );
1123 : 0 : break;
1124 : : case 0x4B:
1125 : : case 0x6B:
1126 : : case 0x2B: // Deleted Area Refernce [323 273]
1127 [ # # ]: 0 : aIn.Ignore( 6 );
1128 : 0 : break;
1129 : : case 0x4C:
1130 : : case 0x6C:
1131 : : case 0x2C: // Cell Reference Within a Name [323 ]
1132 : : // Cell Reference Within a Shared Formula[ 273]
1133 : : {
1134 : : sal_uInt16 nRow, nCol;
1135 : :
1136 [ # # ][ # # ]: 0 : aIn >> nRow >> nCol;
1137 : :
1138 : 0 : aSRD.nRelTab = 0;
1139 : 0 : aSRD.SetTabRel( sal_True );
1140 : 0 : aSRD.SetFlag3D( bRangeName );
1141 : :
1142 [ # # ]: 0 : ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
1143 : :
1144 [ # # ]: 0 : rRangeList.Append( aSRD, nTab );
1145 : : }
1146 : 0 : break;
1147 : : case 0x4D:
1148 : : case 0x6D:
1149 : : case 0x2D: // Area Reference Within a Name [324 ]
1150 : : { // Area Reference Within a Shared Formula[ 274]
1151 : : sal_uInt16 nRowFirst, nRowLast;
1152 : : sal_uInt16 nColFirst, nColLast;
1153 : :
1154 : 0 : aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
1155 : 0 : aCRD.Ref1.SetTabRel( sal_True );
1156 : 0 : aCRD.Ref2.SetTabRel( sal_True );
1157 : 0 : aCRD.Ref1.SetFlag3D( bRangeName );
1158 : 0 : aCRD.Ref2.SetFlag3D( bRangeName );
1159 : :
1160 [ # # ][ # # ]: 0 : aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
[ # # ][ # # ]
1161 : :
1162 [ # # ]: 0 : ExcRelToScRel8( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
1163 [ # # ]: 0 : ExcRelToScRel8( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
1164 : :
1165 [ # # ]: 0 : if( IsComplColRange( nColFirst, nColLast ) )
1166 [ # # ]: 0 : SetComplCol( aCRD );
1167 [ # # ]: 0 : else if( IsComplRowRange( nRowFirst, nRowLast ) )
1168 [ # # ]: 0 : SetComplRow( aCRD );
1169 : :
1170 [ # # ]: 0 : rRangeList.Append( aCRD, nTab );
1171 : : }
1172 : 0 : break;
1173 : : case 0x4E:
1174 : : case 0x6E:
1175 : : case 0x2E: // Reference Subexpression Within a Name [332 282]
1176 : : case 0x4F:
1177 : : case 0x6F:
1178 : : case 0x2F: // Incomplete Reference Subexpression... [332 282]
1179 : : case 0x58:
1180 : : case 0x78:
1181 : : case 0x38: // Command-Equivalent Function [333 ]
1182 [ # # ]: 0 : aIn.Ignore( 2 );
1183 : 0 : break;
1184 : : case 0x59:
1185 : : case 0x79:
1186 : : case 0x39: // Name or External Name [ 275]
1187 [ # # ]: 0 : aIn.Ignore( 24 );
1188 : 0 : break;
1189 : : case 0x5A:
1190 : : case 0x7A:
1191 : : case 0x3A: // 3-D Cell Reference [ 275]
1192 : : {
1193 : : sal_uInt16 nIxti, nRw, nGrbitCol;
1194 : :
1195 [ # # ][ # # ]: 0 : aIn >> nIxti >> nRw >> nGrbitCol;
[ # # ]
1196 : :
1197 : : SCTAB nFirstScTab, nLastScTab;
1198 [ # # ][ # # ]: 0 : if( rLinkMan.GetScTabRange( nFirstScTab, nLastScTab, nIxti ) )
1199 : : {
1200 : 0 : aSRD.nTab = nFirstScTab;
1201 : 0 : aSRD.SetFlag3D( sal_True );
1202 : 0 : aSRD.SetTabRel( false );
1203 : :
1204 [ # # ]: 0 : ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
1205 : :
1206 [ # # ]: 0 : if( nFirstScTab != nLastScTab )
1207 : : {
1208 : 0 : aCRD.Ref1 = aSRD;
1209 : 0 : aCRD.Ref2.nCol = aSRD.nCol;
1210 : 0 : aCRD.Ref2.nRow = aSRD.nRow;
1211 : 0 : aCRD.Ref2.nTab = nLastScTab;
1212 [ # # ]: 0 : rRangeList.Append( aCRD, nTab );
1213 : : }
1214 : : else
1215 [ # # ]: 0 : rRangeList.Append( aSRD, nTab );
1216 : : }
1217 : : }
1218 : 0 : break;
1219 : : case 0x5B:
1220 : : case 0x7B:
1221 : : case 0x3B: // 3-D Area Reference [ 276]
1222 : : {
1223 : : sal_uInt16 nIxti, nRw1, nGrbitCol1, nRw2, nGrbitCol2;
1224 : :
1225 [ # # ][ # # ]: 0 : aIn >> nIxti >> nRw1 >> nRw2 >> nGrbitCol1 >> nGrbitCol2;
[ # # ][ # # ]
[ # # ]
1226 : :
1227 : : SCTAB nFirstScTab, nLastScTab;
1228 [ # # ][ # # ]: 0 : if( rLinkMan.GetScTabRange( nFirstScTab, nLastScTab, nIxti ) )
1229 : : {
1230 : 0 : ScSingleRefData &rR1 = aCRD.Ref1;
1231 : 0 : ScSingleRefData &rR2 = aCRD.Ref2;
1232 : :
1233 : 0 : rR1.nTab = nFirstScTab;
1234 : 0 : rR2.nTab = nLastScTab;
1235 : 0 : rR1.SetFlag3D( sal_True );
1236 : 0 : rR1.SetTabRel( false );
1237 : 0 : rR2.SetFlag3D( nFirstScTab != nLastScTab );
1238 : 0 : rR2.SetTabRel( false );
1239 : :
1240 [ # # ]: 0 : ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
1241 [ # # ]: 0 : ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
1242 : :
1243 [ # # ]: 0 : if( IsComplColRange( nGrbitCol1, nGrbitCol2 ) )
1244 [ # # ]: 0 : SetComplCol( aCRD );
1245 [ # # ]: 0 : else if( IsComplRowRange( nRw1, nRw2 ) )
1246 [ # # ]: 0 : SetComplRow( aCRD );
1247 : :
1248 [ # # ]: 0 : rRangeList.Append( aCRD, nTab );
1249 : : }
1250 : : }
1251 : 0 : break;
1252 : : case 0x5C:
1253 : : case 0x7C:
1254 : : case 0x3C: // Deleted 3-D Cell Reference [ 277]
1255 [ # # ]: 0 : aIn.Ignore( 6 );
1256 : 0 : break;
1257 : : case 0x5D:
1258 : : case 0x7D:
1259 : : case 0x3D: // Deleted 3-D Area Reference [ 277]
1260 [ # # ]: 0 : aIn.Ignore( 10 );
1261 : 0 : break;
1262 : : default:
1263 : 0 : bError = sal_True;
1264 : : }
1265 : 0 : bError |= !aIn.IsValid();
1266 : : }
1267 : :
1268 : : ConvErr eRet;
1269 : :
1270 [ # # ]: 0 : if( bError )
1271 : 0 : eRet = ConvErrNi;
1272 [ # # ][ # # ]: 0 : else if( aIn.GetRecPos() != nEndPos )
1273 : 0 : eRet = ConvErrCount;
1274 [ # # ]: 0 : else if( bExternName )
1275 : 0 : eRet = ConvErrExternal;
1276 : : else
1277 : 0 : eRet = ConvOK;
1278 : :
1279 [ # # ]: 0 : aIn.Seek( nEndPos );
1280 : 0 : return eRet;
1281 : : }
1282 : :
1283 : 0 : ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen,
1284 : : const String& rUrl, const vector<String>& rTabNames )
1285 : : {
1286 [ # # ][ # # ]: 0 : if( !GetDocShell() )
1287 : 0 : return ConvErrNi;
1288 : :
1289 [ # # ][ # # ]: 0 : String aFileUrl = ScGlobal::GetAbsDocName(rUrl, GetDocShell());
1290 : :
1291 : : sal_uInt8 nOp, nByte;
1292 : 0 : bool bError = false;
1293 : :
1294 : : ScSingleRefData aSRD;
1295 : : ScComplexRefData aCRD;
1296 : :
1297 [ # # ]: 0 : if (eStatus != ConvOK)
1298 : : {
1299 [ # # ]: 0 : rStrm.Ignore(nFormulaLen);
1300 : 0 : return eStatus;
1301 : : }
1302 : :
1303 [ # # ]: 0 : if (nFormulaLen == 0)
1304 : : {
1305 [ # # ][ # # ]: 0 : aPool.Store(CREATE_STRING("-/-"));
[ # # ]
1306 [ # # ]: 0 : aPool >> aStack;
1307 [ # # ]: 0 : rpArray = aPool[aStack.Get()];
1308 : 0 : return ConvOK;
1309 : : }
1310 : :
1311 [ # # ]: 0 : ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
1312 [ # # ][ # # ]: 0 : sal_uInt16 nFileId = pRefMgr->getExternalFileId(aFileUrl);
1313 : 0 : sal_uInt16 nTabCount = static_cast< sal_uInt16 >( rTabNames.size() );
1314 : :
1315 [ # # ]: 0 : sal_Size nEndPos = rStrm.GetRecPos() + nFormulaLen;
1316 : :
1317 [ # # ][ # # ]: 0 : while( (rStrm.GetRecPos() < nEndPos) && !bError )
[ # # ][ # # ]
1318 : : {
1319 [ # # ]: 0 : rStrm >> nOp;
1320 : :
1321 : : // always reset flags
1322 : 0 : aSRD.InitFlags();
1323 : 0 : aCRD.InitFlags();
1324 : :
1325 [ # # # # ]: 0 : switch( nOp )
1326 : : {
1327 : : case 0x1C: // Error Value
1328 : : {
1329 [ # # ]: 0 : rStrm >> nByte;
1330 : : DefTokenId eOc;
1331 [ # # # ]: 0 : switch( nByte )
1332 : : {
1333 : : case EXC_ERR_NULL:
1334 : : case EXC_ERR_DIV0:
1335 : : case EXC_ERR_VALUE:
1336 : : case EXC_ERR_REF:
1337 : : case EXC_ERR_NAME:
1338 : 0 : case EXC_ERR_NUM: eOc = ocStop; break;
1339 : 0 : case EXC_ERR_NA: eOc = ocNotAvail; break;
1340 : 0 : default: eOc = ocNoName;
1341 : : }
1342 [ # # ]: 0 : aPool << eOc;
1343 [ # # ]: 0 : if( eOc != ocStop )
1344 [ # # ][ # # ]: 0 : aPool << ocOpen << ocClose;
1345 [ # # ]: 0 : aPool >> aStack;
1346 : : }
1347 : 0 : break;
1348 : : case 0x3A:
1349 : : {
1350 : : // cell reference in external range name
1351 : : sal_uInt16 nExtTab1, nExtTab2, nRow, nGrbitCol;
1352 [ # # ][ # # ]: 0 : rStrm >> nExtTab1 >> nExtTab2 >> nRow >> nGrbitCol;
[ # # ][ # # ]
1353 [ # # ][ # # ]: 0 : if (nExtTab1 >= nTabCount || nExtTab2 >= nTabCount)
1354 : : {
1355 : 0 : bError = true;
1356 : : break;
1357 : : }
1358 : :
1359 : 0 : aSRD.nTab = nExtTab1;
1360 : 0 : aSRD.SetFlag3D(true);
1361 : 0 : aSRD.SetTabRel(false);
1362 [ # # ]: 0 : ExcRelToScRel8(nRow, nGrbitCol, aSRD, true);
1363 : 0 : aCRD.Ref1 = aCRD.Ref2 = aSRD;
1364 [ # # ][ # # ]: 0 : String aTabName = rTabNames[nExtTab1];
1365 : :
1366 [ # # ]: 0 : if (nExtTab1 == nExtTab2)
1367 : : {
1368 : : // single cell reference
1369 [ # # ]: 0 : aStack << aPool.StoreExtRef(nFileId, aTabName, aSRD);
1370 : : }
1371 : : else
1372 : : {
1373 : : // area reference
1374 : 0 : aCRD.Ref2.nTab = nExtTab2;
1375 [ # # ]: 0 : aStack << aPool.StoreExtRef(nFileId, aTabName, aCRD);
1376 [ # # ]: 0 : }
1377 : : }
1378 : 0 : break;
1379 : : case 0x3B:
1380 : : {
1381 : : // area reference
1382 : : sal_uInt16 nExtTab1, nExtTab2, nRow1, nRow2, nGrbitCol1, nGrbitCol2;
1383 [ # # ][ # # ]: 0 : rStrm >> nExtTab1 >> nExtTab2 >> nRow1 >> nRow2 >> nGrbitCol1 >> nGrbitCol2;
[ # # ][ # # ]
[ # # ][ # # ]
1384 : 0 : ScSingleRefData& rR1 = aCRD.Ref1;
1385 : 0 : ScSingleRefData& rR2 = aCRD.Ref2;
1386 : :
1387 : 0 : rR1.nTab = nExtTab1;
1388 : 0 : rR1.SetFlag3D(true);
1389 : 0 : rR1.SetTabRel(false);
1390 [ # # ]: 0 : ExcRelToScRel8(nRow1, nGrbitCol1, rR1, true);
1391 : :
1392 : 0 : rR2.nTab = nExtTab2;
1393 : 0 : rR2.SetFlag3D(true);
1394 : 0 : rR2.SetTabRel(false);
1395 [ # # ]: 0 : ExcRelToScRel8(nRow2, nGrbitCol2, rR2, true);
1396 : :
1397 [ # # ][ # # ]: 0 : String aTabName = rTabNames[nExtTab1];
1398 [ # # ][ # # ]: 0 : aStack << aPool.StoreExtRef(nFileId, aTabName, aCRD);
1399 : : }
1400 : 0 : break;
1401 : : default:
1402 : 0 : bError = true;
1403 : : }
1404 : 0 : bError |= !rStrm.IsValid();
1405 : : }
1406 : :
1407 : : ConvErr eRet;
1408 : :
1409 [ # # ]: 0 : if( bError )
1410 : : {
1411 [ # # ]: 0 : aPool << ocBad;
1412 [ # # ]: 0 : aPool >> aStack;
1413 [ # # ]: 0 : rpArray = aPool[ aStack.Get() ];
1414 : 0 : eRet = ConvErrNi;
1415 : : }
1416 [ # # ][ # # ]: 0 : else if( rStrm.GetRecPos() != nEndPos )
1417 : : {
1418 [ # # ]: 0 : aPool << ocBad;
1419 [ # # ]: 0 : aPool >> aStack;
1420 [ # # ]: 0 : rpArray = aPool[ aStack.Get() ];
1421 : 0 : eRet = ConvErrCount;
1422 : : }
1423 : : else
1424 : : {
1425 [ # # ]: 0 : rpArray = aPool[ aStack.Get() ];
1426 : 0 : eRet = ConvOK;
1427 : : }
1428 : :
1429 [ # # ]: 0 : rStrm.Seek(nEndPos);
1430 [ # # ]: 0 : return eRet;
1431 : : }
1432 : :
1433 : 13848 : void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData &rSRD, const sal_Bool bName )
1434 : : {
1435 : 13848 : const sal_Bool bColRel = ( nC & 0x4000 ) != 0;
1436 : 13848 : const sal_Bool bRowRel = ( nC & 0x8000 ) != 0;
1437 : 13848 : const sal_uInt8 nCol = static_cast<sal_uInt8>(nC);
1438 : :
1439 : 13848 : rSRD.SetColRel( bColRel );
1440 : 13848 : rSRD.SetRowRel( bRowRel );
1441 : :
1442 [ + + ]: 13848 : if( bName )
1443 : : {
1444 : : // C O L
1445 [ - + ]: 87 : if( bColRel )
1446 : : // rel Col
1447 : 0 : rSRD.nRelCol = static_cast<SCsCOL>(static_cast<sal_Int8>(nC));
1448 : : else
1449 : : // abs Col
1450 : 87 : rSRD.nCol = static_cast<SCCOL>(nCol);
1451 : :
1452 : : // R O W
1453 [ - + ]: 87 : if( bRowRel )
1454 : : // rel Row
1455 : 0 : rSRD.nRelRow = static_cast<SCsROW>(static_cast<sal_Int16>(nRow));
1456 : : else
1457 : : // abs Row
1458 : 87 : rSRD.nRow = Min( static_cast<SCROW>(nRow), MAXROW);
1459 : :
1460 : : // T A B
1461 : : // abs needed if rel in shared formula for ScCompiler UpdateNameReference
1462 [ - + ][ # # ]: 87 : if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
[ - + ]
1463 : 0 : rSRD.nTab = GetCurrScTab();
1464 : : }
1465 : : else
1466 : : {
1467 : : // C O L
1468 [ + + ]: 13761 : if ( bColRel )
1469 : : {
1470 : 13731 : rSRD.nRelCol = static_cast<SCsCOL>(nCol) - aEingPos.Col();
1471 : 13731 : rSRD.nCol = rSRD.nRelCol;
1472 : : }
1473 : : else
1474 : 30 : rSRD.nCol = static_cast<SCCOL>(nCol);
1475 : :
1476 : : // R O W
1477 [ + + ]: 13761 : if ( bRowRel )
1478 : : {
1479 : 13731 : rSRD.nRelRow = static_cast<SCsROW>(nRow) - aEingPos.Row();
1480 : 13731 : rSRD.nRow = rSRD.nRelRow;
1481 : : }
1482 : : else
1483 : 30 : rSRD.nRow = static_cast<SCROW>(nRow);
1484 : :
1485 : : // T A B
1486 : : // #i10184# abs needed if rel in shared formula for ScCompiler UpdateNameReference
1487 [ + + ][ + - ]: 13761 : if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
[ + + ]
1488 : 8355 : rSRD.nTab = GetCurrScTab() + rSRD.nRelTab;
1489 : : }
1490 : 13848 : }
1491 : :
1492 : :
1493 : : // stream seeks to first byte after <nLen>
1494 : 3 : sal_Bool ExcelToSc8::GetAbsRefs( ScRangeList& r, XclImpStream& aIn, sal_Size nLen )
1495 : : {
1496 : : sal_uInt8 nOp;
1497 : : sal_uInt16 nRow1, nRow2, nCol1, nCol2;
1498 : : SCTAB nTab1, nTab2;
1499 : : sal_uInt16 nIxti;
1500 : :
1501 : : sal_Size nSeek;
1502 : :
1503 [ + - ]: 3 : sal_Size nEndPos = aIn.GetRecPos() + nLen;
1504 : :
1505 [ + - ][ + - ]: 6 : while( aIn.IsValid() && (aIn.GetRecPos() < nEndPos) )
[ + + ][ + + ]
1506 : : {
1507 [ + - ]: 3 : aIn >> nOp;
1508 : 3 : nSeek = 0;
1509 : :
1510 [ + - - - : 3 : switch( nOp )
- - - - -
- - - - -
- ]
1511 : : {
1512 : : case 0x44:
1513 : : case 0x64:
1514 : : case 0x24: // Cell Reference [319 270]
1515 : : case 0x4C:
1516 : : case 0x6C:
1517 : : case 0x2C: // Cell Reference Within a Name [323 ]
1518 : : // Cell Reference Within a Shared Formula[ 273]
1519 [ + - ][ + - ]: 3 : aIn >> nRow1 >> nCol1;
1520 : :
1521 : 3 : nRow2 = nRow1;
1522 : 3 : nCol2 = nCol1;
1523 : 3 : nTab1 = nTab2 = GetCurrScTab();
1524 : 3 : goto _common;
1525 : : case 0x45:
1526 : : case 0x65:
1527 : : case 0x25: // Area Reference [320 270]
1528 : : case 0x4D:
1529 : : case 0x6D:
1530 : : case 0x2D: // Area Reference Within a Name [324 ]
1531 : : // Area Reference Within a Shared Formula[ 274]
1532 [ # # ][ # # ]: 0 : aIn >> nRow1 >> nRow2 >> nCol1 >> nCol2;
[ # # ][ # # ]
1533 : :
1534 : 0 : nTab1 = nTab2 = GetCurrScTab();
1535 : 0 : goto _common;
1536 : : case 0x5A:
1537 : : case 0x7A:
1538 : : case 0x3A: // 3-D Cell Reference [ 275]
1539 [ # # ][ # # ]: 0 : aIn >> nIxti >> nRow1 >> nCol1;
[ # # ]
1540 : :
1541 : 0 : nRow2 = nRow1;
1542 : 0 : nCol2 = nCol1;
1543 : :
1544 : 0 : goto _3d_common;
1545 : : case 0x5B:
1546 : : case 0x7B:
1547 : : case 0x3B: // 3-D Area Reference [ 276]
1548 [ # # ][ # # ]: 0 : aIn >> nIxti >> nRow1 >> nRow2 >> nCol1 >> nCol2;
[ # # ][ # # ]
[ # # ]
1549 : :
1550 : : _3d_common:
1551 : : // skip references to deleted sheets
1552 [ # # ][ # # ]: 0 : if( !rLinkMan.GetScTabRange( nTab1, nTab2, nIxti ) || !ValidTab( nTab1 ) || !ValidTab( nTab2 ) )
[ # # ][ # # ]
[ # # ]
1553 : 0 : break;
1554 : :
1555 : 0 : goto _common;
1556 : : _common:
1557 : : // do not check abs/rel flags, linked controls have set them!
1558 : : {
1559 : 3 : ScRange aScRange;
1560 : 3 : nCol1 &= 0x3FFF;
1561 : 3 : nCol2 &= 0x3FFF;
1562 [ + - ][ + - ]: 3 : if( GetAddressConverter().ConvertRange( aScRange, XclRange( nCol1, nRow1, nCol2, nRow2 ), nTab1, nTab2, true ) )
[ + - ]
1563 [ + - ]: 3 : r.Append( aScRange );
1564 : : }
1565 : 3 : break;
1566 : : case 0x1C: // Error Value [314 266]
1567 : : case 0x1D: // Boolean [315 266]
1568 : 0 : nSeek = 1;
1569 : 0 : break;
1570 : : case 0x1E: // Integer [315 266]
1571 : : case 0x41:
1572 : : case 0x61:
1573 : : case 0x21: // Function, Fixed Number of Arguments [333 282]
1574 : : case 0x49:
1575 : : case 0x69:
1576 : : case 0x29: // Variable Reference Subexpression [331 281]
1577 : : case 0x4E:
1578 : : case 0x6E:
1579 : : case 0x2E: // Reference Subexpression Within a Name [332 282]
1580 : : case 0x4F:
1581 : : case 0x6F:
1582 : : case 0x2F: // Incomplete Reference Subexpression... [332 282]
1583 : : case 0x58:
1584 : : case 0x78:
1585 : : case 0x38: // Command-Equivalent Function [333 ]
1586 : 0 : nSeek = 2;
1587 : 0 : break;
1588 : : case 0x42:
1589 : : case 0x62:
1590 : : case 0x22: // Function, Variable Number of Arg. [333 283]
1591 : 0 : nSeek = 3;
1592 : 0 : break;
1593 : : case 0x01: // Array Formula [325 ]
1594 : : case 0x02: // Data Table [325 277]
1595 : : case 0x43:
1596 : : case 0x63:
1597 : : case 0x23: // Name [318 269]
1598 : : case 0x4A:
1599 : : case 0x6A:
1600 : : case 0x2A: // Deleted Cell Reference [323 273]
1601 : 0 : nSeek = 4;
1602 : 0 : break;
1603 : : case 0x46:
1604 : : case 0x66:
1605 : : case 0x26: // Constant Reference Subexpression [321 271]
1606 : : case 0x47:
1607 : : case 0x67:
1608 : : case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
1609 : : case 0x48:
1610 : : case 0x68:
1611 : : case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
1612 : : case 0x5C:
1613 : : case 0x7C:
1614 : : case 0x3C: // Deleted 3-D Cell Reference [ 277]
1615 : : case 0x59:
1616 : : case 0x79:
1617 : : case 0x39: // Name or External Name [ 275]
1618 : 0 : nSeek = 6;
1619 : 0 : break;
1620 : : case 0x40:
1621 : : case 0x60:
1622 : : case 0x20: // Array Constant [317 268]
1623 : 0 : nSeek = 7;
1624 : 0 : break;
1625 : : case 0x1F: // Number [315 266]
1626 : : case 0x4B:
1627 : : case 0x6B:
1628 : : case 0x2B: // Deleted Area Refernce [323 273]
1629 : 0 : nSeek = 8;
1630 : 0 : break;
1631 : : case 0x5D:
1632 : : case 0x7D:
1633 : : case 0x3D: // Deleted 3-D Area Reference [ 277]
1634 : 0 : nSeek = 10;
1635 : 0 : break;
1636 : : case 0x17: // String Constant [314 266]
1637 : : {
1638 : : sal_uInt8 nStrLen;
1639 [ # # ]: 0 : aIn >> nStrLen;
1640 [ # # ]: 0 : aIn.IgnoreUniString( nStrLen ); // reads Grbit even if nLen==0
1641 : 0 : nSeek = 0;
1642 : : }
1643 : 0 : break;
1644 : : case 0x19: // Special Attribute [327 279]
1645 : : {
1646 : : sal_uInt16 nData;
1647 : : sal_uInt8 nOpt;
1648 [ # # ][ # # ]: 0 : aIn >> nOpt >> nData;
1649 [ # # ]: 0 : if( nOpt & 0x04 )
1650 : : {// nFakt -> skip bytes or words AttrChoose
1651 : 0 : nData++;
1652 : 0 : nSeek = nData * 2;
1653 : : }
1654 : : }
1655 : 0 : break;
1656 : : }
1657 : :
1658 [ + - ]: 3 : aIn.Ignore( nSeek );
1659 : : }
1660 [ + - ]: 3 : aIn.Seek( nEndPos );
1661 : :
1662 [ + - ]: 3 : return !r.empty();
1663 : : }
1664 : :
1665 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|