[Libreoffice-commits] core.git: sw/source

Mark Hung marklh9 at gmail.com
Sat Apr 15 11:47:05 UTC 2017


 sw/source/core/inc/scriptinfo.hxx   |    2 +-
 sw/source/core/text/porlay.cxx      |   11 +++++------
 sw/source/core/txtnode/fntcache.cxx |    6 +++---
 3 files changed, 9 insertions(+), 10 deletions(-)

New commits:
commit 25f079087fb4368b94ec3cc791fb04eeb1405bb3
Author: Mark Hung <marklh9 at gmail.com>
Date:   Fri Mar 31 23:13:32 2017 +0800

    tdf#43741 do not add space to the last character.
    
    Adding space to the last chracter make textlines extrude
    the boundary. Check SpaceStop to prevent adding space
    after hole portion or the last character.
    
    Change-Id: If252a8a57cf55752cb152aa78688157f5d528b99
    Reviewed-on: https://gerrit.libreoffice.org/35978
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/source/core/inc/scriptinfo.hxx b/sw/source/core/inc/scriptinfo.hxx
index 3a5fed064586..74a792462dce 100644
--- a/sw/source/core/inc/scriptinfo.hxx
+++ b/sw/source/core/inc/scriptinfo.hxx
@@ -357,7 +357,7 @@ public:
     static void CJKJustify( const OUString& rText, long* pKernArray,
                                   long* pScrArray, sal_Int32 nStt,
                                   sal_Int32 nLen, LanguageType aLang,
-                                  long nSpaceAdd );
+                                  long nSpaceAdd, bool bIsSpaceStop );
 
     static SwScriptInfo* GetScriptInfo( const SwTextNode& rNode,
                                         bool bAllowInvalid = false );
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index a3f8506f7fd7..b1bc88582d67 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -2236,17 +2236,15 @@ sal_Int32 SwScriptInfo::CountCJKCharacters( const OUString &rText, sal_Int32 nPo
 void SwScriptInfo::CJKJustify( const OUString& rText, long* pKernArray,
                                      long* pScrArray, sal_Int32 nStt,
                                      sal_Int32 nLen, LanguageType aLang,
-                                     long nSpaceAdd )
+                                     long nSpaceAdd, bool bIsSpaceStop )
 {
     assert( pKernArray != nullptr && nStt >= 0 );
     if ( nLen > 0 && g_pBreakIt->GetBreakIter().is() )
     {
-        long nSpaceSum = nSpaceAdd;
+        long nSpaceSum = 0;
         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 );
+        sal_Int32 nNext = nStt;
         for ( sal_Int32 nI = 0; nI < nLen ; ++nI )
         {
             if ( nI + nStt == nNext )
@@ -2254,7 +2252,8 @@ void SwScriptInfo::CJKJustify( const OUString& rText, long* pKernArray,
                 nNext = g_pBreakIt->GetBreakIter()->nextCharacters( rText, nNext,
                         rLocale,
                         i18n::CharacterIteratorMode::SKIPCELL, 1, nDone );
-                nSpaceSum += nSpaceAdd;
+                if (nNext < nStt + nLen || !bIsSpaceStop)
+                    nSpaceSum += nSpaceAdd;
             }
             pKernArray[ nI ] += nSpaceSum;
             if ( pScrArray )
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 77dc717bda0c..f31db54e71b2 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1242,7 +1242,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                     if (!MsLangId::isKorean(aLang))
                     {
                         SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
-                                rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
+                                rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
 
                         bSpecialJust = true;
                         nSpaceAdd = 0;
@@ -1447,7 +1447,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 if (!MsLangId::isKorean(aLang))
                 {
                     SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), pScrArray.get(),
-                            rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
+                            rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
 
                     nSpaceAdd = 0;
                 }
@@ -2040,7 +2040,7 @@ sal_Int32 SwFntObj::GetCursorOfst( SwDrawTextInfo &rInf )
             if (!MsLangId::isKorean(aLang))
             {
                 SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
-                        rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
+                        rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd, rInf.IsSpaceStop() );
 
                 nSpaceAdd = 0;
             }


More information about the Libreoffice-commits mailing list