Kaydet (Commit) 6130ff73 authored tarafından Mark Hung's avatar Mark Hung Kaydeden (comit) Khaled Hosny

tdf#43740 Don't add space after ininvisible characters.

Move CJK justify code in SwFntObj::DrawText to
SwScriptInfo::CJKJustfiy() and use break iterator to
prevent unecessary space.

Change-Id: Ifd25373530fc97d3ce547ee3cd0484d4a852491c
Reviewed-on: https://gerrit.libreoffice.org/29911Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKhaled Hosny <khaledhosny@eglug.org>
üst 4ac1a406
......@@ -353,6 +353,12 @@ public:
long nSpaceAdd = 0 );
static sal_Int32 CountCJKCharacters( const OUString &rText, sal_Int32 nPos, sal_Int32 nEnd, LanguageType aLang);
static void CJKJustify( const OUString& rText, long* pKernArray,
long* pScrArray, sal_Int32 nStt,
sal_Int32 nLen, LanguageType aLang,
long nSpaceAdd );
static SwScriptInfo* GetScriptInfo( const SwTextNode& rNode,
bool bAllowInvalid = false );
......
......@@ -2163,4 +2163,34 @@ sal_Int32 SwScriptInfo::CountCJKCharacters( const OUString &rText, sal_Int32 nPo
return nCount;
}
void SwScriptInfo::CJKJustify( const OUString& rText, long* pKernArray,
long* pScrArray, sal_Int32 nStt,
sal_Int32 nLen, LanguageType aLang,
long nSpaceAdd )
{
assert( pKernArray != nullptr && nStt >= 0 );
if ( nLen > 0 && g_pBreakIt->GetBreakIter().is() )
{
long nSpaceSum = nSpaceAdd;
const lang::Locale &rLocale = g_pBreakIt->GetLocale( aLang );
sal_Int32 nDone = 0;
sal_Int32 nNext = g_pBreakIt->GetBreakIter()->nextCharacters( rText, nStt,
rLocale,
i18n::CharacterIteratorMode::SKIPCELL, 1, nDone );
for ( sal_Int32 nI = 0; nI < nLen ; ++nI )
{
if ( nI + nStt == nNext )
{
nNext = g_pBreakIt->GetBreakIter()->nextCharacters( rText, nNext,
rLocale,
i18n::CharacterIteratorMode::SKIPCELL, 1, nDone );
nSpaceSum += nSpaceAdd;
}
pKernArray[ nI ] += nSpaceSum;
if ( pScrArray )
pScrArray[ nI ] += nSpaceSum;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -1242,12 +1242,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if (!MsLangId::isKorean(aLang))
{
long nSpaceSum = nSpaceAdd;
for ( sal_Int32 nI = 0; nI < rInf.GetLen(); ++nI )
{
pKernArray[ nI ] += nSpaceSum;
nSpaceSum += nSpaceAdd;
}
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, nullptr,
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
bSpecialJust = true;
nSpaceAdd = 0;
......@@ -1454,13 +1450,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if (!MsLangId::isKorean(aLang))
{
long nSpaceSum = nSpaceAdd;
for ( sal_Int32 nI = 0; nI < rInf.GetLen(); ++nI )
{
pKernArray[ nI ] += nSpaceSum;
pScrArray[ nI ] += nSpaceSum;
nSpaceSum += nSpaceAdd;
}
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, pScrArray,
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
nSpaceAdd = 0;
}
......@@ -2067,12 +2058,8 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf )
if (!MsLangId::isKorean(aLang))
{
long nSpaceSum = nSpaceAdd;
for ( sal_Int32 nI = 0; nI < rInf.GetLen(); ++nI )
{
pKernArray[ nI ] += nSpaceSum;
nSpaceSum += nSpaceAdd;
}
SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, nullptr,
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
nSpaceAdd = 0;
}
......
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