20#if defined __GNUC__ && !defined __clang__
21#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
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& )
64Sequence< OUString > SAL_CALL
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;
116 out = pHeapBuf.get();
124 sal_Int32* offsetData;
125 std::unique_ptr<sal_Int32[]> pOffsetHeapBuf;
126 sal_Int32 nOffsetCount = std::max<sal_Int32>(nLocalBuf,
nCount);
127 if (nOffsetCount <= nLocalBuf)
128 offsetData =
static_cast<sal_Int32*
>(alloca(nOffsetCount *
NMAPPINGMAX *
sizeof(sal_Int32)));
131 pOffsetHeapBuf.reset(
new sal_Int32[ nOffsetCount *
NMAPPINGMAX ]);
132 offsetData = pOffsetHeapBuf.get();
134 sal_Int32* offsetDataEnd = offsetData;
142 std::fill_n(offsetDataEnd,
map.nmap,
i + startPos);
143 offsetDataEnd +=
map.nmap;
144 std::copy_n(
map.map,
map.nmap, out + j);
148 *pOffset = css::uno::Sequence< sal_Int32 >(offsetData, offsetDataEnd - offsetData);
158 std::copy_n(
map.map,
map.nmap, out + j);
163 return OUString(out, j);
170 rtl_uString* pStr = rtl_uString_alloc(
map.nmap);
174 for (
i = 0;
i <
map.nmap;
i++)
178 return OUString( pStr, SAL_NO_ACQUIRE );
186 throw MultipleCharsOutputException();
192 Sequence< sal_Int32 >* pOffset)
224 nMappingType = MappingType::LowerToUpper | MappingType::UpperToLower;
238 std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount,
239 const Locale &rLocale,
240 Sequence< sal_Int32 >* pOffset )
242 const OUString aText( inStr.substr( startPos,
nCount ) );
245 if (!aText.isEmpty())
247 Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
254 sal_uInt32 cFirstChar = aText.iterateCodePoints( &
o3tl::temporary(sal_Int32(0)) );
255 OUString aResolvedLigature( &cFirstChar, 1 );
257 aResolvedLigature = xCharClassImpl->toUpper( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
260 aResolvedLigature = xCharClassImpl->toLower( aResolvedLigature, 0, aResolvedLigature.getLength(), rLocale );
261 sal_Int32 nResolvedLen = aResolvedLigature.getLength();
265 aRes = xCharClassImpl->toTitle( aResolvedLigature, 0, nResolvedLen, rLocale ) +
266 xCharClassImpl->toLower( aText, 1, aText.getLength() - 1, rLocale );
269 pOffset->realloc( aRes.getLength() );
271 auto [
begin,
end] = asNonConstRange(*pOffset);
272 sal_Int32* pOffsetInt = std::fill_n(
begin, nResolvedLen, 0);
273 std::iota(pOffsetInt,
end, 1);
282 const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
283 Sequence< sal_Int32 >* pOffset )
298 const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
299 Sequence< sal_Int32 >* pOffset )
virtual sal_Unicode SAL_CALL transliterateChar2Char(sal_Unicode inChar) override
sal_Int16 SAL_CALL getType() override
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
OUString SAL_CALL transliterateChar2String(sal_Unicode inChar) override
OUString foldingImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
css::uno::Sequence< OUString > SAL_CALL transliterateRange(const OUString &str1, const OUString &str2) override
OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
Transliteration_casemapping()
Transliteration_sentencecase()
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
virtual OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
Transliteration_titlecase()
Transliteration_togglecase()
css::lang::Locale aLocale
const char * transliterationName
const char * implementationName
static sal_Int16 getUnicodeType(const sal_uInt32 ch)
Constant values shared between i18npool and, for example, the number formatter.
static MappingType lcl_getMappingTypeForToggleCase(MappingType nMappingType, sal_Unicode cChar)
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 >)
constexpr T & temporary(T &&x)
std::map< OUString, rtl::Reference< Entity > > map