23 #include <com/sun/star/i18n/ScriptType.hpp>
24 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
25 #include <com/sun/star/i18n/BreakIterator.hpp>
27 #include <unicode/uchar.h>
85 sal_uInt16 nScript = i18n::ScriptType::WEAK;
88 if( nPos && nPos == rText.getLength() )
93 nScript =
m_xBreak->getScriptType(rText, nPos);
94 sal_Int32 nChgPos = 0;
95 if (i18n::ScriptType::WEAK == nScript && nPos >= 0 && nPos + 1 < rText.getLength())
99 switch (u_charType(rText[nPos + 1]))
101 case U_NON_SPACING_MARK:
102 case U_ENCLOSING_MARK:
103 case U_COMBINING_SPACING_MARK:
104 nScript =
m_xBreak->getScriptType(rText, nPos+1);
108 if( i18n::ScriptType::WEAK == nScript && nPos )
110 nChgPos =
m_xBreak->beginOfScript(rText, nPos, nScript);
112 nScript =
m_xBreak->getScriptType(rText, nChgPos-1);
115 if( i18n::ScriptType::WEAK == nScript )
117 nChgPos =
m_xBreak->endOfScript(rText, nPos, nScript);
118 if( rText.getLength() > nChgPos && 0 <= nChgPos )
119 nScript =
m_xBreak->getScriptType(rText, nChgPos);
122 if( i18n::ScriptType::WEAK == nScript )
130 SvtScriptType::ASIAN |
131 SvtScriptType::COMPLEX;
133 sal_uInt16 nScript = 0;
134 if (!rText.isEmpty())
136 for( sal_Int32
n = 0, nEnd = rText.getLength();
n < nEnd;
137 n =
m_xBreak->endOfScript(rText,
n, nScript) )
139 nScript =
m_xBreak->getScriptType(rText,
n);
142 case i18n::ScriptType::LATIN: nRet |= SvtScriptType::LATIN;
break;
143 case i18n::ScriptType::ASIAN: nRet |= SvtScriptType::ASIAN;
break;
144 case i18n::ScriptType::COMPLEX: nRet |= SvtScriptType::COMPLEX;
break;
145 case i18n::ScriptType::WEAK:
146 if( nRet == SvtScriptType::NONE )
147 nRet |= coAllScripts;
150 if( coAllScripts == nRet )
158 sal_Int32 nStart, sal_Int32 nEnd)
const
160 sal_Int32 nGraphemeCount = 0;
162 sal_Int32 nCurPos = std::max(static_cast<sal_Int32>(0), nStart);
163 while (nCurPos < nEnd)
167 if (rText[nCurPos] ==
' ')
173 sal_Int32 nCount2 = 1;
174 nCurPos =
m_xBreak->nextCharacters(rText, nCurPos, lang::Locale(),
175 i18n::CharacterIteratorMode::SKIPCELL, nCount2, nCount2);
180 return nGraphemeCount;
LanguageType m_aForbiddenLang
language of the current forbiddenChar struct
css::uno::Reference< css::uno::XComponentContext > m_xContext
void GetLocale_(const LanguageType aLang)
SvtScriptType GetAllScriptsOfText(const OUString &rText) const
css::i18n::ForbiddenCharacters getForbiddenCharacters() const
std::unique_ptr< LanguageTag > m_xLanguageTag
language tag of the current locale
sal_uInt16 GetRealScriptOfText(const OUString &rText, sal_Int32 nPos) const
const LanguageTag & GetLanguageTag(const LanguageType aLang)
sal_Int32 getGraphemeCount(const OUString &rStr, sal_Int32 nStart, sal_Int32 nEnd) const
SwBreakIt(SwBreakIt const &)=delete
Reference< deployment::XPackageRegistry > create(Reference< deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, Reference< XComponentContext > const &xComponentContext)
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
exports com.sun.star. i18n
#define LANGUAGE_DONTKNOW
void GetForbidden_(const LanguageType aLang)
LanguageType GetAppLanguage()
css::uno::Reference< css::i18n::XBreakIterator > m_xBreak
std::unique_ptr< css::i18n::ForbiddenCharacters > m_xForbidden
static void Create_(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Reference< XComponentContext > m_xContext