diff options
Diffstat (limited to 'svx')
-rw-r--r-- | svx/sdi/svxitems.sdi | 8 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 64 |
2 files changed, 65 insertions, 7 deletions
diff --git a/svx/sdi/svxitems.sdi b/svx/sdi/svxitems.sdi index eabb753f647a..6e8773315d29 100644 --- a/svx/sdi/svxitems.sdi +++ b/svx/sdi/svxitems.sdi @@ -214,7 +214,13 @@ item String SvxPatternListItem; item String SfxLockBytesItem; item String SvxFontListItem; item String avmedia_MediaItem; -item INT32 XColorItem; +struct XColor +{ + INT32 Color MID_COLOR_RGB; + String ComplexColorJSON MID_COMPLEX_COLOR_JSON; +}; +item XColor XColorItem; + item INT16 SdrPercentItem; item INT32 SdrMetricItem; diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index d3fd73f5fa04..3cb12c467b74 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -306,18 +306,70 @@ const Color& XColorItem::GetColorValue() const } -bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const +bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId) const { - rVal <<= GetColorValue().GetRGBColor(); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_COMPLEX_COLOR: + { + auto xComplexColor = model::color::createXComplexColor(getComplexColor()); + rVal <<= xComplexColor; + break; + } + case MID_COMPLEX_COLOR_JSON: + { + rVal <<= OStringToOUString(model::color::convertToJSON(getComplexColor()), RTL_TEXTENCODING_UTF8); + break; + } + default: + { + rVal <<= GetColorValue().GetRGBColor(); + break; + } + } return true; } -bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) +bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId) { - Color nValue; - rVal >>= nValue; - SetColorValue( nValue ); + nMemberId &= ~CONVERT_TWIPS; + switch (nMemberId) + { + case MID_COMPLEX_COLOR: + { + css::uno::Reference<css::util::XComplexColor> xComplexColor; + if (!(rVal >>= xComplexColor)) + return false; + setComplexColor(model::color::getFromXComplexColor(xComplexColor)); + } + break; + case MID_COMPLEX_COLOR_JSON: + { + OUString sComplexColorJson; + if (!(rVal >>= sComplexColorJson)) + return false; + + if (sComplexColorJson.isEmpty()) + return false; + + OString aJSON = OUStringToOString(sComplexColorJson, RTL_TEXTENCODING_ASCII_US); + model::ComplexColor aComplexColor; + model::color::convertFromJSON(aJSON, aComplexColor); + setComplexColor(aComplexColor); + } + break; + default: + { + Color nValue; + if(!(rVal >>= nValue )) + return false; + + SetColorValue( nValue ); + } + break; + } return true; } |