diff options
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 50 | ||||
-rw-r--r-- | sd/source/ui/view/drtxtob1.cxx | 24 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 33 |
3 files changed, 37 insertions, 70 deletions
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index c99d4bd5df49..61ab0c301ed6 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -47,6 +47,7 @@ #include <comphelper/sequenceashashmap.hxx> #include <docmodel/uno/UnoTheme.hxx> #include <docmodel/theme/Theme.hxx> +#include <docmodel/color/ComplexColorJSON.hxx> #include <drawdoc.hxx> #include <DrawDocShell.hxx> @@ -1019,13 +1020,22 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) dispatchCommand(mxComponent, ".uno:SelectAll", {}); // When picking a theme color on the sidebar: - uno::Sequence<beans::PropertyValue> aColorArgs = { - comphelper::makePropertyValue("Color", static_cast<sal_Int32>(0xdae3f3)), // 80% light blue - comphelper::makePropertyValue("ColorThemeIndex", static_cast<sal_Int16>(4)), // accent 1 - comphelper::makePropertyValue("ColorLumMod", static_cast<sal_Int16>(2000)), - comphelper::makePropertyValue("ColorLumOff", static_cast<sal_Int16>(8000)), - }; - dispatchCommand(mxComponent, ".uno:Color", aColorArgs); + { + model::ComplexColor aComplexColor; + aComplexColor.setThemeColor(model::ThemeColorType::Accent1); + aComplexColor.addTransformation({ model::TransformationType::LumMod, 2000 }); + aComplexColor.addTransformation({ model::TransformationType::LumOff, 8000 }); + + OUString aJSON + = OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); + + // When setting the fill color of that shape, with theme metadata & effects: + uno::Sequence<beans::PropertyValue> aColorArgs = { + comphelper::makePropertyValue("Color.Color", sal_Int32(0xdae3f3)), // 80% light blue + comphelper::makePropertyValue("Color.ComplexColorJSON", uno::Any(aJSON)), + }; + dispatchCommand(mxComponent, ".uno:Color", aColorArgs); + } // Then make sure the theme "metadata" is set in the document model: pView->EndTextEditCurrentView(); @@ -1063,14 +1073,24 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme) uno::UNO_QUERY); xController->select(uno::Any(xShape)); - // When setting the fill color of that shape, with theme metadata & effects: - uno::Sequence<beans::PropertyValue> aColorArgs = { - comphelper::makePropertyValue("FillColor", static_cast<sal_Int32>(0xed7d31)), // orange - comphelper::makePropertyValue("ColorThemeIndex", static_cast<sal_Int16>(4)), // accent 1 - comphelper::makePropertyValue("ColorLumMod", static_cast<sal_Int16>(4000)), - comphelper::makePropertyValue("ColorLumOff", static_cast<sal_Int16>(6000)), - }; - dispatchCommand(mxComponent, ".uno:FillColor", aColorArgs); + // Change fill color + { + model::ComplexColor aComplexColor; + aComplexColor.setThemeColor(model::ThemeColorType::Accent1); + aComplexColor.addTransformation({ model::TransformationType::LumMod, 4000 }); + aComplexColor.addTransformation({ model::TransformationType::LumOff, 6000 }); + + OUString aJSON + = OStringToOUString(model::color::convertToJSON(aComplexColor), RTL_TEXTENCODING_UTF8); + + // When setting the fill color of that shape, with theme metadata & effects: + uno::Sequence<beans::PropertyValue> aColorArgs = { + comphelper::makePropertyValue("FillColor.Color", sal_Int32(0xed7d31)), // orange + comphelper::makePropertyValue("FillColor.ComplexColorJSON", + uno::Any(aJSON)), // accent 1 + }; + dispatchCommand(mxComponent, ".uno:FillColor", aColorArgs); + } // Then make sure the theme index is not lost when the sidebar sets it: { diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index f0e46120d5a4..b176db5596c8 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -774,30 +774,6 @@ void TextObjectBar::Execute( SfxRequest &rReq ) } std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone(); - - // Merge the color parameters to the color itself. - std::unique_ptr<SvxColorItem> pColorItem; - if (nSlot == SID_ATTR_CHAR_COLOR) - { - pColorItem = std::make_unique<SvxColorItem>(pNewArgs->Get(EE_CHAR_COLOR)); - model::ComplexColor aComplexColor; - - if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_THEME_INDEX, false)) - { - aComplexColor.setThemeColor(model::convertToThemeColorType(pIntItem->GetValue())); - } - if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_MOD, false)) - { - aComplexColor.addTransformation({model::TransformationType::LumMod, pIntItem->GetValue()}); - } - if (const SfxInt16Item* pIntItem = pArgs->GetItemIfSet(SID_ATTR_COLOR_LUM_OFF, false)) - { - aComplexColor.addTransformation({model::TransformationType::LumOff, pIntItem->GetValue()}); - } - pColorItem->setComplexColor(aComplexColor); - pNewArgs->Put(std::move(pColorItem)); - } - mpView->SetAttributes(*pNewArgs); // invalidate entire shell because of performance and diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 51ebf5ef0773..2fea8a46f879 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -549,7 +549,7 @@ public: } }; - void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs) + void lcl_convertStringArguments(const std::unique_ptr<SfxItemSet>& pArgs) { const SfxPoolItem* pItem = nullptr; @@ -573,35 +573,6 @@ public: pArgs->Put(aItem); } } - - if (nSlot == SID_ATTR_FILL_COLOR) - { - // Merge the color parameters to the color itself. - const XFillColorItem* pColorItem = static_cast<const XFillColorItem*>(pArgs->GetItem(SID_ATTR_FILL_COLOR)); - if (pColorItem) - { - XFillColorItem aColorItem(*pColorItem); - model::ComplexColor aComplexColor = aColorItem.getComplexColor(); - - if (pArgs->GetItemState(SID_ATTR_COLOR_THEME_INDEX, false, &pItem) == SfxItemState::SET) - { - auto pIntItem = static_cast<const SfxInt16Item*>(pItem); - aComplexColor.setThemeColor(model::convertToThemeColorType(pIntItem->GetValue())); - } - if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_MOD, false, &pItem) == SfxItemState::SET) - { - auto pIntItem = static_cast<const SfxInt16Item*>(pItem); - aComplexColor.addTransformation({model::TransformationType::LumMod, pIntItem->GetValue()}); - } - if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_OFF, false, &pItem) == SfxItemState::SET) - { - auto pIntItem = static_cast<const SfxInt16Item*>(pItem); - aComplexColor.addTransformation({model::TransformationType::LumOff, pIntItem->GetValue()}); - } - aColorItem.setComplexColor(aComplexColor); - pArgs->Put(aColorItem); - } - } } } @@ -693,7 +664,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) if( rReq.GetArgs() ) { std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone(); - lcl_convertStringArguments(rReq.GetSlot(), pNewArgs); + lcl_convertStringArguments(pNewArgs); mpDrawView->SetAttributes(*pNewArgs); rReq.Done(); } |