From 516318113f0bd2b3c658aba9b285165e63a280e2 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Wed, 28 Jul 2021 17:31:56 +0200 Subject: Resolves: tdf#76310 Preserve whitespace TAB, CR, LF in formula expressions Allowed whitespace in ODFF and OOXML are U+0020 SPACE U+0009 CHARACTER TABULATION U+000A LINE FEED U+000D CARRIAGE RETURN Line feed and carriage return look a bit funny in the Function Wizard if part of a function's argument but work. Once a formula is edited, CR are converted to LF though, probably already in EditEngine, didn't investigate. Change-Id: I6278f6be48872e0710a3d74212db391dda249ed2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119635 Reviewed-by: Eike Rathke Tested-by: Jenkins --- include/formula/token.hxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/formula/token.hxx') diff --git a/include/formula/token.hxx b/include/formula/token.hxx index 3fa00e89339f..77bf3eeb90ea 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -187,6 +187,7 @@ public: virtual void SetIndex( sal_uInt16 n ); virtual sal_Int16 GetSheet() const; virtual void SetSheet( sal_Int16 n ); + virtual sal_Unicode GetChar() const; virtual short* GetJump() const; virtual const OUString& GetExternal() const; virtual FormulaToken* GetFAPOrigToken() const; @@ -225,6 +226,25 @@ inline void intrusive_ptr_release(const FormulaToken* p) p->DecRef(); } +class FORMULA_DLLPUBLIC FormulaSpaceToken : public FormulaToken +{ +private: + sal_uInt8 nByte; + sal_Unicode cChar; +public: + FormulaSpaceToken( sal_uInt8 n, sal_Unicode c ) : + FormulaToken( svByte, ocWhitespace ), + nByte( n ), cChar( c ) {} + FormulaSpaceToken( const FormulaSpaceToken& r ) : + FormulaToken( r ), + nByte( r.nByte ), cChar( r.cChar ) {} + + virtual FormulaToken* Clone() const override { return new FormulaSpaceToken(*this); } + virtual sal_uInt8 GetByte() const override; + virtual sal_Unicode GetChar() const override; + virtual bool operator==( const FormulaToken& rToken ) const override; +}; + class FORMULA_DLLPUBLIC FormulaByteToken : public FormulaToken { private: -- cgit