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?" );
454 aStack <<
aPool.
Store( static_cast<double>(nUINT16) );
490 DoMulArgs( pFuncInfo->meOpCode, pFuncInfo->mnMaxParamCount );
508 DoMulArgs( pFuncInfo->meOpCode, nParamCount );
526 "-ExcelToSc::Convert(): A little oblivious?" );
544 aSRD.
SetAbsCol(static_cast<SCCOL>(nByte));
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;
756 if ( !
ValidTab(static_cast<SCTAB>(nTabFirst)) )
759 if( nTabLast != nTabFirst )
779 sal_uInt16 nTabFirst, nTabLast, nRowFirst, nRowLast;
797 nTabFirst = nTabLast;
838 if ( !
ValidTab(static_cast<SCTAB>(nTabFirst)) )
840 if ( !
ValidTab(static_cast<SCTAB>(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?" );
1041 aSRD.
SetAbsCol(static_cast<SCCOL>(nByte));
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;
1390 nTab1 =
static_cast< SCTAB >( nTabFirst );
1391 nTab2 =
static_cast< SCTAB >( nTabLast );
1394 if( (nRefIdx >= 0) || !
ValidTab( nTab1 ) || (nTab1 != nTab2) )
1517 nSeek = nData * 2 + 2;
1524 rStrm.
Seek( nEndPos );
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();
1712 sal_uInt16 nRow, nCol;
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 )
1877 aIn.
Ignore( nCount * 4 );
1890 unsigned int nArray = 0;
1892 for(
int eType : rExtensions)
const XclFunctionInfo * GetFuncInfoFromXclMacroName(const OUString &rXclMacroName) const
Returns the function data for an Excel function simulated by a macro call, or 0 on error...
OUString ReadRawByteString(sal_uInt16 nChars)
Reads nChar byte characters and returns the string.
Matrix data type that can store values of mixed types.
const sal_uInt8 EXC_ERR_NULL
DDE application-topic delimiter.
const XclFunctionInfo * GetFuncInfoFromXclFunc(sal_uInt16 nXclFunc) const
Returns the function data for an Excel function index, or 0 on error.
ScDocumentImport & GetDocImport()
void Seek(std::size_t nPos)
Seeks absolute in record content to the specified position.
SharedString intern(const OUString &rStr)
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
const sal_uInt8 EXC_ERR_NA
void ExcRelToScRel(sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData &, const bool bName)
std::size_t GetRecPos() const
Returns the position inside of the whole record content.
static void SetError(ScFormulaCell &rCell, const ConvErr eErr)
std::unique_ptr< SharedFormulaBuffer > pShrfmlaBuff
SC_DLLPUBLIC ScRange toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
Single reference (one address) into the sheet.
void PutDouble(double fVal, SCSIZE nC, SCSIZE nR)
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
ScAddress toAbs(const ScSheetLimits &rLimits, const ScAddress &rPos) const
void SetRelCol(SCCOL nVal)
static bool IsComplRowRange(const sal_uInt16 nRow1, const sal_uInt16 nRow2)
static bool IsComplColRange(const sal_uInt16 nCol1, const sal_uInt16 nCol2)
::std::vector< ExtensionType > ExtensionTypeVec
void SetRelTab(SCTAB nVal)
bool IsValid() const
Returns record reading state: false = record overread.
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
void SetAbsRow(SCROW nVal)
const sal_uInt8 EXC_CACHEDVAL_ERROR
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
RootData & GetOldRoot() const
Returns old RootData struct.
Accessor class to ScDocument.
const XclImpName * GetName(sal_uInt16 nXclNameIdx) const
Returns the defined name specified by its Excel index.
const OUString * GetExternal(const TokenId &rId) const
virtual ~ExcelToSc() override
void PutString(const svl::SharedString &rStr, SCSIZE nC, SCSIZE nR)
void PutEmpty(SCSIZE nC, SCSIZE nR)
void SetRowDeleted(bool bVal)
void SetComplCol(ScComplexRefData &)
SC_DLLPUBLIC void CheckLinkFormulaNeedingCheck(const ScTokenArray &rCode)
Check token array and set link check if ocDde/ocWebservice is contained.
const sal_uInt8 EXC_ERR_NUM
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
SC_DLLPUBLIC SCROW MaxRow() const
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 ...
static void ReadExtensionNlr(XclImpStream &aIn)
void push_back(const ScRange &rRange)
void SetColDeleted(bool bVal)
void PopPosition()
Seeks to last position from user position stack.
bool HasMoreTokens() const
ExcelToSc(XclImpRoot &rRoot)
const sal_uInt8 EXC_ERR_REF
virtual void ConvertExternName(std::unique_ptr< ScTokenArray > &rpArray, XclImpStream &rStrm, std::size_t nFormulaLen, const OUString &rUrl, const ::std::vector< OUString > &rTabNames)
void WrapReference(const ScAddress &rPos, SCCOL nMaxCol, SCROW nMaxRow)
void SetRelRow(SCROW nVal)
void TraceFormulaMissingArg()
void Resize(SCSIZE nC, SCSIZE nR)
Resize the matrix to specified new dimension.
SC_DLLPUBLIC SCCOL MaxCol() const
MS Excel 5.0, MS Excel 7.0 (95)
Represents information for a spreadsheet function for import and export.
static bool ReadSharedFormulaPosition(XclImpStream &rStrm, SCCOL &rCol, SCROW &rRow)
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
const sal_uInt8 EXC_ERR_VALUE
static const sal_uInt16 nRowMask
void SetFlag3D(bool bVal)
void GetDimensions(SCSIZE &rC, SCSIZE &rR) const
std::unique_ptr< ScTokenArray > GetDummy()
void SetAbsCol(SCCOL nVal)
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
const OUString & GetXclName() const
bool IsSingleOp(const TokenId &rId, const DefTokenId eId) const
const sal_uInt8 EXC_CACHEDVAL_BOOL
void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
XclImpNameManager & GetNameManager() const
Returns the buffer that contains internal defined names.
void SetComplRow(ScComplexRefData &)
A 2D cell address struct with Excel column and row indexes.
void SetAbsTab(SCTAB nVal)
ScMatrix * GetMatrix(unsigned int n) const
const sal_uInt8 EXC_CACHEDVAL_EMPTY
TokenId StoreName(sal_uInt16 nIndex, sal_Int16 nSheet)
XclTracer & GetTracer() const
Returns the filter tracer.
virtual ConvErr Convert(std::unique_ptr< ScTokenArray > &, XclImpStream &rStrm, std::size_t nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT=FT_CellFormula) override
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
const ScTokenArray * GetSharedFormula(const ScAddress &rRefPos) const
std::unique_ptr< ScTokenArray > GetTokenArray(const ScDocument &rDoc, const TokenId &rId)
std::unique_ptr< ScTokenArray > GetBoolErr(XclBoolError)
const sal_uInt8 EXC_CACHEDVAL_DOUBLE
std::size_t GetRecLeft()
Returns remaining data size of the whole record without record headers.
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
void PutError(FormulaError nErrorCode, SCSIZE nC, SCSIZE nR)
void DoMulArgs(DefTokenId eId, sal_uInt8 nNumArgs)
const sal_uInt8 EXC_CACHEDVAL_STRING
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
const sal_uInt8 EXC_ERR_NAME
void InitFlags()
No default ctor, because used in ScRawToken union, set InitFlags!
#define SAL_INFO(area, stream)
const sal_uInt8 EXC_ERR_DIV0
void Append(const ScAddress &aSRD, SCTAB nTab)
void ReadExtensions(const ExtensionTypeVec &rExtensions, XclImpStream &aIn)
virtual void GetAbsRefs(ScRangeList &rRangeList, XclImpStream &rStrm, std::size_t nLen)
XclBiff GetBiff() const
Returns the current BIFF version of the importer/exporter.
void PushPosition()
Pushes current position on user position stack.
bool ConvertRange(ScRange &rScRange, const XclRange &rXclRange, SCTAB nScTab1, SCTAB nScTab2, bool bWarn)
Converts the passed Excel cell range to a Calc cell range.
void SetLastFormula(SCCOL nCol, SCROW nRow, double fVal, sal_uInt16 nXF, ScFormulaCell *pCell)
False = mbBiff2HasXfs is undetermined yet.
void Formula(const XclAddress &rXclPos, sal_uInt16 nXF, sal_uInt16 nFormLen, double fCurVal, bool bShrFmla)
Complex reference (a range) into the sheet.
void ReadExtensionArray(unsigned int n, XclImpStream &aIn)
#define SAL_WARN(area, stream)
This class is used to import record oriented streams.
void SetTabDeleted(bool bVal)
const ScRangeData * GetScRangeData() const
Access to global data from other classes.
std::unique_ptr< ExtSheetBuffer > pExtSheetBuff
Represents a defined name.
bool ValidTab(SCTAB nTab)
XclFunctionProvider maFuncProv
std::unique_ptr< ScTokenArray > Clone() const
A 2D cell range address struct with Excel column and row indexes.
void ReadExtensionMemArea(XclImpStream &aIn)