diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-09-25 16:42:37 +0200 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-09-27 15:31:54 +0200 |
commit | d6063f416c78f30f1fb717f3ab05f9691bb3461d (patch) | |
tree | 5056646f01246b45cb7a38df19f40790d7dae785 | |
parent | 44a3839327fe3abee4683134de0071c9aa7f5139 (diff) |
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.heinisch@yahoo.de>
-rw-r--r-- | basic/qa/vba_tests/constants.vb | 11 | ||||
-rw-r--r-- | basic/source/comp/parser.cxx | 18 |
2 files changed, 29 insertions, 0 deletions
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" ); |