diff options
author | Eike Rathke <erack@redhat.com> | 2024-07-29 11:41:41 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2024-07-29 16:29:19 +0200 |
commit | 4c3f65ea3b1f2e7f6d92c732f72936fecc017b29 (patch) | |
tree | 3afac95bd1962351cae0f507c192e406cd0072a7 /sc/source/ui/unoobj | |
parent | 212ffc410aeac602efb2c2bfca3eb2d14a31f490 (diff) |
Resolves: tdf#159343 Implement TableRef API token conversion
Change-Id: I1b0d9e002d267e62dc7cbbbfc9f5c5c728374345
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171165
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r-- | sc/source/ui/unoobj/tokenuno.cxx | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index c5f34540f87f..1f867189687a 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/sheet/ReferenceFlags.hpp> #include <com/sun/star/sheet/AddressConvention.hpp> #include <com/sun/star/sheet/NameToken.hpp> +#include <com/sun/star/sheet/TableRefToken.hpp> #include <com/sun/star/table/CellAddress.hpp> #include <svl/itemprop.hxx> @@ -143,6 +144,14 @@ uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula( SetCompilerFlags( aCompiler ); std::unique_ptr<ScTokenArray> pCode = aCompiler.CompileString( aFormula ); + if (pCode->HasOpCode(ocTableRef)) + { + FormulaError nErr = pCode->GetCodeError(); + aCompiler.EnableJumpCommandReorder(true); + aCompiler.CompileTokenArray(); // needed for corresponding inner reference + pCode->DelRPN(); // can be discarded + pCode->SetCodeError(nErr); // reset to parsing error, if any + } ScTokenConversion::ConvertToTokenSequence( rDoc, aRet, *pCode ); } @@ -442,10 +451,39 @@ void ScTokenConversion::ConvertToTokenSequence( const ScDocument& rDoc, break; case svIndex: { - sheet::NameToken aNameToken; - aNameToken.Index = static_cast<sal_Int32>( rToken.GetIndex() ); - aNameToken.Sheet = rToken.GetSheet(); - rAPI.Data <<= aNameToken; + const ScTableRefToken* pTR; + if (rToken.GetOpCode() == ocTableRef && (pTR = dynamic_cast<const ScTableRefToken*>(&rToken))) + { + sheet::TableRefToken aTableRefToken; + 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"); + if (pRef) + { + switch (pRef->GetType()) + { + case svSingleRef: + lcl_SingleRefToApi( aTableRefToken.Reference.Reference1, *pRef->GetSingleRef()); + aTableRefToken.Reference.Reference2 = aTableRefToken.Reference.Reference1; + break; + case svDoubleRef: + lcl_SingleRefToApi( aTableRefToken.Reference.Reference1, *pRef->GetSingleRef()); + lcl_SingleRefToApi( aTableRefToken.Reference.Reference2, *pRef->GetSingleRef2()); + break; + default: + ; // nothing + } + } + rAPI.Data <<= aTableRefToken; + } + else + { + sheet::NameToken aNameToken; + aNameToken.Index = static_cast<sal_Int32>( rToken.GetIndex() ); + aNameToken.Sheet = rToken.GetSheet(); + rAPI.Data <<= aNameToken; + } } break; case svMatrix: |