include/svx/theme/ThemeColorChangerCommon.hxx | 12 --- sc/qa/unit/ucalc_sparkline.cxx | 1 sc/source/ui/inc/ThemeColorChanger.hxx | 2 sc/source/ui/theme/ThemeColorChanger.cxx | 1 sd/CppunitTest_sd_theme_tests.mk | 78 +++++++++++++++++++++++ sd/Library_sd.mk | 1 sd/Module_sd.mk | 1 sd/inc/theme/ThemeColorChanger.hxx | 33 +++++++++ sd/qa/unit/ThemeTest.cxx | 88 ++++++++++++++------------ sd/sdi/_drvwsh.sdi | 6 + sd/source/core/ThemeColorChanger.cxx | 75 ++++++++++++++++++++++ sd/source/ui/view/drviews2.cxx | 35 ++++++++++ sd/uiconfig/sdraw/menubar/menubar.xml | 1 sd/uiconfig/simpress/menubar/menubar.xml | 1 svx/CppunitTest_svx_styles.mk | 49 -------------- svx/Library_svxcore.mk | 2 svx/Module_svx.mk | 1 svx/source/svdraw/svdpage.cxx | 18 ----- svx/source/theme/ThemeColorChangerCommon.cxx | 39 ----------- sw/source/core/inc/ThemeColorChanger.hxx | 2 sw/source/core/model/ThemeColorChanger.cxx | 1 21 files changed, 289 insertions(+), 158 deletions(-)
New commits: commit c0ba7ba97ce440eff77526e48e3dfbafacc1cdad Author: Tomaž Vajngerl <[email protected]> AuthorDate: Sat Aug 12 04:03:57 2023 +0900 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Aug 28 12:43:11 2023 +0200 sd: add ThemeDialog to Impress/Draw, refactor ThemeColorChanger Add "Theme" menu action, which starts the common ThemeDialog. Add Impress/Draw specific ThemeColorChanger and remove the one in svx, so that only the interface and common function remain. Rename the svx ThemeColorChanger files to THemeColorChangerCommon. Change-Id: Ibf07a443cadf0452747ab6685f65df37b145c984 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155682 Tested-by: Tomaž Vajngerl <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> (cherry picked from commit ad873064b0135e4e00389cd38c7de688286c1fa1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156159 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/svx/theme/ThemeColorChanger.hxx b/include/svx/theme/ThemeColorChangerCommon.hxx similarity index 72% rename from include/svx/theme/ThemeColorChanger.hxx rename to include/svx/theme/ThemeColorChangerCommon.hxx index 8e942ea975ad..235648df2cab 100644 --- a/include/svx/theme/ThemeColorChanger.hxx +++ b/include/svx/theme/ThemeColorChangerCommon.hxx @@ -22,18 +22,6 @@ namespace theme SVXCORE_DLLPUBLIC void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject); } -class SVXCORE_DLLPUBLIC ThemeColorChanger : public IThemeColorChanger -{ -private: - SdrPage* mpPage; - -public: - ThemeColorChanger(SdrPage* pPage); - virtual ~ThemeColorChanger() override; - - void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; -}; - } // end svx namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/unit/ucalc_sparkline.cxx b/sc/qa/unit/ucalc_sparkline.cxx index bd4ffe5c9772..459f1d651dca 100644 --- a/sc/qa/unit/ucalc_sparkline.cxx +++ b/sc/qa/unit/ucalc_sparkline.cxx @@ -20,6 +20,7 @@ #include <SparklineAttributes.hxx> #include <ThemeColorChanger.hxx> #include <docmodel/theme/Theme.hxx> +#include <svx/svdpage.hxx> using namespace css; diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx b/sc/source/ui/inc/ThemeColorChanger.hxx index f3f3b7379671..57ca91cdb83c 100644 --- a/sc/source/ui/inc/ThemeColorChanger.hxx +++ b/sc/source/ui/inc/ThemeColorChanger.hxx @@ -11,7 +11,7 @@ #pragma once #include <scdllapi.h> -#include <svx/theme/ThemeColorChanger.hxx> +#include <svx/theme/IThemeColorChanger.hxx> #include "docsh.hxx" namespace sc diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index 2c0933da5cd9..acef84f89fa0 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -19,6 +19,7 @@ #include <editeng/boxitem.hxx> #include <editeng/borderline.hxx> #include <svx/svditer.hxx> +#include <svx/theme/ThemeColorChangerCommon.hxx> #include <undodraw.hxx> #include <stlpool.hxx> diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 3c60a60b3a3d..24e3c985a4ee 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -154,6 +154,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/core/EffectMigration \ sd/source/core/PageListWatcher \ sd/source/core/TransitionPreset \ + sd/source/core/ThemeColorChanger \ sd/source/core/anminfo \ sd/source/core/annotations/Annotation \ sd/source/core/annotations/AnnotationEnumeration \ diff --git a/sd/inc/theme/ThemeColorChanger.hxx b/sd/inc/theme/ThemeColorChanger.hxx new file mode 100644 index 000000000000..8c8179460dd8 --- /dev/null +++ b/sd/inc/theme/ThemeColorChanger.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sddllapi.h> +#include <svx/theme/IThemeColorChanger.hxx> +#include <docmodel/theme/ColorSet.hxx> +#include <svx/svdpage.hxx> + +namespace sd +{ +class SD_DLLPUBLIC ThemeColorChanger : public svx::IThemeColorChanger +{ +private: + SdrPage* mpMasterPage; + +public: + ThemeColorChanger(SdrPage* pMasterPage); + virtual ~ThemeColorChanger() override; + + void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; +}; + +} // end sd namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/ThemeTest.cxx b/sd/qa/unit/ThemeTest.cxx index c085be7721bc..71313b48a7e6 100644 --- a/sd/qa/unit/ThemeTest.cxx +++ b/sd/qa/unit/ThemeTest.cxx @@ -16,6 +16,7 @@ #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/text/XTextRange.hpp> #include <docmodel/uno/UnoComplexColor.hxx> +#include <docmodel/theme/Theme.hxx> #include <svx/unoapi.hxx> @@ -23,6 +24,7 @@ #include <unomodel.hxx> #include <sdpage.hxx> #include <ViewShell.hxx> +#include <theme/ThemeColorChanger.hxx> using namespace css; @@ -38,7 +40,7 @@ public: namespace { /// Get the character color of the first text portion in xShape. -sal_Int32 GetShapeTextColor(const uno::Reference<text::XTextRange>& xShape) +Color GetShapeTextColor(const uno::Reference<text::XTextRange>& xShape) { uno::Reference<container::XEnumerationAccess> xText(xShape->getText(), uno::UNO_QUERY); uno::Reference<container::XEnumerationAccess> xPara(xText->createEnumeration()->nextElement(), @@ -47,15 +49,15 @@ sal_Int32 GetShapeTextColor(const uno::Reference<text::XTextRange>& xShape) uno::UNO_QUERY); sal_Int32 nColor{}; xPortion->getPropertyValue("CharColor") >>= nColor; - return nColor; + return Color(nColor); } /// Get the solid fill color of xShape. -sal_Int32 GetShapeFillColor(const uno::Reference<beans::XPropertySet>& xShape) +Color GetShapeFillColor(const uno::Reference<beans::XPropertySet>& xShape) { sal_Int32 nColor{}; xShape->getPropertyValue("FillColor") >>= nColor; - return nColor; + return Color(nColor); } } // end anonymous namespace @@ -86,7 +88,7 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) // Shape fill: uno::Reference<beans::XPropertySet> xShape4(xDrawPageShapes->getByIndex(4), uno::UNO_QUERY); // Blue. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472c4), GetShapeFillColor(xShape4)); + CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), GetShapeFillColor(xShape4)); // The theme color of this filled shape is set by the PPTX import: { @@ -99,7 +101,7 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); // Blue, lighter. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeFillColor(xShape5)); + CPPUNIT_ASSERT_EQUAL(Color(0xb4c7e7), GetShapeFillColor(xShape5)); // The theme index, and effects (lum mod, lum off) are set by the PPTX import: { uno::Reference<util::XComplexColor> xComplexColor; @@ -124,6 +126,14 @@ CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY); xMasterPage->setPropertyValue("Theme", aTheme); + css::uno::Reference<css::drawing::XDrawPage> xDrawPageMaster(xMasterPage, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDrawPageMaster.is()); + auto* pMasterPage = GetSdrPageFromXDrawPage(xDrawPageMaster); + auto pTheme = pMasterPage->getSdrPageProperties().GetTheme(); + + sd::ThemeColorChanger aChanger(pMasterPage); + aChanger.apply(pTheme->getColorSet()); + // Then make sure the shape text color is now green: CPPUNIT_ASSERT_EQUAL(Color(0x90c226), GetShapeTextColor(xShape)); // Green, lighter: diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index b9c52054b897..f28ccfb7e7bd 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -2942,5 +2942,9 @@ interface DrawView ExecMethod = FuTemporary; StateMethod = GetAttrState; ] - + SID_THEME_DIALOG + [ + ExecMethod = FuTemporary; + StateMethod = GetAttrState; + ] } diff --git a/sd/source/core/ThemeColorChanger.cxx b/sd/source/core/ThemeColorChanger.cxx new file mode 100644 index 000000000000..7ca2b6478232 --- /dev/null +++ b/sd/source/core/ThemeColorChanger.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <theme/ThemeColorChanger.hxx> +#include <svx/theme/ThemeColorChangerCommon.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svditer.hxx> +#include <docmodel/theme/Theme.hxx> + +using namespace css; + +namespace sd +{ +ThemeColorChanger::ThemeColorChanger(SdrPage* pMasterPage) + : mpMasterPage(pMasterPage) +{ +} + +ThemeColorChanger::~ThemeColorChanger() = default; + +namespace +{ +void changeTheTheme(SdrPage* pMasterPage, std::shared_ptr<model::ColorSet> const& pColorSet) +{ + auto pTheme = pMasterPage->getSdrPageProperties().GetTheme(); + if (!pTheme) + { + pTheme = std::make_shared<model::Theme>("Office"); + pMasterPage->getSdrPageProperties().SetTheme(pTheme); + } + pTheme->setColorSet(pColorSet); +} + +} // end anonymous ns + +void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) +{ + SdrModel& rModel = mpMasterPage->getSdrModelFromSdrPage(); + for (sal_uInt16 nPage = 0; nPage < rModel.GetPageCount(); ++nPage) + { + SdrPage* pCurrentPage = rModel.GetPage(nPage); + if (!pCurrentPage->TRG_HasMasterPage() + || &pCurrentPage->TRG_GetMasterPage() != mpMasterPage) + continue; + + for (size_t nObject = 0; nObject < pCurrentPage->GetObjCount(); ++nObject) + { + SdrObject* pObject = pCurrentPage->GetObj(nObject); + svx::theme::updateSdrObject(*pColorSet, pObject); + + // update child objects + SdrObjList* pList = pObject->GetSubList(); + if (pList) + { + SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); + while (aIter.IsMore()) + { + svx::theme::updateSdrObject(*pColorSet, aIter.Next()); + } + } + } + } + + changeTheTheme(mpMasterPage, pColorSet); +} + +} // end sd namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 9ff430918842..95efac1c5358 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -186,6 +186,12 @@ #include <controller/SlsPageSelector.hxx> #include <tools/GraphicSizeCheck.hxx> +#include <theme/ThemeColorChanger.hxx> +#include <svx/dialog/ThemeDialog.hxx> +#include <svx/theme/ThemeColorPaletteManager.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> + #include <ViewShellBase.hxx> #include <memory> @@ -3578,6 +3584,35 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) } break; + case SID_THEME_DIALOG: + { + 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) + { + if (RET_OK != nResult) + return; + + auto pColorSet = pDialog->getCurrentColorSet(); + if (pColorSet) + { + sd::ThemeColorChanger aChanger(pMasterPage); + aChanger.apply(pColorSet); + + if (comphelper::LibreOfficeKit::isActive()) + { + svx::ThemeColorPaletteManager aManager(pColorSet); + SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, aManager.generateJSON()); + } + } + }); + + Cancel(); + rReq.Ignore(); + } + break; + case SID_ADDITIONS_DIALOG: { OUString sAdditionsTag = ""; diff --git a/sd/uiconfig/sdraw/menubar/menubar.xml b/sd/uiconfig/sdraw/menubar/menubar.xml index 640a4446e322..b1eddcb79b5c 100644 --- a/sd/uiconfig/sdraw/menubar/menubar.xml +++ b/sd/uiconfig/sdraw/menubar/menubar.xml @@ -363,6 +363,7 @@ <menu:menuitem menu:id=".uno:FontDialog"/> <menu:menuitem menu:id=".uno:ParagraphDialog"/> <menu:menuitem menu:id=".uno:OutlineBullet"/> + <menu:menuitem menu:id=".uno:ThemeDialog"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:ModifyLayer"/> <menu:menu menu:id=".uno:TableMenu"> diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml index 23f80c7276a5..010e764ce3d1 100644 --- a/sd/uiconfig/simpress/menubar/menubar.xml +++ b/sd/uiconfig/simpress/menubar/menubar.xml @@ -395,6 +395,7 @@ <menu:menuitem menu:id=".uno:FontDialog"/> <menu:menuitem menu:id=".uno:ParagraphDialog"/> <menu:menuitem menu:id=".uno:OutlineBullet"/> + <menu:menuitem menu:id=".uno:ThemeDialog"/> <menu:menuseparator/> <menu:menu menu:id=".uno:TableMenu"> <menu:menupopup> diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index b2386326301d..456be06af7fa 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -429,7 +429,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/table/tablerows \ svx/source/table/tableundo \ svx/source/table/viewcontactoftableobj \ - svx/source/theme/ThemeColorChanger \ + svx/source/theme/ThemeColorChangerCommon \ svx/source/theme/ThemeColorPaletteManager \ svx/source/tbxctrls/extrusioncontrols \ svx/source/tbxctrls/fontworkgallery \ diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index dd8ac4c53fec..7caed6bbfc58 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -45,7 +45,6 @@ #include <svx/svdundo.hxx> #include <svx/xfillit0.hxx> #include <svx/fmdpage.hxx> -#include <svx/theme/ThemeColorChanger.hxx> #include <svx/ColorSets.hxx> #include <sdr/contact/viewcontactofsdrpage.hxx> @@ -1308,23 +1307,6 @@ void SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme) return; mpTheme = pTheme; - - if (mpTheme && mpTheme->getColorSet() && mpSdrPage->IsMasterPage()) - { - SdrModel& rModel = mpSdrPage->getSdrModelFromSdrPage(); - sal_uInt16 nPageCount = rModel.GetPageCount(); - for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage) - { - SdrPage* pPage = rModel.GetPage(nPage); - if (!pPage->TRG_HasMasterPage() || &pPage->TRG_GetMasterPage() != mpSdrPage) - { - continue; - } - - svx::ThemeColorChanger aChanger(pPage); - aChanger.apply(mpTheme->getColorSet()); - } - } } std::shared_ptr<model::Theme> const& SdrPageProperties::GetTheme() const diff --git a/svx/source/theme/ThemeColorChanger.cxx b/svx/source/theme/ThemeColorChangerCommon.cxx similarity index 83% rename from svx/source/theme/ThemeColorChanger.cxx rename to svx/source/theme/ThemeColorChangerCommon.cxx index 7e7ba984729d..db78e1c343b1 100644 --- a/svx/source/theme/ThemeColorChanger.cxx +++ b/svx/source/theme/ThemeColorChangerCommon.cxx @@ -7,11 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <svx/theme/ThemeColorChanger.hxx> +#include <svx/theme/ThemeColorChangerCommon.hxx> #include <sal/config.h> -#include <svx/svdpage.hxx> -#include <svx/svditer.hxx> #include <editeng/unoprnms.hxx> #include <docmodel/uno/UnoComplexColor.hxx> #include <docmodel/theme/ColorSet.hxx> @@ -24,9 +22,7 @@ using namespace css; -namespace svx -{ -namespace theme +namespace svx::theme { namespace { @@ -126,35 +122,6 @@ void updateSdrObject(model::ColorSet const& rColorSet, SdrObject* pObject) updateLineColorSet(rColorSet, xShapeProps); } -} // end theme - -ThemeColorChanger::ThemeColorChanger(SdrPage* pPage) - : mpPage(pPage) -{ -} - -ThemeColorChanger::~ThemeColorChanger() = default; - -void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) -{ - for (size_t nObject = 0; nObject < mpPage->GetObjCount(); ++nObject) - { - SdrObject* pObject = mpPage->GetObj(nObject); - theme::updateSdrObject(*pColorSet, pObject); - - // update child objects - SdrObjList* pList = pObject->GetSubList(); - if (pList) - { - SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); - while (aIter.IsMore()) - { - theme::updateSdrObject(*pColorSet, aIter.Next()); - } - } - } -} - -} // end svx namespace +} // end svx::theme namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/ThemeColorChanger.hxx b/sw/source/core/inc/ThemeColorChanger.hxx index 6c3e9f3cc7f7..6eeb3a25f612 100644 --- a/sw/source/core/inc/ThemeColorChanger.hxx +++ b/sw/source/core/inc/ThemeColorChanger.hxx @@ -12,7 +12,7 @@ #include <swdllapi.h> #include <docsh.hxx> #include <docmodel/theme/ColorSet.hxx> -#include <svx/theme/ThemeColorChanger.hxx> +#include <svx/theme/IThemeColorChanger.hxx> namespace sw { diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index eca153f30484..6eb840436755 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -30,6 +30,7 @@ #include <sal/config.h> #include <svx/svdpage.hxx> #include <svx/svditer.hxx> +#include <svx/theme/ThemeColorChangerCommon.hxx> #include <docmodel/uno/UnoComplexColor.hxx> #include <docmodel/theme/Theme.hxx> #include <editeng/unoprnms.hxx> commit 6c8df0fe62ffc62fbe0c228e0928179a0fd2a4e4 Author: Tomaž Vajngerl <[email protected]> AuthorDate: Sat Aug 19 17:46:12 2023 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Aug 28 12:43:02 2023 +0200 move theme test from svx to sd - so we can use ThemeColorChange Change-Id: I39cdc3baf81d3cb75d21ec963c05be57b97f30ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155865 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> (cherry picked from commit eb217182a5c44de748218fea009a245254f30b95) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156151 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Mike Kaganski <[email protected]> diff --git a/sd/CppunitTest_sd_theme_tests.mk b/sd/CppunitTest_sd_theme_tests.mk new file mode 100644 index 000000000000..b5f70456dd92 --- /dev/null +++ b/sd/CppunitTest_sd_theme_tests.mk @@ -0,0 +1,78 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sd_theme_tests)) + +$(eval $(call gb_CppunitTest_use_externals,sd_theme_tests,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_use_common_precompiled_header,sd_theme_tests)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sd_theme_tests, \ + sd/qa/unit/ThemeTest \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sd_theme_tests, \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + docmodel \ + editeng \ + for \ + forui \ + i18nlangtag \ + sal \ + salhelper \ + sax \ + sd \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,sd_theme_tests,\ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sd_theme_tests)) +$(eval $(call gb_CppunitTest_use_ure,sd_theme_tests)) +$(eval $(call gb_CppunitTest_use_vcl,sd_theme_tests)) +$(eval $(call gb_CppunitTest_use_rdb,sd_theme_tests,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sd_theme_tests,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,sd_theme_tests)) + +$(eval $(call gb_CppunitTest_add_arguments,sd_theme_tests, \ + -env:arg-env=$(gb_Helper_LIBRARY_PATH_VAR)"$$$${$(gb_Helper_LIBRARY_PATH_VAR)+=$$$$$(gb_Helper_LIBRARY_PATH_VAR)}" \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index 9b7736a41a5f..d29e06763b7a 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -50,6 +50,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\ CppunitTest_sd_shape_import_export_tests \ CppunitTest_sd_a11y \ CppunitTest_sd_textfitting_tests \ + CppunitTest_sd_theme_tests \ )) endif diff --git a/svx/qa/unit/styles.cxx b/sd/qa/unit/ThemeTest.cxx similarity index 73% rename from svx/qa/unit/styles.cxx rename to sd/qa/unit/ThemeTest.cxx index db4469cbcf7d..c085be7721bc 100644 --- a/svx/qa/unit/styles.cxx +++ b/sd/qa/unit/ThemeTest.cxx @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "sdmodeltestbase.hxx" + #include <test/unoapi_test.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -15,20 +17,26 @@ #include <com/sun/star/text/XTextRange.hpp> #include <docmodel/uno/UnoComplexColor.hxx> -using namespace ::com::sun::star; +#include <svx/unoapi.hxx> -namespace -{ -/// Tests for svx/source/styles/ code. -class Test : public UnoApiTest +#include <DrawDocShell.hxx> +#include <unomodel.hxx> +#include <sdpage.hxx> +#include <ViewShell.hxx> + +using namespace css; + +class ThemeTest : public SdModelTestBase { public: - Test() - : UnoApiTest("svx/qa/unit/data/") + ThemeTest() + : SdModelTestBase("/sd/qa/unit/data/") { } }; +namespace +{ /// Get the character color of the first text portion in xShape. sal_Int32 GetShapeTextColor(const uno::Reference<text::XTextRange>& xShape) { @@ -50,24 +58,31 @@ sal_Int32 GetShapeFillColor(const uno::Reference<beans::XPropertySet>& xShape) return nColor; } -CPPUNIT_TEST_FIXTURE(Test, testThemeChange) +} // end anonymous namespace + +CPPUNIT_TEST_FIXTURE(ThemeTest, testThemeChange) { // Given a document, with a first slide and blue shape text from theme: loadFromURL(u"theme.pptx"); + 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( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShapes> xDrawPageShapes(xDrawPage, uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xDrawPageShapes->getByIndex(0), uno::UNO_QUERY); // Blue. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4472c4), GetShapeTextColor(xShape)); + CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), GetShapeTextColor(xShape)); + uno::Reference<text::XTextRange> xShape2(xDrawPageShapes->getByIndex(1), uno::UNO_QUERY); // Blue, lighter. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeTextColor(xShape2)); + CPPUNIT_ASSERT_EQUAL(Color(0xb4c7e7), GetShapeTextColor(xShape2)); + uno::Reference<text::XTextRange> xShape3(xDrawPageShapes->getByIndex(2), uno::UNO_QUERY); // Blue, darker. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x2f5597), GetShapeTextColor(xShape3)); + CPPUNIT_ASSERT_EQUAL(Color(0x2f5597), GetShapeTextColor(xShape3)); + // Shape fill: uno::Reference<beans::XPropertySet> xShape4(xDrawPageShapes->getByIndex(4), uno::UNO_QUERY); // Blue. @@ -81,6 +96,7 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) auto aComplexColor = model::color::getFromXComplexColor(xComplexColor); CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType()); } + uno::Reference<beans::XPropertySet> xShape5(xDrawPageShapes->getByIndex(5), uno::UNO_QUERY); // Blue, lighter. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xb4c7e7), GetShapeFillColor(xShape5)); @@ -98,40 +114,26 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeChange) aComplexColor.getTransformations()[1].meType); CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.getTransformations()[1].mnValue); } + // When changing the master slide of slide 1 to use the theme of the second master slide: uno::Reference<drawing::XMasterPageTarget> xDrawPage2( xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xMasterPage2(xDrawPage2->getMasterPage(), uno::UNO_QUERY); uno::Any aTheme = xMasterPage2->getPropertyValue("Theme"); + uno::Reference<beans::XPropertySet> xMasterPage(xDrawPage->getMasterPage(), uno::UNO_QUERY); xMasterPage->setPropertyValue("Theme", aTheme); // Then make sure the shape text color is now green: - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 9486886 (#90c226, green) - // - Actual : 4485828 (#4472c4, blue) - // i.e. shape text was not updated on theme change. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90c226), GetShapeTextColor(xShape)); + CPPUNIT_ASSERT_EQUAL(Color(0x90c226), GetShapeTextColor(xShape)); // Green, lighter: - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 14020002 (#d5eda2, light green) - // - Actual : 9486886 (#90c226, stock green) - // i.e. the "light" effect on green was not applied. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xd5eda2), GetShapeTextColor(xShape2)); + CPPUNIT_ASSERT_EQUAL(Color(0xd5eda2), GetShapeTextColor(xShape2)); // Green, darker. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x6c911d), GetShapeTextColor(xShape3)); + CPPUNIT_ASSERT_EQUAL(Color(0x6c911d), GetShapeTextColor(xShape3)); // Shape fill: - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 9486886 (#90c226, green) - // - Actual : 4485828 (#4472c4, blue) - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x90c226), GetShapeFillColor(xShape4)); + CPPUNIT_ASSERT_EQUAL(Color(0x90c226), GetShapeFillColor(xShape4)); // Green, lighter: - // Without the accompanying fix in place, this test would have failed with: - // - Expected: 14020002 (#d5eda2, light green) - // - Actual : 9486886 (#90c226, green) - // i.e. the "light" effect on green was not applied. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xd5eda2), GetShapeFillColor(xShape5)); -} + CPPUNIT_ASSERT_EQUAL(Color(0xd5eda2), GetShapeFillColor(xShape5)); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/qa/unit/data/theme.pptx b/sd/qa/unit/data/theme.pptx similarity index 100% rename from svx/qa/unit/data/theme.pptx rename to sd/qa/unit/data/theme.pptx diff --git a/svx/CppunitTest_svx_styles.mk b/svx/CppunitTest_svx_styles.mk deleted file mode 100644 index 9d5cccabb8b9..000000000000 --- a/svx/CppunitTest_svx_styles.mk +++ /dev/null @@ -1,49 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -#************************************************************************* -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -#************************************************************************* - -$(eval $(call gb_CppunitTest_CppunitTest,svx_styles)) - -$(eval $(call gb_CppunitTest_use_externals,svx_styles,\ - boost_headers \ -)) - -$(eval $(call gb_CppunitTest_add_exception_objects,svx_styles, \ - svx/qa/unit/styles \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,svx_styles, \ - comphelper \ - cppu \ - cppuhelper \ - docmodel \ - svx \ - sal \ - subsequenttest \ - test \ - unotest \ - utl \ - tl \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,svx_styles)) - -$(eval $(call gb_CppunitTest_use_ure,svx_styles)) -$(eval $(call gb_CppunitTest_use_vcl,svx_styles)) - -$(eval $(call gb_CppunitTest_use_rdb,svx_styles,services)) - -$(eval $(call gb_CppunitTest_use_custom_headers,svx_styles,\ - officecfg/registry \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,svx_styles)) - -# vim: set noet sw=4 ts=4: diff --git a/svx/Module_svx.mk b/svx/Module_svx.mk index 40e65bd70d0d..ddf824cdf4bc 100644 --- a/svx/Module_svx.mk +++ b/svx/Module_svx.mk @@ -39,7 +39,6 @@ $(eval $(call gb_Module_add_check_targets,svx,\ CppunitTest_svx_unit \ CppunitTest_svx_gallery_test \ CppunitTest_svx_removewhichrange \ - CppunitTest_svx_styles \ CppunitTest_svx_core \ ))
