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