diff options
author | Eike Rathke <erack@redhat.com> | 2024-08-06 00:47:26 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-08-06 09:12:04 +0200 |
commit | 6e12713a7938e464b55a54b9dfd662000057a85f (patch) | |
tree | 247273937aa02e30133524885ebdebf70f252c30 /sc | |
parent | 56796ffc8f58c99204638702a0e09308956a4b99 (diff) |
Do not assert TableRef inner reference for dumb sequence, tdf#159343
... of FormulaToken that's only created to extract a range from an
expression because that OOXML import part doesn't know to operate
on a ScTokenArray.
Change-Id: I4011723b682c3eae0e1c8d8e768553154c024061
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171516
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/tokenuno.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/oox/defnamesbuffer.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/unoobj/tokenuno.cxx | 7 |
3 files changed, 15 insertions, 5 deletions
diff --git a/sc/inc/tokenuno.hxx b/sc/inc/tokenuno.hxx index d025ba0cf44d..b8368688245a 100644 --- a/sc/inc/tokenuno.hxx +++ b/sc/inc/tokenuno.hxx @@ -44,7 +44,8 @@ public: static SC_DLLPUBLIC void ConvertToTokenSequence( const ScDocument& rDoc, css::uno::Sequence< css::sheet::FormulaToken >& rSequence, - const ScTokenArray& rTokenArray ); + const ScTokenArray& rTokenArray, + bool bIgnoreTableRefNoInnerReference = false ); }; class ScFormulaParserObj final : public ::cppu::WeakImplHelper< diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 431ff8a34f35..06a6ec114787 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -299,8 +299,11 @@ void DefinedName::convertFormula( const css::uno::Sequence<css::sheet::ExternalL } ScTokenArray* pTokenArray = pScRangeData->GetCode(); + /* TODO: conversion to FormulaToken sequence would be completely + * unnecessary if getFormulaParser().extractCellRangeList() could operate + * on ScTokenArray instead. */ Sequence< FormulaToken > aFTokenSeq; - ScTokenConversion::ConvertToTokenSequence( getScDocument(), aFTokenSeq, *pTokenArray ); + ScTokenConversion::ConvertToTokenSequence( getScDocument(), aFTokenSeq, *pTokenArray, true); // set built-in names (print ranges, repeated titles, filter ranges) if( isGlobalName() ) return; @@ -358,8 +361,11 @@ bool DefinedName::getAbsoluteRange( ScRange& orRange ) const { ScRangeData* pScRangeData = maScRangeData.first; ScTokenArray* pTokenArray = pScRangeData->GetCode(); + /* TODO: conversion to FormulaToken sequence would be completely + * unnecessary if getFormulaParser().extractCellRange() could operate + * on ScTokenArray instead. */ Sequence< FormulaToken > aFTokenSeq; - ScTokenConversion::ConvertToTokenSequence(getScDocument(), aFTokenSeq, *pTokenArray); + ScTokenConversion::ConvertToTokenSequence(getScDocument(), aFTokenSeq, *pTokenArray, true); return getFormulaParser().extractCellRange( orRange, aFTokenSeq ); } diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index 1f867189687a..51da3621cd4b 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -387,7 +387,8 @@ bool ScTokenConversion::ConvertToTokenArray( ScDocument& rDoc, } void ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, - uno::Sequence<sheet::FormulaToken>& rSequence, const ScTokenArray& rTokenArray ) + uno::Sequence<sheet::FormulaToken>& rSequence, const ScTokenArray& rTokenArray, + bool bIgnoreTableRefNoInnerReference ) { sal_Int32 nLen = static_cast<sal_Int32>(rTokenArray.GetLen()); formula::FormulaToken** pTokens = rTokenArray.GetArray(); @@ -458,7 +459,9 @@ void ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, aTableRefToken.Index = static_cast<sal_Int32>( pTR->GetIndex()); aTableRefToken.Item = static_cast<sal_Int16>( pTR->GetItem()); const FormulaToken* pRef = pTR->GetAreaRefRPN(); - assert(pRef && "something forgot to create RPN for ocTableRef inner reference"); + assert((pRef || bIgnoreTableRefNoInnerReference) + && "something forgot to create RPN for ocTableRef inner reference"); + (void)bIgnoreTableRefNoInnerReference; if (pRef) { switch (pRef->GetType()) |