idl/source/objects/types.cxx | 1 include/svx/svxids.hrc | 4 ++ sd/qa/unit/uiimpress.cxx | 62 +++++++++++++++++++++++++++++++++ sd/source/ui/view/drtxtob1.cxx | 28 ++++++++++++++ svx/sdi/svx.sdi | 2 - svx/source/tbxctrls/PaletteManager.cxx | 14 +++++-- svx/source/tbxctrls/tbcontrl.cxx | 11 +++-- 7 files changed, 114 insertions(+), 8 deletions(-)
New commits: commit ca2a3ffb63fb701406ff453e2220b520c0319d0e Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Dec 22 10:40:58 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jun 30 12:39:04 2022 +0200 sd theme: allow setting color effects in the sidebar Which requires adding slot ids for the theme index / luminance modulation / luminance offset. Also merge them on the sd/ side, similar to what the character dialog does already. (cherry picked from commit 60d7796624f1c56eb036d3e73d7f8a8216cce2a4) Also squash in commit 03faef951a0dd4352a371ead89ca79040359234b (mergelibs: fix duplicate aSfxInt16Item_Impl, 2021-12-24). Change-Id: I0ae1b4d315b2bd53c17522dbccab160e6208716b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136625 Tested-by: Miklos Vajna <vmik...@collabora.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index 57d62c49c24c..46262e7b98d9 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -231,6 +231,7 @@ void SvMetaType::WriteSfxItem( bool bExport = false, bReturn = false; // these are exported from sfx library if (rItemName == "SfxBoolItem" || + rItemName == "SfxInt16Item" || rItemName == "SfxStringItem" || rItemName == "SfxUInt16Item" || rItemName == "SfxUInt32Item" || diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 9cd52877bf63..573f036128c8 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -430,6 +430,10 @@ class SdrAngleItem; #define SID_ATTR_TEXTCOLUMNS_NUMBER ( SID_SVX_START + 340 ) #define SID_ATTR_TEXTCOLUMNS_SPACING ( SID_SVX_START + 341 ) +#define SID_ATTR_COLOR_THEME_INDEX ( SID_SVX_START + 342 ) +#define SID_ATTR_COLOR_LUM_MOD ( SID_SVX_START + 343 ) +#define SID_ATTR_COLOR_LUM_OFF ( SID_SVX_START + 344 ) + #define SID_SB_CONNECTIONPOOLING ( SID_SVX_START + 348 ) #define SID_SB_DBREGISTEROPTIONS ( SID_SVX_START + 349 ) #define SID_BMPMASK ( SID_SVX_START + 350 ) diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 286672341a3b..abcd5fc084ad 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/table/XMergeableCell.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> @@ -42,6 +43,7 @@ #include <svl/stritem.hxx> #include <undo/undomanager.hxx> #include <vcl/scheduler.hxx> +#include <comphelper/propertyvalue.hxx> #include <DrawDocShell.hxx> #include <ViewShell.hxx> @@ -849,6 +851,66 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf142589) CPPUNIT_ASSERT_EQUAL(false, pImpressDocument->GetDoc()->getPresentationSettings().mbCustomShow); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) +{ + // Given an Impress document with a shape, with its text selected: + 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<text::XTextRange> xShape(xPage->getByIndex(0), uno::UNO_QUERY); + { + uno::Reference<text::XSimpleText> xText = xShape->getText(); + xText->insertString(xText->getStart(), "test", false); + } + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<view::XSelectionSupplier> xController(xModel->getCurrentController(), + uno::UNO_QUERY); + xController->select(uno::makeAny(xShape)); + Scheduler::ProcessEventsToIdle(); + dispatchCommand(mxComponent, ".uno:Text", {}); + Scheduler::ProcessEventsToIdle(); + auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell(); + SdrView* pView = pViewShell->GetView(); + CPPUNIT_ASSERT(pView->IsTextEdit()); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + Scheduler::ProcessEventsToIdle(); + + // 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); + Scheduler::ProcessEventsToIdle(); + + // Then make sure the theme "metadata" is set in the document model: + pView->EndTextEditCurrentView(); + CPPUNIT_ASSERT(!pView->IsTextEdit()); + uno::Reference<container::XEnumerationAccess> xShapeParaAccess(xShape, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xPara( + xShapeParaAccess->createEnumeration()->nextElement(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPortion(xPara->createEnumeration()->nextElement(), + uno::UNO_QUERY); + sal_Int16 nCharColorTheme{}; + xPortion->getPropertyValue("CharColorTheme") >>= nCharColorTheme; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4 + // - Actual : -1 + // i.e. the theme index (accent1) was not set. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), nCharColorTheme); + sal_Int16 nCharColorLumMod{}; + xPortion->getPropertyValue("CharColorLumMod") >>= nCharColorLumMod; + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(2000), nCharColorLumMod); + sal_Int16 nCharColorLumOff{}; + xPortion->getPropertyValue("CharColorLumOff") >>= nCharColorLumOff; + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(8000), nCharColorLumOff); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 7dd3f80be36c..3fa5aa4dfb51 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -816,6 +816,34 @@ void TextObjectBar::Execute( SfxRequest &rReq ) std::unique_ptr<SfxItemSet> pNewArgs = pArgs->Clone(); lcl_convertStringArguments(nSlot, pNewArgs); + + // 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)); + } + const SfxPoolItem* pItem = nullptr; + if (pArgs->GetItemState(SID_ATTR_COLOR_THEME_INDEX, false, &pItem) == SfxItemState::SET) + { + auto pIntItem = static_cast<const SfxInt16Item*>(pItem); + pColorItem->SetThemeIndex(pIntItem->GetValue()); + } + if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_MOD, false, &pItem) == SfxItemState::SET) + { + auto pIntItem = static_cast<const SfxInt16Item*>(pItem); + pColorItem->SetLumMod(pIntItem->GetValue()); + } + if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_OFF, false, &pItem) == SfxItemState::SET) + { + auto pIntItem = static_cast<const SfxInt16Item*>(pItem); + pColorItem->SetLumOff(pIntItem->GetValue()); + } + if (pColorItem) + { + pNewArgs->Put(*pColorItem); + } + mpView->SetAttributes(*pNewArgs); // invalidate entire shell because of performance and diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index d4a4d6eee905..94ef06fde21c 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -1506,7 +1506,7 @@ SfxVoidItem ClearOutline SID_OUTLINE_DELETEALL SvxColorItem Color SID_ATTR_CHAR_COLOR -(SfxStringItem Color SID_ATTR_COLOR_STR, SvxColorItem Color SID_ATTR_CHAR_COLOR) +(SfxStringItem Color SID_ATTR_COLOR_STR, SvxColorItem Color SID_ATTR_CHAR_COLOR, SfxInt16Item ColorThemeIndex SID_ATTR_COLOR_THEME_INDEX, SfxInt16Item ColorLumMod SID_ATTR_COLOR_LUM_MOD, SfxInt16Item ColorLumOff SID_ATTR_COLOR_LUM_OFF) [ AutoUpdate = TRUE, FastCall = FALSE, diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index c9ca2a3f70ab..cfc7eedeeeaf 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -32,6 +32,7 @@ #include <tbxcolorupdate.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <comphelper/sequence.hxx> #include <stack> #include <set> #include <officecfg/Office/Common.hxx> @@ -415,8 +416,15 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const svx::N INetURLObject aObj( aCommand ); - Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue(aObj.GetURLPath(), - sal_Int32(rColor.m_aColor)) }; + std::vector<PropertyValue> aArgs{ + comphelper::makePropertyValue(aObj.GetURLPath(), sal_Int32(rColor.m_aColor)), + }; + if (rColor.m_nThemeIndex != -1) + { + aArgs.push_back(comphelper::makePropertyValue("ColorThemeIndex", rColor.m_nThemeIndex)); + aArgs.push_back(comphelper::makePropertyValue("ColorLumMod", rColor.m_nLumMod)); + aArgs.push_back(comphelper::makePropertyValue("ColorLumOff", rColor.m_nLumOff)); + } URL aTargetURL; aTargetURL.Complete = aCommand; @@ -426,7 +434,7 @@ void PaletteManager::DispatchColorCommand(const OUString& aCommand, const svx::N Reference<XDispatch> xDispatch = xDispatchProvider->queryDispatch(aTargetURL, OUString(), 0); if (xDispatch.is()) { - xDispatch->dispatch(aTargetURL, aArgs); + xDispatch->dispatch(aTargetURL, comphelper::containerToSequence(aArgs)); if (xFrame->getContainerWindow().is()) xFrame->getContainerWindow()->setFocus(); } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index a649578e0e51..2025ef455076 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1966,15 +1966,18 @@ IMPL_LINK(ColorWindow, SelectHdl, ValueSet*, pColorSet, void) // triggers a callback that destroys ourself ColorSelectFunction aColorSelectFunction(maColorSelectFunction); OUString sCommand(maCommand); + // Same for querying IsTheme early. + bool bThemePaletteSelected = mxPaletteManager->IsThemePaletteSelected(); + sal_uInt16 nSelectedItemId = pColorSet->GetSelectedItemId(); maMenuButton.set_inactive(); auto aNamedThemedColor = svx::NamedThemedColor::FromNamedColor(aNamedColor); - if (mxPaletteManager->IsThemePaletteSelected()) + if (bThemePaletteSelected) { - PaletteManager::GetThemeIndexLumModOff( - pColorSet->GetSelectedItemId(), aNamedThemedColor.m_nThemeIndex, - aNamedThemedColor.m_nLumMod, aNamedThemedColor.m_nLumOff); + PaletteManager::GetThemeIndexLumModOff(nSelectedItemId, aNamedThemedColor.m_nThemeIndex, + aNamedThemedColor.m_nLumMod, + aNamedThemedColor.m_nLumOff); } aColorSelectFunction(sCommand, aNamedThemedColor); }