/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
m_pHints->AdvanceTo(m_nIndex); auto eCurrHint = m_pHints->Peek();
auto nChar = m_rText.iterateCodePoints(&m_nIndex);
nScript = GetScriptClass(nChar);
// tdf#166011 Apply style:script-type rules per ODF standard: if (eCurrHint == ScriptHintType::Ignore)
{ // The generic/latin font attributes are always used if the hint is ignore.
nScript = css::i18n::ScriptType::LATIN;
} elseif (nScript == css::i18n::ScriptType::WEAK)
{ switch (eCurrHint)
{ case ScriptHintType::Latin:
nScript = css::i18n::ScriptType::LATIN; break;
case ScriptHintType::Asian:
nScript = css::i18n::ScriptType::ASIAN; break;
case ScriptHintType::Complex:
nScript = css::i18n::ScriptType::COMPLEX; break;
default: break;
}
}
// #i16354# Change script type for RTL text to CTL: // 1. All text in RTL runs will use the CTL font // #i89825# change the script type also to CTL (hennerdrewes) // 2. Text in embedded LTR runs that does not have any strong LTR characters (numbers!) // tdf#163660 Asian-script characters inside RTL runs should still use Asian font if ((eCurrHint == ScriptHintType::Automatic || eCurrHint == ScriptHintType::Complex)
&& (bCharIsRtl || (bCharIsRtlOrEmbedded && !bRunHasStrongEmbeddedLTR)))
{ if (nScript != css::i18n::ScriptType::ASIAN)
{
nScript = css::i18n::ScriptType::COMPLEX;
}
} elseif (nScript == css::i18n::ScriptType::WEAK)
{
nScript = m_nPrevScript;
}
if (nScript != m_nPrevScript)
{
m_nNextStart = nPrevIndex; break;
}
m_nNextStart = m_nIndex;
}
if (m_nNextStart > 0)
{ // special case for dotted circle since it can be used with complex // before a mark, so we want it associated with the mark's script // tdf#112594: another special case for NNBSP followed by a Mongolian // character, since NNBSP has special uses in Mongolian (tdf#112594) auto nPrevPos = m_nNextStart; auto nPrevChar = m_rText.iterateCodePoints(&nPrevPos, -1); if (m_nNextStart < m_rText.getLength()
&& css::i18n::ScriptType::WEAK == GetScriptClass(nPrevChar))
{ auto nChar = m_rText.iterateCodePoints(&m_nNextStart, 0); auto nType = unicode::getUnicodeType(nChar); if (nType == css::i18n::UnicodeType::NON_SPACING_MARK
|| nType == css::i18n::UnicodeType::ENCLOSING_MARK
|| nType == css::i18n::UnicodeType::COMBINING_SPACING_MARK
|| (nPrevChar == CHAR_NNBSP
&& u_getIntPropertyValue(nChar, UCHAR_SCRIPT) == USCRIPT_MONGOLIAN))
{
m_nNextStart = nPrevPos;
}
}
}
public:
GreedyScriptChangeScanner(const OUString& rText, sal_Int16 nDefaultScriptType,
DirectionChangeScanner* pDirScanner, ScriptHintProvider* pHints)
: m_pDirScanner(pDirScanner)
, m_pHints(pHints)
, m_rText(rText)
{ // tdf#66791: For compatibility with other programs, the Asian script is // applied to any weak-script quote characters if the enclosing paragraph // contains Chinese- or Japanese-script characters. // In the original Writer algorithm, the application language is used for // all leading weak characters (#94331#). This implementation deviates by // instead using the first-seen non-weak script.
sal_Int32 nCjBase = 0; while (nCjBase < m_rText.getLength())
{ auto nChar = m_rText.iterateCodePoints(&nCjBase); auto nScript = GetScriptClass(nChar); if (m_nPrevScript == css::i18n::ScriptType::WEAK)
{
m_nPrevScript = nScript;
}
}
// Fall back to the application language for leading weak characters if a // better candidate was not found. if (m_nPrevScript == css::i18n::ScriptType::WEAK)
{
m_nPrevScript = nDefaultScriptType;
}
m_pHints->Start();
Advance();
}
bool AtEnd() const override { return m_bAtEnd; }
void Advance() override
{ do
{
AdvanceOnce();
} while (!AtEnd() && (m_stCurr.m_nStartIndex == m_stCurr.m_nEndIndex));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.