From 0548269ca03f093c41f6292e783cc6c77328808e Mon Sep 17 00:00:00 2001 From: Hannah Meeks Date: Fri, 23 Dec 2022 21:54:01 +0000 Subject: 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 --- vbahelper/source/vbahelper/vbafontbase.cxx | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'vbahelper') 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; countgetPropertyValue( 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 -- cgit