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

Zolnai Tamás zolnaitamas2000 at gmail.com
Fri Aug 2 07:33:52 PDT 2013


 sw/source/core/inc/frmtool.hxx     |    2 
 sw/source/core/inc/swfont.hxx      |   35 +++++++++----
 sw/source/core/layout/paintfrm.cxx |   46 ++++++++++-------
 sw/source/core/text/inftxt.cxx     |   30 +++++++----
 sw/source/core/text/itratr.cxx     |   72 +++++++++++++++++++++++++++
 sw/source/core/text/itratr.hxx     |   21 ++++++--
 sw/source/core/text/itrcrsr.cxx    |   52 ++++++++++++++++++--
 sw/source/core/text/porlay.cxx     |    9 +++
 sw/source/core/text/txtdrop.cxx    |   19 ++++++-
 sw/source/core/txtnode/swfont.cxx  |   96 +++++++++++++++++++++++++++++++++++--
 10 files changed, 327 insertions(+), 55 deletions(-)

New commits:
commit 051b59ca35b30ec44226c7e5d429c46c00076ad5
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Thu Aug 1 20:17:41 2013 +0200

    CharBrd 4.3: drop caps
    
    -Increase the height with the borders width.
    (drop portion calculates the height by own, but width is right)
    -Avoid caching when there is a border, because caching work
    with height and it can happen that border change, but height not.
    -Avoid drop portion height when calculate the line height
    (except when there is only one line)
    -Drop portion has an own font, so we have to use this
    font when change the cursor position.
    -When painting text, use the current drop portion
    part width.
    
    Change-Id: I3d8f4ef9e6f067e28827453f9b6412184943b72e

diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index 532ee1e..a57a20f 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -379,6 +379,8 @@ public:
     const boost::optional<editeng::SvxBorderLine>& GetAbsBottomBorder( const bool bVertLayout ) const;
     const boost::optional<editeng::SvxBorderLine>& GetAbsRightBorder( const bool bVertLayout ) const;
     const boost::optional<editeng::SvxBorderLine>& GetAbsLeftBorder( const bool bVertLayout ) const;
+
+    bool HasBorder() const;
 };
 
 inline void SwFont::SetColor( const Color& rColor )
@@ -828,6 +830,11 @@ inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertF
     Font::SetOrientation( nDir );
 }
 
+inline bool SwFont::HasBorder() const
+{
+    return m_aTopBorder || m_aBottomBorder || m_aLeftBorder || m_aRightBorder;
+}
+
 
 /*************************************************************************
  *                      class SwUnderlineFont
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 17b7681..3e97fa7 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -29,6 +29,7 @@
 #include <editeng/adjustitem.hxx>
 #include <editeng/lspcitem.hxx>
 #include <editeng/lrspitem.hxx>
+#include <editeng/borderline.hxx>
 #include <frmatr.hxx>
 #include <pagedesc.hxx> // SwPageDesc
 #include <tgrditem.hxx>
@@ -925,9 +926,28 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst,
 
                         // Shift the cursor with the right border width
                         // Note: nX remains positive because GetTxtSize() also include the width of the right border
-                        if( GetInfo().GetFont()->GetRightBorder() && aInf.GetIdx() < nOfst && nOfst < aInf.GetIdx() + pPor->GetLen() )
+                        if( aInf.GetIdx() < nOfst && nOfst < aInf.GetIdx() + pPor->GetLen() )
+                        {
+                            // Find the current drop portion part and use its right border
+                            if( pPor->IsDropPortion() )
+                            {
+                                SwDropPortion* pDrop = static_cast<SwDropPortion*>(pPor);
+                                const SwDropPortionPart* pCurrPart = pDrop->GetPart();
+                                sal_Int16 nSumLength = 0;
+                                while( pCurrPart && (nSumLength += pCurrPart->GetLen()) < nOfst - aInf.GetIdx() )
+                                {
+                                    pCurrPart = pCurrPart->GetFollow();
+                                }
+                                if( pCurrPart && nSumLength != nOfst - aInf.GetIdx() && pCurrPart->GetFont().GetRightBorder() )
+                                {
+                                    nX -= pCurrPart->GetFont().GetRightBorder().get().GetScaledWidth();
+                                }
+                            }
+                            else if(GetInfo().GetFont()->GetRightBorder())
+                            {
                                 nX -= GetInfo().GetFont()->GetRightBorder().get().GetScaledWidth();
-
+                            }
+                         }
                     }
                     bWidth = sal_False;
                     break;
@@ -1088,7 +1108,7 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst,
                 if ( pCMS->pSpecialPos )
                 {
                     // apply attributes to font
-                    Seek( nOfst );
+                    SeekAndChgAttrIter( nOfst, aInf.GetOut() );
                     lcl_GetCharRectInsideField( aInf, *pOrig, *pCMS, *pPor );
                 }
             }
@@ -1617,10 +1637,34 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint,
                                          aSizeInf.GetIdx(),
                                          pPor->GetLen() );
 
+                // Drop portion works like a multi portion, just its parts are not portions
+                if( pPor->IsDropPortion() )
+                {
+                    SwDropPortion* pDrop = static_cast<SwDropPortion*>(pPor);
+                    const SwDropPortionPart* pCurrPart = pDrop->GetPart();
+                    sal_uInt16 nSumWidth = 0;
+                    sal_uInt16 nSumBorderWidth = 0;
+                    // Shift offset with the right and left border of previous parts and left border of actual one
+                    while( pCurrPart && nSumWidth <= nX - nCurrStart )
+                    {
+                        nSumWidth += pCurrPart->GetWidth();
+                        if( pCurrPart->GetFont().GetLeftBorder() )
+                        {
+                            nSumBorderWidth += pCurrPart->GetFont().GetLeftBorder().get().GetScaledWidth();
+                        }
+                        if( nSumWidth <= nX - nCurrStart && pCurrPart->GetFont().GetRightBorder() )
+                        {
+                            nSumBorderWidth += pCurrPart->GetFont().GetRightBorder().get().GetScaledWidth();
+                        }
+                        pCurrPart = pCurrPart->GetFollow();
+                    }
+                    nX = std::max(0, nX - nSumBorderWidth);
+                }
                 // Shift the offset with the left border width
-                if( GetInfo().GetFont()->GetLeftBorder() )
+                else if (GetInfo().GetFont()->GetLeftBorder() )
                     nX = std::max(0, nX - GetInfo().GetFont()->GetLeftBorder().get().GetScaledWidth());
 
+
                 aDrawInf.SetOfst( nX );
 
                 if ( nSpaceAdd )
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index edc8458..45ec2e9 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -27,6 +27,7 @@
 #include "porfly.hxx"   // SwFlyCntPortion
 #include <porrst.hxx>   // SwHangingPortion
 #include <pormulti.hxx> // SwMultiPortion
+#include <pordrop.hxx> // SwDropPortion
 #include <breakit.hxx>
 #include <unicode/uchar.h>
 #include <com/sun/star/i18n/ScriptType.hpp>
@@ -370,6 +371,14 @@ void SwLineLayout::CalcLine( SwTxtFormatter &rLine, SwTxtFormatInfo &rInf )
                     }
                 }
 
+                // Ignore drop portion height
+                if( pPos->IsDropPortion() && static_cast<SwDropPortion*>(pPos)->GetLines() > 1)
+                {
+                    pLast = pPos;
+                    pPos = pPos->GetPortion();
+                    continue;
+                }
+
                 bHasOnlyBlankPortions = false;
 
                 // We had an attribute change: Sum up/build maxima of length and mass
diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx
index d708cc67..5d2d5a2 100644
--- a/sw/source/core/text/txtdrop.cxx
+++ b/sw/source/core/text/txtdrop.cxx
@@ -281,6 +281,7 @@ void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const
 
     const SwDropPortionPart* pCurrPart = GetPart();
     const xub_StrLen nOldLen = GetLen();
+    const KSHORT nOldWidth = Width();
     const KSHORT nOldAscent = GetAscent();
 
     const SwTwips nBasePosY  = rInf.Y();
@@ -294,6 +295,7 @@ void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const
     while ( pCurrPart )
     {
         ((SwDropPortion*)this)->SetLen( pCurrPart->GetLen() );
+        ((SwDropPortion*)this)->Width( pCurrPart->GetWidth() );
         ((SwTxtPaintInfo&)rInf).SetLen( pCurrPart->GetLen() );
         SwFontSave aFontSave( rInf, &pCurrPart->GetFont() );
 
@@ -305,6 +307,7 @@ void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const
     }
 
     ((SwTxtPaintInfo&)rInf).Y( nBasePosY );
+    ((SwDropPortion*)this)->Width( nOldWidth );
     ((SwDropPortion*)this)->SetLen( nOldLen );
     ((SwDropPortion*)this)->SetAscent( nOldAscent );
 }
@@ -601,7 +604,7 @@ SwDropPortion *SwTxtFormatter::NewDropPortion( SwTxtFormatInfo &rInf )
     while ( nNextChg  < nPorLen )
     {
         // check for attribute changes and if the portion has to split:
-        Seek( nNextChg );
+        SeekAndChgAttrIter( nNextChg, rInf.GetOut() );
 
         // the font is deleted in the destructor of the drop portion part
         SwFont* pTmpFnt = new SwFont( *rInf.GetFont() );
@@ -737,7 +740,7 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf )
     OSL_ENSURE( pDrop->GetPart(),"DropPortion without part during font calculation");
 
     SwDropPortionPart* pCurrPart = pDrop->GetPart();
-    const bool bUseCache = ! pCurrPart->GetFollow();
+    const bool bUseCache = ! pCurrPart->GetFollow() && !pCurrPart->GetFont().HasBorder();
     xub_StrLen nIdx = rInf.GetIdx();
     XubString aStr( rInf.GetTxt(), nIdx, pCurrPart->GetLen() );
 
@@ -885,6 +888,18 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf )
                 rFnt.SetSize( aOldSize, rFnt.GetActual() );
                 rFnt.SetProportion( nOldProp );
 
+                // Modify the bounding rectangle with the borders
+                if( rFnt.GetTopBorder() )
+                {
+                    aRect.setHeight(aRect.GetHeight() + rFnt.GetTopBorder().get().GetScaledWidth());
+                    aRect.setY(aRect.getY() - rFnt.GetTopBorder().get().GetScaledWidth());
+                }
+
+                if( rFnt.GetBottomBorder() )
+                {
+                    aRect.setHeight(aRect.GetHeight() + rFnt.GetBottomBorder().get().GetScaledWidth());
+                }
+
                 if ( bFirstGlyphRect )
                 {
                     aCommonRect = aRect;
commit 8bdb89558778d992cb5e82383fe7138f46232944
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Thu Aug 1 17:23:50 2013 +0200

    Useless variable
    
    Change-Id: I56fac8b812b23d38f335e90769a0ad20ee22f413

diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index c81528e..a88e47e 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -645,12 +645,10 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
         aSub[SW_CTL].SetWeight( pAttrSet->GetCTLWeight().GetWeight() );
         aSub[SW_CTL].SetLanguage( pAttrSet->GetCTLLanguage().GetLanguage() );
     }
-
-    const FontUnderline eUnderline = pAttrSet->GetUnderline().GetLineStyle();
     if ( pAttrSet->GetCharHidden().GetValue() )
         SetUnderline( UNDERLINE_DOTTED );
     else
-        SetUnderline( eUnderline );
+        SetUnderline( pAttrSet->GetUnderline().GetLineStyle() );
     SetUnderColor( pAttrSet->GetUnderline().GetColor() );
     SetOverline( pAttrSet->GetOverline().GetLineStyle() );
     SetOverColor( pAttrSet->GetOverline().GetColor() );
commit f780802f33951a08931c3a327f32b34434d801b2
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Tue Jul 30 15:39:03 2013 +0200

    CharBrd 4.2: vertical text
    
    - Check the orientation while painting border
    and text
    - Do not merge border of different oriented fonts
    
    Change-Id: Ic4c8e73affe8ec2577f9e40004b353d1633bb5cf

diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index bd2e495..4b9f638 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -66,7 +66,7 @@ void SwAlignRect( SwRect &rRect, const ViewShell *pSh );
 void SwAlignGrfRect( SwRect *pGrfRect, const OutputDevice &rOut );
 
 // Paint character border using frame painting code
-void PaintCharacterBorder( const SwFont& rFont, const SwRect& rPaintArea);
+void PaintCharacterBorder( const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout);
 
 // get Fly, if no List is given use the current shell
 // Implementation in feshview.cxx
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index c2dc2d1..532ee1e 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -176,17 +176,6 @@ public:
     void SetBackColor( Color* pNewColor );
     inline const Color* GetBackColor() const{ return pBackColor; }
 
-    // set/get borders
-    void SetTopBorder( const editeng::SvxBorderLine* pTopBorder );
-    void SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder );
-    void SetRightBorder( const editeng::SvxBorderLine* pRightBorder );
-    void SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder );
-
-    const boost::optional<editeng::SvxBorderLine>& GetTopBorder() const { return m_aTopBorder; }
-    const boost::optional<editeng::SvxBorderLine>& GetBottomBorder() const { return m_aBottomBorder; }
-    const boost::optional<editeng::SvxBorderLine>& GetRightBorder() const { return m_aRightBorder; }
-    const boost::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; }
-
     inline void ChkMagic( ViewShell *pSh, sal_uInt8 nWhich )
         { if( !aSub[ nWhich ].pMagic ) GoMagic( pSh, nWhich ); }
     // uebernimmt die MagicNumber eines (hoffentlich ident.) Kollegen
@@ -373,6 +362,23 @@ public:
 
     inline void Invalidate()
         { bFntChg = bOrgChg = sal_True; }
+
+    // set/get borders
+    void SetTopBorder( const editeng::SvxBorderLine* pTopBorder );
+    void SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder );
+    void SetRightBorder( const editeng::SvxBorderLine* pRightBorder );
+    void SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder );
+
+    const boost::optional<editeng::SvxBorderLine>& GetTopBorder() const { return m_aTopBorder; }
+    const boost::optional<editeng::SvxBorderLine>& GetBottomBorder() const { return m_aBottomBorder; }
+    const boost::optional<editeng::SvxBorderLine>& GetRightBorder() const { return m_aRightBorder; }
+    const boost::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; }
+
+    // Get borders which are at absolute positions
+    const boost::optional<editeng::SvxBorderLine>& GetAbsTopBorder( const bool bVertLayout ) const;
+    const boost::optional<editeng::SvxBorderLine>& GetAbsBottomBorder( const bool bVertLayout ) const;
+    const boost::optional<editeng::SvxBorderLine>& GetAbsRightBorder( const bool bVertLayout ) const;
+    const boost::optional<editeng::SvxBorderLine>& GetAbsLeftBorder( const bool bVertLayout ) const;
 };
 
 inline void SwFont::SetColor( const Color& rColor )
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index ca3fcd7..3405c1d 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4765,33 +4765,41 @@ static void lcl_PaintTopBottomLine( const bool         _bTop,
 
 void PaintCharacterBorder(
     const SwFont& rFont,
-    const SwRect& rPaintArea )
+    const SwRect& rPaintArea,
+    const bool bVerticalLayout )
 {
+    // Init borders, after this initialization top, bottom, right and left means the
+    // absolute position
+    const boost::optional<editeng::SvxBorderLine>& aTopBorder = rFont.GetAbsTopBorder(bVerticalLayout);
+    const boost::optional<editeng::SvxBorderLine>& aBottomBorder = rFont.GetAbsBottomBorder(bVerticalLayout);
+    const boost::optional<editeng::SvxBorderLine>& aLeftBorder = rFont.GetAbsLeftBorder(bVerticalLayout);
+    const boost::optional<editeng::SvxBorderLine>& aRightBorder = rFont.GetAbsRightBorder(bVerticalLayout);
+
     SwRect aAlignedRect(rPaintArea);
     SwAlignRect(aAlignedRect, pGlobalShell);
 
-    if( rFont.GetTopBorder() )
+    if( aTopBorder )
     {
         Point aLeftTop (
             aAlignedRect.Left(),
             aAlignedRect.Top());
         Point aRightBottom (
             aAlignedRect.Right(),
-            aAlignedRect.Top() + rFont.GetTopBorder().get().GetScaledWidth());
+            aAlignedRect.Top() + aTopBorder.get().GetScaledWidth());
 
         lcl_MakeBorderLine(
             SwRect( aLeftTop, aRightBottom),
             false, true, false,
-            rFont.GetTopBorder().get(),
-            rFont.GetLeftBorder().get_ptr(),
-            rFont.GetRightBorder().get_ptr());
+            aTopBorder.get(),
+            aLeftBorder.get_ptr(),
+            aRightBorder.get_ptr());
     }
 
-    if( rFont.GetBottomBorder() )
+    if( aBottomBorder )
     {
         Point aLeftTop (
             aAlignedRect.Left(),
-            aAlignedRect.Bottom() - rFont.GetBottomBorder().get().GetScaledWidth());
+            aAlignedRect.Bottom() - aBottomBorder.get().GetScaledWidth());
         Point aRightBottom (
             aAlignedRect.Right(),
             aAlignedRect.Bottom());
@@ -4799,12 +4807,12 @@ void PaintCharacterBorder(
         lcl_MakeBorderLine(
             SwRect( aLeftTop, aRightBottom),
             false, false, false,
-            rFont.GetBottomBorder().get(),
-            rFont.GetLeftBorder().get_ptr(),
-            rFont.GetRightBorder().get_ptr());
+            aBottomBorder.get(),
+            aLeftBorder.get_ptr(),
+            aRightBorder.get_ptr());
     }
 
-    if( rFont.GetLeftBorder() )
+    if( aLeftBorder )
     {
         Point aLeftTop (
             aAlignedRect.Left(),
@@ -4816,12 +4824,12 @@ void PaintCharacterBorder(
         lcl_MakeBorderLine(
             SwRect( aLeftTop, aRightBottom),
             true, true, true,
-            rFont.GetLeftBorder().get(),
-            rFont.GetTopBorder().get_ptr(),
-            rFont.GetBottomBorder().get_ptr());
+            aLeftBorder.get(),
+            aTopBorder.get_ptr(),
+            aBottomBorder.get_ptr());
     }
 
-    if( rFont.GetRightBorder() )
+    if( aRightBorder )
     {
         Point aLeftTop (
             aAlignedRect.Right() - rFont.GetRightBorder().get().GetScaledWidth(),
@@ -4833,9 +4841,9 @@ void PaintCharacterBorder(
         lcl_MakeBorderLine(
             SwRect( aLeftTop, aRightBottom),
             true, false, true,
-            rFont.GetRightBorder().get(),
-            rFont.GetTopBorder().get_ptr(),
-            rFont.GetBottomBorder().get_ptr());
+            aRightBorder.get(),
+            aTopBorder.get_ptr(),
+            aBottomBorder.get_ptr());
     }
 }
 
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 2ce4a60..4c87c9e 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -661,15 +661,9 @@ void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPo
     SwDrawTextInfo aDrawInf( m_pFrm->getRootFrm()->GetCurrShell(), *m_pOut, pSI, rText, nStart, nLength,
                              rPor.Width(), bBullet );
 
-    if( m_pFnt->GetLeftBorder() )
-        aDrawInf.SetLeft( GetPaintRect().Left() + m_pFnt->GetLeftBorder().get().GetScaledWidth() );
-    else
-        aDrawInf.SetLeft( GetPaintRect().Left() );
 
-    if( m_pFnt->GetRightBorder() )
-        aDrawInf.SetRight( GetPaintRect().Right() - m_pFnt->GetRightBorder().get().GetScaledWidth() );
-    else
-        aDrawInf.SetRight( GetPaintRect().Right());
+    aDrawInf.SetLeft( GetPaintRect().Left() );
+    aDrawInf.SetRight( GetPaintRect().Right());
 
     aDrawInf.SetUnderFnt( m_pUnderFnt );
 
@@ -703,7 +697,23 @@ void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPo
     // Draw text next to the left border
     Point aFontPos(aPos);
     if( m_pFnt->GetLeftBorder() )
-       aFontPos.X() += m_pFnt->GetLeftBorder().get().GetScaledWidth();
+    {
+        switch( m_pFnt->GetOrientation(GetTxtFrm()->IsVertical()) )
+        {
+            case 0 :
+                aFontPos.X() += m_pFnt->GetLeftBorder().get().GetScaledWidth();
+                break;
+            case 900 :
+                aFontPos.Y() -= m_pFnt->GetLeftBorder().get().GetScaledWidth();
+                break;
+            case 1800 :
+                aFontPos.X() -= m_pFnt->GetLeftBorder().get().GetScaledWidth();
+                break;
+            case 2700 :
+                aFontPos.Y() += m_pFnt->GetLeftBorder().get().GetScaledWidth();
+                break;
+        }
+    }
 
     if( GetTxtFly()->IsOn() )
     {
@@ -1223,7 +1233,7 @@ void SwTxtPaintInfo::DrawBorder( const SwLinePortion &rPor ) const
     CalcRect( rPor, &aDrawArea );
     if ( aDrawArea.HasArea() )
     {
-        PaintCharacterBorder(*m_pFnt, aDrawArea);
+        PaintCharacterBorder(*m_pFnt, aDrawArea, GetTxtFrm()->IsVertical());
     }
 }
 
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 249f132..7e0fefc 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -369,6 +369,7 @@ xub_StrLen SwAttrIter::GetNextAttr( ) const
 static bool lcl_HasMergeableBorder(const SwFont& rFirst, const SwFont& rSecond)
 {
     return
+        rFirst.GetOrientation() == rSecond.GetOrientation() &&
         rFirst.GetTopBorder() == rSecond.GetTopBorder() &&
         rFirst.GetBottomBorder() == rSecond.GetBottomBorder() &&
         rFirst.GetLeftBorder() == rSecond.GetLeftBorder() &&
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 7a62c47..c81528e 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -117,6 +117,98 @@ void SwFont::SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder )
     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
 }
 
+const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsTopBorder( const bool bVertLayout ) const
+{
+    switch( GetOrientation( bVertLayout ) )
+    {
+        case 0 :
+            return m_aTopBorder;
+            break;
+        case 900 :
+            return m_aRightBorder;
+            break;
+        case 1800 :
+            return m_aBottomBorder;
+            break;
+        case 2700 :
+            return m_aLeftBorder;
+            break;
+        default :
+            assert(false);
+            return m_aTopBorder;
+            break;
+    }
+}
+
+const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsBottomBorder( const bool bVertLayout ) const
+{
+    switch( GetOrientation( bVertLayout ) )
+    {
+        case 0 :
+            return m_aBottomBorder;
+            break;
+        case 900 :
+            return m_aLeftBorder;
+            break;
+        case 1800 :
+            return m_aTopBorder;
+            break;
+        case 2700 :
+            return m_aRightBorder;
+            break;
+        default :
+            assert(false);
+            return m_aBottomBorder;
+            break;
+    }
+}
+
+const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsLeftBorder( const bool bVertLayout ) const
+{
+    switch( GetOrientation( bVertLayout ) )
+    {
+        case 0 :
+            return m_aLeftBorder;
+            break;
+        case 900 :
+            return m_aTopBorder;
+            break;
+        case 1800 :
+            return m_aRightBorder;
+            break;
+        case 2700 :
+            return m_aBottomBorder;
+            break;
+        default :
+            assert(false);
+            return m_aLeftBorder;
+            break;
+    }
+}
+
+const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsRightBorder( const bool bVertLayout ) const
+{
+    switch( GetOrientation( bVertLayout ) )
+    {
+        case 0 :
+            return m_aRightBorder;
+            break;
+        case 900 :
+            return m_aBottomBorder;
+            break;
+        case 1800 :
+            return m_aLeftBorder;
+            break;
+        case 2700 :
+            return m_aTopBorder;
+            break;
+        default :
+            assert(false);
+            return m_aRightBorder;
+            break;
+    }
+}
+
 // maps directions for vertical layout
 sal_uInt16 MapDirection( sal_uInt16 nDir, const sal_Bool bVertFormat )
 {
commit 0d9ddccd8810a81a6f4d737870969d0dcf367d23
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Sun Jul 28 12:44:52 2013 +0200

    CharBrd 4.1: merge borders of text portions
    
    If two neighbouring text portion has the same height
    and same border then the left/right border between
    them will be removed.
    
    Change-Id: Id91ed33acbd8d052dc8d5248c0caf0822303bce7

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index fba4898..249f132 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -122,6 +122,12 @@ SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const
 
 sal_Bool SwAttrIter::SeekAndChgAttrIter( const xub_StrLen nNewPos, OutputDevice* pOut )
 {
+    sal_Bool bRet = ImplSeekAndChgAttrIter(nNewPos, pOut);
+    return MergeCharBorder(false) || bRet;
+}
+
+sal_Bool SwAttrIter::ImplSeekAndChgAttrIter( const xub_StrLen nNewPos, OutputDevice* pOut )
+{
     sal_Bool bChg = nStartIndex && nNewPos == nPos ? pFnt->IsFntChg() : Seek( nNewPos );
     if ( pLastOut != pOut )
     {
@@ -138,6 +144,7 @@ sal_Bool SwAttrIter::SeekAndChgAttrIter( const xub_StrLen nNewPos, OutputDevice*
                 aFntIdx[ pFnt->GetActual() ], pFnt->GetActual() );
         pFnt->ChgPhysFnt( pShell, *pOut );
     }
+
     return bChg;
 }
 
@@ -153,9 +160,14 @@ sal_Bool SwAttrIter::IsSymbol( const xub_StrLen nNewPos )
 /*************************************************************************
  *                        SwAttrIter::SeekStartAndChg()
  *************************************************************************/
-
 sal_Bool SwAttrIter::SeekStartAndChgAttrIter( OutputDevice* pOut, const sal_Bool bParaFont )
 {
+    sal_Bool bRet = ImplSeekStartAndChgAttrIter( pOut, bParaFont );
+    return bParaFont ? bRet : MergeCharBorder(true) || bRet;
+}
+
+sal_Bool SwAttrIter::ImplSeekStartAndChgAttrIter( OutputDevice* pOut, const sal_Bool bParaFont )
+{
     if ( pRedln && pRedln->ExtOn() )
         pRedln->LeaveExtend( *pFnt, 0 );
 
@@ -246,6 +258,7 @@ void SwAttrIter::SeekFwd( const xub_StrLen nNewPos )
     while ( ( nStartIndex < pHints->GetStartCount() ) &&
            (*(pTxtAttr=pHints->GetStart(nStartIndex))->GetStart()<=nNewPos))
     {
+
         // oeffne die TextAttribute, deren Ende hinter der neuen Position liegt
         if ( *pTxtAttr->GetAnyEnd() > nNewPos )  Chg( pTxtAttr );
         nStartIndex++;
@@ -353,6 +366,62 @@ xub_StrLen SwAttrIter::GetNextAttr( ) const
     return nNext;
 }
 
+static bool lcl_HasMergeableBorder(const SwFont& rFirst, const SwFont& rSecond)
+{
+    return
+        rFirst.GetTopBorder() == rSecond.GetTopBorder() &&
+        rFirst.GetBottomBorder() == rSecond.GetBottomBorder() &&
+        rFirst.GetLeftBorder() == rSecond.GetLeftBorder() &&
+        rFirst.GetRightBorder() == rSecond.GetRightBorder();
+}
+
+bool SwAttrIter::MergeCharBorder( const bool bStart )
+{
+    const xub_StrLen nActPos = nPos;
+    bool bRemoveLeft = false;
+    bool bRemoveRight = false;
+    SwFont aTmpFont = *pFnt;
+    const sal_Int32 nTmpStart = nStartIndex;
+
+    // Check whether next neightbour has same border and height
+    if( aTmpFont.GetRightBorder() && pHints && nTmpStart < pHints->GetStartCount() )
+    {
+        ImplSeekAndChgAttrIter(GetNextAttr(), pLastOut);
+        if( aTmpFont.GetHeight(pShell, *pLastOut) == pFnt->GetHeight(pShell, *pLastOut) &&
+            lcl_HasMergeableBorder(aTmpFont, *pFnt) )
+        {
+            bRemoveRight = true;
+        }
+    }
+
+    // Check whether previous neightbour has same border and height
+    if( aTmpFont.GetLeftBorder() && nTmpStart > 1)
+    {
+        ImplSeekAndChgAttrIter(nActPos-1, pLastOut);
+        if( aTmpFont.GetHeight(pShell, *pLastOut) == pFnt->GetHeight(pShell, *pLastOut) &&
+            lcl_HasMergeableBorder(aTmpFont, *pFnt) )
+        {
+            bRemoveLeft = true;
+        }
+    }
+
+    // If the iterator changed its position, than we have to reset it.
+    if( nPos != nActPos )
+    {
+        if( bStart )
+            ImplSeekStartAndChgAttrIter(pLastOut, false);
+        else
+            ImplSeekAndChgAttrIter(nActPos, pLastOut);
+    }
+
+    if( bRemoveRight )
+        pFnt->SetRightBorder(0);
+    if( bRemoveLeft )
+        pFnt->SetLeftBorder(0);
+
+    return bRemoveLeft || bRemoveRight;
+}
+
 class SwMinMaxArgs
 {
 public:
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index a4a7fbc..317e59d 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -72,6 +72,9 @@ protected:
             aMagicNo[SW_LATIN] = aMagicNo[SW_CJK] = aMagicNo[SW_CTL] = NULL;
         }
 
+    /// Implementation of the considering public methods (to avoid recursion)
+    sal_Bool ImplSeekAndChgAttrIter( const xub_StrLen nNewPos, OutputDevice* pOut );
+    sal_Bool ImplSeekStartAndChgAttrIter( OutputDevice* pOut, const sal_Bool bParaFont );
 public:
     // Constructor, destructor
     inline SwAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf )
@@ -83,19 +86,29 @@ public:
     inline SwRedlineItr *GetRedln() { return pRedln; }
     // The parameter returns the position of the next change before or at the
     // char position.
-    // Returns sal_False, if there's no change before or at the positon,
-    // else sal_True.
     xub_StrLen GetNextAttr( ) const;
-    // Enables the attributes used at char pos nPos in the logical font
+    /// Enables the attributes used at char pos nPos in the logical font
     sal_Bool Seek( const xub_StrLen nPos );
     // Creates the font at the specified position via Seek() and checks
     // if it's a symbol font.
     sal_Bool IsSymbol( const xub_StrLen nPos );
 
-    // Executes ChgPhysFnt if Seek() returns sal_True
+    /** Executes ChgPhysFnt if Seek() returns sal_True
+     *  and change font to merge character border with neighbours.
+    **/
     sal_Bool SeekAndChgAttrIter( const xub_StrLen nPos, OutputDevice* pOut );
     sal_Bool SeekStartAndChgAttrIter( OutputDevice* pOut, const sal_Bool bParaFont = sal_False );
 
+    /** Merge character border with removing left/right border of the font if the
+     *  the neighbours of the current position (nPos) has the same height
+     *  and same kind of border.
+     *  @param      bStart  true if it is called from SeekStartAndChgAttrIter
+     *                      false, otherwise
+     *  @return     true,   if font change (removing some of its borders)
+     *              false,  otherwise
+    **/
+    bool MergeCharBorder( const bool bStart );
+
     // Do we have an attribute change at all?
     inline sal_Bool HasHints() const { return 0 != pHints; }
 


More information about the Libreoffice-commits mailing list