LibreOffice Module sc (master) 1
excform.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <excform.hxx>
21
22#include <formulacell.hxx>
23#include <document.hxx>
24#include <scmatrix.hxx>
25
28#include <sal/log.hxx>
29
30#include <imp_op.hxx>
31#include <namebuff.hxx>
32#include <root.hxx>
33#include <xltracer.hxx>
34#include <xihelper.hxx>
35#include <xiname.hxx>
36#include <xistyle.hxx>
37#include <documentimport.hxx>
38
39using ::std::vector;
40
41const sal_uInt16 ExcelToSc::nRowMask = 0x3FFF;
42
44{
45 XclAddress aXclPos;
46 sal_uInt16 nXF = 0, nFormLen;
47 double fCurVal;
48 bool bShrFmla;
49
50 aIn >> aXclPos;
51
52 if( GetBiff() == EXC_BIFF2 )
53 {// BIFF2
54 aIn.Ignore( 3 );
55
56 fCurVal = aIn.ReadDouble();
57 aIn.Ignore( 1 );
58 nFormLen = aIn.ReaduInt8();
59 bShrFmla = false;
60 }
61 else
62 {// BIFF5
63 sal_uInt8 nFlag0;
64 nXF = aIn.ReaduInt16();
65 fCurVal = aIn.ReadDouble();
66 nFlag0 = aIn.ReaduInt8();
67 aIn.Ignore( 5 );
68
69 nFormLen = aIn.ReaduInt16();
70
71 bShrFmla = nFlag0 & 0x08; // shared or not shared
72 }
73
74 Formula( aXclPos, nXF, nFormLen, fCurVal, bShrFmla );
75}
76
78{
79 Formula4();
80}
81
83{
84 XclAddress aXclPos;
85
86 aIn >> aXclPos;
87 sal_uInt16 nXF = aIn.ReaduInt16();
88 double fCurVal = aIn.ReadDouble();
89 aIn.Ignore( 2 );
90 sal_uInt16 nFormLen = aIn.ReaduInt16();
91
92 Formula( aXclPos, nXF, nFormLen, fCurVal, false );
93}
94
96 const XclAddress& rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
97{
98 if (!nFormLen)
99 return;
100
102 if (!GetAddressConverter().ConvertAddress(aScPos, rXclPos, GetCurrScTab(), true))
103 // Conversion failed.
104 return;
105
106 // Formula will be read next, length in nFormLen
107 std::unique_ptr<ScTokenArray> pResult;
108
109 pFormConv->Reset( aScPos );
111
112 if (bShrFmla)
113 {
114 // This is a shared formula. Get the token array from the shared formula pool.
115 SCCOL nSharedCol;
116 SCROW nSharedRow;
117 if (ExcelToSc::ReadSharedFormulaPosition(maStrm, nSharedCol, nSharedRow))
118 {
119 ScAddress aRefPos(nSharedCol, nSharedRow, GetCurrScTab());
120 const ScTokenArray* pSharedCode = pFormConv->GetSharedFormula(aRefPos);
121 if (pSharedCode)
122 {
123 ScFormulaCell* pCell;
124 pCell = new ScFormulaCell(rD, aScPos, pSharedCode->Clone());
125 pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8);
126 rDoc.getDoc().EnsureTable(aScPos.Tab());
127 rDoc.setFormulaCell(aScPos, pCell);
128 pCell->SetNeedNumberFormat(false);
129 if (std::isfinite(fCurVal))
130 pCell->SetResultDouble(fCurVal);
131
132 GetXFRangeBuffer().SetXF(aScPos, nXF);
133 SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell);
134 }
135 else
136 {
137 // Shared formula not found even though it's clearly a shared formula.
138 // The cell will be created in the following shared formula
139 // record.
140 SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, nullptr);
141 }
142 return;
143 }
144 }
145
146 ConvErr eErr = pFormConv->Convert( pResult, maStrm, nFormLen, true );
147
148 ScFormulaCell* pCell = nullptr;
149
150 if (pResult)
151 {
152 pCell = new ScFormulaCell(rDoc.getDoc(), aScPos, std::move(pResult));
153 pCell->GetCode()->WrapReference(aScPos, EXC_MAXCOL8, EXC_MAXROW8);
155 rDoc.getDoc().EnsureTable(aScPos.Tab());
156 rDoc.setFormulaCell(aScPos, pCell);
157 SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell);
158 }
159 else
160 {
161 pCell = rDoc.getDoc().GetFormulaCell(aScPos);
162 if (pCell)
163 pCell->AddRecalcMode( ScRecalcMode::ONLOAD_ONCE );
164 }
165
166 if (pCell)
167 {
168 pCell->SetNeedNumberFormat(false);
169 if( eErr != ConvErr::OK )
170 ExcelToSc::SetError( *pCell, eErr );
171
172 if (std::isfinite(fCurVal))
173 pCell->SetResultDouble(fCurVal);
174 }
175
176 GetXFRangeBuffer().SetXF(aScPos, nXF);
177}
178
180 ExcelConverterBase(rRoot.GetDocImport().getDoc().GetSharedStringPool()),
181 XclImpRoot( rRoot ),
182 maFuncProv( rRoot ),
183 meBiff( rRoot.GetBiff() )
184{
185}
186
188{
189}
190
191std::unique_ptr<ScTokenArray> ExcelToSc::GetDummy()
192{
193 aPool.Store( "Dummy()" );
194 aPool >> aStack;
195 return aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
196}
197
198// if bAllowArrays is false stream seeks to first byte after <nFormulaLen>
199// otherwise it will seek to the first byte after the additional content (eg
200// inline arrays) following <nFormulaLen>
201ConvErr ExcelToSc::Convert( std::unique_ptr<ScTokenArray>& pResult, XclImpStream& aIn, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT )
202{
203 RootData& rR = GetOldRoot();
204 sal_uInt8 nOp, nLen;
205 bool bError = false;
206 bool bArrayFormula = false;
207 TokenId nBuf0;
208 const bool bRangeName = eFT == FT_RangeName;
209 const bool bSharedFormula = eFT == FT_SharedFormula;
210 const bool bConditional = eFT == FT_CondFormat;
211 const bool bRNorSF = bRangeName || bSharedFormula || bConditional;
212
213 ScSingleRefData aSRD;
214 ScComplexRefData aCRD;
215 ExtensionTypeVec aExtensions;
216
217 if( nFormulaLen == 0 )
218 {
219 aPool.Store( "-/-" );
220 aPool >> aStack;
221 pResult = aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
222 return ConvErr::OK;
223 }
224
225 std::size_t nEndPos = aIn.GetRecPos() + nFormulaLen;
226
227 while( (aIn.GetRecPos() < nEndPos) && !bError )
228 {
229 nOp = aIn.ReaduInt8();
230
231 // always reset flags
232 aSRD.InitFlags();
233 aCRD.InitFlags();
234
235 switch( nOp ) // book page:
236 { // SDK4 SDK5
237 case 0x01: // Array Formula [325 ]
238 // Array Formula or Shared Formula [ 277]
239 case 0x02: // Data Table [325 277]
240 {
241 sal_uInt16 nUINT16 = 3;
242
243 if( meBiff != EXC_BIFF2 )
244 nUINT16++;
245
246 aIn.Ignore( nUINT16 );
247
248 bArrayFormula = true;
249 break;
250 }
251 case 0x03: // Addition [312 264]
252 aStack >> nBuf0;
253 aPool << aStack << ocAdd << nBuf0;
254 aPool >> aStack;
255 break;
256 case 0x04: // Subtraction [313 264]
257 // SECOND-TOP minus TOP
258 aStack >> nBuf0;
259 aPool << aStack << ocSub << nBuf0;
260 aPool >> aStack;
261 break;
262 case 0x05: // Multiplication [313 264]
263 aStack >> nBuf0;
264 aPool << aStack << ocMul << nBuf0;
265 aPool >> aStack;
266 break;
267 case 0x06: // Division [313 264]
268 // divide TOP by SECOND-TOP
269 aStack >> nBuf0;
270 aPool << aStack << ocDiv << nBuf0;
271 aPool >> aStack;
272 break;
273 case 0x07: // Exponentiation [313 265]
274 // raise SECOND-TOP to power of TOP
275 aStack >> nBuf0;
276 aPool << aStack << ocPow << nBuf0;
277 aPool >> aStack;
278 break;
279 case 0x08: // Concatenation [313 265]
280 // append TOP to SECOND-TOP
281 aStack >> nBuf0;
282 aPool << aStack << ocAmpersand << nBuf0;
283 aPool >> aStack;
284 break;
285 case 0x09: // Less Than [313 265]
286 // SECOND-TOP < TOP
287 aStack >> nBuf0;
288 aPool << aStack << ocLess << nBuf0;
289 aPool >> aStack;
290 break;
291 case 0x0A: // Less Than or Equal [313 265]
292 // SECOND-TOP <= TOP
293 aStack >> nBuf0;
294 aPool << aStack << ocLessEqual << nBuf0;
295 aPool >> aStack;
296 break;
297 case 0x0B: // Equal [313 265]
298 // SECOND-TOP == TOP
299 aStack >> nBuf0;
300 aPool << aStack << ocEqual << nBuf0;
301 aPool >> aStack;
302 break;
303 case 0x0C: // Greater Than or Equal [313 265]
304 // SECOND-TOP >= TOP
305 aStack >> nBuf0;
306 aPool << aStack << ocGreaterEqual << nBuf0;
307 aPool >> aStack;
308 break;
309 case 0x0D: // Greater Than [313 265]
310 // SECOND-TOP > TOP
311 aStack >> nBuf0;
312 aPool << aStack << ocGreater << nBuf0;
313 aPool >> aStack;
314 break;
315 case 0x0E: // Not Equal [313 265]
316 // SECOND-TOP != TOP
317 aStack >> nBuf0;
318 aPool << aStack << ocNotEqual << nBuf0;
319 aPool >> aStack;
320 break;
321 case 0x0F: // Intersection [314 265]
322 aStack >> nBuf0;
323 aPool << aStack << ocIntersect << nBuf0;
324 aPool >> aStack;
325 break;
326 case 0x10: // Union [314 265]
327 // ocSep instead of 'ocUnion'
328 aStack >> nBuf0;
329 aPool << aStack << ocSep << nBuf0;
330 // doesn't fit exactly, but is more Excel-like
331 aPool >> aStack;
332 break;
333 case 0x11: // Range [314 265]
334 aStack >> nBuf0;
335 aPool << aStack << ocRange << nBuf0;
336 aPool >> aStack;
337 break;
338 case 0x12: // Unary Plus [312 264]
339 aPool << ocAdd << aStack;
340 aPool >> aStack;
341 break;
342 case 0x13: // Unary Minus [312 264]
343 aPool << ocNegSub << aStack;
344 aPool >> aStack;
345 break;
346 case 0x14: // Percent Sign [312 264]
348 aPool >> aStack;
349 break;
350 case 0x15: // Parenthesis [326 278]
351 aPool << ocOpen << aStack << ocClose;
352 aPool >> aStack;
353 break;
354 case 0x16: // Missing Argument [314 266]
355 aPool << ocMissing;
356 aPool >> aStack;
358 break;
359 case 0x17: // String Constant [314 266]
360 {
361 nLen = aIn.ReaduInt8();
362 OUString aString = aIn.ReadRawByteString( nLen );
363
364 aStack << aPool.Store( aString );
365 break;
366 }
367 case 0x19: // Special Attribute [327 279]
368 {
369 sal_uInt16 nData(0), nFactor(0);
370
371 sal_uInt8 nOpt = aIn.ReaduInt8();
372
373 if( meBiff == EXC_BIFF2 )
374 {
375 nData = aIn.ReaduInt8();
376 nFactor = 1;
377 }
378 else
379 {
380 nData = aIn.ReaduInt16();
381 nFactor = 2;
382 }
383
384 if( nOpt & 0x04 )
385 {
386 // nFactor -> skip bytes or words AttrChoose
387 ++nData;
388 aIn.Ignore(static_cast<std::size_t>(nData) * nFactor);
389 }
390 else if( nOpt & 0x10 ) // AttrSum
391 DoMulArgs( ocSum, 1 );
392 }
393 break;
394 case 0x1A: // External Reference [330 ]
395 switch( meBiff )
396 {
397 case EXC_BIFF2: aIn.Ignore( 7 ); break;
398 case EXC_BIFF3:
399 case EXC_BIFF4: aIn.Ignore( 10 ); break;
400 case EXC_BIFF5:
401 SAL_INFO( "sc", "-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
402 [[fallthrough]];
403 default:
404 SAL_INFO( "sc", "-ExcelToSc::Convert(): A little oblivious?" );
405 }
406 break;
407 case 0x1B: // End External Reference [330 ]
408 switch( meBiff )
409 {
410 case EXC_BIFF2: aIn.Ignore( 3 ); break;
411 case EXC_BIFF3:
412 case EXC_BIFF4: aIn.Ignore( 4 ); break;
413 case EXC_BIFF5:
414 SAL_INFO( "sc", "-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
415 [[fallthrough]];
416 default:
417 SAL_INFO( "sc", "-ExcelToSc::Convert(): A little oblivious?" );
418 }
419 break;
420 case 0x1C: // Error Value [314 266]
421 {
422 sal_uInt8 nByte = aIn.ReaduInt8();
423 DefTokenId eOc;
424 switch( nByte )
425 {
426 case EXC_ERR_NULL:
427 case EXC_ERR_DIV0:
428 case EXC_ERR_VALUE:
429 case EXC_ERR_REF:
430 case EXC_ERR_NAME:
431 case EXC_ERR_NUM: eOc = ocStop; break;
432 case EXC_ERR_NA: eOc = ocNotAvail; break;
433 default: eOc = ocNoName;
434 }
435 aPool << eOc;
436 if( eOc != ocStop )
437 aPool << ocOpen << ocClose;
438 aPool >> aStack;
439 break;
440 }
441 case 0x1D: // Boolean [315 266]
442 {
443 sal_uInt8 nByte = aIn.ReaduInt8();
444 if( nByte == 0 )
445 aPool << ocFalse << ocOpen << ocClose;
446 else
447 aPool << ocTrue << ocOpen << ocClose;
448 aPool >> aStack;
449 break;
450 }
451 case 0x1E: // Integer [315 266]
452 {
453 sal_uInt16 nUINT16 = aIn.ReaduInt16();
454 aStack << aPool.Store( static_cast<double>(nUINT16) );
455 break;
456 }
457 case 0x1F: // Number [315 266]
458 {
459 double fDouble = aIn.ReadDouble();
460 aStack << aPool.Store( fDouble );
461 break;
462 }
463 case 0x40:
464 case 0x60:
465 case 0x20: // Array Constant [317 268]
466 {
467 aIn.Ignore( (meBiff == EXC_BIFF2) ? 6 : 7 );
468 if( bAllowArrays )
469 {
471 aExtensions.push_back( EXTENSION_ARRAY );
472 }
473 else
474 {
475 aPool << ocBad;
476 aPool >> aStack;
477 }
478 break;
479 }
480 case 0x41:
481 case 0x61:
482 case 0x21: // Function, Fixed Number of Arguments [333 282]
483 {
484 sal_uInt16 nXclFunc;
485 if( meBiff <= EXC_BIFF3 )
486 nXclFunc = aIn.ReaduInt8();
487 else
488 nXclFunc = aIn.ReaduInt16();
489 if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
490 DoMulArgs( pFuncInfo->meOpCode, pFuncInfo->mnMaxParamCount );
491 else
492 DoMulArgs( ocNoName, 0 );
493 }
494 break;
495 case 0x42:
496 case 0x62:
497 case 0x22: // Function, Variable Number of Arg. [333 283]
498 {
499 sal_uInt16 nXclFunc;
500 sal_uInt8 nParamCount;
501 nParamCount = aIn.ReaduInt8();
502 nParamCount &= 0x7F;
503 if( meBiff <= EXC_BIFF3 )
504 nXclFunc = aIn.ReaduInt8();
505 else
506 nXclFunc = aIn.ReaduInt16();
507 if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclFunc( nXclFunc ) )
508 DoMulArgs( pFuncInfo->meOpCode, nParamCount );
509 else
510 DoMulArgs( ocNoName, 0 );
511 }
512 break;
513 case 0x43:
514 case 0x63:
515 case 0x23: // Name [318 269]
516 {
517 sal_uInt16 nUINT16 = aIn.ReaduInt16();
518 switch( meBiff )
519 {
520 case EXC_BIFF2: aIn.Ignore( 5 ); break;
521 case EXC_BIFF3:
522 case EXC_BIFF4: aIn.Ignore( 8 ); break;
523 case EXC_BIFF5: aIn.Ignore( 12 ); break;
524 default:
525 OSL_FAIL(
526 "-ExcelToSc::Convert(): A little oblivious?" );
527 }
528 const XclImpName* pName = GetNameManager().GetName( nUINT16 );
529 if(pName && !pName->GetScRangeData())
530 aStack << aPool.Store( ocMacro, pName->GetXclName() );
531 else
532 aStack << aPool.StoreName(nUINT16, -1);
533 }
534 break;
535 case 0x44:
536 case 0x64:
537 case 0x24: // Cell Reference [319 270]
538 case 0x4A:
539 case 0x6A:
540 case 0x2A: // Deleted Cell Reference [323 273]
541 {
542 sal_uInt16 nUINT16 = aIn.ReaduInt16();
543 sal_uInt8 nByte = aIn.ReaduInt8();
544 aSRD.SetAbsCol(static_cast<SCCOL>(nByte));
545 aSRD.SetAbsRow(nUINT16 & 0x3FFF);
546 aSRD.SetRelTab(0);
547 aSRD.SetFlag3D( bRangeName );
548
549 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
550
551 switch ( nOp )
552 {
553 case 0x4A:
554 case 0x6A:
555 case 0x2A: // Deleted Cell Reference [323 273]
556 // no information which part is deleted, set both
557 aSRD.SetColDeleted( true );
558 aSRD.SetRowDeleted( true );
559 }
560
561 aStack << aPool.Store( aSRD );
562 break;
563 }
564 case 0x45:
565 case 0x65:
566 case 0x25: // Area Reference [320 270]
567 case 0x4B:
568 case 0x6B:
569 case 0x2B: // Deleted Area Reference [323 273]
570 {
571 sal_uInt16 nRowFirst, nRowLast;
572 sal_uInt8 nColFirst, nColLast;
573 ScSingleRefData& rSRef1 = aCRD.Ref1;
574 ScSingleRefData& rSRef2 = aCRD.Ref2;
575
576 nRowFirst = aIn.ReaduInt16();
577 nRowLast = aIn.ReaduInt16();
578 nColFirst = aIn.ReaduInt8();
579 nColLast = aIn.ReaduInt8();
580
581 rSRef1.SetRelTab(0);
582 rSRef2.SetRelTab(0);
583 rSRef1.SetFlag3D( bRangeName );
584 rSRef2.SetFlag3D( bRangeName );
585
586 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
587 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
588
589 if( IsComplColRange( nColFirst, nColLast ) )
590 SetComplCol( aCRD );
591 else if( IsComplRowRange( nRowFirst, nRowLast ) )
592 SetComplRow( aCRD );
593
594 switch ( nOp )
595 {
596 case 0x4B:
597 case 0x6B:
598 case 0x2B: // Deleted Area Reference [323 273]
599 // no information which part is deleted, set all
600 rSRef1.SetColDeleted( true );
601 rSRef1.SetRowDeleted( true );
602 rSRef2.SetColDeleted( true );
603 rSRef2.SetRowDeleted( true );
604 }
605
606 aStack << aPool.Store( aCRD );
607 }
608 break;
609 case 0x46:
610 case 0x66:
611 case 0x26: // Constant Reference Subexpression [321 271]
612 aExtensions.push_back( EXTENSION_MEMAREA );
613 [[fallthrough]];
614
615 case 0x47:
616 case 0x67:
617 case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
618 case 0x48:
619 case 0x68:
620 case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
621 aIn.Ignore( (meBiff == EXC_BIFF2) ? 4 : 6 );
622 break;
623 case 0x4C:
624 case 0x6C:
625 case 0x2C: // Cell Reference Within a Name [323 ]
626 // Cell Reference Within a Shared Formula[ 273]
627 {
628 sal_uInt16 nUINT16 = aIn.ReaduInt16();
629 sal_uInt8 nByte = aIn.ReaduInt8(); // >> Attribute, Row >> Col
630
631 aSRD.SetRelTab(0);
632 aSRD.SetFlag3D( bRangeName );
633
634 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
635
636 aStack << aPool.Store( aSRD );
637 break;
638 }
639 case 0x4D:
640 case 0x6D:
641 case 0x2D: // Area Reference Within a Name [324 ]
642 { // Area Reference Within a Shared Formula[ 274]
643 sal_uInt16 nRowFirst, nRowLast;
644 sal_uInt8 nColFirst, nColLast;
645
646 aCRD.Ref1.SetRelTab(0);
647 aCRD.Ref2.SetRelTab(0);
648 aCRD.Ref1.SetFlag3D( bRangeName );
649 aCRD.Ref2.SetFlag3D( bRangeName );
650
651 nRowFirst = aIn.ReaduInt16();
652 nRowLast = aIn.ReaduInt16();
653 nColFirst = aIn.ReaduInt8();
654 nColLast = aIn.ReaduInt8( );
655
656 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
657 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
658
659 if( IsComplColRange( nColFirst, nColLast ) )
660 SetComplCol( aCRD );
661 else if( IsComplRowRange( nRowFirst, nRowLast ) )
662 SetComplRow( aCRD );
663
664 aStack << aPool.Store( aCRD );
665 }
666 break;
667 case 0x49:
668 case 0x69:
669 case 0x29: // Variable Reference Subexpression [331 281]
670 case 0x4E:
671 case 0x6E:
672 case 0x2E: // Reference Subexpression Within a Name [332 282]
673 case 0x4F:
674 case 0x6F:
675 case 0x2F: // Incomplete Reference Subexpression... [332 282]
676 aIn.Ignore( (meBiff == EXC_BIFF2) ? 1 : 2 );
677 break;
678 case 0x58:
679 case 0x78:
680 case 0x38: // Command-Equivalent Function [333 ]
681 {
682 OUString aString = "COMM_EQU_FUNC";
683 sal_uInt8 nByte = aIn.ReaduInt8();
684 aString += OUString::number( nByte );
685 nByte = aIn.ReaduInt8();
686 aStack << aPool.Store( aString );
687 DoMulArgs( ocPush, nByte + 1 );
688 break;
689 }
690 case 0x59:
691 case 0x79:
692 case 0x39: // Name or External Name [ 275]
693 {
694 sal_Int16 nINT16 = aIn.ReadInt16();
695 aIn.Ignore( 8 );
696 sal_uInt16 nUINT16 = aIn.ReaduInt16();
697 if( nINT16 >= 0 )
698 {
699 aPool << ocBad;
700 aPool >> aStack;
701 }
702 else
703 aStack << aPool.StoreName( nUINT16, -1 );
704 aIn.Ignore( 12 );
705 break;
706 }
707 case 0x5A:
708 case 0x7A:
709 case 0x3A: // 3-D Cell Reference [ 275]
710 case 0x5C:
711 case 0x7C:
712 case 0x3C: // Deleted 3-D Cell Reference [ 277]
713 {
714 sal_uInt16 nTabFirst, nTabLast, nRow;
715 sal_Int16 nExtSheet;
716 sal_uInt8 nCol;
717
718 nExtSheet = aIn.ReadInt16();
719 aIn.Ignore( 8 );
720 nTabFirst = aIn.ReaduInt16();
721 nTabLast = aIn.ReaduInt16();
722 nRow = aIn.ReaduInt16();
723 nCol = aIn.ReaduInt8();
724
725 if( nExtSheet >= 0 )
726 { // from external
727 if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
728 {
729 nTabFirst = nTabLast;
730 nExtSheet = 0; // found
731 }
732 else
733 {
734 aPool << ocBad;
735 aPool >> aStack;
736 nExtSheet = 1; // don't create a SingleRef
737 }
738 }
739
740 if( nExtSheet <= 0 )
741 { // in current Workbook
742 aSRD.SetAbsTab(nTabFirst);
743 aSRD.SetFlag3D(true);
744
745 ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
746
747 switch ( nOp )
748 {
749 case 0x5C:
750 case 0x7C:
751 case 0x3C: // Deleted 3-D Cell Reference [ 277]
752 // no information which part is deleted, set both
753 aSRD.SetColDeleted( true );
754 aSRD.SetRowDeleted( true );
755 }
756 if ( !ValidTab(static_cast<SCTAB>(nTabFirst)) )
757 aSRD.SetTabDeleted( true );
758
759 if( nTabLast != nTabFirst )
760 {
761 aCRD.Ref1 = aCRD.Ref2 = aSRD;
762 aCRD.Ref2.SetAbsTab(nTabLast);
763 aCRD.Ref2.SetTabDeleted( !ValidTab(static_cast<SCTAB>(nTabLast)) );
764 aStack << aPool.Store( aCRD );
765 }
766 else
767 aStack << aPool.Store( aSRD );
768 }
769 }
770
771 break;
772 case 0x5B:
773 case 0x7B:
774 case 0x3B: // 3-D Area Reference [ 276]
775 case 0x5D:
776 case 0x7D:
777 case 0x3D: // Deleted 3-D Area Reference [ 277]
778 {
779 sal_uInt16 nTabFirst, nTabLast, nRowFirst, nRowLast;
780 sal_Int16 nExtSheet;
781 sal_uInt8 nColFirst, nColLast;
782
783 nExtSheet = aIn.ReadInt16();
784 aIn.Ignore( 8 );
785 nTabFirst = aIn.ReaduInt16();
786 nTabLast = aIn.ReaduInt16();
787 nRowFirst = aIn.ReaduInt16();
788 nRowLast = aIn.ReaduInt16();
789 nColFirst = aIn.ReaduInt8();
790 nColLast = aIn.ReaduInt8();
791
792 if( nExtSheet >= 0 )
793 // from external
794 {
795 if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
796 {
797 nTabFirst = nTabLast;
798 nExtSheet = 0; // found
799 }
800 else
801 {
802 aPool << ocBad;
803 aPool >> aStack;
804 nExtSheet = 1; // don't create a CompleteRef
805 }
806 }
807
808 if( nExtSheet <= 0 )
809 {// in current Workbook
810 // first part of range
811 ScSingleRefData& rR1 = aCRD.Ref1;
812 ScSingleRefData& rR2 = aCRD.Ref2;
813
814 rR1.SetAbsTab(nTabFirst);
815 rR2.SetAbsTab(nTabLast);
816 rR1.SetFlag3D(true);
817 rR2.SetFlag3D( nTabFirst != nTabLast );
818
819 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
820 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
821
822 if( IsComplColRange( nColFirst, nColLast ) )
823 SetComplCol( aCRD );
824 else if( IsComplRowRange( nRowFirst, nRowLast ) )
825 SetComplRow( aCRD );
826
827 switch ( nOp )
828 {
829 case 0x5D:
830 case 0x7D:
831 case 0x3D: // Deleted 3-D Area Reference [ 277]
832 // no information which part is deleted, set all
833 rR1.SetColDeleted( true );
834 rR1.SetRowDeleted( true );
835 rR2.SetColDeleted( true );
836 rR2.SetRowDeleted( true );
837 }
838 if ( !ValidTab(static_cast<SCTAB>(nTabFirst)) )
839 rR1.SetTabDeleted( true );
840 if ( !ValidTab(static_cast<SCTAB>(nTabLast)) )
841 rR2.SetTabDeleted( true );
842
843 aStack << aPool.Store( aCRD );
844 }//END in current Workbook
845 }
846 break;
847 default: bError = true;
848 }
849 bError |= !aIn.IsValid();
850 }
851
852 ConvErr eRet;
853
854 if( bError )
855 {
856 aPool << ocBad;
857 aPool >> aStack;
858 pResult = aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
859 eRet = ConvErr::Ni;
860 }
861 else if( aIn.GetRecPos() != nEndPos )
862 {
863 aPool << ocBad;
864 aPool >> aStack;
865 pResult = aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
866 eRet = ConvErr::Count;
867 }
868 else if( bArrayFormula )
869 {
870 pResult = nullptr;
871 eRet = ConvErr::OK;
872 }
873 else
874 {
875 pResult = aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
876 eRet = ConvErr::OK;
877 }
878
879 aIn.Seek( nEndPos );
880
881 if( eRet == ConvErr::OK )
882 ReadExtensions( aExtensions, aIn );
883
884 return eRet;
885}
886
887// stream seeks to first byte after <nFormulaLen>
888ConvErr ExcelToSc::Convert( ScRangeListTabs& rRangeList, XclImpStream& aIn, std::size_t nFormulaLen,
889 SCTAB nTab, const FORMULA_TYPE eFT )
890{
891 RootData& rR = GetOldRoot();
892 sal_uInt8 nOp, nLen;
893 bool bError = false;
894 const bool bRangeName = eFT == FT_RangeName;
895 const bool bSharedFormula = eFT == FT_SharedFormula;
896 const bool bRNorSF = bRangeName || bSharedFormula;
897
898 ScSingleRefData aSRD;
899 ScComplexRefData aCRD;
900 aCRD.Ref1.SetAbsTab(aEingPos.Tab());
901 aCRD.Ref2.SetAbsTab(aEingPos.Tab());
902
903 if( nFormulaLen == 0 )
904 return ConvErr::OK;
905
906 std::size_t nEndPos = aIn.GetRecPos() + nFormulaLen;
907
908 while( (aIn.GetRecPos() < nEndPos) && !bError )
909 {
910 nOp = aIn.ReaduInt8();
911 std::size_t nIgnore = 0;
912
913 // always reset flags
914 aSRD.InitFlags();
915 aCRD.InitFlags();
916
917 switch( nOp ) // book page:
918 { // SDK4 SDK5
919 case 0x01: // Array Formula [325 ]
920 // Array Formula or Shared Formula [ 277]
921 nIgnore = (meBiff == EXC_BIFF2) ? 3 : 4;
922 break;
923 case 0x02: // Data Table [325 277]
924 nIgnore = (meBiff == EXC_BIFF2) ? 3 : 4;
925 break;
926 case 0x03: // Addition [312 264]
927 case 0x04: // Subtraction [313 264]
928 case 0x05: // Multiplication [313 264]
929 case 0x06: // Division [313 264]
930 case 0x07: // Exponetiation [313 265]
931 case 0x08: // Concatenation [313 265]
932 case 0x09: // Less Than [313 265]
933 case 0x0A: // Less Than or Equal [313 265]
934 case 0x0B: // Equal [313 265]
935 case 0x0C: // Greater Than or Equal [313 265]
936 case 0x0D: // Greater Than [313 265]
937 case 0x0E: // Not Equal [313 265]
938 case 0x0F: // Intersection [314 265]
939 case 0x10: // Union [314 265]
940 case 0x11: // Range [314 265]
941 case 0x12: // Unary Plus [312 264]
942 case 0x13: // Unary Minus [312 264]
943 case 0x14: // Percent Sign [312 264]
944 case 0x15: // Parenthesis [326 278]
945 case 0x16: // Missing Argument [314 266]
946 break;
947 case 0x17: // String Constant [314 266]
948 nLen = aIn.ReaduInt8();
949 nIgnore = nLen;
950 break;
951 case 0x19: // Special Attribute [327 279]
952 {
953 sal_uInt16 nData(0), nFactor(0);
954
955 sal_uInt8 nOpt = aIn.ReaduInt8();
956
957 if( meBiff == EXC_BIFF2 )
958 {
959 nData = aIn.ReaduInt8();
960 nFactor = 1;
961 }
962 else
963 {
964 nData = aIn.ReaduInt16();
965 nFactor = 2;
966 }
967
968 if( nOpt & 0x04 )
969 {
970 // nFactor -> skip bytes or words AttrChoose
971 ++nData;
972 aIn.Ignore(static_cast<std::size_t>(nData) * nFactor);
973 }
974 }
975 break;
976 case 0x1A: // External Reference [330 ]
977 switch( meBiff )
978 {
979 case EXC_BIFF2: nIgnore = 7; break;
980 case EXC_BIFF3:
981 case EXC_BIFF4: nIgnore = 10; break;
982 case EXC_BIFF5: SAL_INFO( "sc", "-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
983 [[fallthrough]];
984 default: SAL_INFO( "sc", "-ExcelToSc::Convert(): A little oblivious?" );
985 }
986 break;
987 case 0x1B: // End External Reference [330 ]
988 switch( meBiff )
989 {
990 case EXC_BIFF2: nIgnore = 3; break;
991 case EXC_BIFF3:
992 case EXC_BIFF4: nIgnore = 4; break;
993 case EXC_BIFF5: SAL_INFO( "sc", "-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
994 [[fallthrough]];
995 default: SAL_INFO( "sc", "-ExcelToSc::Convert(): A little oblivious?" );
996 }
997 break;
998 case 0x1C: // Error Value [314 266]
999 case 0x1D: // Boolean [315 266]
1000 nIgnore = 1;
1001 break;
1002 case 0x1E: // Integer [315 266]
1003 nIgnore = 2;
1004 break;
1005 case 0x1F: // Number [315 266]
1006 nIgnore = 8;
1007 break;
1008 case 0x40:
1009 case 0x60:
1010 case 0x20: // Array Constant [317 268]
1011 nIgnore = (meBiff == EXC_BIFF2) ? 6 : 7;
1012 break;
1013 case 0x41:
1014 case 0x61:
1015 case 0x21: // Function, Fixed Number of Arguments [333 282]
1016 nIgnore = (meBiff <= EXC_BIFF3) ? 1 : 2;
1017 break;
1018 case 0x42:
1019 case 0x62:
1020 case 0x22: // Function, Variable Number of Arg. [333 283]
1021 nIgnore = (meBiff <= EXC_BIFF3) ? 2 : 3;
1022 break;
1023 case 0x43:
1024 case 0x63:
1025 case 0x23: // Name [318 269]
1026 switch( meBiff )
1027 {
1028 case EXC_BIFF2: nIgnore = 7; break;
1029 case EXC_BIFF3:
1030 case EXC_BIFF4: nIgnore = 10; break;
1031 case EXC_BIFF5: nIgnore = 14; break;
1032 default: OSL_FAIL( "-ExcelToSc::Convert(): A little oblivious?" );
1033 }
1034 break;
1035 case 0x44:
1036 case 0x64:
1037 case 0x24: // Cell Reference [319 270]
1038 {
1039 sal_uInt16 nUINT16 = aIn.ReaduInt16();
1040 sal_uInt8 nByte = aIn.ReaduInt8();
1041 aSRD.SetAbsCol(static_cast<SCCOL>(nByte));
1042 aSRD.SetAbsRow(nUINT16 & 0x3FFF);
1043 aSRD.SetRelTab(0);
1044 aSRD.SetFlag3D( bRangeName );
1045
1046 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
1047
1048 rRangeList.Append(aSRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1049 break;
1050 }
1051 case 0x45:
1052 case 0x65:
1053 case 0x25: // Area Reference [320 270]
1054 {
1055 sal_uInt16 nRowFirst, nRowLast;
1056 sal_uInt8 nColFirst, nColLast;
1057 ScSingleRefData &rSRef1 = aCRD.Ref1;
1058 ScSingleRefData &rSRef2 = aCRD.Ref2;
1059
1060 nRowFirst = aIn.ReaduInt16();
1061 nRowLast = aIn.ReaduInt16();
1062 nColFirst = aIn.ReaduInt8();
1063 nColLast = aIn.ReaduInt8();
1064
1065 rSRef1.SetRelTab(0);
1066 rSRef2.SetRelTab(0);
1067 rSRef1.SetFlag3D( bRangeName );
1068 rSRef2.SetFlag3D( bRangeName );
1069
1070 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
1071 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
1072
1073 if( IsComplColRange( nColFirst, nColLast ) )
1074 SetComplCol( aCRD );
1075 else if( IsComplRowRange( nRowFirst, nRowLast ) )
1076 SetComplRow( aCRD );
1077
1078 rRangeList.Append(aCRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1079 }
1080 break;
1081 case 0x46:
1082 case 0x66:
1083 case 0x26: // Constant Reference Subexpression [321 271]
1084 case 0x47:
1085 case 0x67:
1086 case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
1087 case 0x48:
1088 case 0x68:
1089 case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
1090 nIgnore = (meBiff == EXC_BIFF2) ? 4 : 6;
1091 break;
1092 case 0x4A:
1093 case 0x6A:
1094 case 0x2A: // Deleted Cell Reference [323 273]
1095 nIgnore = 3;
1096 break;
1097 case 0x4B:
1098 case 0x6B:
1099 case 0x2B: // Deleted Area Reference [323 273]
1100 nIgnore = 6;
1101 break;
1102 case 0x4C:
1103 case 0x6C:
1104 case 0x2C: // Cell Reference Within a Name [323 ]
1105 // Cell Reference Within a Shared Formula[ 273]
1106 {
1107 sal_uInt16 nUINT16 = aIn.ReaduInt16();
1108 sal_uInt8 nByte = aIn.ReaduInt8(); // >> Attribute, Row >> Col
1109
1110 aSRD.SetRelTab(0);
1111 aSRD.SetFlag3D( bRangeName );
1112
1113 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
1114
1115 rRangeList.Append(aSRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1116 break;
1117 }
1118 case 0x4D:
1119 case 0x6D:
1120 case 0x2D: // Area Reference Within a Name [324 ]
1121 { // Area Reference Within a Shared Formula[ 274]
1122 sal_uInt16 nRowFirst, nRowLast;
1123 sal_uInt8 nColFirst, nColLast;
1124
1125 aCRD.Ref1.SetRelTab(0);
1126 aCRD.Ref2.SetRelTab(0);
1127 aCRD.Ref1.SetFlag3D( bRangeName );
1128 aCRD.Ref2.SetFlag3D( bRangeName );
1129
1130 nRowFirst = aIn.ReaduInt16();
1131 nRowLast = aIn.ReaduInt16();
1132 nColFirst = aIn.ReaduInt8();
1133 nColLast = aIn.ReaduInt8();
1134
1135 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRNorSF );
1136 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRNorSF );
1137
1138 if( IsComplColRange( nColFirst, nColLast ) )
1139 SetComplCol( aCRD );
1140 else if( IsComplRowRange( nRowFirst, nRowLast ) )
1141 SetComplRow( aCRD );
1142
1143 rRangeList.Append(aCRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1144 }
1145 break;
1146 case 0x49:
1147 case 0x69:
1148 case 0x29: // Variable Reference Subexpression [331 281]
1149 case 0x4E:
1150 case 0x6E:
1151 case 0x2E: // Reference Subexpression Within a Name [332 282]
1152 case 0x4F:
1153 case 0x6F:
1154 case 0x2F: // Incomplete Reference Subexpression... [332 282]
1155 nIgnore = (meBiff == EXC_BIFF2) ? 1 : 2;
1156 break;
1157 case 0x58:
1158 case 0x78:
1159 case 0x38: // Command-Equivalent Function [333 ]
1160 nIgnore = 2;
1161 break;
1162 case 0x59:
1163 case 0x79:
1164 case 0x39: // Name or External Name [ 275]
1165 nIgnore = 24;
1166 break;
1167 case 0x5A:
1168 case 0x7A:
1169 case 0x3A: // 3-D Cell Reference [ 275]
1170 {
1171 sal_uInt16 nTabFirst, nTabLast, nRow;
1172 sal_Int16 nExtSheet;
1173 sal_uInt8 nCol;
1174
1175 nExtSheet = aIn.ReadInt16();
1176 aIn.Ignore( 8 );
1177 nTabFirst = aIn.ReaduInt16();
1178 nTabLast = aIn.ReaduInt16();
1179 nRow = aIn.ReaduInt16();
1180 nCol = aIn.ReaduInt8();
1181
1182 if( nExtSheet >= 0 )
1183 // from external
1184 {
1185 if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
1186 {
1187 nTabFirst = nTabLast;
1188 nExtSheet = 0; // found
1189 }
1190 else
1191 {
1192 aPool << ocBad;
1193 aPool >> aStack;
1194 nExtSheet = 1; // don't create a SingleRef
1195 }
1196 }
1197
1198 if( nExtSheet <= 0 )
1199 {// in current Workbook
1200 bool b3D = ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName;
1201 aSRD.SetAbsTab(nTabFirst);
1202 aSRD.SetFlag3D( b3D );
1203
1204 ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
1205
1206 if( nTabLast != nTabFirst )
1207 {
1208 aCRD.Ref1 = aSRD;
1209 aCRD.Ref2 = aSRD;
1210 aCRD.Ref2.SetAbsTab(static_cast<SCTAB>(nTabLast));
1211 b3D = ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() );
1212 aCRD.Ref2.SetFlag3D( b3D );
1213 rRangeList.Append(aCRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1214 }
1215 else
1216 rRangeList.Append(aSRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1217 }
1218 }
1219
1220 break;
1221 case 0x5B:
1222 case 0x7B:
1223 case 0x3B: // 3-D Area Reference [ 276]
1224 {
1225 sal_uInt16 nTabFirst, nTabLast, nRowFirst, nRowLast;
1226 sal_Int16 nExtSheet;
1227 sal_uInt8 nColFirst, nColLast;
1228
1229 nExtSheet = aIn.ReadInt16();
1230 aIn.Ignore( 8 );
1231 nTabFirst = aIn.ReaduInt16();
1232 nTabLast = aIn.ReaduInt16();
1233 nRowFirst = aIn.ReaduInt16();
1234 nRowLast = aIn.ReaduInt16();
1235 nColFirst = aIn.ReaduInt8();
1236 nColLast = aIn.ReaduInt8();
1237
1238 if( nExtSheet >= 0 )
1239 // from external
1240 {
1241 if( rR.pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
1242 {
1243 nTabFirst = nTabLast;
1244 nExtSheet = 0; // found
1245 }
1246 else
1247 {
1248 aPool << ocBad;
1249 aPool >> aStack;
1250 nExtSheet = 1; // don't create a CompleteRef
1251 }
1252 }
1253
1254 if( nExtSheet <= 0 )
1255 {// in current Workbook
1256 // first part of range
1257 ScSingleRefData &rR1 = aCRD.Ref1;
1258 ScSingleRefData &rR2 = aCRD.Ref2;
1259
1260 rR1.SetAbsTab(nTabFirst);
1261 rR2.SetAbsTab(nTabLast);
1262 rR1.SetFlag3D( ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName );
1263 rR2.SetFlag3D( ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() ) || bRangeName );
1264
1265 ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
1266 ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
1267
1268 if( IsComplColRange( nColFirst, nColLast ) )
1269 SetComplCol( aCRD );
1270 else if( IsComplRowRange( nRowFirst, nRowLast ) )
1271 SetComplRow( aCRD );
1272
1273 rRangeList.Append(aCRD.toAbs(GetDocImport().getDoc(), aEingPos), nTab);
1274 }//END in current Workbook
1275 }
1276 break;
1277 case 0x5C:
1278 case 0x7C:
1279 case 0x3C: // Deleted 3-D Cell Reference [ 277]
1280 nIgnore = 17;
1281 break;
1282 case 0x5D:
1283 case 0x7D:
1284 case 0x3D: // Deleted 3-D Area Reference [ 277]
1285 nIgnore = 20;
1286 break;
1287 default: bError = true;
1288 }
1289 bError |= !aIn.IsValid();
1290
1291 aIn.Ignore( nIgnore );
1292 }
1293
1294 ConvErr eRet;
1295
1296 if( bError )
1297 eRet = ConvErr::Ni;
1298 else if( aIn.GetRecPos() != nEndPos )
1299 eRet = ConvErr::Count;
1300 else
1301 eRet = ConvErr::OK;
1302
1303 aIn.Seek( nEndPos );
1304 return eRet;
1305}
1306
1307void ExcelToSc::ConvertExternName( std::unique_ptr<ScTokenArray>& /*rpArray*/, XclImpStream& /*rStrm*/, std::size_t /*nFormulaLen*/,
1308 const OUString& /*rUrl*/, const vector<OUString>& /*rTabNames*/ )
1309{
1310}
1311
1312void ExcelToSc::GetAbsRefs( ScRangeList& rRangeList, XclImpStream& rStrm, std::size_t nLen )
1313{
1315 if( GetBiff() != EXC_BIFF5 )
1316 return;
1317
1318 sal_uInt8 nOp;
1319 sal_uInt16 nRow1, nRow2;
1320 sal_uInt8 nCol1, nCol2;
1321 SCTAB nTab1, nTab2;
1322 sal_uInt16 nTabFirst, nTabLast;
1323 sal_Int16 nRefIdx;
1324
1325 std::size_t nSeek;
1326 std::size_t nEndPos = rStrm.GetRecPos() + nLen;
1327
1328 while( rStrm.IsValid() && (rStrm.GetRecPos() < nEndPos) )
1329 {
1330 nOp = rStrm.ReaduInt8();
1331 nSeek = 0;
1332
1333 switch( nOp )
1334 {
1335 case 0x44:
1336 case 0x64:
1337 case 0x24: // Cell Reference [319 270]
1338 case 0x4C:
1339 case 0x6C:
1340 case 0x2C: // Cell Reference Within a Name [323 ]
1341 // Cell Reference Within a Shared Formula[ 273]
1342 nRow1 = rStrm.ReaduInt16();
1343 nCol1 = rStrm.ReaduInt8();
1344
1345 nRow2 = nRow1;
1346 nCol2 = nCol1;
1347 nTab1 = nTab2 = GetCurrScTab();
1348 goto _common;
1349 case 0x45:
1350 case 0x65:
1351 case 0x25: // Area Reference [320 270]
1352 case 0x4D:
1353 case 0x6D:
1354 case 0x2D: // Area Reference Within a Name [324 ]
1355 // Area Reference Within a Shared Formula[ 274]
1356 nRow1 = rStrm.ReaduInt16();
1357 nRow2 = rStrm.ReaduInt16();
1358 nCol1 = rStrm.ReaduInt8();
1359 nCol2 = rStrm.ReaduInt8();
1360
1361 nTab1 = nTab2 = GetCurrScTab();
1362 goto _common;
1363 case 0x5A:
1364 case 0x7A:
1365 case 0x3A: // 3-D Cell Reference [ 275]
1366 nRefIdx = rStrm.ReadInt16();
1367 rStrm.Ignore( 8 );
1368 nTabFirst = rStrm.ReaduInt16();
1369 nTabLast = rStrm.ReaduInt16();
1370 nRow1 = rStrm.ReaduInt16();
1371 nCol1 = rStrm.ReaduInt8();
1372
1373 nRow2 = nRow1;
1374 nCol2 = nCol1;
1375
1376 goto _3d_common;
1377 case 0x5B:
1378 case 0x7B:
1379 case 0x3B: // 3-D Area Reference [ 276]
1380 nRefIdx = rStrm.ReadInt16();
1381 rStrm.Ignore( 8 );
1382 nTabFirst = rStrm.ReaduInt16();
1383 nTabLast = rStrm.ReaduInt16();
1384 nRow1 = rStrm.ReaduInt16();
1385 nRow2 = rStrm.ReaduInt16();
1386 nCol1 = rStrm.ReaduInt8();
1387 nCol2 = rStrm.ReaduInt8();
1388
1389 _3d_common:
1390 nTab1 = static_cast< SCTAB >( nTabFirst );
1391 nTab2 = static_cast< SCTAB >( nTabLast );
1392
1393 // skip references to deleted sheets
1394 if( (nRefIdx >= 0) || !ValidTab( nTab1 ) || (nTab1 != nTab2) )
1395 break;
1396
1397 goto _common;
1398 _common:
1399 // do not check abs/rel flags, linked controls have set them!
1400 {
1401 ScRange aScRange;
1402 nRow1 &= 0x3FFF;
1403 nRow2 &= 0x3FFF;
1404 if( GetAddressConverter().ConvertRange( aScRange, XclRange( nCol1, nRow1, nCol2, nRow2 ), nTab1, nTab2, true ) )
1405 rRangeList.push_back( aScRange );
1406 }
1407 break;
1408
1409 case 0x03: // Addition [312 264]
1410 case 0x04: // Subtraction [313 264]
1411 case 0x05: // Multiplication [313 264]
1412 case 0x06: // Division [313 264]
1413 case 0x07: // Exponetiation [313 265]
1414 case 0x08: // Concatenation [313 265]
1415 case 0x09: // Less Than [313 265]
1416 case 0x0A: // Less Than or Equal [313 265]
1417 case 0x0B: // Equal [313 265]
1418 case 0x0C: // Greater Than or Equal [313 265]
1419 case 0x0D: // Greater Than [313 265]
1420 case 0x0E: // Not Equal [313 265]
1421 case 0x0F: // Intersection [314 265]
1422 case 0x10: // Union [314 265]
1423 case 0x11: // Range [314 265]
1424 case 0x12: // Unary Plus [312 264]
1425 case 0x13: // Unary Minus [312 264]
1426 case 0x14: // Percent Sign [312 264]
1427 case 0x15: // Parenthesis [326 278]
1428 case 0x16: // Missing Argument [314 266]
1429 break;
1430 case 0x1C: // Error Value [314 266]
1431 case 0x1D: // Boolean [315 266]
1432 nSeek = 1;
1433 break;
1434 case 0x1E: // Integer [315 266]
1435 case 0x41:
1436 case 0x61:
1437 case 0x21: // Function, Fixed Number of Arguments [333 282]
1438 case 0x49:
1439 case 0x69:
1440 case 0x29: // Variable Reference Subexpression [331 281]
1441 case 0x4E:
1442 case 0x6E:
1443 case 0x2E: // Reference Subexpression Within a Name [332 282]
1444 case 0x4F:
1445 case 0x6F:
1446 case 0x2F: // Incomplete Reference Subexpression... [332 282]
1447 case 0x58:
1448 case 0x78:
1449 case 0x38: // Command-Equivalent Function [333 ]
1450 nSeek = 2;
1451 break;
1452 case 0x42:
1453 case 0x62:
1454 case 0x22: // Function, Variable Number of Arg. [333 283]
1455 case 0x4A:
1456 case 0x6A:
1457 case 0x2A: // Deleted Cell Reference [323 273]
1458 nSeek = 3;
1459 break;
1460 case 0x01: // Array Formula [325 ]
1461 // Array Formula or Shared Formula [ 277]
1462 case 0x02: // Data Table [325 277]
1463 nSeek = 4;
1464 break;
1465 case 0x46:
1466 case 0x66:
1467 case 0x26: // Constant Reference Subexpression [321 271]
1468 case 0x47:
1469 case 0x67:
1470 case 0x27: // Erroneous Constant Reference Subexpr. [322 272]
1471 case 0x48:
1472 case 0x68:
1473 case 0x28: // Incomplete Constant Reference Subexpr.[331 281]
1474 case 0x4B:
1475 case 0x6B:
1476 case 0x2B: // Deleted Area Reference [323 273]
1477 nSeek = 6;
1478 break;
1479 case 0x40:
1480 case 0x60:
1481 case 0x20: // Array Constant [317 268]
1482 nSeek = 7;
1483 break;
1484 case 0x1F: // Number [315 266]
1485 nSeek = 8;
1486 break;
1487 case 0x43:
1488 case 0x63:
1489 case 0x23: // Name [318 269]
1490 nSeek = 14;
1491 break;
1492 case 0x5C:
1493 case 0x7C:
1494 case 0x3C: // Deleted 3-D Cell Reference [ 277]
1495 nSeek = 17;
1496 break;
1497 case 0x5D:
1498 case 0x7D:
1499 case 0x3D: // Deleted 3-D Area Reference [ 277]
1500 nSeek = 20;
1501 break;
1502 case 0x59:
1503 case 0x79:
1504 case 0x39: // Name or External Name [ 275]
1505 nSeek = 24;
1506 break;
1507 case 0x17: // String Constant [314 266]
1508 nSeek = rStrm.ReaduInt8();
1509 break;
1510 case 0x19: // Special Attribute [327 279]
1511 {
1512 sal_uInt8 nOpt;
1513 sal_uInt16 nData;
1514 nOpt = rStrm.ReaduInt8();
1515 nData = rStrm.ReaduInt16();
1516 if( nOpt & 0x04 )
1517 nSeek = nData * 2 + 2;
1518 }
1519 break;
1520 }
1521
1522 rStrm.Ignore( nSeek );
1523 }
1524 rStrm.Seek( nEndPos );
1525}
1526
1528{
1529 TokenId eParam[ 256 ];
1530 sal_Int32 nPass;
1531
1532 if( eId == ocCeil || eId == ocFloor )
1533 {
1534 aStack << aPool.Store( 1.0 ); // default, because not present in Excel
1535 nCnt++;
1536 }
1537
1538 for( nPass = 0; aStack.HasMoreTokens() && (nPass < nCnt); nPass++ )
1539 aStack >> eParam[ nPass ];
1540 // #i70925# reduce parameter count, if no more tokens available on token stack
1541 if( nPass < nCnt )
1542 nCnt = static_cast< sal_uInt8 >( nPass );
1543
1544 if( nCnt > 0 && eId == ocExternal )
1545 {
1546 TokenId n = eParam[ nCnt - 1 ];
1547//##### ADJUST STUPIDITY FOR BASIC-FUNCS!
1548 if( const OUString* pExt = aPool.GetExternal( n ) )
1549 {
1550 if( const XclFunctionInfo* pFuncInfo = maFuncProv.GetFuncInfoFromXclMacroName( *pExt ) )
1551 aPool << pFuncInfo->meOpCode;
1552 else
1553 aPool << n;
1554 nCnt--;
1555 }
1556 else
1557 aPool << eId;
1558 }
1559 else
1560 aPool << eId;
1561
1562 aPool << ocOpen;
1563
1564 if( nCnt > 0 )
1565 {
1566 // attention: 0 = last parameter, nCnt-1 = first parameter
1567 sal_Int16 nSkipEnd = -1; // skip all parameters <= nSkipEnd
1568
1569 sal_Int16 nLast = nCnt - 1;
1570
1571 // functions for which parameters have to be skipped
1572 if( eId == ocPercentrank && nCnt == 3 )
1573 nSkipEnd = 0; // skip last parameter if necessary
1574
1575 // Joost special cases
1576 else if( eId == ocIf )
1577 {
1578 sal_uInt16 nNullParam = 0;
1579 for( nPass = 0 ; nPass < nCnt ; nPass++ )
1580 {
1581 if( aPool.IsSingleOp( eParam[ nPass ], ocMissing ) )
1582 {
1583 if( !nNullParam )
1584 nNullParam = static_cast<sal_uInt16>(aPool.Store( 0.0 ));
1585 eParam[ nPass ] = nNullParam;
1586 }
1587 }
1588 }
1589
1590 // [Parameter{;Parameter}]
1591 if( nLast > nSkipEnd )
1592 {
1593 // nSkipEnd is either 0 or -1 => nLast >= 0
1594 aPool << eParam[ nLast ];
1595 for( nPass = nLast - 1 ; nPass > nSkipEnd ; nPass-- )
1596 {
1597 // nPass > nSkipEnd => nPass >= 0
1598 aPool << ocSep << eParam[nPass];
1599 }
1600 }
1601 }
1602 aPool << ocClose;
1603
1604 aPool >> aStack;
1605}
1606
1607void ExcelToSc::ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &rSRD, const bool bName )
1608{
1609 if( bName )
1610 {
1611 // C O L
1612 if( nRow & 0x4000 )
1613 rSRD.SetRelCol(nCol);
1614 else
1615 rSRD.SetAbsCol(nCol);
1616
1617 // R O W
1618 if( nRow & 0x8000 )
1619 {// rel Row
1620 if( nRow & 0x2000 ) // Bit 13 set?
1621 // Row negative
1622 rSRD.SetRelRow(nRow | 0xC000);
1623 else
1624 // Row positive
1625 rSRD.SetRelRow(nRow & nRowMask);
1626 }
1627 else
1628 {// abs Row
1629 rSRD.SetAbsRow(nRow & nRowMask);
1630 }
1631
1632 // T A B
1633 // abs needed if rel in shared formula for ScCompiler UpdateNameReference
1634 if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
1635 rSRD.SetAbsTab(GetCurrScTab());
1636 }
1637 else
1638 {
1639 bool bColRel = (nRow & 0x4000) > 0;
1640 bool bRowRel = (nRow & 0x8000) > 0;
1641
1642 if (bColRel)
1643 rSRD.SetRelCol(nCol - aEingPos.Col());
1644 else
1645 rSRD.SetAbsCol(nCol);
1646
1647 rSRD.SetAbsRow(nRow & nRowMask);
1648 if (bRowRel)
1649 rSRD.SetRelRow(rSRD.Row() - aEingPos.Row());
1650
1651 // T A B
1652 // #i10184# abs needed if rel in shared formula for ScCompiler UpdateNameReference
1653 if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
1654 rSRD.SetAbsTab(GetCurrScTab() + rSRD.Tab());
1655 }
1656}
1657
1658std::unique_ptr<ScTokenArray> ExcelToSc::GetBoolErr( XclBoolError eType )
1659{
1660 FormulaError nError;
1661 aPool.Reset();
1662 aStack.Reset();
1663
1664 DefTokenId eOc;
1665
1666 switch( eType )
1667 {
1668 case xlErrNull: eOc = ocStop; nError = FormulaError::NoCode; break;
1669 case xlErrDiv0: eOc = ocStop; nError = FormulaError::DivisionByZero; break;
1670 case xlErrValue: eOc = ocStop; nError = FormulaError::NoValue; break;
1671 case xlErrRef: eOc = ocStop; nError = FormulaError::NoRef; break;
1672 case xlErrName: eOc = ocStop; nError = FormulaError::NoName; break;
1673 case xlErrNum: eOc = ocStop; nError = FormulaError::IllegalFPOperation; break;
1674 case xlErrNA: eOc = ocNotAvail; nError = FormulaError::NotAvailable; break;
1675 case xlErrTrue: eOc = ocTrue; nError = FormulaError::NONE; break;
1676 case xlErrFalse: eOc = ocFalse; nError = FormulaError::NONE; break;
1677 case xlErrUnknown: eOc = ocStop; nError = FormulaError::UnknownState; break;
1678 default:
1679 OSL_FAIL( "ExcelToSc::GetBoolErr - wrong enum!" );
1680 eOc = ocNoName;
1681 nError = FormulaError::UnknownState;
1682 }
1683
1684 aPool << eOc;
1685 if( eOc != ocStop )
1686 aPool << ocOpen << ocClose;
1687
1688 aPool >> aStack;
1689
1690 std::unique_ptr<ScTokenArray> pResult = aPool.GetTokenArray( GetDocImport().getDoc(), aStack.Get());
1691 if( nError != FormulaError::NONE )
1692 pResult->SetCodeError( nError );
1693
1694 pResult->SetExclusiveRecalcModeNormal();
1695
1696 return pResult;
1697}
1698
1700{
1701 rStrm.PushPosition();
1702
1703 sal_uInt8 nOp;
1704 nOp = rStrm.ReaduInt8();
1705
1706 if (nOp != 0x01) // must be PtgExp token.
1707 {
1708 rStrm.PopPosition();
1709 return false;
1710 }
1711
1712 sal_uInt16 nRow, nCol;
1713 nRow = rStrm.ReaduInt16();
1714 nCol = rStrm.ReaduInt16();
1715 rStrm.PopPosition();
1716 rCol = nCol;
1717 rRow = nRow;
1718 return true;
1719}
1720
1722{
1723 return GetOldRoot().pShrfmlaBuff->Find(rRefPos);
1724}
1725
1727{
1728 FormulaError nInd;
1729
1730 switch( eErr )
1731 {
1732 case ConvErr::Ni: nInd = FormulaError::UnknownToken; break;
1733 case ConvErr::Count: nInd = FormulaError::CodeOverflow; break;
1734 default: nInd = FormulaError::NoCode; // I had no better idea
1735 }
1736
1737 rCell.SetErrCode( nInd );
1738}
1739
1741{
1742 ScSingleRefData &rSRD = rCRD.Ref2;
1743 ScDocument& rDoc = GetDocImport().getDoc();
1744 if( rSRD.IsColRel() )
1745 rSRD.SetRelCol(rDoc.MaxCol() - aEingPos.Col());
1746 else
1747 rSRD.SetAbsCol(rDoc.MaxCol());
1748}
1749
1751{
1752 ScSingleRefData &rSRD = rCRD.Ref2;
1753 ScDocument& rDoc = GetDocImport().getDoc();
1754 if( rSRD.IsRowRel() )
1755 rSRD.SetRelRow(rDoc.MaxRow() - aEingPos.Row());
1756 else
1757 rSRD.SetAbsRow(rDoc.MaxRow());
1758}
1759
1761{
1762 sal_uInt8 nByte = aIn.ReaduInt8();
1763 sal_uInt16 nUINT16 = aIn.ReaduInt16();
1764
1765 SCSIZE nC, nCols;
1766 SCSIZE nR, nRows;
1767 if( GetBiff() == EXC_BIFF8 )
1768 {
1769 nCols = nByte + 1;
1770 nRows = nUINT16 + 1;
1771 }
1772 else
1773 {
1774 nCols = nByte ? nByte : 256;
1775 nRows = nUINT16;
1776 }
1777
1778 ScMatrix* pMatrix = aPool.GetMatrix( n );
1779
1780 if( nullptr != pMatrix )
1781 {
1782 pMatrix->Resize(nCols, nRows);
1783 pMatrix->GetDimensions( nC, nR);
1784 if( nC != nCols || nR != nRows )
1785 {
1786 OSL_FAIL( "ExcelToSc::ReadExtensionArray - matrix size mismatch" );
1787 pMatrix = nullptr;
1788 }
1789 }
1790 else
1791 {
1792 OSL_FAIL( "ExcelToSc::ReadExtensionArray - missing matrix" );
1793 }
1794
1795 //assuming worst case scenario of unknown types
1796 const size_t nMinRecordSize = 1;
1797 const size_t nMaxRows = aIn.GetRecLeft() / (nMinRecordSize * nCols);
1798 if (nRows > nMaxRows)
1799 {
1800 SAL_WARN("sc", "Parsing error: " << nMaxRows <<
1801 " max possible rows, but " << nRows << " claimed, truncating");
1802 nRows = nMaxRows;
1803 }
1804
1806 for( nR = 0 ; nR < nRows; nR++ )
1807 {
1808 for( nC = 0 ; nC < nCols; nC++ )
1809 {
1810 nByte = aIn.ReaduInt8();
1811 switch( nByte )
1812 {
1814 aIn.Ignore( 8 );
1815 if( nullptr != pMatrix )
1816 {
1817 pMatrix->PutEmpty( nC, nR );
1818 }
1819 break;
1820
1822 {
1823 double fDouble = aIn.ReadDouble();
1824 if( nullptr != pMatrix )
1825 {
1826 pMatrix->PutDouble( fDouble, nC, nR );
1827 }
1828 break;
1829 }
1831 {
1832 OUString aString;
1833 if( GetBiff() == EXC_BIFF8 )
1834 {
1835 nUINT16 = aIn.ReaduInt16();
1836 aString = aIn.ReadUniString( nUINT16 );
1837 }
1838 else
1839 {
1840 nByte = aIn.ReaduInt8();
1841 aString = aIn.ReadRawByteString( nByte );
1842 }
1843 if( nullptr != pMatrix )
1844 {
1845 pMatrix->PutString(rPool.intern(aString), nC, nR);
1846 }
1847 break;
1848 }
1849 case EXC_CACHEDVAL_BOOL:
1850 nByte = aIn.ReaduInt8();
1851 aIn.Ignore( 7 );
1852 if( nullptr != pMatrix )
1853 {
1854 pMatrix->PutBoolean( nByte != 0, nC, nR );
1855 }
1856 break;
1857
1859 nByte = aIn.ReaduInt8();
1860 aIn.Ignore( 7 );
1861 if( nullptr != pMatrix )
1862 {
1863 pMatrix->PutError( XclTools::GetScErrorCode( nByte ), nC, nR );
1864 }
1865 break;
1866 }
1867 }
1868 }
1869}
1870
1872{
1873 sal_uInt32 nFlags;
1874 nFlags = aIn.ReaduInt32();
1875
1876 sal_uInt32 nCount = nFlags & EXC_TOK_NLR_ADDMASK;
1877 aIn.Ignore( nCount * 4 ); // Drop the cell positions
1878}
1879
1881{
1882 sal_uInt16 nCount = aIn.ReaduInt16();
1883
1884 aIn.Ignore( static_cast<std::size_t>(nCount) * ((GetBiff() == EXC_BIFF8) ? 8 : 6) ); // drop the ranges
1885}
1886
1888 XclImpStream& aIn )
1889{
1890 unsigned int nArray = 0;
1891
1892 for(int eType : rExtensions)
1893 {
1894 switch( eType )
1895 {
1896 case EXTENSION_ARRAY:
1897 ReadExtensionArray( nArray++, aIn );
1898 break;
1899
1900 case EXTENSION_NLR:
1901 ReadExtensionNlr( aIn );
1902 break;
1903
1904 case EXTENSION_MEMAREA:
1905 ReadExtensionMemArea( aIn );
1906 break;
1907 }
1908 }
1909}
1910
1911/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
bool ValidTab(SCTAB nTab)
Definition: address.hxx:111
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
ScAddress aEingPos
Definition: formel.hxx:81
TokenPool aPool
Definition: formel.hxx:79
TokenStack aStack
Definition: formel.hxx:80
void ExcRelToScRel(sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &, const bool bName)
Definition: excform.cxx:1607
void ReadExtensions(const ExtensionTypeVec &rExtensions, XclImpStream &aIn)
Definition: excform.cxx:1887
void ReadExtensionArray(unsigned int n, XclImpStream &aIn)
Definition: excform.cxx:1760
static bool IsComplRowRange(const sal_uInt16 nRow1, const sal_uInt16 nRow2)
Definition: excform.hxx:87
std::unique_ptr< ScTokenArray > GetDummy()
Definition: excform.cxx:191
@ EXTENSION_MEMAREA
Definition: excform.hxx:35
@ EXTENSION_NLR
Definition: excform.hxx:35
@ EXTENSION_ARRAY
Definition: excform.hxx:35
static bool ReadSharedFormulaPosition(XclImpStream &rStrm, SCCOL &rCol, SCROW &rRow)
Definition: excform.cxx:1699
const XclBiff meBiff
Definition: excform.hxx:41
virtual ~ExcelToSc() override
Definition: excform.cxx:187
static void SetError(ScFormulaCell &rCell, const ConvErr eErr)
Definition: excform.cxx:1726
virtual void GetAbsRefs(ScRangeList &rRangeList, XclImpStream &rStrm, std::size_t nLen)
Definition: excform.cxx:1312
::std::vector< ExtensionType > ExtensionTypeVec
Definition: excform.hxx:36
XclFunctionProvider maFuncProv
Definition: excform.hxx:40
void DoMulArgs(DefTokenId eId, sal_uInt8 nNumArgs)
Definition: excform.cxx:1527
void SetComplCol(ScComplexRefData &)
Definition: excform.cxx:1740
static bool IsComplColRange(const sal_uInt16 nCol1, const sal_uInt16 nCol2)
Definition: excform.hxx:82
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
Definition: excform.cxx:201
std::unique_ptr< ScTokenArray > GetBoolErr(XclBoolError)
Definition: excform.cxx:1658
ExcelToSc(XclImpRoot &rRoot)
Definition: excform.cxx:179
void ReadExtensionMemArea(XclImpStream &aIn)
Definition: excform.cxx:1880
const ScTokenArray * GetSharedFormula(const ScAddress &rRefPos) const
Definition: excform.cxx:1721
virtual void ConvertExternName(std::unique_ptr< ScTokenArray > &rpArray, XclImpStream &rStrm, std::size_t nFormulaLen, const OUString &rUrl, const ::std::vector< OUString > &rTabNames)
Definition: excform.cxx:1307
void SetComplRow(ScComplexRefData &)
Definition: excform.cxx:1750
static void ReadExtensionNlr(XclImpStream &aIn)
Definition: excform.cxx:1871
static const sal_uInt16 nRowMask
Definition: excform.hxx:38
void Formula4()
Definition: excform.cxx:82
void Formula25()
Definition: excform.cxx:43
void Formula3()
Definition: excform.cxx:77
XclImpStream maStrm
Definition: imp_op.hxx:89
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
Definition: imp_op.hxx:95
void Formula(const XclAddress &rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
Definition: excform.cxx:95
XclImpStream & aIn
Definition: imp_op.hxx:90
void SetLastFormula(SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell *pCell)
True if fuzzing filter.
Definition: impop.cxx:142
ScDocument & rD
Definition: imp_op.hxx:46
@ UNINITIALIZED
Definition: address.hxx:220
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
Accessor class to ScDocument.
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
ScDocument & getDoc()
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:892
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
Definition: documen2.cxx:577
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
Definition: documen8.cxx:1149
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:601
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Definition: document.cxx:3714
void SetErrCode(FormulaError n)
void SetResultDouble(double n)
For import only: set a double result.
void SetNeedNumberFormat(bool bVal)
void AddRecalcMode(ScRecalcMode)
ScTokenArray * GetCode()
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:101
void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
Definition: scmatrix.cxx:3213
void PutString(const svl::SharedString &rStr, SCSIZE nC, SCSIZE nR)
Definition: scmatrix.cxx:3183
void PutEmpty(SCSIZE nC, SCSIZE nR)
Definition: scmatrix.cxx:3198
void Resize(SCSIZE nC, SCSIZE nR)
Resize the matrix to specified new dimension.
Definition: scmatrix.cxx:3120
void PutDouble(double fVal, SCSIZE nC, SCSIZE nR)
Definition: scmatrix.cxx:3168
void PutError(FormulaError nErrorCode, SCSIZE nC, SCSIZE nR)
Definition: scmatrix.cxx:3208
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
Definition: scmatrix.cxx:3143
void Append(const ScAddress &aSRD, SCTAB nTab)
Definition: frmbase.cxx:33
void push_back(const ScRange &rRange)
Definition: rangelst.cxx:1137
std::unique_ptr< ScTokenArray > Clone() const
Definition: token.cxx:1931
void WrapReference(const ScAddress &rPos, SCCOL nMaxCol, SCROW nMaxRow)
Definition: token.cxx:5316
SvStream & ReadInt16(sal_Int16 &rInt16)
sal_uInt64 Seek(sal_uInt64 nPos)
TokenId StoreName(sal_uInt16 nIndex, sal_Int16 nSheet)
Definition: tokstack.cxx:601
bool IsSingleOp(const TokenId &rId, const DefTokenId eId) const
Definition: tokstack.cxx:687
ScMatrix * GetMatrix(unsigned int n) const
Definition: tokstack.cxx:731
TokenId StoreMatrix()
Definition: tokstack.cxx:579
void Reset()
Definition: tokstack.cxx:675
TokenId Store()
Definition: tokstack.hxx:404
std::unique_ptr< ScTokenArray > GetTokenArray(const ScDocument &rDoc, const TokenId &rId)
Definition: tokstack.hxx:411
const OUString * GetExternal(const TokenId &rId) const
Definition: tokstack.cxx:713
bool HasMoreTokens() const
Definition: tokstack.hxx:277
void Reset()
Definition: tokstack.hxx:328
TokenId Get()
Definition: tokstack.hxx:281
const XclFunctionInfo * GetFuncInfoFromXclMacroName(const OUString &rXclMacroName) const
Returns the function data for an Excel function simulated by a macro call, or 0 on error.
Definition: xlformula.cxx:684
const XclFunctionInfo * GetFuncInfoFromXclFunc(sal_uInt16 nXclFunc) const
Returns the function data for an Excel function index, or 0 on error.
Definition: xlformula.cxx:676
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
Definition: xihelper.cxx:101
const XclImpName * GetName(sal_uInt16 nXclNameIdx) const
Returns the defined name specified by its Excel index.
Definition: xiname.cxx:317
Represents a defined name.
Definition: xiname.hxx:34
Access to global data from other classes.
Definition: xiroot.hxx:129
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xiroot.cxx:123
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
Definition: xiroot.cxx:165
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:294
XclImpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
Definition: xiroot.cxx:185
This class is used to import record oriented streams.
Definition: xistream.hxx:278
bool IsValid() const
Returns record reading state: false = record overread.
Definition: xistream.hxx:351
sal_Int16 ReadInt16()
Definition: xistream.cxx:631
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
Definition: xistream.cxx:564
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
Definition: xistream.cxx:781
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
Definition: xistream.cxx:582
sal_uInt8 ReaduInt8()
Definition: xistream.cxx:617
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:685
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
Definition: xistream.cxx:891
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
Definition: xistream.cxx:798
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:649
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
Definition: xistream.cxx:949
double ReadDouble()
Definition: xistream.cxx:703
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
Definition: xistyle.cxx:1926
XclTracer & GetTracer() const
Returns the filter tracer.
Definition: xlroot.cxx:434
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
Definition: xlroot.hxx:141
RootData & GetOldRoot() const
Returns old RootData struct.
Definition: xlroot.hxx:138
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
static FormulaError GetScErrorCode(sal_uInt8 nXclError)
Converts an Excel error code to a Calc error code.
Definition: xltools.cxx:226
void TraceFormulaMissingArg()
Definition: xltracer.cxx:80
SharedString intern(const OUString &rStr)
int nCount
FormulaError
DocumentType eType
ConvErr
Definition: formel.hxx:41
FORMULA_TYPE
Definition: formel.hxx:48
@ FT_CondFormat
Definition: formel.hxx:52
@ FT_RangeName
Definition: formel.hxx:50
@ FT_SharedFormula
Definition: formel.hxx:51
sal_Int64 n
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
void SvStream & rStrm
OpCode
ocNegSub
ocDiv
ocFalse
ocAmpersand
ocLessEqual
ocNotEqual
ocClose
ocFloor
ocMacro
ocPow
ocAdd
ocStop
ocPercentrank
ocRange
ocEqual
ocOpen
ocSub
ocGreater
ocCeil
ocTrue
ocExternal
ocPercentSign
ocSep
ocMissing
ocIntersect
ocPush
ocGreaterEqual
ocBad
ocLess
ocNoName
ocMul
ocNotAvail
ocIf
ocSum
std::unique_ptr< SharedFormulaBuffer > pShrfmlaBuff
Definition: root.hxx:47
std::unique_ptr< ExtSheetBuffer > pExtSheetBuff
Definition: root.hxx:46
Complex reference (a range) into the sheet.
Definition: refdata.hxx:123
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:493
void InitFlags()
Definition: refdata.hxx:128
ScSingleRefData Ref2
Definition: refdata.hxx:125
ScSingleRefData Ref1
Definition: refdata.hxx:124
Single reference (one address) into the sheet.
Definition: refdata.hxx:30
void SetAbsCol(SCCOL nVal)
Definition: refdata.cxx:59
void SetAbsTab(SCTAB nVal)
Definition: refdata.cxx:93
SCTAB Tab() const
Definition: refdata.cxx:254
bool IsTabRel() const
Definition: refdata.hxx:69
SCROW Row() const
Definition: refdata.cxx:240
void SetColDeleted(bool bVal)
Definition: refdata.cxx:110
void SetRelRow(SCROW nVal)
Definition: refdata.cxx:82
bool IsRowRel() const
Definition: refdata.hxx:67
void SetRelTab(SCTAB nVal)
Definition: refdata.cxx:99
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Definition: refdata.cxx:193
bool IsColRel() const
Definition: refdata.hxx:65
void SetAbsRow(SCROW nVal)
Definition: refdata.cxx:76
void SetRelCol(SCCOL nVal)
Definition: refdata.cxx:65
void SetFlag3D(bool bVal)
Definition: refdata.hxx:89
bool IsFlag3D() const
Definition: refdata.hxx:90
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
Definition: refdata.hxx:54
void SetRowDeleted(bool bVal)
Definition: refdata.cxx:115
void SetTabDeleted(bool bVal)
Definition: refdata.cxx:120
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
Represents information for a spreadsheet function for import and export.
Definition: xlformula.hxx:311
A 2D cell range address struct with Excel column and row indexes.
Definition: xladdress.hxx:59
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
const SCCOL EXC_MAXCOL8
Definition: xlconst.hxx:64
const sal_uInt8 EXC_ERR_NA
Definition: xlconst.hxx:110
const sal_uInt8 EXC_ERR_REF
Definition: xlconst.hxx:107
const sal_uInt8 EXC_ERR_NAME
Definition: xlconst.hxx:108
const sal_uInt8 EXC_ERR_NULL
DDE application-topic delimiter.
Definition: xlconst.hxx:104
const sal_uInt8 EXC_ERR_VALUE
Definition: xlconst.hxx:106
const sal_uInt8 EXC_CACHEDVAL_ERROR
Definition: xlconst.hxx:118
const sal_uInt8 EXC_CACHEDVAL_STRING
Definition: xlconst.hxx:116
const SCROW EXC_MAXROW8
Definition: xlconst.hxx:65
@ EXC_BIFF5
MS Excel 4.0.
Definition: xlconst.hxx:34
@ EXC_BIFF4
MS Excel 3.0.
Definition: xlconst.hxx:33
@ EXC_BIFF2
Definition: xlconst.hxx:31
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
Definition: xlconst.hxx:35
@ EXC_BIFF3
MS Excel 2.1.
Definition: xlconst.hxx:32
const sal_uInt8 EXC_ERR_DIV0
Definition: xlconst.hxx:105
const sal_uInt8 EXC_CACHEDVAL_EMPTY
Definition: xlconst.hxx:114
const sal_uInt8 EXC_CACHEDVAL_BOOL
Definition: xlconst.hxx:117
const sal_uInt8 EXC_ERR_NUM
Definition: xlconst.hxx:109
const sal_uInt8 EXC_CACHEDVAL_DOUBLE
Definition: xlconst.hxx:115
const sal_uInt32 EXC_TOK_NLR_ADDMASK
NLR relative (in appended data).
Definition: xlformula.hxx:156
#define OSL_ENSURE_BIFF(c)
Definition: xltools.hxx:34
XclBoolError
An enumeration for all Excel error codes and the values true and false.
Definition: xltools.hxx:40
@ xlErrDiv0
The error code NULL!
Definition: xltools.hxx:42
@ xlErrValue
The error code #DIV/0!
Definition: xltools.hxx:43
@ xlErrNA
The error code #NUM!
Definition: xltools.hxx:47
@ xlErrNull
Definition: xltools.hxx:41
@ xlErrUnknown
The Boolean value false.
Definition: xltools.hxx:50
@ xlErrName
The error code #REF!
Definition: xltools.hxx:45
@ xlErrNum
The error code #NAME?
Definition: xltools.hxx:46
@ xlErrFalse
The Boolean value true.
Definition: xltools.hxx:49
@ xlErrTrue
The error code N/A!
Definition: xltools.hxx:48
@ xlErrRef
The error code #VALUE!
Definition: xltools.hxx:44
const char * pExt