cui/source/tabpages/tpline.cxx | 12 ++++++--- sd/inc/theme/ThemeColorChanger.hxx | 5 +++ sd/qa/unit/ThemeTest.cxx | 6 +++- sd/source/core/ThemeColorChanger.cxx | 46 ++++++++++++++++++++++++++++++++++- sd/source/ui/view/drviews2.cxx | 5 ++- 5 files changed, 65 insertions(+), 9 deletions(-)
New commits: commit 593d97ff8b071a4966c6b083340e5a8144ff9a93 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Aug 14 22:32:36 2023 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Aug 28 12:43:45 2023 +0200 sd: change fill/line theme colors for graphic styles on theme change Change-Id: Ieeb425519e805160bf6726a64086508290f9d521 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155684 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit b5aaf194866c5e416167cb54d37f9f04dabc5375) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156161 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sd/inc/theme/ThemeColorChanger.hxx b/sd/inc/theme/ThemeColorChanger.hxx index 8c8179460dd8..72ae70a0ea3c 100644 --- a/sd/inc/theme/ThemeColorChanger.hxx +++ b/sd/inc/theme/ThemeColorChanger.hxx @@ -13,6 +13,8 @@ #include <svx/theme/IThemeColorChanger.hxx> #include <docmodel/theme/ColorSet.hxx> #include <svx/svdpage.hxx> +#include <svx/svdpage.hxx> +#include <drawdoc.hxx> namespace sd { @@ -20,9 +22,10 @@ class SD_DLLPUBLIC ThemeColorChanger : public svx::IThemeColorChanger { private: SdrPage* mpMasterPage; + sd::DrawDocShell* mpDocShell; public: - ThemeColorChanger(SdrPage* pMasterPage); + ThemeColorChanger(SdrPage* pMasterPage, sd::DrawDocShell* pDocShell); virtual ~ThemeColorChanger() override; void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; diff --git a/sd/qa/unit/ThemeTest.cxx b/sd/qa/unit/ThemeTest.cxx index 71313b48a7e6..9a663106c1c8 100644 --- a/sd/qa/unit/ThemeTest.cxx +++ b/sd/qa/unit/ThemeTest.cxx @@ -67,6 +67,10 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) // Given a document, with a first slide and blue shape text from theme: loadFromURL(u"theme.pptx"); + SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pXImpressDocument); + auto* pDocShell = pXImpressDocument->GetDocShell(); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); // The draw page also contains a group shape to make sure we don't crash on group shapes. uno::Reference<drawing::XMasterPageTarget> xDrawPage( @@ -131,7 +135,7 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) auto* pMasterPage = GetSdrPageFromXDrawPage(xDrawPageMaster); auto pTheme = pMasterPage->getSdrPageProperties().GetTheme(); - sd::ThemeColorChanger aChanger(pMasterPage); + sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); aChanger.apply(pTheme->getColorSet()); // Then make sure the shape text color is now green: diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx index 7ca2b6478232..d0a84c866495 100644 --- a/sd/source/core/ThemeColorChanger.cxx +++ b/sd/source/core/ThemeColorChanger.cxx @@ -12,13 +12,19 @@ #include <svx/svdmodel.hxx> #include <svx/svditer.hxx> #include <docmodel/theme/Theme.hxx> +#include <DrawDocShell.hxx> +#include <stlsheet.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xflclit.hxx> +#include <svx/xdef.hxx> using namespace css; namespace sd { -ThemeColorChanger::ThemeColorChanger(SdrPage* pMasterPage) +ThemeColorChanger::ThemeColorChanger(SdrPage* pMasterPage, sd::DrawDocShell* pDocShell) : mpMasterPage(pMasterPage) + , mpDocShell(pDocShell) { } @@ -37,10 +43,48 @@ void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr<model::ColorSet> const pTheme->setColorSet(pColorSet); } +bool changeStyles(sd::DrawDocShell* pDocShell, std::shared_ptr<model::ColorSet> const& pColorSet) +{ + SfxStyleSheetBasePool* pPool = pDocShell->GetStyleSheetPool(); + + SdStyleSheet* pStyle = static_cast<SdStyleSheet*>(pPool->First(SfxStyleFamily::Para)); + while (pStyle) + { + auto& rItemSet = pStyle->GetItemSet(); + if (const XFillColorItem* pItem = rItemSet.GetItemIfSet(XATTR_FILLCOLOR, false)) + { + model::ComplexColor const& rComplexColor = pItem->getComplexColor(); + if (rComplexColor.isValidThemeType()) + { + Color aNewColor = pColorSet->resolveColor(rComplexColor); + std::unique_ptr<XFillColorItem> pNewItem(pItem->Clone()); + pNewItem->SetColorValue(aNewColor); + rItemSet.Put(*pNewItem); + } + } + if (const XLineColorItem* pItem = rItemSet.GetItemIfSet(XATTR_LINECOLOR, false)) + { + model::ComplexColor const& rComplexColor = pItem->getComplexColor(); + if (rComplexColor.isValidThemeType()) + { + Color aNewColor = pColorSet->resolveColor(rComplexColor); + std::unique_ptr<XLineColorItem> pNewItem(pItem->Clone()); + pNewItem->SetColorValue(aNewColor); + rItemSet.Put(*pNewItem); + } + } + pStyle = static_cast<SdStyleSheet*>(pPool->Next()); + } + + return true; +} + } // end anonymous ns void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) { + changeStyles(mpDocShell, pColorSet); + SdrModel& rModel = mpMasterPage->getSdrModelFromSdrPage(); for (sal_uInt16 nPage = 0; nPage < rModel.GetPageCount(); ++nPage) { diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 95efac1c5358..0f5b6b9256c5 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -3589,7 +3589,8 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) SdrPage* pMasterPage = &GetActualPage()->TRG_GetMasterPage(); auto pTheme = pMasterPage->getSdrPageProperties().GetTheme(); auto pDialog = std::make_shared<svx::ThemeDialog>(GetFrameWeld(), pTheme.get()); - weld::DialogController::runAsync(pDialog, [pDialog, pMasterPage](sal_uInt32 nResult) + auto* pDocShell = GetDocSh(); + weld::DialogController::runAsync(pDialog, [pDialog, pMasterPage, pDocShell](sal_uInt32 nResult) { if (RET_OK != nResult) return; @@ -3597,7 +3598,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) auto pColorSet = pDialog->getCurrentColorSet(); if (pColorSet) { - sd::ThemeColorChanger aChanger(pMasterPage); + sd::ThemeColorChanger aChanger(pMasterPage, pDocShell); aChanger.apply(pColorSet); if (comphelper::LibreOfficeKit::isActive()) commit 3498bb21500f03bb20790fc9ed86e4057b3ebd6a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Aug 14 22:28:16 2023 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Aug 28 12:43:31 2023 +0200 Fix setting ComplexColor for lines/strokes through the dialog Setting the line/stroke color through the (tab) dialog did not work as the complex colors was not set to the XLineColorItem. Change-Id: Ie1404264f2f82964fe3a5507a6f61ba269254134 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155683 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 37203cb43758048134584f7d52efbc9b3dc59f65) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156160 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 01786624aa02..db8d65458f12 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -456,8 +456,10 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) // Line color if (m_xLbColor->IsValueChangedFromSaved()) { - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - XLineColorItem aItem(aColor.m_aName, aColor.m_aColor); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aItem(aNamedColor.m_aName, aNamedColor.m_aColor); + aItem.setComplexColor(aNamedColor.getComplexColor()); + pOld = GetOldItem( *rAttrs, XATTR_LINECOLOR ); if ( !pOld || !( *static_cast<const XLineColorItem*>(pOld) == aItem ) ) { @@ -758,8 +760,10 @@ void SvxLineTabPage::FillXLSet_Impl() m_rXLSet.Put( XLineEndWidthItem( GetCoreValue( *m_xMtrEndWidth, m_ePoolUnit ) ) ); m_rXLSet.Put( XLineWidthItem( GetCoreValue( *m_xMtrLineWidth, m_ePoolUnit ) ) ); - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - m_rXLSet.Put(XLineColorItem(aColor.m_aName, aColor.m_aColor)); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aLineColor(aNamedColor.m_aName, aNamedColor.m_aColor); + aLineColor.setComplexColor(aNamedColor.getComplexColor()); + m_rXLSet.Put(aLineColor); // Centered line end if( m_xTsbCenterStart->get_state() == TRISTATE_TRUE )