summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-08-17 17:40:15 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-08-18 09:49:52 +0200
commitcc7a94cfa8ec901627e8f9abf28c724923deb520 (patch)
tree0b6aa425c7e44c91f1a93164f754a818bbfe2fce /sw
parentd055f7eba0ad624ff1642a0f1421aa1fbfbbe9c5 (diff)
Reduce text background painting rect with border
Change-Id: I48fa36aafa17b9660c65ed713ae2faf9c0c4d056
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/inc/swfont.hxx27
-rw-r--r--sw/source/core/text/inftxt.cxx32
-rw-r--r--sw/source/core/text/inftxt.hxx2
3 files changed, 50 insertions, 11 deletions
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index 82acffd8b5fb..d7a6eb578243 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -396,7 +396,12 @@ public:
sal_uInt16 GetRightBorderDist() const { return m_nRightBorderDist; }
sal_uInt16 GetLeftBorderDist() const { return m_nLeftBorderDist; }
- // Return with the border width plus spacing
+ sal_uInt16 GetTopBorderWidth() const;
+ sal_uInt16 GetBottomBorderWidth() const;
+ sal_uInt16 GetRightBorderWidth() const;
+ sal_uInt16 GetLeftBorderWidth() const;
+
+ // Return the border width plus spacing
sal_uInt16 GetTopBorderSpace() const;
sal_uInt16 GetBottomBorderSpace() const;
sal_uInt16 GetRightBorderSpace() const;
@@ -881,6 +886,26 @@ inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist )
aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
}
+inline sal_uInt16 SwFont::GetTopBorderWidth() const
+{
+ return m_aTopBorder ? m_aTopBorder.get().GetScaledWidth() : 0;
+}
+
+inline sal_uInt16 SwFont::GetBottomBorderWidth() const
+{
+ return m_aBottomBorder ? m_aBottomBorder.get().GetScaledWidth() : 0;
+}
+
+inline sal_uInt16 SwFont::GetRightBorderWidth() const
+{
+ return m_aRightBorder ? m_aRightBorder.get().GetScaledWidth() : 0;
+}
+
+inline sal_uInt16 SwFont::GetLeftBorderWidth() const
+{
+ return m_aLeftBorder ? m_aLeftBorder.get().GetScaledWidth() : 0;
+}
+
inline sal_uInt16 SwFont::GetTopBorderSpace() const
{
if( m_aTopBorder )
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index aff0ec99833b..069cf8f39208 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -748,9 +748,23 @@ void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPo
}
void SwTxtPaintInfo::CalcRect( const SwLinePortion& rPor,
- SwRect* pRect, SwRect* pIntersect ) const
+ SwRect* pRect, SwRect* pIntersect,
+ const bool bInsideBorder ) const
{
- Size aSize( rPor.Width(), rPor.Height() );
+ KSHORT nPorHeight = rPor.Height();
+ KSHORT nPorAscent = rPor.GetAscent();
+ KSHORT nPorWidth = rPor.Width();
+ SwTwips nX = X();
+
+ if( bInsideBorder )
+ {
+ nPorAscent -= GetFont()->GetTopBorderWidth();
+ nPorHeight -= GetFont()->GetTopBorderWidth() + GetFont()->GetBottomBorderWidth();
+ nPorWidth -= GetFont()->GetRightBorderWidth() + GetFont()->GetLeftBorderWidth();
+ nX += GetFont()->GetLeftBorderWidth();
+ }
+
+ Size aSize( nPorWidth, nPorHeight );
if( rPor.IsHangingPortion() )
aSize.Width() = ((SwHangingPortion&)rPor).GetInnerWidth();
if( rPor.InSpaceGrp() && GetSpaceAdd() )
@@ -770,23 +784,23 @@ void SwTxtPaintInfo::CalcRect( const SwLinePortion& rPor,
aSize.Height() = nTmp;
if ( 1 == GetDirection() )
{
- aPoint.A() = X() - rPor.GetAscent();
+ aPoint.A() = nX - nPorAscent;
aPoint.B() = Y() - aSize.Height();
}
else
{
- aPoint.A() = X() - rPor.Height() + rPor.GetAscent();
+ aPoint.A() = nX - nPorHeight + nPorAscent;
aPoint.B() = Y();
}
}
else
{
- aPoint.A() = X();
+ aPoint.A() = nX;
//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
if ( GetTxtFrm()->IsVertLR() )
- aPoint.B() = Y() - rPor.Height() + rPor.GetAscent();
+ aPoint.B() = Y() - nPorHeight + nPorAscent;
else
- aPoint.B() = Y() - rPor.GetAscent();
+ aPoint.B() = Y() - nPorAscent;
}
// Adjust x coordinate if we are inside a bidi portion
@@ -1124,7 +1138,7 @@ void SwTxtPaintInfo::DrawBackground( const SwLinePortion &rPor ) const
OSL_ENSURE( OnWin(), "SwTxtPaintInfo::DrawBackground: printer pollution ?" );
SwRect aIntersect;
- CalcRect( rPor, 0, &aIntersect );
+ CalcRect( rPor, 0, &aIntersect, true );
if ( aIntersect.HasArea() )
{
@@ -1209,7 +1223,7 @@ void SwTxtPaintInfo::_DrawBackBrush( const SwLinePortion &rPor ) const
OSL_ENSURE( m_pFnt->GetBackColor(), "DrawBackBrush: Lost Color" );
SwRect aIntersect;
- CalcRect( rPor, 0, &aIntersect );
+ CalcRect( rPor, 0, &aIntersect, true );
if ( aIntersect.HasArea() )
{
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index c9d5d10985bb..e22ec7ae45ea 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -449,7 +449,7 @@ public:
inline void NotifyURL( const SwLinePortion &rPor ) const
{ if( URLNotify() ) _NotifyURL( rPor ); }
- void CalcRect( const SwLinePortion& rPor, SwRect* pRect, SwRect* pIntersect = 0 ) const;
+ void CalcRect( const SwLinePortion& rPor, SwRect* pRect, SwRect* pIntersect = 0, const bool bInsideBorder = false ) const;
inline SwTwips GetPaintOfst() const;
inline void SetPaintOfst( const SwTwips nNew );