sw/source/core/text/itrform2.cxx |   27 +++++++++++++++++++--------
 sw/source/core/text/itrform2.hxx |    3 ++-
 sw/source/core/text/porrst.cxx   |    2 ++
 3 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit d5fab973d0af95c433c5f6a9492014f7db642489
Author: Mark Hung <mark...@gmail.com>
Date:   Thu Jul 28 20:20:26 2016 +0800

    tdf#87224 Merge character borders across different scripts.
    
    Character borders were broken when it contains multiple scripts.
    Merge borders on kern portions and draw its border as necessary.
    Refer to correct previous portion so it decide whether it join
    previous or next border correctly.
    
    Change-Id: I881da36a5204ef627289ee799438c4ff915b00ef
    Reviewed-on: https://gerrit.libreoffice.org/27652
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Mark Hung <mark...@gmail.com>

diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index b4ea8e8..4fe661a 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -466,6 +466,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo &rInf 
)
                         new SwKernPortion( *rInf.GetLast(), nLstHeight,
                                            pLast->InFieldGrp() && 
pPor->InFieldGrp() );
                     rInf.GetLast()->SetPortion( nullptr );
+                    MergeCharacterBorder(*pKrn, 
rInf.GetLast()->FindLastPortion(), rInf);
                     InsertPortion( rInf, pKrn );
                 }
             }
@@ -510,7 +511,11 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo 
&rInf )
             }
 
             if ( pGridKernPortion != pPor )
+            {
+                SwLinePortion *pLast = rInf.GetLast()? 
rInf.GetLast()->FindLastPortion():nullptr ;
+                MergeCharacterBorder(*pGridKernPortion, pLast , rInf);
                 InsertPortion( rInf, pGridKernPortion );
+            }
         }
 
         if( pPor->IsDropPortion() )
@@ -669,7 +674,15 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo 
&rInf )
         rInf.SetFull( bFull );
 
         if( !pPor->IsDropPortion() )
-            MergeCharacterBorder(*pPor, rInf);
+        {
+            SwLinePortion *pPrev = rInf.GetLast() ? 
rInf.GetLast()->FindLastPortion() : nullptr;
+            for ( SwLinePortion *pNext = pPor ; pNext!= NULL ; 
pNext=pNext->GetPortion())
+            {
+                if ( !pNext->IsParaPortion() )
+                    MergeCharacterBorder(*pNext, pPrev, rInf);
+                pPrev = pNext ;
+            }
+        }
 
         // Restportions from fields with multiple lines don't yet have the 
right ascent
         if ( !pPor->GetLen() && !pPor->IsFlyPortion()
@@ -2578,15 +2591,12 @@ void SwTextFormatter::MergeCharacterBorder( 
SwDropPortion& rPortion )
     }
 }
 
-void SwTextFormatter::MergeCharacterBorder( SwLinePortion& rPortion, 
SwTextFormatInfo& rInf )
+void SwTextFormatter::MergeCharacterBorder( SwLinePortion& rPortion, 
SwLinePortion *pPrev, SwTextFormatInfo& rInf )
 {
     const SwFont aCurFont = *rInf.GetFont();
     if( aCurFont.HasBorder() )
     {
-        // The current portion isn't inserted into the portion chain yet, so 
the info's
-        // last portion will be the previous one
-        if( rInf.GetLast() && rInf.GetLast() != &rPortion && // For para 
portion (special case)
-            rInf.GetLast()->GetJoinBorderWithNext() )
+        if (pPrev && pPrev->GetJoinBorderWithNext() )
         {
             // In some case border merge is called twice to the portion
             if( !rPortion.GetJoinBorderWithPrev() )
@@ -2607,9 +2617,10 @@ void SwTextFormatter::MergeCharacterBorder( 
SwLinePortion& rPortion, SwTextForma
         if( !rInf.IsFull() && // Not the last portion of the line (in case of 
line break)
             rInf.GetIdx() + rPortion.GetLen() != rInf.GetText().getLength() ) 
// Not the last portion of the paragraph
             bSeek = Seek(rInf.GetIdx() + rPortion.GetLen());
-
+        // Don't join the next portion if SwKernPortion sits between two 
different boxes.
+        bool bDisconnect = rPortion.IsKernPortion() && 
!rPortion.GetJoinBorderWithPrev();
         // If next portion has the same border then merge
-        if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, 
*GetFnt()) )
+        if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, 
*GetFnt()) && !bDisconnect )
         {
             // In some case border merge is called twice to the portion
             if( !rPortion.GetJoinBorderWithNext() )
diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx
index 9a335fe..2320b3e 100644
--- a/sw/source/core/text/itrform2.hxx
+++ b/sw/source/core/text/itrform2.hxx
@@ -238,9 +238,10 @@ public:
      * changing the size (width, height and ascent) of the portion
      * to get a merged border.
      * @param   rPortion    portion for merge
+     * @param   pPrev       portion immediately before rPortion
      * @param   rInf        contain information
     **/
-    void MergeCharacterBorder( SwLinePortion& rPortion, SwTextFormatInfo& rInf 
);
+    void MergeCharacterBorder( SwLinePortion& rPortion, SwLinePortion *pPrev, 
SwTextFormatInfo& rInf );
 };
 
 #endif
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 15ead55..e82b695 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -144,6 +144,8 @@ void SwKernPortion::Paint( const SwTextPaintInfo &rInf ) 
const
             rInf.DrawViewOpt( *this, POR_FLD );
 
         rInf.DrawBackBrush( *this );
+        if (GetJoinBorderWithNext() ||GetJoinBorderWithPrev())
+            rInf.DrawBorder( *this );
 
         // do we have to repaint a post it portion?
         if( rInf.OnWin() && pPortion && !pPortion->Width() )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to