20 #if defined __GNUC__ && !defined __clang__
21 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
24 #include <rtl/ref.hxx>
27 #include <com/sun/star/i18n/MultipleCharsOutputException.hpp>
28 #include <com/sun/star/i18n/TransliterationType.hpp>
54 return TransliterationType::ONE_TO_ONE;
58 const OUString& , sal_Int32 , sal_Int32 , sal_Int32& ,
59 const OUString& , sal_Int32 , sal_Int32 , sal_Int32& )
67 return { str1, str2 };
77 if (nMappingType == (MappingType::LowerToUpper | MappingType::UpperToLower))
81 nRes = MappingType::LowerToUpper;
85 nRes = MappingType::UpperToLower;
94 const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
95 Sequence< sal_Int32 >* pOffset)
108 constexpr sal_Int32 nLocalBuf = 2048;
110 std::unique_ptr<sal_Unicode[]> pHeapBuf;
111 if (nCount <= nLocalBuf)
116 out = pHeapBuf.get();
124 std::vector<sal_Int32> aVec;
125 aVec.reserve(std::max<sal_Int32>(nLocalBuf, nCount) *
NMAPPINGMAX);
127 for (sal_Int32
i = 0;
i < nCount;
i++)
133 std::fill_n(std::back_inserter(aVec), map.
nmap, i + startPos);
134 std::copy_n(map.
map, map.
nmap, out + j);
142 for ( sal_Int32
i = 0;
i < nCount;
i++)
148 std::copy_n(map.
map, map.
nmap, out + j);
153 return OUString(out, j);
160 rtl_uString* pStr = rtl_uString_alloc(map.
nmap);
164 for (i = 0; i < map.
nmap; i++)
168 return OUString( pStr, SAL_NO_ACQUIRE );
176 throw MultipleCharsOutputException();
182 Sequence< sal_Int32 >* pOffset)
214 nMappingType = MappingType::LowerToUpper | MappingType::UpperToLower;
228 std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount,
229 const Locale &rLocale,
230 Sequence< sal_Int32 >* pOffset )
232 const OUString aText( inStr.substr( startPos, nCount ) );
235 if (!aText.isEmpty())
244 sal_uInt32 cFirstChar = aText.iterateCodePoints( &
o3tl::temporary(sal_Int32(0)) );
245 OUString aResolvedLigature( &cFirstChar, 1 );
247 aResolvedLigature = xCharClassImpl->toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
250 aResolvedLigature = xCharClassImpl->toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
251 sal_Int32 nResolvedLen = aResolvedLigature.getLength();
255 aRes = xCharClassImpl->toTitle( aResolvedLigature, 0, nResolvedLen, rLocale ) +
256 xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale );
257 pOffset->realloc( aRes.getLength() );
259 auto [
begin,
end] = asNonConstRange(*pOffset);
260 sal_Int32* pOffsetInt = std::fill_n(
begin, nResolvedLen, 0);
261 std::iota(pOffsetInt,
end, 1);
269 const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
270 Sequence< sal_Int32 >* pOffset )
279 implementationName =
"com.sun.star.i18n.Transliteration.Transliteration_sentencecase";
285 const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
286 Sequence< sal_Int32 >* pOffset )
Transliteration_titlecase()
static MappingType lcl_getMappingTypeForToggleCase(MappingType nMappingType, sal_Unicode cChar)
css::uno::Sequence< OUString > SAL_CALL transliterateRange(const OUString &str1, const OUString &str2) override
const char * transliterationName
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
static OUString transliterate_titlecase_Impl(std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount, const Locale &rLocale, Sequence< sal_Int32 > *pOffset)
enumrange< T >::Iterator begin(enumrange< T >)
sal_Unicode map[NMAPPINGMAX]
const char * implementationName
css::lang::Locale aLocale
Transliteration_sentencecase()
OUString SAL_CALL transliterateChar2String(sal_Unicode inChar) override
OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
Constant values shared between i18npool and, for example, the number formatter.
enumrange< T >::Iterator end(enumrange< T >)
constexpr T & temporary(T &&x)
sal_Bool SAL_CALL equals(const OUString &str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32 &nMatch1, const OUString &str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32 &nMatch2) override
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Transliteration_togglecase()
std::map< OUString, rtl::Reference< Entity > > map
sal_Int16 SAL_CALL getType() override
Transliteration_casemapping()
static sal_Int16 getUnicodeType(const sal_Unicode ch)
OUString foldingImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
virtual sal_Unicode SAL_CALL transliterateChar2Char(sal_Unicode inChar) override