23#include <document.hxx>
46 sal_uInt16 nXF = 0, nFormLen;
71 bShrFmla = nFlag0 & 0x08;
74 Formula( aXclPos, nXF, nFormLen, fCurVal, bShrFmla );
92 Formula( aXclPos, nXF, nFormLen, fCurVal,
false );
96 const XclAddress& rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen,
double fCurVal,
bool bShrFmla)
107 std::unique_ptr<ScTokenArray> pResult;
129 if (std::isfinite(fCurVal))
172 if (std::isfinite(fCurVal))
183 meBiff( rRoot.GetBiff() )
206 bool bArrayFormula =
false;
211 const bool bRNorSF = bRangeName || bSharedFormula || bConditional;
217 if( nFormulaLen == 0 )
225 std::size_t nEndPos = aIn.
GetRecPos() + nFormulaLen;
227 while( (aIn.
GetRecPos() < nEndPos) && !bError )
241 sal_uInt16 nUINT16 = 3;
248 bArrayFormula =
true;
369 sal_uInt16 nData(0), nFactor(0);
388 aIn.
Ignore(
static_cast<std::size_t
>(nData) * nFactor);
390 else if( nOpt & 0x10 )
401 SAL_INFO(
"sc",
"-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
404 SAL_INFO(
"sc",
"-ExcelToSc::Convert(): A little oblivious?" );
414 SAL_INFO(
"sc",
"-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
417 SAL_INFO(
"sc",
"-ExcelToSc::Convert(): A little oblivious?" );
490 DoMulArgs( pFuncInfo->meOpCode, pFuncInfo->mnMaxParamCount );
508 DoMulArgs( pFuncInfo->meOpCode, nParamCount );
526 "-ExcelToSc::Convert(): A little oblivious?" );
571 sal_uInt16 nRowFirst, nRowLast;
643 sal_uInt16 nRowFirst, nRowLast;
682 OUString aString =
"COMM_EQU_FUNC";
684 aString += OUString::number( nByte );
714 sal_uInt16 nTabFirst, nTabLast, nRow;
729 nTabFirst = nTabLast;
759 if( nTabLast != nTabFirst )
779 sal_uInt16 nTabFirst, nTabLast, nRowFirst, nRowLast;
797 nTabFirst = nTabLast;
847 default: bError =
true;
868 else if( bArrayFormula )
896 const bool bRNorSF = bRangeName || bSharedFormula;
903 if( nFormulaLen == 0 )
906 std::size_t nEndPos = aIn.
GetRecPos() + nFormulaLen;
908 while( (aIn.
GetRecPos() < nEndPos) && !bError )
911 std::size_t nIgnore = 0;
953 sal_uInt16 nData(0), nFactor(0);
972 aIn.
Ignore(
static_cast<std::size_t
>(nData) * nFactor);
982 case EXC_BIFF5:
SAL_INFO(
"sc",
"-ExcelToSc::Convert(): 0x1A does not exist in Biff5!" );
984 default:
SAL_INFO(
"sc",
"-ExcelToSc::Convert(): A little oblivious?" );
993 case EXC_BIFF5:
SAL_INFO(
"sc",
"-ExcelToSc::Convert(): 0x1B does not exist in Biff5!" );
995 default:
SAL_INFO(
"sc",
"-ExcelToSc::Convert(): A little oblivious?" );
1032 default: OSL_FAIL(
"-ExcelToSc::Convert(): A little oblivious?" );
1055 sal_uInt16 nRowFirst, nRowLast;
1122 sal_uInt16 nRowFirst, nRowLast;
1171 sal_uInt16 nTabFirst, nTabLast, nRow;
1172 sal_Int16 nExtSheet;
1182 if( nExtSheet >= 0 )
1185 if( rR.
pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
1187 nTabFirst = nTabLast;
1198 if( nExtSheet <= 0 )
1200 bool b3D = (
static_cast<SCTAB>(nTabFirst) !=
aEingPos.
Tab() ) || bRangeName;
1206 if( nTabLast != nTabFirst )
1225 sal_uInt16 nTabFirst, nTabLast, nRowFirst, nRowLast;
1226 sal_Int16 nExtSheet;
1238 if( nExtSheet >= 0 )
1241 if( rR.
pExtSheetBuff->GetScTabIndex( nExtSheet, nTabLast ) )
1243 nTabFirst = nTabLast;
1254 if( nExtSheet <= 0 )
1287 default: bError =
true;
1303 aIn.
Seek( nEndPos );
1308 const OUString& ,
const vector<OUString>& )
1319 sal_uInt16 nRow1, nRow2;
1322 sal_uInt16 nTabFirst, nTabLast;
1326 std::size_t nEndPos =
rStrm.GetRecPos() + nLen;
1328 while(
rStrm.IsValid() && (
rStrm.GetRecPos() < nEndPos) )
1330 nOp =
rStrm.ReaduInt8();
1342 nRow1 =
rStrm.ReaduInt16();
1343 nCol1 =
rStrm.ReaduInt8();
1356 nRow1 =
rStrm.ReaduInt16();
1357 nRow2 =
rStrm.ReaduInt16();
1358 nCol1 =
rStrm.ReaduInt8();
1359 nCol2 =
rStrm.ReaduInt8();
1368 nTabFirst =
rStrm.ReaduInt16();
1369 nTabLast =
rStrm.ReaduInt16();
1370 nRow1 =
rStrm.ReaduInt16();
1371 nCol1 =
rStrm.ReaduInt8();
1382 nTabFirst =
rStrm.ReaduInt16();
1383 nTabLast =
rStrm.ReaduInt16();
1384 nRow1 =
rStrm.ReaduInt16();
1385 nRow2 =
rStrm.ReaduInt16();
1386 nCol1 =
rStrm.ReaduInt8();
1387 nCol2 =
rStrm.ReaduInt8();
1390 nTab1 =
static_cast< SCTAB >( nTabFirst );
1391 nTab2 =
static_cast< SCTAB >( nTabLast );
1394 if( (nRefIdx >= 0) || !
ValidTab( nTab1 ) || (nTab1 != nTab2) )
1508 nSeek =
rStrm.ReaduInt8();
1514 nOpt =
rStrm.ReaduInt8();
1515 nData =
rStrm.ReaduInt16();
1517 nSeek = nData * 2 + 2;
1522 rStrm.Ignore( nSeek );
1539 aStack >> eParam[ nPass ];
1542 nCnt =
static_cast< sal_uInt8 >( nPass );
1551 aPool << pFuncInfo->meOpCode;
1567 sal_Int16 nSkipEnd = -1;
1569 sal_Int16 nLast = nCnt - 1;
1576 else if( eId ==
ocIf )
1578 sal_uInt16 nNullParam = 0;
1579 for( nPass = 0 ; nPass < nCnt ; nPass++ )
1584 nNullParam =
static_cast<sal_uInt16
>(
aPool.
Store( 0.0 ));
1585 eParam[ nPass ] = nNullParam;
1591 if( nLast > nSkipEnd )
1594 aPool << eParam[ nLast ];
1595 for( nPass = nLast - 1 ; nPass > nSkipEnd ; nPass-- )
1639 bool bColRel = (nRow & 0x4000) > 0;
1640 bool bRowRel = (nRow & 0x8000) > 0;
1669 case xlErrDiv0: eOc =
ocStop; nError = FormulaError::DivisionByZero;
break;
1671 case xlErrRef: eOc =
ocStop; nError = FormulaError::NoRef;
break;
1673 case xlErrNum: eOc =
ocStop; nError = FormulaError::IllegalFPOperation;
break;
1679 OSL_FAIL(
"ExcelToSc::GetBoolErr - wrong enum!" );
1681 nError = FormulaError::UnknownState;
1691 if( nError != FormulaError::NONE )
1692 pResult->SetCodeError( nError );
1694 pResult->SetExclusiveRecalcModeNormal();
1701 rStrm.PushPosition();
1704 nOp =
rStrm.ReaduInt8();
1708 rStrm.PopPosition();
1712 sal_uInt16 nRow, nCol;
1713 nRow =
rStrm.ReaduInt16();
1714 nCol =
rStrm.ReaduInt16();
1715 rStrm.PopPosition();
1732 case ConvErr::Ni: nInd = FormulaError::UnknownToken;
break;
1734 default: nInd = FormulaError::NoCode;
1770 nRows = nUINT16 + 1;
1774 nCols = nByte ? nByte : 256;
1780 if(
nullptr != pMatrix )
1782 pMatrix->
Resize(nCols, nRows);
1784 if( nC != nCols || nR != nRows )
1786 OSL_FAIL(
"ExcelToSc::ReadExtensionArray - matrix size mismatch" );
1792 OSL_FAIL(
"ExcelToSc::ReadExtensionArray - missing matrix" );
1796 const size_t nMinRecordSize = 1;
1797 const size_t nMaxRows = aIn.
GetRecLeft() / (nMinRecordSize * nCols);
1798 if (nRows > nMaxRows)
1800 SAL_WARN(
"sc",
"Parsing error: " << nMaxRows <<
1801 " max possible rows, but " << nRows <<
" claimed, truncating");
1806 for( nR = 0 ; nR < nRows; nR++ )
1808 for( nC = 0 ; nC < nCols; nC++ )
1815 if(
nullptr != pMatrix )
1824 if(
nullptr != pMatrix )
1843 if(
nullptr != pMatrix )
1852 if(
nullptr != pMatrix )
1861 if(
nullptr != pMatrix )
1890 unsigned int nArray = 0;
1892 for(
int eType : rExtensions)
bool ValidTab(SCTAB nTab)
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 ...
void ExcRelToScRel(sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &, const bool bName)
void ReadExtensions(const ExtensionTypeVec &rExtensions, XclImpStream &aIn)
void ReadExtensionArray(unsigned int n, XclImpStream &aIn)
static bool IsComplRowRange(const sal_uInt16 nRow1, const sal_uInt16 nRow2)
std::unique_ptr< ScTokenArray > GetDummy()
static bool ReadSharedFormulaPosition(XclImpStream &rStrm, SCCOL &rCol, SCROW &rRow)
virtual ~ExcelToSc() override
static void SetError(ScFormulaCell &rCell, const ConvErr eErr)
virtual void GetAbsRefs(ScRangeList &rRangeList, XclImpStream &rStrm, std::size_t nLen)
::std::vector< ExtensionType > ExtensionTypeVec
XclFunctionProvider maFuncProv
void DoMulArgs(DefTokenId eId, sal_uInt8 nNumArgs)
void SetComplCol(ScComplexRefData &)
static bool IsComplColRange(const sal_uInt16 nCol1, const sal_uInt16 nCol2)
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
std::unique_ptr< ScTokenArray > GetBoolErr(XclBoolError)
ExcelToSc(XclImpRoot &rRoot)
void ReadExtensionMemArea(XclImpStream &aIn)
const ScTokenArray * GetSharedFormula(const ScAddress &rRefPos) const
virtual void ConvertExternName(std::unique_ptr< ScTokenArray > &rpArray, XclImpStream &rStrm, std::size_t nFormulaLen, const OUString &rUrl, const ::std::vector< OUString > &rTabNames)
void SetComplRow(ScComplexRefData &)
static void ReadExtensionNlr(XclImpStream &aIn)
static const sal_uInt16 nRowMask
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
void Formula(const XclAddress &rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
void SetLastFormula(SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell *pCell)
True if fuzzing filter.
Accessor class to ScDocument.
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
SC_DLLPUBLIC SCROW MaxRow() const
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Matrix data type that can store values of mixed types.
void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
void PutString(const svl::SharedString &rStr, SCSIZE nC, SCSIZE nR)
void PutEmpty(SCSIZE nC, SCSIZE nR)
void Resize(SCSIZE nC, SCSIZE nR)
Resize the matrix to specified new dimension.
void PutDouble(double fVal, SCSIZE nC, SCSIZE nR)
void PutError(FormulaError nErrorCode, SCSIZE nC, SCSIZE nR)
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
void Append(const ScAddress &aSRD, SCTAB nTab)
void push_back(const ScRange &rRange)
std::unique_ptr< ScTokenArray > Clone() const
void WrapReference(const ScAddress &rPos, SCCOL nMaxCol, SCROW nMaxRow)
SvStream & ReadInt16(sal_Int16 &rInt16)
sal_uInt64 Seek(sal_uInt64 nPos)
TokenId StoreName(sal_uInt16 nIndex, sal_Int16 nSheet)
bool IsSingleOp(const TokenId &rId, const DefTokenId eId) const
ScMatrix * GetMatrix(unsigned int n) const
std::unique_ptr< ScTokenArray > GetTokenArray(const ScDocument &rDoc, const TokenId &rId)
const OUString * GetExternal(const TokenId &rId) const
bool HasMoreTokens() const
const XclFunctionInfo * GetFuncInfoFromXclMacroName(const OUString &rXclMacroName) const
Returns the function data for an Excel function simulated by a macro call, or 0 on error.
const XclFunctionInfo * GetFuncInfoFromXclFunc(sal_uInt16 nXclFunc) const
Returns the function data for an Excel function index, or 0 on error.
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
const XclImpName * GetName(sal_uInt16 nXclNameIdx) const
Returns the defined name specified by its Excel index.
Represents a defined name.
Access to global data from other classes.
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
ScDocumentImport & GetDocImport()
XclImpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
This class is used to import record oriented streams.
bool IsValid() const
Returns record reading state: false = record overread.
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
XclTracer & GetTracer() const
Returns the filter tracer.
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
RootData & GetOldRoot() const
Returns old RootData struct.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
void TraceFormulaMissingArg()
SharedString intern(const OUString &rStr)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< SharedFormulaBuffer > pShrfmlaBuff
std::unique_ptr< ExtSheetBuffer > pExtSheetBuff
Complex reference (a range) into the sheet.
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Single reference (one address) into the sheet.
void SetAbsCol(SCCOL nVal)
void SetAbsTab(SCTAB nVal)
void SetColDeleted(bool bVal)
void SetRelRow(SCROW nVal)
void SetRelTab(SCTAB nVal)
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
void SetAbsRow(SCROW nVal)
void SetRelCol(SCCOL nVal)
void SetFlag3D(bool bVal)
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
void SetRowDeleted(bool bVal)
void SetTabDeleted(bool bVal)
A 2D cell address struct with Excel column and row indexes.
Represents information for a spreadsheet function for import and export.
A 2D cell range address struct with Excel column and row indexes.
const sal_uInt8 EXC_ERR_NA
const sal_uInt8 EXC_ERR_REF
const sal_uInt8 EXC_ERR_NAME
const sal_uInt8 EXC_ERR_NULL
DDE application-topic delimiter.
const sal_uInt8 EXC_ERR_VALUE
const sal_uInt8 EXC_CACHEDVAL_ERROR
const sal_uInt8 EXC_CACHEDVAL_STRING
@ EXC_BIFF8
MS Excel 5.0, MS Excel 7.0 (95)
const sal_uInt8 EXC_ERR_DIV0
const sal_uInt8 EXC_CACHEDVAL_EMPTY
const sal_uInt8 EXC_CACHEDVAL_BOOL
const sal_uInt8 EXC_ERR_NUM
const sal_uInt8 EXC_CACHEDVAL_DOUBLE