diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-08-26 12:40:43 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-08-26 12:40:43 +0200 |
commit | 28cb2c1764f2365d69ce09cb69f0f5a676458a33 (patch) | |
tree | 614b44a9dc1b4928af5db1880e9869cd3e997eb1 /i18npool | |
parent | Remove wrong check through template args from containsXInterfaceSubclass (diff) | |
download | core-28cb2c1764f2365d69ce09cb69f0f5a676458a33.tar.gz core-28cb2c1764f2365d69ce09cb69f0f5a676458a33.zip |
loplugin:refcounting: also cover temporaries being directly stack managed
Change-Id: Ib0f7c60df1d2fba0d4d9d3fa6faf3bb97867ebc0
Diffstat (limited to 'i18npool')
12 files changed, 34 insertions, 30 deletions
diff --git a/i18npool/inc/localedata.hxx b/i18npool/inc/localedata.hxx index 0a28ee0301f6..c36e71175864 100644 --- a/i18npool/inc/localedata.hxx +++ b/i18npool/inc/localedata.hxx @@ -39,6 +39,7 @@ #include <com/sun/star/i18n/UnicodeScript.hpp> #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/XInterface.hpp> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> #include <vector> #include <memory> @@ -68,6 +69,8 @@ public: LocaleDataImpl(); virtual ~LocaleDataImpl(); + static rtl::Reference<LocaleDataImpl> get() { return new LocaleDataImpl; } + static css::uno::Sequence< css::i18n::CalendarItem > downcastCalendarItems( const css::uno::Sequence< css::i18n::CalendarItem2 > & rCi ); static css::i18n::Calendar downcastCalendar( const css::i18n::Calendar2 & rC ); diff --git a/i18npool/source/breakiterator/breakiterator_cjk.cxx b/i18npool/source/breakiterator/breakiterator_cjk.cxx index 88ea6efb29d9..c9268b3e3439 100644 --- a/i18npool/source/breakiterator/breakiterator_cjk.cxx +++ b/i18npool/source/breakiterator/breakiterator_cjk.cxx @@ -117,7 +117,7 @@ LineBreakResults SAL_CALL BreakIterator_CJK::getLineBreak( BreakIterator_zh::BreakIterator_zh() { dict = new xdictionary("zh"); - hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "CN")); + hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "CN")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh"; } @@ -132,7 +132,7 @@ BreakIterator_zh::~BreakIterator_zh() BreakIterator_zh_TW::BreakIterator_zh_TW() { dict = new xdictionary("zh"); - hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("zh", "TW")); + hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("zh", "TW")); cBreakIterator = "com.sun.star.i18n.BreakIterator_zh_TW"; } @@ -148,7 +148,7 @@ BreakIterator_ja::BreakIterator_ja() { dict = new xdictionary("ja"); dict->setJapaneseWordBreak(); - hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ja", "JP")); + hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("ja", "JP")); cBreakIterator = "com.sun.star.i18n.BreakIterator_ja"; } @@ -162,7 +162,7 @@ BreakIterator_ja::~BreakIterator_ja() // ----------------------------------------------------; BreakIterator_ko::BreakIterator_ko() { - hangingCharacters = LocaleDataImpl().getHangingCharacters(LOCALE("ko", "KR")); + hangingCharacters = LocaleDataImpl::get()->getHangingCharacters(LOCALE("ko", "KR")); cBreakIterator = "com.sun.star.i18n.BreakIterator_ko"; } diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx index 117b0ba04537..3b0b227148fa 100644 --- a/i18npool/source/breakiterator/breakiterator_unicode.cxx +++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx @@ -109,7 +109,7 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const css::lang::Local icuBI->aBreakIterator=nullptr; } if (rule) { - uno::Sequence< OUString > breakRules = LocaleDataImpl().getBreakIteratorRules(rLocale); + uno::Sequence< OUString > breakRules = LocaleDataImpl::get()->getBreakIteratorRules(rLocale); status = U_ZERO_ERROR; udata_setAppData("OpenOffice", OpenOffice_dat, &status); diff --git a/i18npool/source/calendar/calendarImpl.cxx b/i18npool/source/calendar/calendarImpl.cxx index 48c4ad2d02a3..89432a433cfa 100644 --- a/i18npool/source/calendar/calendarImpl.cxx +++ b/i18npool/source/calendar/calendarImpl.cxx @@ -44,7 +44,7 @@ CalendarImpl::~CalendarImpl() void SAL_CALL CalendarImpl::loadDefaultCalendar( const Locale& rLocale ) throw(RuntimeException, std::exception) { - Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale); + Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); for (sal_Int32 i = 0; i < xC.getLength(); i++) { if (xC[i].Default) { loadCalendar(xC[i].Name, rLocale); @@ -74,7 +74,7 @@ CalendarImpl::loadCalendar(const OUString& uniqueID, const Locale& rLocale ) thr if ( ! xI.is() ) { // check if the calendar is defined in localedata, load gregorian calendar service. - Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale); + Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); for (i = 0; i < xC.getLength(); i++) { if (uniqueID == xC[i].Name) { xI = m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.i18n.Calendar_gregorian", m_xContext); @@ -129,7 +129,7 @@ CalendarImpl::getLoadedCalendar() throw(RuntimeException, std::exception) Sequence< OUString > SAL_CALL CalendarImpl::getAllCalendars( const Locale& rLocale ) throw(RuntimeException, std::exception) { - Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale); + Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); sal_Int32 nLen = xC.getLength(); Sequence< OUString > xSeq( nLen ); for (sal_Int32 i = 0; i < nLen; i++) diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index f3fa8ea6dac8..c7ff413d297a 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -189,8 +189,8 @@ Calendar_hanja::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 if ( displayIndex == CalendarDisplayIndex::AM_PM ) { // Am/Pm string for Korean Hanja calendar will refer to Japanese locale css::lang::Locale jaLocale(OUString("ja"), OUString(), OUString()); - if (idx == 0) return LocaleDataImpl().getLocaleItem(jaLocale).timeAM; - else if (idx == 1) return LocaleDataImpl().getLocaleItem(jaLocale).timePM; + if (idx == 0) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timeAM; + else if (idx == 1) return LocaleDataImpl::get()->getLocaleItem(jaLocale).timePM; else throw ERROR; } else @@ -242,7 +242,7 @@ Calendar_gregorian::loadCalendar( const OUString& uniqueID, const css::lang::Loc getValue(); aLocale = rLocale; - Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale); + Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); for (sal_Int32 i = 0; i < xC.getLength(); i++) { if (uniqueID == xC[i].Name) @@ -776,8 +776,8 @@ Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_I switch( displayIndex ) { case CalendarDisplayIndex::AM_PM:/* ==0 */ - if (idx == 0) aStr = LocaleDataImpl().getLocaleItem(aLocale).timeAM; - else if (idx == 1) aStr = LocaleDataImpl().getLocaleItem(aLocale).timePM; + if (idx == 0) aStr = LocaleDataImpl::get()->getLocaleItem(aLocale).timeAM; + else if (idx == 1) aStr = LocaleDataImpl::get()->getLocaleItem(aLocale).timePM; else throw ERROR; break; case CalendarDisplayIndex::DAY: @@ -839,7 +839,7 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In if (nCalendarDisplayCode == CalendarDisplayCode::SHORT_QUARTER || nCalendarDisplayCode == CalendarDisplayCode::LONG_QUARTER) { - Sequence< OUString> xR = LocaleDataImpl().getReservedWord(aLocale); + Sequence< OUString> xR = LocaleDataImpl::get()->getReservedWord(aLocale); sal_Int16 quarter = value / 3; // Since this base class method may be called by derived calendar // classes where a year consists of more than 12 months we need a check diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx index f5fefa0a49c8..a1022e49473c 100644 --- a/i18npool/source/collator/collator_unicode.cxx +++ b/i18npool/source/collator/collator_unicode.cxx @@ -136,7 +136,7 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: { if (!collator) { UErrorCode status = U_ZERO_ERROR; - OUString rule = LocaleDataImpl().getCollatorRuleByAlgorithm(rLocale, rAlgorithm); + OUString rule = LocaleDataImpl::get()->getCollatorRuleByAlgorithm(rLocale, rAlgorithm); if (!rule.isEmpty()) { collator = new RuleBasedCollator(reinterpret_cast<const UChar *>(rule.getStr()), status); // UChar != sal_Unicode in MinGW if (! U_SUCCESS(status)) throw RuntimeException(); diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx index 82f3fa434185..61097457362b 100644 --- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx +++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx @@ -280,13 +280,13 @@ void DefaultNumberingProvider::impl_loadTranslit() Sequence< Reference<container::XIndexAccess> > DefaultNumberingProvider::getDefaultOutlineNumberings(const Locale& rLocale ) throw(RuntimeException, std::exception) { - return LocaleDataImpl().getOutlineNumberingLevels( rLocale ); + return LocaleDataImpl::get()->getOutlineNumberingLevels( rLocale ); } Sequence< Sequence<beans::PropertyValue> > DefaultNumberingProvider::getDefaultContinuousNumberingLevels( const Locale& rLocale ) throw(RuntimeException, std::exception) { - return LocaleDataImpl().getContinuousNumberingLevels( rLocale ); + return LocaleDataImpl::get()->getContinuousNumberingLevels( rLocale ); } OUString toRoman( sal_Int32 n ) diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx index 2ade78f958a4..cb06d7968329 100644 --- a/i18npool/source/indexentry/indexentrysupplier.cxx +++ b/i18npool/source/indexentry/indexentrysupplier.cxx @@ -34,12 +34,12 @@ IndexEntrySupplier::IndexEntrySupplier( const Reference < XComponentContext >& r Sequence < Locale > SAL_CALL IndexEntrySupplier::getLocaleList() throw (RuntimeException, std::exception) { - return LocaleDataImpl().getAllInstalledLocaleNames(); + return LocaleDataImpl::get()->getAllInstalledLocaleNames(); } Sequence < OUString > SAL_CALL IndexEntrySupplier::getAlgorithmList( const Locale& rLocale ) throw (RuntimeException, std::exception) { - return LocaleDataImpl().getIndexAlgorithm(rLocale); + return LocaleDataImpl::get()->getIndexAlgorithm(rLocale); } sal_Bool SAL_CALL IndexEntrySupplier::loadAlgorithm( const Locale& rLocale, const OUString& SortAlgorithm, @@ -57,7 +57,7 @@ sal_Bool SAL_CALL IndexEntrySupplier::loadAlgorithm( const Locale& rLocale, cons sal_Bool SAL_CALL IndexEntrySupplier::usePhoneticEntry( const Locale& rLocale ) throw (RuntimeException, std::exception) { - return LocaleDataImpl().hasPhonetic(rLocale); + return LocaleDataImpl::get()->hasPhonetic(rLocale); } OUString SAL_CALL IndexEntrySupplier::getPhoneticCandidate( const OUString& rIndexEntry, @@ -167,7 +167,7 @@ IndexEntrySupplier::getLocaleSpecificIndexEntrySupplier(const Locale& rLocale, c OUString SAL_CALL IndexEntrySupplier::getIndexFollowPageWord( sal_Bool bMorePages, const Locale& rLocale ) throw (RuntimeException, std::exception) { - Sequence< OUString > aFollowPageWords = LocaleDataImpl().getFollowPageWords(rLocale); + Sequence< OUString > aFollowPageWords = LocaleDataImpl::get()->getFollowPageWords(rLocale); return (bMorePages && aFollowPageWords.getLength() > 1) ? aFollowPageWords[1] : (aFollowPageWords.getLength() > 0 ? diff --git a/i18npool/source/indexentry/indexentrysupplier_common.cxx b/i18npool/source/indexentry/indexentrysupplier_common.cxx index 74009b97e843..fafb3046d5b2 100644 --- a/i18npool/source/indexentry/indexentrysupplier_common.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_common.cxx @@ -63,7 +63,7 @@ sal_Bool SAL_CALL IndexEntrySupplier_Common::usePhoneticEntry( const lang::Local sal_Bool SAL_CALL IndexEntrySupplier_Common::loadAlgorithm( const lang::Locale& rLocale, const OUString& rAlgorithm, sal_Int32 collatorOptions ) throw (RuntimeException, std::exception) { - usePhonetic = LocaleDataImpl().isPhonetic(rLocale, rAlgorithm); + usePhonetic = LocaleDataImpl::get()->isPhonetic(rLocale, rAlgorithm); collator->loadCollatorAlgorithm(rAlgorithm, rLocale, collatorOptions); aLocale = rLocale; aAlgorithm = rAlgorithm; diff --git a/i18npool/source/indexentry/indexentrysupplier_default.cxx b/i18npool/source/indexentry/indexentrysupplier_default.cxx index 6db7a116c0eb..ee0c3f5b6ab2 100644 --- a/i18npool/source/indexentry/indexentrysupplier_default.cxx +++ b/i18npool/source/indexentry/indexentrysupplier_default.cxx @@ -167,11 +167,11 @@ OUString Index::getIndexDescription(const OUString& rIndexEntry) void Index::makeIndexKeys(const lang::Locale &rLocale, const OUString &algorithm) throw (RuntimeException) { - OUString keyStr = LocaleDataImpl().getIndexKeysByAlgorithm(rLocale, algorithm); + OUString keyStr = LocaleDataImpl::get()->getIndexKeysByAlgorithm(rLocale, algorithm); if (keyStr.isEmpty()) { - keyStr = LocaleDataImpl().getIndexKeysByAlgorithm(LOCALE_EN, - LocaleDataImpl().getDefaultIndexAlgorithm(LOCALE_EN)); + keyStr = LocaleDataImpl::get()->getIndexKeysByAlgorithm(LOCALE_EN, + LocaleDataImpl::get()->getDefaultIndexAlgorithm(LOCALE_EN)); if (keyStr.isEmpty()) throw RuntimeException(); } @@ -255,10 +255,10 @@ void Index::init(const lang::Locale &rLocale, const OUString& algorithm) throw ( { makeIndexKeys(rLocale, algorithm); - Sequence< UnicodeScript > scriptList = LocaleDataImpl().getUnicodeScripts( rLocale ); + Sequence< UnicodeScript > scriptList = LocaleDataImpl::get()->getUnicodeScripts( rLocale ); if (scriptList.getLength() == 0) { - scriptList = LocaleDataImpl().getUnicodeScripts(LOCALE_EN); + scriptList = LocaleDataImpl::get()->getUnicodeScripts(LOCALE_EN); if (scriptList.getLength() == 0) throw RuntimeException(); } diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx index 628a27fa7f6f..3fd27e5d0466 100644 --- a/i18npool/source/nativenumber/nativenumbersupplier.cxx +++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx @@ -578,7 +578,7 @@ OUString SAL_CALL NativeNumberSupplierService::getNativeNumberString(const OUStr if (!aLocale.Language.equals(rLocale.Language) || !aLocale.Country.equals(rLocale.Country) || !aLocale.Variant.equals(rLocale.Variant)) { - LocaleDataItem item = LocaleDataImpl().getLocaleItem( rLocale ); + LocaleDataItem item = LocaleDataImpl::get()->getLocaleItem( rLocale ); aLocale = rLocale; DecimalChar[NumberChar_HalfWidth]=item.decimalSeparator.toChar(); if (DecimalChar[NumberChar_HalfWidth] > 0x7E || DecimalChar[NumberChar_HalfWidth] < 0x21) diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx index 86de70f765f0..3ec34f92ed04 100644 --- a/i18npool/source/transliteration/transliteration_Numeric.cxx +++ b/i18npool/source/transliteration/transliteration_Numeric.cxx @@ -22,6 +22,7 @@ #include <nativenumbersupplier.hxx> #include <defaultnumberingprovider.hxx> #include <comphelper/string.hxx> +#include <rtl/ref.hxx> using namespace com::sun::star::uno; @@ -119,7 +120,7 @@ transliteration_Numeric::transliterate( const OUString& inStr, sal_Int32 startPo if (tableSize) return transliterateBullet( inStr, startPos, nCount, offset); else - return NativeNumberSupplierService(useOffset).getNativeNumberString( inStr.copy(startPos, nCount), aLocale, nNativeNumberMode, offset ); + return rtl::Reference<NativeNumberSupplierService>(new NativeNumberSupplierService(useOffset))->getNativeNumberString( inStr.copy(startPos, nCount), aLocale, nNativeNumberMode, offset ); } sal_Unicode SAL_CALL @@ -134,7 +135,7 @@ transliteration_Numeric::transliterateChar2Char( sal_Unicode inChar ) throw(Runt return inChar; } else - return NativeNumberSupplierService().getNativeNumberChar( inChar, aLocale, nNativeNumberMode ); + return rtl::Reference<NativeNumberSupplierService>(new NativeNumberSupplierService)->getNativeNumberChar( inChar, aLocale, nNativeNumberMode ); } } } } } |