sd theme: add PPTX import for shape fill color

The theme index is typically not a direct property, but comes from style
-> fillref -> theme index, so support that.

Change-Id: I00733db44bb5321019bbc7337d10feb0a34661a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131268
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna
2022-03-09 20:51:34 +01:00
parent 51fb84829a
commit f5089e7453
5 changed files with 19 additions and 5 deletions

View File

@@ -145,6 +145,7 @@ struct FillProperties
const GraphicHelper& rGraphicHelper,
sal_Int32 nShapeRotation = 0,
::Color nPhClr = API_RGB_TRANSPARENT,
sal_Int16 nPhClrTheme = -1,
bool bFlipH = false,
bool bFlipV = false,
bool bIsCustomShape = false ) const;

View File

@@ -371,7 +371,7 @@ Color FillProperties::getBestSolidColor() const
}
void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr,
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr, sal_Int16 nPhClrTheme,
bool bFlipH, bool bFlipV, bool bIsCustomShape) const
{
if( !moFillType.has() )
@@ -388,9 +388,16 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
case XML_solidFill:
if( maFillColor.isUsed() )
{
rPropMap.setProperty( ShapeProperty::FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
::Color aFillColor = maFillColor.getColor(rGraphicHelper, nPhClr);
rPropMap.setProperty(ShapeProperty::FillColor, aFillColor);
if( maFillColor.hasTransparency() )
rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() );
if (aFillColor == nPhClr)
{
rPropMap.setProperty(PROP_FillColorTheme, nPhClrTheme);
}
eFillStyle = FillStyle_SOLID;
}
break;

View File

@@ -1161,6 +1161,7 @@ Reference< XShape > const & Shape::createAndInsert(
::Color nLinePhClr(ColorTransparency, 0xffffffff);
::Color nFillPhClr(ColorTransparency, 0xffffffff);
sal_Int16 nFillPhClrTheme = -1;
// TODO: use ph color when applying effect properties
//sal_Int32 nEffectPhClr = -1;
@@ -1197,6 +1198,7 @@ Reference< XShape > const & Shape::createAndInsert(
if (!mbUseBgFill)
{
nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
nFillPhClrTheme = pFillRef->maPhClr.getSchemeColorIndex();
}
OUString sColorScheme = pFillRef->maPhClr.getSchemeColorName();
@@ -1259,7 +1261,7 @@ Reference< XShape > const & Shape::createAndInsert(
if (getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill)
getFillProperties().assignUsed(aFillProperties);
if(!bIsCroppedGraphic)
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV, bIsCustomShape );
aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape );
LineProperties aLineProperties = getActualLineProperties(pTheme);
aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
EffectProperties aEffectProperties = getActualEffectProperties(pTheme);

View File

@@ -176,6 +176,7 @@ FillBitmapSizeX
FillBitmapSizeY
FillBitmap
FillColor
FillColorTheme
FillGradient
FillGradientName
FillHatch

View File

@@ -93,8 +93,11 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange)
uno::Reference<beans::XPropertySet> xShape4(xDrawPageShapes->getByIndex(4), uno::UNO_QUERY);
// Blue.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472c4), GetShapeFillColor(xShape4));
// Set theme index to accent 1 till PPTX import is missing.
xShape4->setPropertyValue("FillColorTheme", uno::makeAny(static_cast<sal_Int16>(4)));
// The theme index of this filled shape is set by the PPTX import:
sal_Int32 nColorTheme = -1;
xShape4->getPropertyValue("FillColorTheme") >>= nColorTheme;
// 4 means accent1, this was -1 without the PPTX import bit in place.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), nColorTheme);
// When changing the master slide of slide 1 to use the theme of the second master slide:
uno::Reference<drawing::XMasterPageTarget> xDrawPage2(