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.

Change-Id: I83e3c4fc37b8d7bd34f0ef9c0cb96e164f7f0b99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132646
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index f56a044..41664ef 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -959,6 +959,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_TEST_FIXTURE(SdUiImpressTest, testTdf127696)
{
    mxComponent = loadFromDesktop("private:factory/simpress",
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index bef73c1..2141cc9 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -594,6 +594,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 b4e3e50..b29647e 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -2781,7 +2781,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,