Kaydet (Commit) d0a0da71 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#91057 transliterateChar2Char throws MultipleCharsOutputException

for ß, but toTitle only allows RuntimeException, which is our usual
awesomeness

Change-Id: Ib5618a55a369fa5cd1d323f657f0798776828386
üst 220c9fc2
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
#include <com/sun/star/i18n/UnicodeScript.hpp> #include <com/sun/star/i18n/UnicodeScript.hpp>
#include <com/sun/star/i18n/UnicodeType.hpp> #include <com/sun/star/i18n/UnicodeType.hpp>
#include <com/sun/star/i18n/KCharacterType.hpp> #include <com/sun/star/i18n/KCharacterType.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <unicode/uchar.h> #include <unicode/uchar.h>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <breakiteratorImpl.hxx> #include <breakiteratorImpl.hxx>
...@@ -79,27 +81,41 @@ cclass_Unicode::toLower( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount, ...@@ -79,27 +81,41 @@ cclass_Unicode::toLower( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
OUString SAL_CALL OUString SAL_CALL
cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException, std::exception) { cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount, const Locale& rLocale ) throw(RuntimeException, std::exception) {
sal_Int32 len = Text.getLength(); try
if (nPos >= len) {
return OUString(); sal_Int32 len = Text.getLength();
if (nCount + nPos > len) if (nPos >= len)
nCount = len - nPos; return OUString();
if (nCount + nPos > len)
trans->setMappingType(MappingTypeToTitle, rLocale); nCount = len - nPos;
rtl_uString* pStr = rtl_uString_alloc(nCount);
sal_Unicode* out = pStr->buffer; trans->setMappingType(MappingTypeToTitle, rLocale);
BreakIteratorImpl brk(m_xContext); rtl_uString* pStr = rtl_uString_alloc(nCount);
Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale, sal_Unicode* out = pStr->buffer;
WordType::ANYWORD_IGNOREWHITESPACES, sal_True); BreakIteratorImpl brk(m_xContext);
for (sal_Int32 i = nPos; i < nCount + nPos; i++, out++) { Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
if (i >= bdy.endPos) WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
bdy = brk.nextWord(Text, bdy.endPos, rLocale, for (sal_Int32 i = nPos; i < nCount + nPos; i++, out++) {
WordType::ANYWORD_IGNOREWHITESPACES); if (i >= bdy.endPos)
*out = (i == bdy.startPos) ? bdy = brk.nextWord(Text, bdy.endPos, rLocale,
trans->transliterateChar2Char(Text[i]) : Text[i]; WordType::ANYWORD_IGNOREWHITESPACES);
*out = (i == bdy.startPos) ?
trans->transliterateChar2Char(Text[i]) : Text[i];
}
*out = 0;
return OUString( pStr, SAL_NO_ACQUIRE );
}
catch (const RuntimeException&)
{
throw;
}
catch (const Exception& e)
{
uno::Any a(cppu::getCaughtException());
throw lang::WrappedTargetRuntimeException(
"wrapped Exception " + e.Message,
uno::Reference<uno::XInterface>(), a);
} }
*out = 0;
return OUString( pStr, SAL_NO_ACQUIRE );
} }
sal_Int16 SAL_CALL sal_Int16 SAL_CALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment