diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-05 13:12:34 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-18 12:57:51 +0000 |
commit | 8cec5a700a36ad6d3ac6b054a3366b22354d7f1d (patch) | |
tree | d5633bb5471805efade88ce9471544cce023e651 | |
parent | 5b1f5319fc065eac71267b29472111d81e0dc14e (diff) |
support theme color for lines + oox support + tests
Extended XLineColor to handle model::ThemeColor which then maps
to the newly added LineColorThemeData property.
Extended oox import and export to map the scheme color elements
to and from ThemeColor. Added a new test to check the theme line
color in impress shapes.
Change-Id: I23ecc18c88b5b47608c9110f5681f189d02e2f36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145071
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit af8fdba1194e657237f9abc460381a1c4bc49982)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145651
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/editeng/unoprnms.hxx | 1 | ||||
-rw-r--r-- | include/oox/export/drawingml.hxx | 2 | ||||
-rw-r--r-- | include/svx/unoshprp.hxx | 1 | ||||
-rw-r--r-- | oox/inc/drawingml/lineproperties.hxx | 3 | ||||
-rw-r--r-- | oox/qa/unit/data/ThemeShapesReference.pptx | bin | 0 -> 42644 bytes | |||
-rw-r--r-- | oox/qa/unit/drawingml.cxx | 72 | ||||
-rw-r--r-- | oox/source/drawingml/lineproperties.cxx | 34 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 4 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 62 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rw-r--r-- | sd/source/core/stlsheet.cxx | 10 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 12 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 10 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 44 |
14 files changed, 192 insertions, 64 deletions
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index 77d4636bb14f..a85afe0788f8 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -77,6 +77,7 @@ #define UNO_NAME_LINEDASH "LineDash" #define UNO_NAME_LINEWIDTH "LineWidth" #define UNO_NAME_LINECOLOR "LineColor" +#define UNO_NAME_LINECOLOR_THEME_REFERENCE "LineColorThemeReference" #define UNO_NAME_LINEJOINT "LineJoint" #define UNO_NAME_LINESTART "LineStart" #define UNO_NAME_LINEEND "LineEnd" diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index f2ef8c910da0..65c9112ab497 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -230,7 +230,7 @@ public: void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID ); bool WriteCharColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet); - bool WriteFillColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet); + bool WriteSchemeColor(OUString const& rPropertyName, const css::uno::Reference<css::beans::XPropertySet>& xPropertySet); void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT ); diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx index fec53929fb80..357655c5e71a 100644 --- a/include/svx/unoshprp.hxx +++ b/include/svx/unoshprp.hxx @@ -236,6 +236,7 @@ #define LINE_PROPERTIES_DEFAULTS\ { u"" UNO_NAME_LINECAP, XATTR_LINECAP, ::cppu::UnoType<css::drawing::LineCap>::get(), 0, 0}, \ { u"" UNO_NAME_LINECOLOR, XATTR_LINECOLOR, ::cppu::UnoType<sal_Int32>::get() , 0, 0}, \ + { u"" UNO_NAME_LINECOLOR_THEME_REFERENCE, XATTR_LINECOLOR, ::cppu::UnoType<css::uno::XInterface>::get() , 0, MID_COLOR_THEME_REFERENCE}, \ { u"" UNO_NAME_LINEENDCENTER, XATTR_LINEENDCENTER, cppu::UnoType<bool>::get() , 0, 0}, \ { u"" UNO_NAME_LINEENDWIDTH, XATTR_LINEENDWIDTH, ::cppu::UnoType<sal_Int32>::get() , 0, 0, PropertyMoreFlags::METRIC_ITEM}, \ { u"" UNO_NAME_LINEJOINT, XATTR_LINEJOINT, ::cppu::UnoType<css::drawing::LineJoint>::get(), 0, 0}, \ diff --git a/oox/inc/drawingml/lineproperties.hxx b/oox/inc/drawingml/lineproperties.hxx index 214aadba12e9..d2025515b67e 100644 --- a/oox/inc/drawingml/lineproperties.hxx +++ b/oox/inc/drawingml/lineproperties.hxx @@ -69,7 +69,8 @@ struct LineProperties void pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, - ::Color nPhClr = API_RGB_TRANSPARENT ) const; + ::Color nPhClr = API_RGB_TRANSPARENT, + sal_Int16 nPhClrTheme = -1) const; /** Calculates the line style attribute from the internal state of the object */ css::drawing::LineStyle getLineStyle() const; diff --git a/oox/qa/unit/data/ThemeShapesReference.pptx b/oox/qa/unit/data/ThemeShapesReference.pptx Binary files differnew file mode 100644 index 000000000000..d871cc56a099 --- /dev/null +++ b/oox/qa/unit/data/ThemeShapesReference.pptx diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx index 077ad261e620..db9db658ac48 100644 --- a/oox/qa/unit/drawingml.cxx +++ b/oox/qa/unit/drawingml.cxx @@ -509,7 +509,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTdf132557_footerCustomShapes) xShapeSlideNum->getShapeType()); } -CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeTint) +CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColorTint_Table) { // Given a document with a table style, using theme color with tinting in the A2 cell: OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "theme-tint.pptx"; @@ -557,6 +557,76 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeTint) } } +CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testThemeColor_Shape) +{ + // Given a document with a table style, using theme color with tinting in the A2 cell: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "ThemeShapesReference.pptx"; + load(aURL); + + // Then make sure that we only import theming info to the doc model if the effects are limited + // to lum mod / off that we can handle (i.e. no tint/shade): + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + + // check line and fill theme color of shape1 + { + model::ThemeColor aThemeColor; + uno::Reference<util::XThemeColor> xThemeColor; + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + + CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType()); + { + auto const& rTrans = aThemeColor.getTransformations(); + CPPUNIT_ASSERT_EQUAL(size_t(2), rTrans.size()); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTrans[0].mnValue); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, rTrans[1].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), rTrans[1].mnValue); + } + + CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent6, aThemeColor.getType()); + { + auto const& rTrans = aThemeColor.getTransformations(); + CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size()); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTrans[0].mnValue); + } + } + // check line and fill theme color of shape2 + { + model::ThemeColor aThemeColor; + uno::Reference<util::XThemeColor> xThemeColor; + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + + CPPUNIT_ASSERT(xShape->getPropertyValue("FillColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + { + auto const& rTrans = aThemeColor.getTransformations(); + CPPUNIT_ASSERT_EQUAL(size_t(0), rTrans.size()); + } + + CPPUNIT_ASSERT(xShape->getPropertyValue("LineColorThemeReference") >>= xThemeColor); + CPPUNIT_ASSERT(xThemeColor.is()); + model::theme::setFromXThemeColor(aThemeColor, xThemeColor); + CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aThemeColor.getType()); + { + auto const& rTrans = aThemeColor.getTransformations(); + CPPUNIT_ASSERT_EQUAL(size_t(1), rTrans.size()); + CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, rTrans[0].meType); + CPPUNIT_ASSERT_EQUAL(sal_Int16(7500), rTrans[0].mnValue); + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index dedde505e61a..0c4100bcd91c 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -34,6 +34,9 @@ #include <oox/helper/containerhelper.hxx> #include <oox/helper/graphichelper.hxx> #include <oox/token/tokens.hxx> +#include <oox/token/properties.hxx> +#include <docmodel/uno/UnoThemeColor.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -431,7 +434,7 @@ void LineProperties::assignUsed( const LineProperties& rSourceProps ) } void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, - const GraphicHelper& rGraphicHelper, ::Color nPhClr ) const + const GraphicHelper& rGraphicHelper, ::Color nPhClr, sal_Int16 nPhClrTheme) const { // line fill type must exist, otherwise ignore other properties if( !maLineFill.moFillType.has() ) @@ -491,11 +494,36 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, // line color and transparence Color aLineColor = maLineFill.getBestSolidColor(); - if( aLineColor.isUsed() ) + if (aLineColor.isUsed()) { - rPropMap.setProperty( ShapeProperty::LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) ); + ::Color aColor = aLineColor.getColor(rGraphicHelper, nPhClr); + rPropMap.setProperty(ShapeProperty::LineColor, aColor); if( aLineColor.hasTransparency() ) rPropMap.setProperty( ShapeProperty::LineTransparency, aLineColor.getTransparency() ); + + model::ThemeColor aThemeColor; + + if (aColor == nPhClr) + { + aThemeColor.setType(model::convertToThemeColorType(nPhClrTheme)); + rPropMap.setProperty(PROP_LineColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + } + else + { + aThemeColor.setType(model::convertToThemeColorType(aLineColor.getSchemeColorIndex())); + if (aLineColor.getLumMod() != 10000) + aThemeColor.addTransformation({model::TransformationType::LumMod, aLineColor.getLumMod()}); + if (aLineColor.getLumOff() != 0) + aThemeColor.addTransformation({model::TransformationType::LumOff, aLineColor.getLumOff()}); + if (aLineColor.getTintOrShade() > 0) + aThemeColor.addTransformation({model::TransformationType::Tint, aLineColor.getTintOrShade()}); + if (aLineColor.getTintOrShade() < 0) + { + sal_Int16 nShade = o3tl::narrowing<sal_Int16>(-aLineColor.getTintOrShade()); + aThemeColor.addTransformation({model::TransformationType::Shade, nShade}); + } + rPropMap.setProperty(PROP_LineColorThemeReference, model::theme::createXThemeColor(aThemeColor)); + } } // line markers diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 2343f8b3b027..c1af364f85ac 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1058,6 +1058,7 @@ Reference< XShape > const & Shape::createAndInsert( ::Color nLinePhClr(ColorTransparency, 0xffffffff); ::Color nFillPhClr(ColorTransparency, 0xffffffff); sal_Int16 nFillPhClrTheme = -1; + sal_Int16 nLinePhClrTheme = -1; // TODO: use ph color when applying effect properties //sal_Int32 nEffectPhClr = -1; @@ -1074,6 +1075,7 @@ Reference< XShape > const & Shape::createAndInsert( if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) aLineProperties.assignUsed( *pLineProps ); nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper ); + nLinePhClrTheme = pLineRef->maPhClr.getSchemeColorIndex(); // Store style-related properties to InteropGrabBag to be able to export them back uno::Sequence<beans::PropertyValue> aProperties = comphelper::InitPropertySequence( @@ -1166,7 +1168,7 @@ Reference< XShape > const & Shape::createAndInsert( if(!bIsCroppedGraphic) aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, nFillPhClrTheme, mbFlipH, mbFlipV, bIsCustomShape ); LineProperties aLineProperties = getActualLineProperties(pTheme); - aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr ); + aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr, nLinePhClrTheme); EffectProperties aEffectProperties = getActualEffectProperties(pTheme); // TODO: use ph color when applying effect properties aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 0db7abf2c8ef..da43043bd9c5 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -418,49 +418,6 @@ void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTra } } -bool DrawingML::WriteCharColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet) -{ - if (!xPropertySet->getPropertySetInfo()->hasPropertyByName("CharColorThemeReference")) - return false; - - uno::Reference<util::XThemeColor> xThemeColor; - xPropertySet->getPropertyValue("CharColorThemeReference") >>= xThemeColor; - if (!xThemeColor.is()) - return false; - - model::ThemeColor aThemeColor; - model::theme::setFromXThemeColor(aThemeColor, xThemeColor); - if (aThemeColor.getType() == model::ThemeColorType::Unknown) - return false; - const char* pColorName = g_aPredefinedClrNames[sal_Int16(aThemeColor.getType())]; - mpFS->startElementNS(XML_a, XML_solidFill); - mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, pColorName); - for (auto const& rTransform : aThemeColor.getTransformations()) - { - switch (rTransform.meType) - { - case model::TransformationType::LumMod: - mpFS->singleElementNS(XML_a, XML_lumMod, XML_val, OString::number(rTransform.mnValue * 10)); - break; - case model::TransformationType::LumOff: - mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, OString::number(rTransform.mnValue * 10)); - break; - case model::TransformationType::Tint: - mpFS->singleElementNS(XML_a, XML_tint, XML_val, OString::number(rTransform.mnValue * 10)); - break; - case model::TransformationType::Shade: - mpFS->singleElementNS(XML_a, XML_shade, XML_val, OString::number(rTransform.mnValue * 10)); - break; - default: - break; - } - } - mpFS->endElementNS(XML_a, XML_schemeClr); - mpFS->endElementNS(XML_a, XML_solidFill); - - return true; -} - void DrawingML::WriteSolidFill( ::Color nColor, sal_Int32 nAlpha ) { mpFS->startElementNS(XML_a, XML_solidFill); @@ -553,7 +510,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) else if ( nFillColor != nOriginalColor ) { // the user has set a different color for the shape - if (!WriteFillColor(rXPropSet)) + if (!WriteSchemeColor(u"FillColorThemeReference", rXPropSet)) { WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha); } @@ -571,13 +528,13 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) } } -bool DrawingML::WriteFillColor(const uno::Reference<beans::XPropertySet>& xPropertySet) +bool DrawingML::WriteSchemeColor(OUString const& rPropertyName, const uno::Reference<beans::XPropertySet>& xPropertySet) { - if (!xPropertySet->getPropertySetInfo()->hasPropertyByName("FillColorThemeReference")) + if (!xPropertySet->getPropertySetInfo()->hasPropertyByName(rPropertyName)) return false; uno::Reference<util::XThemeColor> xThemeColor; - xPropertySet->getPropertyValue("FillColorThemeReference") >>= xThemeColor; + xPropertySet->getPropertyValue(rPropertyName) >>= xThemeColor; if (!xThemeColor.is()) return false; @@ -598,6 +555,12 @@ bool DrawingML::WriteFillColor(const uno::Reference<beans::XPropertySet>& xPrope case model::TransformationType::LumOff: mpFS->singleElementNS(XML_a, XML_lumOff, XML_val, OString::number(rTransform.mnValue * 10)); break; + case model::TransformationType::Tint: + mpFS->singleElementNS(XML_a, XML_tint, XML_val, OString::number(rTransform.mnValue * 10)); + break; + case model::TransformationType::Shade: + mpFS->singleElementNS(XML_a, XML_shade, XML_val, OString::number(rTransform.mnValue * 10)); + break; default: break; } @@ -1058,7 +1021,8 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc if( nColor != nOriginalColor ) { // the user has set a different color for the line - WriteSolidFill( nColor, nColorAlpha ); + if (!WriteSchemeColor(u"LineColorThemeReference", rXPropSet)) + WriteSolidFill(nColor, nColorAlpha); } else if( !sColorFillScheme.isEmpty() ) { @@ -2260,7 +2224,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool { color.SetAlpha(255); // TODO: special handle embossed/engraved - if (!WriteCharColor(rXPropSet)) + if (!WriteSchemeColor(u"CharColorThemeReference", rXPropSet)) { WriteSolidFill(color, nTransparency); } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 7b504bd529bf..e31885499992 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -315,6 +315,7 @@ LeftPageHeaderContent LegacyFragment LineCap LineColor +LineColorThemeReference LineCount LineDash LineDashName diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx index 19f62ffd3140..cb1de01f1659 100644 --- a/sd/source/core/stlsheet.cxx +++ b/sd/source/core/stlsheet.cxx @@ -40,6 +40,7 @@ #include <svx/xflbmtit.hxx> #include <svx/xflbstit.hxx> +#include <svx/xlnclit.hxx> #include <editeng/bulletitem.hxx> #include <editeng/lrspitem.hxx> #include <svx/unoshprp.hxx> @@ -1363,6 +1364,15 @@ PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyN } } break; + case XATTR_LINECOLOR: + if (pEntry->nMemberId == MID_COLOR_THEME_REFERENCE) + { + auto const* pColor = rStyleSet.GetItem<XLineColorItem>(pEntry->nWID); + if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown) + { + eState = PropertyState_DEFAULT_VALUE; + } + } break; } } diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 89c2113fd4f4..8aef7510e45a 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -55,6 +55,7 @@ #include <editeng/charrotateitem.hxx> #include <svx/xflbstit.hxx> #include <svx/xflbmtit.hxx> +#include <svx/xlnclit.hxx> #include <svx/svdpool.hxx> #include <svx/xflclit.hxx> #include <tools/diagnose_ex.h> @@ -1444,7 +1445,6 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) } break; case XATTR_FILLCOLOR: - if (pMap->nMemberId == MID_COLOR_THEME_INDEX) { const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID); @@ -1490,6 +1490,16 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) } } break; + case XATTR_LINECOLOR: + if (pMap->nMemberId == MID_COLOR_THEME_REFERENCE) + { + auto const* pColor = rSet.GetItem<XLineColorItem>(pMap->nWID); + if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown) + { + eState = PropertyState_DEFAULT_VALUE; + } + } + break; } } } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 1f02b0c97c31..5cc292621bfa 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -42,6 +42,7 @@ #include <svx/xflbmtit.hxx> #include <svx/xlnstit.hxx> #include <svx/xlnedit.hxx> +#include <svx/xlnclit.hxx> #include <svx/svdmodel.hxx> #include <svx/svdobjkind.hxx> #include <svx/unopage.hxx> @@ -2086,6 +2087,15 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName ) } } break; + case XATTR_LINECOLOR: + if (pMap->nMemberId == MID_COLOR_THEME_REFERENCE) + { + auto const* pColor = rSet.GetItem<XLineColorItem>(pMap->nWID); + if (pColor->GetThemeColor().getType() == model::ThemeColorType::Unknown) + { + eState = beans::PropertyState_DEFAULT_VALUE; + } + } break; } } diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index d5da15155815..608829503d16 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -990,19 +990,49 @@ bool XLineColorItem::GetPresentation return true; } -bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const +bool XLineColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const { - rVal <<= GetColorValue().GetRGBColor(); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_COLOR_THEME_REFERENCE: + { + auto xThemeColor = model::theme::createXThemeColor(GetThemeColor()); + rVal <<= xThemeColor; + break; + } + default: + { + rVal <<= GetColorValue().GetRGBColor(); + break; + } + } return true; } -bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) +bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId) { - sal_Int32 nValue = 0; - if(!(rVal >>= nValue)) - return false; + nMemberId &= ~CONVERT_TWIPS; + switch(nMemberId) + { + case MID_COLOR_THEME_REFERENCE: + { + css::uno::Reference<css::util::XThemeColor> xThemeColor; + if (!(rVal >>= xThemeColor)) + return false; + model::theme::setFromXThemeColor(GetThemeColor(), xThemeColor); + } + break; + default: + { + sal_Int32 nValue; + if(!(rVal >>= nValue )) + return false; - SetColorValue( Color(ColorTransparency, nValue) ); + SetColorValue( Color(ColorTransparency, nValue) ); + break; + } + } return true; } |