summaryrefslogtreecommitdiffstats
path: root/i18npool
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-07-13 16:17:00 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-08-03 06:37:16 +0000
commit2660d24a07866e083c5135ea263030f3e3a2e729 (patch)
tree0089d6018d4fc33a7fde955e585e77191cdd258b /i18npool
parenttdf#93068 - UI: Crash when Character dialogue opened (diff)
downloadcore-2660d24a07866e083c5135ea263030f3e3a2e729.tar.gz
core-2660d24a07866e083c5135ea263030f3e3a2e729.zip
new loplugin: refcounting
This was a feature requested by mmeeks, as a result of tdf#92611. It validates that things that extend XInterface are not directly heap/stack-allocated, but have their lifecycle managed via css::uno::Reference or rtl::Reference. Change-Id: I28e3b8b236f6a4a56d0a6d6f26ad54e44b36e692 Reviewed-on: https://gerrit.libreoffice.org/16924 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/calendar_gregorian.hxx2
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx4
-rw-r--r--i18npool/source/calendar/calendar_jewish.cxx2
-rw-r--r--i18npool/source/characterclassification/cclass_unicode.cxx6
-rw-r--r--i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx4
-rw-r--r--i18npool/source/indexentry/indexentrysupplier.cxx6
-rw-r--r--i18npool/source/transliteration/ignoreKana.cxx14
-rw-r--r--i18npool/source/transliteration/ignoreSize_ja_JP.cxx14
-rw-r--r--i18npool/source/transliteration/ignoreWidth.cxx14
-rw-r--r--i18npool/source/transliteration/transliteration_body.cxx12
-rw-r--r--i18npool/source/transliteration/transliteration_caseignore.cxx16
11 files changed, 48 insertions, 46 deletions
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index f270779f7b87..a6b81c92431d 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -97,7 +97,7 @@ public:
protected:
const Era *eraArray;
icu::Calendar *body;
- NativeNumberSupplierService aNatNum;
+ css::uno::Reference<NativeNumberSupplierService> mxNatNum;
const sal_Char* cCalendar;
com::sun::star::lang::Locale aLocale;
sal_uInt32 fieldSet;
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index 5b4a9b74b590..e455c53097b3 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -130,10 +130,12 @@ namespace com { namespace sun { namespace star { namespace i18n {
#define ERROR RuntimeException()
Calendar_gregorian::Calendar_gregorian()
+ : mxNatNum(new NativeNumberSupplierService)
{
init(NULL);
}
Calendar_gregorian::Calendar_gregorian(const Era *_earArray)
+ : mxNatNum(new NativeNumberSupplierService)
{
init(_earArray);
}
@@ -1180,7 +1182,7 @@ Calendar_gregorian::getDisplayStringImpl( sal_Int32 nCalendarDisplayCode, sal_In
}
sal_Int16 nNatNum = NatNumForCalendar(aLocale, nCalendarDisplayCode, nNativeNumberMode, value);
if (nNatNum > 0)
- return aNatNum.getNativeNumberString(aOUStr, aLocale, nNatNum);
+ return mxNatNum->getNativeNumberString(aOUStr, aLocale, nNatNum);
}
return aOUStr;
}
diff --git a/i18npool/source/calendar/calendar_jewish.cxx b/i18npool/source/calendar/calendar_jewish.cxx
index 0dc82bd1ac56..1e399ebf5c05 100644
--- a/i18npool/source/calendar/calendar_jewish.cxx
+++ b/i18npool/source/calendar/calendar_jewish.cxx
@@ -287,7 +287,7 @@ Calendar_jewish::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNa
if (nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR) {
sal_Int32 value = getValue(CalendarFieldIndex::YEAR) % 1000; // take last 3 digits
- return aNatNum.getNativeNumberString(OUString::number(value), aLocale, nNativeNumberMode );
+ return mxNatNum->getNativeNumberString(OUString::number(value), aLocale, nNativeNumberMode );
}
else
return Calendar_gregorian::getDisplayString(nCalendarDisplayCode, nNativeNumberMode );
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 495cd2139a79..86891ad38d3d 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -92,12 +92,12 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
trans->setMappingType(MappingTypeToTitle, rLocale);
rtl_uString* pStr = rtl_uString_alloc(nCount);
sal_Unicode* out = pStr->buffer;
- BreakIteratorImpl brk(m_xContext);
- Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
+ Reference< BreakIteratorImpl > xBrk(new BreakIteratorImpl(m_xContext));
+ Boundary bdy = xBrk->getWordBoundary(Text, nPos, rLocale,
WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
for (sal_Int32 i = nPos; i < nCount + nPos; i++, out++) {
if (i >= bdy.endPos)
- bdy = brk.nextWord(Text, bdy.endPos, rLocale,
+ bdy = xBrk->nextWord(Text, bdy.endPos, rLocale,
WordType::ANYWORD_IGNOREWHITESPACES);
*out = (i == bdy.startPos) ?
trans->transliterateChar2Char(Text[i]) : Text[i];
diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 5e4d58291438..a48f6e4655c9 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -858,8 +858,8 @@ DefaultNumberingProvider::makeNumberingString( const Sequence<beans::PropertyVal
}
if (natNum) {
- NativeNumberSupplierService sNatNum;
- result += sNatNum.getNativeNumberString(OUString::number( number ), locale, natNum);
+ uno::Reference<NativeNumberSupplierService> xNatNum(new NativeNumberSupplierService);
+ result += xNatNum->getNativeNumberString(OUString::number( number ), locale, natNum);
} else if (tableSize) {
if ( number > tableSize && !recycleSymbol)
result += OUString::number( number);
diff --git a/i18npool/source/indexentry/indexentrysupplier.cxx b/i18npool/source/indexentry/indexentrysupplier.cxx
index fc109658fb40..96fef17c9f44 100644
--- a/i18npool/source/indexentry/indexentrysupplier.cxx
+++ b/i18npool/source/indexentry/indexentrysupplier.cxx
@@ -116,14 +116,14 @@ IndexEntrySupplier::getLocaleSpecificIndexEntrySupplier(const Locale& rLocale, c
rLocale.Country == aLocale.Country && rLocale.Variant == aLocale.Variant)
return xIES;
else {
- LocaleDataImpl ld;
+ uno::Reference<LocaleDataImpl> ld(new LocaleDataImpl);
aLocale = rLocale;
if (rSortAlgorithm.isEmpty())
- aSortAlgorithm = ld.getDefaultIndexAlgorithm( rLocale );
+ aSortAlgorithm = ld->getDefaultIndexAlgorithm( rLocale );
else
aSortAlgorithm = rSortAlgorithm;
- OUString module = ld.getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
+ OUString module = ld->getIndexModuleByAlgorithm(rLocale, aSortAlgorithm);
if (!module.isEmpty() && createLocaleSpecificIndexEntrySupplier(module))
return xIES;
diff --git a/i18npool/source/transliteration/ignoreKana.cxx b/i18npool/source/transliteration/ignoreKana.cxx
index d468ecf1f2dd..6aa1e90dbd01 100644
--- a/i18npool/source/transliteration/ignoreKana.cxx
+++ b/i18npool/source/transliteration/ignoreKana.cxx
@@ -31,25 +31,25 @@ OUString SAL_CALL
ignoreKana::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
throw(RuntimeException, std::exception)
{
- hiraganaToKatakana t1;
- return t1.transliterate(inStr, startPos, nCount, offset);
+ Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+ return t1->transliterate(inStr, startPos, nCount, offset);
}
Sequence< OUString > SAL_CALL
ignoreKana::transliterateRange( const OUString& str1, const OUString& str2 )
throw(RuntimeException, std::exception)
{
- hiraganaToKatakana t1;
- katakanaToHiragana t2;
+ Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+ Reference< katakanaToHiragana > t2(new katakanaToHiragana);
- return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+ return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
}
sal_Unicode SAL_CALL
ignoreKana::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
{
- hiraganaToKatakana t1;
- return t1.transliterateChar2Char(inChar);
+ Reference< hiraganaToKatakana > t1(new hiraganaToKatakana);
+ return t1->transliterateChar2Char(inChar);
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreSize_ja_JP.cxx b/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
index e5645ad0986d..45f10be4f949 100644
--- a/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreSize_ja_JP.cxx
@@ -29,8 +29,8 @@ OUString SAL_CALL
ignoreSize_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
throw(RuntimeException, std::exception)
{
- smallToLarge_ja_JP t1;
- return t1.transliterate(inStr, startPos, nCount, offset);
+ Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+ return t1->transliterate(inStr, startPos, nCount, offset);
}
@@ -38,17 +38,17 @@ Sequence< OUString > SAL_CALL
ignoreSize_ja_JP::transliterateRange( const OUString& str1, const OUString& str2 )
throw(RuntimeException, std::exception)
{
- smallToLarge_ja_JP t1;
- largeToSmall_ja_JP t2;
+ Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+ Reference< largeToSmall_ja_JP > t2(new largeToSmall_ja_JP);
- return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+ return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
}
sal_Unicode SAL_CALL
ignoreSize_ja_JP::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
{
- smallToLarge_ja_JP t1;
- return t1.transliterateChar2Char(inChar);
+ Reference< smallToLarge_ja_JP > t1(new smallToLarge_ja_JP);
+ return t1->transliterateChar2Char(inChar);
}
} } } }
diff --git a/i18npool/source/transliteration/ignoreWidth.cxx b/i18npool/source/transliteration/ignoreWidth.cxx
index ebe640c44808..ab4ade0ace75 100644
--- a/i18npool/source/transliteration/ignoreWidth.cxx
+++ b/i18npool/source/transliteration/ignoreWidth.cxx
@@ -31,25 +31,25 @@ OUString SAL_CALL
ignoreWidth::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
throw(RuntimeException, std::exception)
{
- fullwidthToHalfwidth t1;
- return t1.transliterate(inStr, startPos, nCount, offset);
+ Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+ return t1->transliterate(inStr, startPos, nCount, offset);
}
Sequence< OUString > SAL_CALL
ignoreWidth::transliterateRange( const OUString& str1, const OUString& str2 )
throw(RuntimeException, std::exception)
{
- fullwidthToHalfwidth t1;
- halfwidthToFullwidth t2;
+ Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+ Reference< halfwidthToFullwidth > t2(new halfwidthToFullwidth);
- return transliteration_Ignore::transliterateRange(str1, str2, t1, t2);
+ return transliteration_Ignore::transliterateRange(str1, str2, *t1.get(), *t2.get());
}
sal_Unicode SAL_CALL
ignoreWidth::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
{
- fullwidthToHalfwidth t1;
- return t1.transliterateChar2Char(inChar);
+ Reference< fullwidthToHalfwidth > t1(new fullwidthToHalfwidth);
+ return t1->transliterateChar2Char(inChar);
}
} } } }
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index c9c41ef773d0..875b4a150d60 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -269,9 +269,9 @@ static OUString transliterate_titlecase_Impl(
if (!aText.isEmpty())
{
Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
- CharacterClassificationImpl aCharClassImpl( xContext );
+ Reference< CharacterClassificationImpl > xCharClassImpl( new CharacterClassificationImpl( xContext ) );
- // because aCharClassImpl.toTitle does not handle ligatures or Beta but will raise
+ // because xCharClassImpl.toTitle does not handle ligatures or Beta but will raise
// an exception we need to handle the first chara manually...
// we don't want to change surrogates by accident, thuse we use proper code point iteration
@@ -279,16 +279,16 @@ static OUString transliterate_titlecase_Impl(
sal_uInt32 cFirstChar = aText.iterateCodePoints( &nPos );
OUString aResolvedLigature( &cFirstChar, 1 );
// toUpper can be used to properly resolve ligatures and characters like Beta
- aResolvedLigature = aCharClassImpl.toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
+ aResolvedLigature = xCharClassImpl->toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
// since toTitle will leave all-uppercase text unchanged we first need to
// use toLower to bring possible 2nd and following chars in lowercase
- aResolvedLigature = aCharClassImpl.toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
+ aResolvedLigature = xCharClassImpl->toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
sal_Int32 nResolvedLen = aResolvedLigature.getLength();
// now we can properly use toTitle to get the expected result for the resolved string.
// The rest of the text should just become lowercase.
- aRes = aCharClassImpl.toTitle( aResolvedLigature, 0, nResolvedLen, rLocale );
- aRes += aCharClassImpl.toLower( aText, 1, aText.getLength() - 1, rLocale );
+ aRes = xCharClassImpl->toTitle( aResolvedLigature, 0, nResolvedLen, rLocale );
+ aRes += xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale );
offset.realloc( aRes.getLength() );
sal_Int32 *pOffset = offset.getArray();
diff --git a/i18npool/source/transliteration/transliteration_caseignore.cxx b/i18npool/source/transliteration/transliteration_caseignore.cxx
index dcfefe3f6d5a..9e89c39356b9 100644
--- a/i18npool/source/transliteration/transliteration_caseignore.cxx
+++ b/i18npool/source/transliteration/transliteration_caseignore.cxx
@@ -59,16 +59,16 @@ Transliteration_caseignore::transliterateRange( const OUString& str1, const OUSt
if (str1.getLength() != 1 || str2.getLength() != 1)
throw RuntimeException();
- static Transliteration_u2l u2l;
- static Transliteration_l2u l2u;
+ static Reference< Transliteration_u2l > u2l(new Transliteration_u2l);
+ static Reference< Transliteration_l2u > l2u(new Transliteration_l2u);
- u2l.loadModule((TransliterationModules)0, aLocale);
- l2u.loadModule((TransliterationModules)0, aLocale);
+ u2l->loadModule((TransliterationModules)0, aLocale);
+ l2u->loadModule((TransliterationModules)0, aLocale);
- OUString l1 = u2l.transliterateString2String(str1, 0, str1.getLength());
- OUString u1 = l2u.transliterateString2String(str1, 0, str1.getLength());
- OUString l2 = u2l.transliterateString2String(str2, 0, str2.getLength());
- OUString u2 = l2u.transliterateString2String(str2, 0, str2.getLength());
+ OUString l1 = u2l->transliterateString2String(str1, 0, str1.getLength());
+ OUString u1 = l2u->transliterateString2String(str1, 0, str1.getLength());
+ OUString l2 = u2l->transliterateString2String(str2, 0, str2.getLength());
+ OUString u2 = l2u->transliterateString2String(str2, 0, str2.getLength());
if ((l1 == u1) && (l2 == u2)) {
Sequence< OUString > r(2);