From ba76f0ba7e8de4d2953739c952004b7d9af47197 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 8 Dec 2022 10:19:26 +0100 Subject: loplugin:unocast (i18npool::Calendar_gregorian) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I1b0e544145c364cb9ee669b913132f41c1a8a66a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144147 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- i18npool/inc/calendar_gregorian.hxx | 7 ++++++- i18npool/source/calendar/calendarImpl.cxx | 3 ++- i18npool/source/calendar/calendar_gregorian.cxx | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx index 1ee7cabaab1e..1f29d63f9f02 100644 --- a/i18npool/inc/calendar_gregorian.hxx +++ b/i18npool/inc/calendar_gregorian.hxx @@ -21,7 +21,9 @@ #include "calendarImpl.hxx" #include +#include +#include #include #include @@ -44,7 +46,7 @@ struct Era { const sal_Int16 FIELD_INDEX_COUNT = css::i18n::CalendarFieldIndex::FIELD_COUNT2; -class Calendar_gregorian : public CalendarImpl +class Calendar_gregorian : public cppu::ImplInheritanceHelper { public: @@ -98,6 +100,9 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence < OUString > SAL_CALL getSupportedServiceNames() override; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence const & aIdentifier) override; + static css::uno::Sequence const & getUnoTunnelId(); + protected: const Era *eraArray; std::unique_ptr body; diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index 4e364696cf20..60391473f944 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -90,7 +91,7 @@ CalendarImpl::loadCalendarTZ( const OUString& uniqueID, const css::lang::Locale& /* XXX NOTE: currently (2019-06-19) calendar implementations derive * from Calendar_gregorian, even Hijri and Jewish. If that should * change in future this should be adapted. */ - Calendar_gregorian* pCal = dynamic_cast(xCalendar.get()); + Calendar_gregorian* pCal = comphelper::getFromUnoTunnel(xCalendar); bTimeZone = (pCal && pCal->setTimeZone(rTimeZone)); } diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index e586470a0c31..9e9b248a5b28 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1077,6 +1078,15 @@ Calendar_gregorian::getSupportedServiceNames() return aRet; } +sal_Int64 Calendar_gregorian::getSomething(css::uno::Sequence const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence const & Calendar_gregorian::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit