include/vbahelper/vbafontbase.hxx | 8 ++++++- sc/qa/extras/testdocuments/BGR-RGBTest.xls |binary sc/qa/extras/vba-macro-test.cxx | 2 + sc/source/ui/vba/vbafont.cxx | 2 - sw/source/ui/vba/vbafont.cxx | 11 +--------- sw/source/ui/vba/vbafont.hxx | 1 vbahelper/source/vbahelper/vbafontbase.cxx | 30 ++++++++++++++++++++++------- 7 files changed, 35 insertions(+), 19 deletions(-)
New commits: commit 0548269ca03f093c41f6292e783cc6c77328808e Author: Hannah Meeks <hmeeks4...@gmail.com> AuthorDate: Fri Dec 23 21:54:01 2022 +0000 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Feb 20 16:55:31 2023 +0000 VBA: Remove conversions in writer from OORGBTOXLRGB (XLRGB is actually BGR!) Enum to store if document is Writer or Calc because font colors are treated differently depending on this: In writer the colors come in as RGB but in calc they are in BGR and both palettes are in RBG so we only need this conversion for calc. Includes testdoc for calc - to show this still works Change-Id: I79d9d585dbfc527c0781543ce1f1095c4db190b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144788 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/vbahelper/vbafontbase.hxx b/include/vbahelper/vbafontbase.hxx index 732a67bc1d1e..d388715c93ba 100644 --- a/include/vbahelper/vbafontbase.hxx +++ b/include/vbahelper/vbafontbase.hxx @@ -44,9 +44,13 @@ typedef InheritedHelperInterfaceWeakImpl< ov::XFontBase > VbaFontBase_BASE; class VBAHELPER_DLLPUBLIC VbaFontBase : public VbaFontBase_BASE { +public: + enum Component { WORD, EXCEL }; + protected: css::uno::Reference< css::beans::XPropertySet > mxFont; css::uno::Reference< css::container::XIndexAccess > mxPalette; + Component meWhich; bool mbFormControl; public: @@ -79,7 +83,9 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPalette, const css::uno::Reference< css::beans::XPropertySet >& xPropertySet, - bool bFormControl = false ); + Component eWhich, + bool bFormControl = false); + virtual ~VbaFontBase() override;// {} // Attributes diff --git a/sc/qa/extras/testdocuments/BGR-RGBTest.xls b/sc/qa/extras/testdocuments/BGR-RGBTest.xls new file mode 100755 index 000000000000..e2bf43fb0e92 Binary files /dev/null and b/sc/qa/extras/testdocuments/BGR-RGBTest.xls differ diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx index 04e4efece2cf..2464996d2812 100644 --- a/sc/qa/extras/vba-macro-test.cxx +++ b/sc/qa/extras/vba-macro-test.cxx @@ -466,6 +466,8 @@ void VBAMacroTest::testVba() { OUString("vba_findFunction."), OUString( "vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document") }, + { OUString("BGR-RGBTest."), + OUString("vnd.sun.Star.script:VBAProject.Module1.test?language=Basic&location=document") } }; OUString sTempDir; OUString sTempDirURL; diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 99afd919bea7..db49f013499c 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -37,7 +37,7 @@ ScVbaFont::ScVbaFont( const ScVbaPalette& dPalette, const uno::Reference< beans::XPropertySet >& xPropertySet, ScCellRangeObj* pRangeObj, bool bFormControl ) : - ScVbaFont_BASE( xParent, xContext, dPalette.getPalette(), xPropertySet, bFormControl ), + ScVbaFont_BASE( xParent, xContext, dPalette.getPalette(), xPropertySet, Component::EXCEL, bFormControl ), mpRangeObj( pRangeObj ) { } diff --git a/sw/source/ui/vba/vbafont.cxx b/sw/source/ui/vba/vbafont.cxx index de37a6c74e18..91a31ec66470 100644 --- a/sw/source/ui/vba/vbafont.cxx +++ b/sw/source/ui/vba/vbafont.cxx @@ -111,7 +111,8 @@ public: } -SwVbaFont::SwVbaFont( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPalette, uno::Reference< css::beans::XPropertySet > const & xPropertySet ) : SwVbaFont_BASE( xParent, xContext, xPalette, xPropertySet ) +SwVbaFont::SwVbaFont( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPalette, uno::Reference< css::beans::XPropertySet > const & xPropertySet ) + : SwVbaFont_BASE( xParent, xContext, xPalette, xPropertySet, Component::WORD ) { } @@ -141,14 +142,6 @@ SwVbaFont::getServiceImplName() return "SwVbaFont"; } -void SAL_CALL -SwVbaFont::setColorIndex( const uno::Any& _colorindex ) -{ - sal_Int32 nIndex = 0; - _colorindex >>= nIndex; - return setColor( mxPalette->getByIndex( nIndex ) ); -} - uno::Any SAL_CALL SwVbaFont::getColorIndex() { diff --git a/sw/source/ui/vba/vbafont.hxx b/sw/source/ui/vba/vbafont.hxx index 24b5832e7ee3..61bfc0f52636 100644 --- a/sw/source/ui/vba/vbafont.hxx +++ b/sw/source/ui/vba/vbafont.hxx @@ -31,7 +31,6 @@ public: SwVbaFont( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPalette, css::uno::Reference< css::beans::XPropertySet > const & xPropertySet ); // Attributes - virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) override; virtual css::uno::Any SAL_CALL getColorIndex() override; virtual css::uno::Any SAL_CALL getUnderline() override; virtual void SAL_CALL setUnderline( const css::uno::Any& _underline ) override; diff --git a/vbahelper/source/vbahelper/vbafontbase.cxx b/vbahelper/source/vbahelper/vbafontbase.cxx index 50bac8f92d25..797fefd5cd7e 100644 --- a/vbahelper/source/vbahelper/vbafontbase.cxx +++ b/vbahelper/source/vbahelper/vbafontbase.cxx @@ -37,10 +37,12 @@ VbaFontBase::VbaFontBase( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< css::container::XIndexAccess >& xPalette, const uno::Reference< beans::XPropertySet >& xPropertySet, + Component eWhich, bool bFormControl ) : VbaFontBase_BASE( xParent, xContext ), mxFont( xPropertySet, uno::UNO_SET_THROW ), mxPalette( xPalette, uno::UNO_SET_THROW ), + meWhich( eWhich ), mbFormControl( bFormControl ) { } @@ -141,10 +143,12 @@ VbaFontBase::setColorIndex( const uno::Any& _colorindex ) --nIndex; // OOo indices are zero bases - // setColor expects colors in XL RGB values - // #FIXME this is daft we convert OO RGB val to XL RGB val and - // then back again to OO RGB value - setColor( OORGBToXLRGB(mxPalette->getByIndex( nIndex )) ); + if (meWhich == EXCEL){ + setColor( OORGBToXLRGB(mxPalette->getByIndex( nIndex )) ); + } + else{ + setColor( mxPalette->getByIndex( nIndex )); + } } @@ -153,7 +157,13 @@ VbaFontBase::getColorIndex() { sal_Int32 nColor = 0; - XLRGBToOORGB( getColor() ) >>= nColor; + if (meWhich == EXCEL){ + XLRGBToOORGB( getColor() ) >>= nColor; + } + else{ + getColor() >>= nColor; + } + sal_Int32 nElems = mxPalette->getCount(); sal_Int32 nIndex = -1; for ( sal_Int32 count=0; count<nElems; ++count ) @@ -257,8 +267,14 @@ VbaFontBase::getName() uno::Any VbaFontBase::getColor() { - uno::Any aAny = OORGBToXLRGB( mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharColor", "TextColor" ) ) ); - return aAny; + if (meWhich == EXCEL){ + uno::Any aAny = OORGBToXLRGB( mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharColor", "TextColor" ) ) ); + return aAny; + } + else{ + uno::Any aAny = mxFont->getPropertyValue( VBAFONTBASE_PROPNAME( "CharColor", "TextColor" ) ); + return aAny; + } } void