basic/qa/vba_tests/constants.vb | 11 +++++++++++ basic/source/comp/parser.cxx | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+)
New commits: commit d765faacd1933c091e9eb0ecd566460beeb2a33d Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Sat Sep 25 16:42:37 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Sep 28 11:00:33 2021 +0200 tdf#131563 - Add vba color constants Change-Id: I59bcd11b5da1450fced77671c2cf6ed44e299a06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122607 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> (cherry picked from commit d6063f416c78f30f1fb717f3ab05f9691bb3461d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122648 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb index d03fdda95afe..be7add515e83 100644 --- a/basic/qa/vba_tests/constants.vb +++ b/basic/qa/vba_tests/constants.vb @@ -25,6 +25,17 @@ Sub verify_testConstants() TestUtil.AssertEqual(vbNewLine, vbLf, "vbNewline") End If + ' tdf#131563 - check for vba color constants + ' See https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants + TestUtil.AssertEqual(vbBlack, RGB(0, 0, 0), "vbBlack") + TestUtil.AssertEqual(vbRed, RGB(255, 0, 0), "vbRed") + TestUtil.AssertEqual(vbGreen, RGB(0, 255, 0), "vbGreen") + TestUtil.AssertEqual(vbYellow, RGB(255, 255, 0), "vbYellow") + TestUtil.AssertEqual(vbBlue, RGB(0, 0, 255), "vbBlue") + TestUtil.AssertEqual(vbMagenta, RGB(255, 0, 255), "vbMagenta") + TestUtil.AssertEqual(vbCyan, RGB(0, 255, 255), "vbCyan") + TestUtil.AssertEqual(vbWhite, RGB(255, 255, 255), "vbWhite") + Exit Sub errorHandler: TestUtil.ReportErrorHandler("verify_testConstants", Err, Error$, Erl) diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 6ebc2208ae42..dc0b3b16b348 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -841,8 +841,26 @@ static void addStringConst( SbiSymPool& rPool, const OUString& pSym, const OUStr rPool.Add( pConst ); } +static void addNumericConst(SbiSymPool& rPool, const OUString& pSym, double nVal) +{ + SbiConstDef* pConst = new SbiConstDef(pSym); + pConst->Set(nVal, SbxDOUBLE); + rPool.Add(pConst); +} + void SbiParser::AddConstants() { + // tdf#131563 - add vba color constants + // See https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants + addNumericConst(aPublics, "vbBlack", 0x0); + addNumericConst(aPublics, "vbRed", 0xFF); + addNumericConst(aPublics, "vbGreen", 0xFF00); + addNumericConst(aPublics, "vbYellow", 0xFFFF); + addNumericConst(aPublics, "vbBlue", 0xFF0000); + addNumericConst(aPublics, "vbMagenta", 0xFF00FF); + addNumericConst(aPublics, "vbCyan", 0xFFFF00); + addNumericConst(aPublics, "vbWhite", 0xFFFFFF); + // #113063 Create constant RTL symbols addStringConst( aPublics, "vbCr", "\x0D" ); addStringConst( aPublics, "vbCrLf", "\x0D\x0A" );