summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2016-07-28 20:20:26 +0800
committerMark Hung <marklh9@gmail.com>2016-08-24 00:06:38 +0000
commitd5fab973d0af95c433c5f6a9492014f7db642489 (patch)
treef19158f0387942588c76dda42293b377fb462273 /sw
parentcc497d86e092315f78a89f3ace8b81623dad7b46 (diff)
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 <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/itrform2.cxx27
-rw-r--r--sw/source/core/text/itrform2.hxx3
-rw-r--r--sw/source/core/text/porrst.cxx2
3 files changed, 23 insertions, 9 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index b4ea8e8598d4..4fe661a1d8c5 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 9a335fe64484..2320b3ef3973 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 15ead55817fa..e82b69504ecb 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() )