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 <sbergman@redhat.com>
This commit is contained in:
@@ -21,7 +21,9 @@
|
||||
#include "calendarImpl.hxx"
|
||||
|
||||
#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
|
||||
#include <com/sun/star/lang/XUnoTunnel.hpp>
|
||||
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <unicode/calendar.h>
|
||||
#include <rtl/ref.hxx>
|
||||
|
||||
@@ -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<CalendarImpl, css::lang::XUnoTunnel>
|
||||
{
|
||||
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<sal_Int8> const & aIdentifier) override;
|
||||
static css::uno::Sequence<sal_Int8> const & getUnoTunnelId();
|
||||
|
||||
protected:
|
||||
const Era *eraArray;
|
||||
std::unique_ptr<icu::Calendar> body;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <calendar_gregorian.hxx>
|
||||
#include <localedata.hxx>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/servicehelper.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
@@ -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<Calendar_gregorian*>(xCalendar.get());
|
||||
Calendar_gregorian* pCal = comphelper::getFromUnoTunnel<Calendar_gregorian>(xCalendar);
|
||||
bTimeZone = (pCal && pCal->setTimeZone(rTimeZone));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <com/sun/star/i18n/CalendarDisplayIndex.hpp>
|
||||
#include <com/sun/star/i18n/NativeNumberMode.hpp>
|
||||
#include <com/sun/star/i18n/reservedWords.hpp>
|
||||
#include <comphelper/servicehelper.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
#include <o3tl/sprintf.hxx>
|
||||
#include <rtl/math.hxx>
|
||||
@@ -1077,6 +1078,15 @@ Calendar_gregorian::getSupportedServiceNames()
|
||||
return aRet;
|
||||
}
|
||||
|
||||
sal_Int64 Calendar_gregorian::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) {
|
||||
return comphelper::getSomethingImpl(aIdentifier, this);
|
||||
}
|
||||
|
||||
css::uno::Sequence<sal_Int8> const & Calendar_gregorian::getUnoTunnelId() {
|
||||
static comphelper::UnoIdInit const id;
|
||||
return id.getSeq();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user