docmodel/source/theme/Theme.cxx | 3 +++ sd/source/ui/unoidl/unomodel.cxx | 23 ++++------------------- sd/source/ui/unoidl/unopage.cxx | 35 ++++++----------------------------- 3 files changed, 13 insertions(+), 48 deletions(-)
New commits: commit a25172b81142df86b7c1854edbeb885d63bf0182 Author: Mike Kaganski <[email protected]> AuthorDate: Sun Jun 15 16:58:58 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sun Jun 15 16:40:30 2025 +0200 Simplify UNO theme handling, by allowing empty Any in FromAny This allows to avoid passing empty sequence as the "no theme" value. Change-Id: I46b077149ec317fbcb19b39591aca6db3bf97393 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186520 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/docmodel/source/theme/Theme.cxx b/docmodel/source/theme/Theme.cxx index a21d13643ae8..2e340f22c9bf 100644 --- a/docmodel/source/theme/Theme.cxx +++ b/docmodel/source/theme/Theme.cxx @@ -99,6 +99,9 @@ static std::shared_ptr<model::ColorSet> makeColorSet(const OUString& name, std::shared_ptr<Theme> Theme::FromAny(const uno::Any& rVal) { + if (!rVal.hasValue()) + return {}; + if (css::uno::Reference<css::util::XTheme> xTheme; rVal >>= xTheme) { if (!xTheme) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index e569fa25c077..588c78721da1 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2874,11 +2874,7 @@ void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyNam setGrabBagItem(aValue); break; case WID_MODEL_THEME: - { - SdrModel& rModel = getSdrModelFromUnoModel(); - std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue); - rModel.setTheme(pTheme); - } + getSdrModelFromUnoModel().setTheme(model::Theme::FromAny(aValue)); break; default: throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); @@ -3007,20 +3003,9 @@ uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& Property getGrabBagItem(aAny); break; case WID_MODEL_THEME: - { - SdrModel& rModel = getSdrModelFromUnoModel(); - auto const& pTheme = rModel.getTheme(); - if (pTheme) - { - pTheme->ToAny(aAny); - } - else - { - beans::PropertyValues aValues; - aAny <<= aValues; - } - break; - } + if (auto const& pTheme = getSdrModelFromUnoModel().getTheme()) + pTheme->ToAny(aAny); + break; default: throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this)); } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 8279858b20df..9566c9274ef9 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -987,24 +987,16 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName } case WID_PAGE_THEME: - { - SdrPage* pPage = GetPage(); - uno::Reference<util::XTheme> xTheme; - if (aValue >>= xTheme) + if (uno::Reference<util::XTheme> xTheme; aValue >>= xTheme) { auto& rUnoTheme = dynamic_cast<UnoTheme&>(*xTheme); - pPage->getSdrPageProperties().setTheme(rUnoTheme.getTheme()); + GetPage()->getSdrPageProperties().setTheme(rUnoTheme.getTheme()); } break; - } case WID_PAGE_THEME_UNO_REPRESENTATION: - { - SdrPage* pPage = GetPage(); - std::shared_ptr<model::Theme> pTheme = model::Theme::FromAny(aValue); - pPage->getSdrPageProperties().setTheme(pTheme); + GetPage()->getSdrPageProperties().setTheme(model::Theme::FromAny(aValue)); break; - } default: throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); @@ -1324,29 +1316,14 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) break; case WID_PAGE_THEME: - { - SdrPage* pPage = GetPage(); - css::uno::Reference<css::util::XTheme> xTheme; - auto pTheme = pPage->getSdrPageProperties().getTheme(); - if (pTheme) - xTheme = model::theme::createXTheme(pTheme); - aAny <<= xTheme; + if (auto pTheme = GetPage()->getSdrPageProperties().getTheme()) + aAny <<= model::theme::createXTheme(pTheme); break; - } case WID_PAGE_THEME_UNO_REPRESENTATION: - { - SdrPage* pPage = GetPage(); - auto pTheme = pPage->getSdrPageProperties().getTheme(); - if (pTheme) + if (auto pTheme = GetPage()->getSdrPageProperties().getTheme()) pTheme->ToAny(aAny); - else - { - beans::PropertyValues aValues; - aAny <<= aValues; - } break; - } default: throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
