sd/qa/unit/uiimpress.cxx | 32 ++++++++++++++++++++++++++++++++ sd/source/ui/view/drviews2.cxx | 13 +++++++++++++ svx/sdi/svx.sdi | 2 +- 3 files changed, 46 insertions(+), 1 deletion(-)
New commits: commit 0572eef9ba5526a1c7c1c05ad736f9d4347cd4b5 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Apr 6 20:14:52 2022 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Jul 1 11:40:39 2022 +0200 sd theme: add UI (sidebar) for shape fill color This requires extending .uno:FillColor with a new parameter, and then merging that parameter into the fill color item in sd/. The sidebar's color picker already generated these parameters. (cherry picked from commit f5db3b12ae1cd3bfe6ee5d260aec9532cc65f2dc) Conflicts: sd/qa/unit/uiimpress.cxx Change-Id: I83e3c4fc37b8d7bd34f0ef9c0cb96e164f7f0b99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136693 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index abcd5fc084ad..fd4756388463 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -911,6 +911,38 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(8000), nCharColorLumOff); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme) +{ + // Given an Impress document with a selected shape: + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + uno::Reference<drawing::XDrawPagesSupplier> xPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xPage(xPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<view::XSelectionSupplier> xController(xModel->getCurrentController(), + uno::UNO_QUERY); + xController->select(uno::makeAny(xShape)); + + // When setting the fill color of that shape, with theme metadata: + uno::Sequence<beans::PropertyValue> aColorArgs = { + comphelper::makePropertyValue("FillColor", static_cast<sal_Int32>(0xed7d31)), // orange + comphelper::makePropertyValue("ColorThemeIndex", static_cast<sal_Int16>(4)), // accent 1 + }; + dispatchCommand(mxComponent, ".uno:FillColor", aColorArgs); + Scheduler::ProcessEventsToIdle(); + + // Then make sure the theme index is not lost when the sidebar sets it: + sal_Int16 nFillColorTheme{}; + xShape->getPropertyValue("FillColorTheme") >>= nFillColorTheme; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4 + // - Actual : -1 + // i.e. the theme index was lost during the dispatch of the command. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nFillColorTheme); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 87d1a34e2ebe..b7f0638adb15 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -593,6 +593,19 @@ public: pArgs->Put(aItem); } } + + if (nSlot == SID_ATTR_FILL_COLOR) + { + // Merge the color parameters to the color itself. + XFillColorItem aColorItem( + *static_cast<const XFillColorItem*>(pArgs->GetItem(SID_ATTR_FILL_COLOR))); + if (pArgs->GetItemState(SID_ATTR_COLOR_THEME_INDEX, false, &pItem) == SfxItemState::SET) + { + auto pIntItem = static_cast<const SfxInt16Item*>(pItem); + aColorItem.GetThemeColor().SetThemeIndex(pIntItem->GetValue()); + } + pArgs->Put(aColorItem); + } } } diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 94ef06fde21c..4a258d860439 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -2746,7 +2746,7 @@ XFillBitmapItem FillPageBitmap SID_ATTR_PAGE_BITMAP ] XFillColorItem FillColor SID_ATTR_FILL_COLOR -(SfxStringItem Color SID_ATTR_COLOR_STR, XFillColorItem FillColor SID_ATTR_FILL_COLOR) +(SfxStringItem Color SID_ATTR_COLOR_STR, XFillColorItem FillColor SID_ATTR_FILL_COLOR, SfxInt16Item ColorThemeIndex SID_ATTR_COLOR_THEME_INDEX) [ AutoUpdate = TRUE, FastCall = FALSE,
