diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-08-06 10:58:09 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-08-12 10:30:01 +0200 |
commit | 36651940d2164569030796db3521efc69abcb9b5 (patch) | |
tree | 283f3bb2b1f969efe0cc1663107d735bb3fb211e /sw | |
parent | 13c81d8741c57da9111f9f42061d5c62b94667c9 (diff) |
CharBrd 5: border padding/spacing
Change-Id: I47529dce4cdb04b5b9d2b7aa6106be9bbd7d8428
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/swfont.hxx | 83 | ||||
-rw-r--r-- | sw/source/core/text/atrstck.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/text/guess.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/text/txtdrop.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 50 |
7 files changed, 158 insertions, 33 deletions
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 97c78d23a4ce..f57147e22a90 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -136,6 +136,12 @@ class SwFont boost::optional<editeng::SvxBorderLine> m_aRightBorder; boost::optional<editeng::SvxBorderLine> m_aLeftBorder; + // border distance + sal_uInt16 m_nTopBorderDist; + sal_uInt16 m_nBottomBorderDist; + sal_uInt16 m_nRightBorderDist; + sal_uInt16 m_nLeftBorderDist; + sal_uInt8 nToxCnt; // Zaehlt die Schachtelungstiefe der Tox sal_uInt8 nRefCnt; // Zaehlt die Schachtelungstiefe der Refs sal_uInt8 m_nMetaCount; // count META/METAFIELD @@ -380,6 +386,22 @@ public: const boost::optional<editeng::SvxBorderLine>& GetAbsRightBorder( const bool bVertLayout ) const; const boost::optional<editeng::SvxBorderLine>& GetAbsLeftBorder( const bool bVertLayout ) const; + void SetTopBorderDist( const sal_uInt16 nTopDist ); + void SetBottomBorderDist( const sal_uInt16 nBottomDist ); + void SetRightBorderDist( const sal_uInt16 nRightDist ); + void SetLeftBorderDist( const sal_uInt16 nLeftDist ); + + sal_uInt16 GetTopBorderDist() const { return m_nTopBorderDist; } + sal_uInt16 GetBottomBorderDist() const { return m_nBottomBorderDist; } + sal_uInt16 GetRightBorderDist() const { return m_nRightBorderDist; } + sal_uInt16 GetLeftBorderDist() const { return m_nLeftBorderDist; } + + // Return with the border width plus spacing + sal_uInt16 GetTopBorderSpace() const; + sal_uInt16 GetBottomBorderSpace() const; + sal_uInt16 GetRightBorderSpace() const; + sal_uInt16 GetLeftBorderSpace() const; + bool HasBorder() const; void RemoveBorders(); }; @@ -831,6 +853,66 @@ inline void SwSubFont::SetVertical( const sal_uInt16 nDir, const sal_Bool bVertF Font::SetOrientation( nDir ); } +inline void SwFont::SetTopBorderDist( const sal_uInt16 nTopDist ) +{ + m_nTopBorderDist = nTopDist; + bFntChg = sal_True; + aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; +} + +inline void SwFont::SetBottomBorderDist( const sal_uInt16 nBottomDist ) +{ + m_nBottomBorderDist = nBottomDist; + bFntChg = sal_True; + aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; +} + +inline void SwFont::SetRightBorderDist( const sal_uInt16 nRightDist ) +{ + m_nRightBorderDist = nRightDist; + bFntChg = sal_True; + aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; +} + +inline void SwFont::SetLeftBorderDist( const sal_uInt16 nLeftDist ) +{ + m_nLeftBorderDist = nLeftDist; + bFntChg = sal_True; + aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; +} + +inline sal_uInt16 SwFont::GetTopBorderSpace() const +{ + if( m_aTopBorder ) + return m_aTopBorder.get().GetScaledWidth() + m_nTopBorderDist; + else + return 0; +} + +inline sal_uInt16 SwFont::GetBottomBorderSpace() const +{ + if( m_aBottomBorder ) + return m_aBottomBorder.get().GetScaledWidth() + m_nBottomBorderDist; + else + return 0; +} + +inline sal_uInt16 SwFont::GetRightBorderSpace() const +{ + if( m_aRightBorder ) + return m_aRightBorder.get().GetScaledWidth() + m_nRightBorderDist; + else + return 0; +} + +inline sal_uInt16 SwFont::GetLeftBorderSpace() const +{ + if( m_aLeftBorder ) + return m_aLeftBorder.get().GetScaledWidth() + m_nLeftBorderDist; + else + return 0; +} + inline bool SwFont::HasBorder() const { return m_aTopBorder || m_aBottomBorder || m_aLeftBorder || m_aRightBorder; @@ -839,6 +921,7 @@ inline bool SwFont::HasBorder() const inline void SwFont::RemoveBorders() { m_aTopBorder = m_aBottomBorder = m_aLeftBorder = m_aRightBorder = boost::none; + m_nTopBorderDist = m_nBottomBorderDist = m_nRightBorderDist = m_nLeftBorderDist = 0; } /************************************************************************* diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 99fef3d13227..28973032e025 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -745,11 +745,18 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu break; } case RES_CHRATR_BOX: - rFnt.SetTopBorder( ((SvxBoxItem&)rItem).GetTop() ); - rFnt.SetBottomBorder( ((SvxBoxItem&)rItem).GetBottom() ); - rFnt.SetRightBorder( ((SvxBoxItem&)rItem).GetRight() ); - rFnt.SetLeftBorder( ((SvxBoxItem&)rItem).GetLeft() ); + { + const SvxBoxItem& aBoxItem = static_cast<const SvxBoxItem&>(rItem); + rFnt.SetTopBorder( aBoxItem.GetTop() ); + rFnt.SetBottomBorder( aBoxItem.GetBottom() ); + rFnt.SetRightBorder( aBoxItem.GetRight() ); + rFnt.SetLeftBorder( aBoxItem.GetLeft() ); + rFnt.SetTopBorderDist( aBoxItem.GetDistance(BOX_LINE_TOP) ); + rFnt.SetBottomBorderDist( aBoxItem.GetDistance(BOX_LINE_BOTTOM) ); + rFnt.SetRightBorderDist( aBoxItem.GetDistance(BOX_LINE_RIGHT) ); + rFnt.SetLeftBorderDist( aBoxItem.GetDistance(BOX_LINE_LEFT) ); break; + } case RES_CHRATR_OVERLINE : rFnt.SetOverline( ((SvxOverlineItem&)rItem).GetLineStyle() ); rFnt.SetOverColor( ((SvxOverlineItem&)rItem).GetColor() ); diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 37baa9ec0368..9a3ea15f7d13 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -114,9 +114,9 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, // Decrease the line width with the right and left border width if( rInf.GetFont()->GetRightBorder() ) - nLineWidth -= rInf.GetFont()->GetRightBorder().get().GetScaledWidth(); + nLineWidth -= rInf.GetFont()->GetRightBorderSpace(); if( rInf.GetFont()->GetLeftBorder() ) - nLineWidth -= rInf.GetFont()->GetLeftBorder().get().GetScaledWidth(); + nLineWidth -= rInf.GetFont()->GetLeftBorderSpace(); const bool bUnbreakableNumberings = rInf.GetTxtFrm()->GetTxtNode()-> getIDocumentSettingAccess()->get(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS); diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 4c87c9eeee20..59bc5246b3c2 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -375,7 +375,7 @@ KSHORT SwTxtSizeInfo::GetAscent() const sal_uInt16 nAscent = ((SwFont*)GetFont())->GetAscent( m_pVsh, *GetOut() ); if( GetFont()->GetTopBorder() ) - nAscent += GetFont()->GetTopBorder().get().GetScaledWidth(); + nAscent += GetFont()->GetTopBorderSpace(); return nAscent; } @@ -387,9 +387,9 @@ KSHORT SwTxtSizeInfo::GetTxtHeight() const sal_uInt16 nHeight = ((SwFont*)GetFont())->GetHeight( m_pVsh, *GetOut() ); if( GetFont()->GetTopBorder() ) - nHeight += GetFont()->GetTopBorder().get().GetScaledWidth(); + nHeight += GetFont()->GetTopBorderSpace(); if( GetFont()->GetBottomBorder() ) - nHeight += GetFont()->GetBottomBorder().get().GetScaledWidth(); + nHeight += GetFont()->GetBottomBorderSpace(); return nHeight; } @@ -401,13 +401,13 @@ static void lcl_IncreaseSizeWithBorders(SwPosSize& rSize, const SwFont& rFont) sal_uInt16 nHeight = rSize.Height(); if( rFont.GetTopBorder() ) - nHeight += rFont.GetTopBorder().get().GetScaledWidth(); + nHeight += rFont.GetTopBorderSpace(); if( rFont.GetBottomBorder() ) - nHeight += rFont.GetBottomBorder().get().GetScaledWidth(); + nHeight += rFont.GetBottomBorderSpace(); if( rFont.GetRightBorder() ) - nWidth += rFont.GetRightBorder().get().GetScaledWidth(); + nWidth += rFont.GetRightBorderSpace(); if( rFont.GetLeftBorder() ) - nWidth += rFont.GetLeftBorder().get().GetScaledWidth(); + nWidth += rFont.GetLeftBorderSpace(); rSize.Height(nHeight); rSize.Width(nWidth); @@ -698,19 +698,20 @@ void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPo Point aFontPos(aPos); if( m_pFnt->GetLeftBorder() ) { + const sal_uInt16 nLeftBorderSpace = m_pFnt->GetLeftBorderSpace(); switch( m_pFnt->GetOrientation(GetTxtFrm()->IsVertical()) ) { case 0 : - aFontPos.X() += m_pFnt->GetLeftBorder().get().GetScaledWidth(); + aFontPos.X() += nLeftBorderSpace; break; case 900 : - aFontPos.Y() -= m_pFnt->GetLeftBorder().get().GetScaledWidth(); + aFontPos.Y() -= nLeftBorderSpace; break; case 1800 : - aFontPos.X() -= m_pFnt->GetLeftBorder().get().GetScaledWidth(); + aFontPos.X() -= nLeftBorderSpace; break; case 2700 : - aFontPos.Y() += m_pFnt->GetLeftBorder().get().GetScaledWidth(); + aFontPos.Y() += nLeftBorderSpace; break; } } diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 3e97fa7c5a61..4410cc82de9e 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -940,12 +940,12 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, } if( pCurrPart && nSumLength != nOfst - aInf.GetIdx() && pCurrPart->GetFont().GetRightBorder() ) { - nX -= pCurrPart->GetFont().GetRightBorder().get().GetScaledWidth(); + nX -= pCurrPart->GetFont().GetRightBorderSpace(); } } else if(GetInfo().GetFont()->GetRightBorder()) { - nX -= GetInfo().GetFont()->GetRightBorder().get().GetScaledWidth(); + nX -= GetInfo().GetFont()->GetRightBorderSpace(); } } } @@ -1650,11 +1650,11 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, nSumWidth += pCurrPart->GetWidth(); if( pCurrPart->GetFont().GetLeftBorder() ) { - nSumBorderWidth += pCurrPart->GetFont().GetLeftBorder().get().GetScaledWidth(); + nSumBorderWidth += pCurrPart->GetFont().GetLeftBorderSpace(); } if( nSumWidth <= nX - nCurrStart && pCurrPart->GetFont().GetRightBorder() ) { - nSumBorderWidth += pCurrPart->GetFont().GetRightBorder().get().GetScaledWidth(); + nSumBorderWidth += pCurrPart->GetFont().GetRightBorderSpace(); } pCurrPart = pCurrPart->GetFollow(); } @@ -1662,7 +1662,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, } // Shift the offset with the left border width else if (GetInfo().GetFont()->GetLeftBorder() ) - nX = std::max(0, nX - GetInfo().GetFont()->GetLeftBorder().get().GetScaledWidth()); + nX = std::max(0, nX - GetInfo().GetFont()->GetLeftBorderSpace()); aDrawInf.SetOfst( nX ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 5d2d5a2688fc..cb956b37a683 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -891,13 +891,13 @@ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf ) // 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()); + aRect.setHeight(aRect.GetHeight() + rFnt.GetTopBorderSpace()); + aRect.setY(aRect.getY() - rFnt.GetTopBorderSpace()); } if( rFnt.GetBottomBorder() ) { - aRect.setHeight(aRect.GetHeight() + rFnt.GetBottomBorder().get().GetScaledWidth()); + aRect.setHeight(aRect.GetHeight() + rFnt.GetBottomBorderSpace()); } if ( bFirstGlyphRect ) diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index f81663670f89..c12c787151b5 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -82,7 +82,10 @@ void SwFont::SetTopBorder( const editeng::SvxBorderLine* pTopBorder ) if( pTopBorder ) m_aTopBorder = *pTopBorder; else + { m_aTopBorder = boost::none; + m_nTopBorderDist = 0; + } bFntChg = sal_True; aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; } @@ -92,7 +95,10 @@ void SwFont::SetBottomBorder( const editeng::SvxBorderLine* pBottomBorder ) if( pBottomBorder ) m_aBottomBorder = *pBottomBorder; else + { m_aBottomBorder = boost::none; + m_nBottomBorderDist = 0; + } bFntChg = sal_True; aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; } @@ -102,7 +108,10 @@ void SwFont::SetRightBorder( const editeng::SvxBorderLine* pRightBorder ) if( pRightBorder ) m_aRightBorder = *pRightBorder; else + { m_aRightBorder = boost::none; + m_nRightBorderDist = 0; + } bFntChg = sal_True; aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; } @@ -112,7 +121,10 @@ void SwFont::SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder ) if( pLeftBorder ) m_aLeftBorder = *pLeftBorder; else + { m_aLeftBorder = boost::none; + m_nLeftBorderDist = 0; + } bFntChg = sal_True; aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0; } @@ -520,10 +532,15 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet, if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX, sal_True, &pItem )) { - SetTopBorder(((SvxBoxItem*)pItem)->GetTop()); - SetBottomBorder(((SvxBoxItem*)pItem)->GetBottom()); - SetRightBorder(((SvxBoxItem*)pItem)->GetRight()); - SetLeftBorder(((SvxBoxItem*)pItem)->GetLeft()); + const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem); + SetTopBorder(pBoxItem->GetTop()); + SetBottomBorder(pBoxItem->GetBottom()); + SetRightBorder(pBoxItem->GetRight()); + SetLeftBorder(pBoxItem->GetLeft()); + SetTopBorderDist(pBoxItem->GetDistance(BOX_LINE_TOP)); + SetBottomBorderDist(pBoxItem->GetDistance(BOX_LINE_BOTTOM)); + SetRightBorderDist(pBoxItem->GetDistance(BOX_LINE_RIGHT)); + SetLeftBorderDist(pBoxItem->GetDistance(BOX_LINE_LEFT)); } const SfxPoolItem* pTwoLinesItem = 0; if( SFX_ITEM_SET == @@ -548,6 +565,10 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet, SwFont::SwFont() : pBackColor(0) + , m_nTopBorderDist(0) + , m_nBottomBorderDist(0) + , m_nRightBorderDist(0) + , m_nLeftBorderDist(0) , nActual(SW_LATIN) { } @@ -563,6 +584,10 @@ SwFont::SwFont( const SwFont &rFont ) m_aBottomBorder = rFont.m_aBottomBorder; m_aRightBorder = rFont.m_aRightBorder; m_aLeftBorder = rFont.m_aLeftBorder; + m_nTopBorderDist = rFont.m_nTopBorderDist; + m_nBottomBorderDist = rFont.m_nBottomBorderDist; + m_nRightBorderDist = rFont.m_nRightBorderDist; + m_nLeftBorderDist = rFont.m_nLeftBorderDist; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); nToxCnt = 0; @@ -687,10 +712,15 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX, sal_True, &pItem )) { - SetTopBorder(((SvxBoxItem*)pItem)->GetTop()); - SetBottomBorder(((SvxBoxItem*)pItem)->GetBottom()); - SetRightBorder(((SvxBoxItem*)pItem)->GetRight()); - SetLeftBorder(((SvxBoxItem*)pItem)->GetLeft()); + const SvxBoxItem* pBoxItem = static_cast<const SvxBoxItem*>(pItem); + SetTopBorder(pBoxItem->GetTop()); + SetBottomBorder(pBoxItem->GetBottom()); + SetRightBorder(pBoxItem->GetRight()); + SetLeftBorder(pBoxItem->GetLeft()); + SetTopBorderDist(pBoxItem->GetDistance(BOX_LINE_TOP)); + SetBottomBorderDist(pBoxItem->GetDistance(BOX_LINE_BOTTOM)); + SetRightBorderDist(pBoxItem->GetDistance(BOX_LINE_RIGHT)); + SetLeftBorderDist(pBoxItem->GetDistance(BOX_LINE_LEFT)); } else RemoveBorders(); @@ -738,6 +768,10 @@ SwFont& SwFont::operator=( const SwFont &rFont ) m_aBottomBorder = rFont.m_aBottomBorder; m_aRightBorder = rFont.m_aRightBorder; m_aLeftBorder = rFont.m_aLeftBorder; + m_nTopBorderDist = rFont.m_nTopBorderDist; + m_nBottomBorderDist = rFont.m_nBottomBorderDist; + m_nRightBorderDist = rFont.m_nRightBorderDist; + m_nLeftBorderDist = rFont.m_nLeftBorderDist; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); nToxCnt = 0; |