diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-08-21 13:17:07 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-08-23 21:01:37 +0200 |
commit | 9509a46683e40fc2feea6631b701b766797b7882 (patch) | |
tree | 36a54015c0c754fe1001b457a5dc7a49b4a3b12f /sw | |
parent | 517e1056649646ca170f4c17cdd36b06656587ac (diff) |
Use text portion's join members without changing font
- The main advantage of avoiding font change and
use join members is that part of the border can be
removed (e.g. right or left border) but shadow won't.
- Other advantage, SwTxtSizeInfo is used for calculate
the length of the specified string and there are some
case when this length have to exclude the border width.
- Add join members to SwDropPortionPart and use these
members to set the whole drop portion's same member.
In general a drop portion' join members are false
and it get true value only temporarly during the actual
part formatting. (maybe it would be better solution to
make distinct drop portions instead of parts)
- Improve line break
Change-Id: I6d11ec7b250c9a8b769cffaf83861f25f0c477a5
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/frmtool.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 46 | ||||
-rw-r--r-- | sw/source/core/text/guess.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 64 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.hxx | 16 | ||||
-rw-r--r-- | sw/source/core/text/itrcrsr.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 31 | ||||
-rw-r--r-- | sw/source/core/text/pordrop.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/text/porfld.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/text/portxt.cxx | 26 | ||||
-rw-r--r-- | sw/source/core/text/txtdrop.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 12 |
12 files changed, 142 insertions, 119 deletions
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 4b9f63803fee..b478f551b2cc 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -66,7 +66,9 @@ 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, const bool bVerticalLayout); +void PaintCharacterBorder( + const SwFont& rFont, const SwRect& rPaintArea, const bool bVerticalLayout, + const bool bJoinWithPrev, const bool bJoinWithNext ); // get Fly, if no List is given use the current shell // Implementation in feshview.cxx diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index b70bb16a36f3..d965830957f3 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -4748,17 +4748,49 @@ static void lcl_PaintTopBottomLine( const bool _bTop, void PaintCharacterBorder( const SwFont& rFont, const SwRect& rPaintArea, - const bool bVerticalLayout ) + const bool bVerticalLayout, + const bool bJoinWithPrev, + const bool bJoinWithNext ) { + SwRect aAlignedRect(rPaintArea); + SwAlignRect(aAlignedRect, pGlobalShell); + + bool bTop = true; + bool bBottom = true; + bool bLeft = true; + bool bRight = true; + + switch( rFont.GetOrientation(bVerticalLayout) ) + { + case 0 : + bLeft = !bJoinWithPrev; + bRight = !bJoinWithNext; + break; + case 900 : + bBottom = !bJoinWithPrev; + bTop = !bJoinWithNext; + break; + case 1800 : + bRight = !bJoinWithPrev; + bLeft = !bJoinWithNext; + break; + case 2700 : + bTop = !bJoinWithPrev; + bBottom = !bJoinWithNext; + break; + } + // 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); + const boost::optional<editeng::SvxBorderLine> aTopBorder = + (bTop ? rFont.GetAbsTopBorder(bVerticalLayout) : boost::none); + const boost::optional<editeng::SvxBorderLine> aBottomBorder = + (bBottom ? rFont.GetAbsBottomBorder(bVerticalLayout) : boost::none); + const boost::optional<editeng::SvxBorderLine> aLeftBorder = + (bLeft ? rFont.GetAbsLeftBorder(bVerticalLayout) : boost::none); + const boost::optional<editeng::SvxBorderLine> aRightBorder = + (bRight ? rFont.GetAbsRightBorder(bVerticalLayout) : boost::none); - SwRect aAlignedRect(rPaintArea); - SwAlignRect(aAlignedRect, pGlobalShell); if( aTopBorder ) { diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 4ee643ad875a..ae5a8ff763c4 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -111,11 +111,11 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, if ( nLineWidth < 0 ) nLineWidth = 0; } - // Decrease the line width with the right and left border width - if( rInf.GetFont()->GetRightBorder() ) - nLineWidth -= rInf.GetFont()->GetRightBorderSpace(); - if( rInf.GetFont()->GetLeftBorder() ) - nLineWidth -= rInf.GetFont()->GetLeftBorderSpace(); + const sal_Int32 nLeftRightBorderSpace = + (!rPor.GetJoinBorderWithNext() ? rInf.GetFont()->GetRightBorderSpace() : 0) + + (!rPor.GetJoinBorderWithPrev() ? rInf.GetFont()->GetLeftBorderSpace() : 0); + + nLineWidth -= nLeftRightBorderSpace; const bool bUnbreakableNumberings = rInf.GetTxtFrm()->GetTxtNode()-> getIDocumentSettingAccess()->get(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS); @@ -143,6 +143,8 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, if ( nMaxSizeDiff ) rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); + nBreakWidth += nLeftRightBorderSpace; + return sal_True; } } @@ -193,6 +195,8 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, if ( nMaxSizeDiff ) rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); + nBreakWidth += nLeftRightBorderSpace; + return sal_True; } } @@ -464,6 +468,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, const xub_StrLen nHangingLen = nBreakPos - nCutPos; SwPosSize aTmpSize = rInf.GetTxtSize( &rSI, nCutPos, nHangingLen, 0 ); + aTmpSize.Width(aTmpSize.Width() + nLeftRightBorderSpace); OSL_ENSURE( !pHanging, "A hanging portion is hanging around" ); pHanging = new SwHangingPortion( aTmpSize ); pHanging->SetLen( nHangingLen ); @@ -510,7 +515,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, if ( nMaxSizeDiff ) rInf.SetMaxWidthDiff( (sal_uLong)&rPor, nMaxSizeDiff ); - nBreakWidth += nItalic; + nBreakWidth += nItalic + nLeftRightBorderSpace; } else nBreakWidth = 0; diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index a6c7de0ca9c5..2af2b3dca2c0 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -360,52 +360,6 @@ void SwTxtSizeInfo::NoteAnimation() const "SwTxtSizeInfo::NoteAnimation() changed m_pOut" ); } - -KSHORT SwTxtSizeInfo::GetAscent() const -{ - SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetAscent() without m_pOut" ); - - sal_uInt16 nAscent = ((SwFont*)GetFont())->GetAscent( m_pVsh, *GetOut() ); - - if( GetFont()->GetTopBorder() ) - nAscent += GetFont()->GetTopBorderSpace(); - - return nAscent; -} - -KSHORT SwTxtSizeInfo::GetTxtHeight() const -{ - SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetTxtHeight() without m_pOut" ); - - sal_uInt16 nHeight = ((SwFont*)GetFont())->GetHeight( m_pVsh, *GetOut() ); - - if( GetFont()->GetTopBorder() ) - nHeight += GetFont()->GetTopBorderSpace(); - if( GetFont()->GetBottomBorder() ) - nHeight += GetFont()->GetBottomBorderSpace(); - - return nHeight; -} - -static void lcl_IncreaseSizeWithBorders(SwPosSize& rSize, const SwFont& rFont) -{ - - sal_uInt16 nWidth = rSize.Width(); - sal_uInt16 nHeight = rSize.Height(); - - if( rFont.GetTopBorder() ) - nHeight += rFont.GetTopBorderSpace(); - if( rFont.GetBottomBorder() ) - nHeight += rFont.GetBottomBorderSpace(); - if( rFont.GetRightBorder() ) - nWidth += rFont.GetRightBorderSpace(); - if( rFont.GetLeftBorder() ) - nWidth += rFont.GetLeftBorderSpace(); - - rSize.Height(nHeight); - rSize.Width(nWidth); -} - SwPosSize SwTxtSizeInfo::GetTxtSize( OutputDevice* pOutDev, const SwScriptInfo* pSI, const XubString& rTxt, @@ -418,9 +372,7 @@ SwPosSize SwTxtSizeInfo::GetTxtSize( OutputDevice* pOutDev, aDrawInf.SetFont( m_pFnt ); aDrawInf.SetSnapToGrid( SnapToGrid() ); aDrawInf.SetKanaComp( nComp ); - SwPosSize aSize = m_pFnt->_GetTxtSize( aDrawInf ); - lcl_IncreaseSizeWithBorders(aSize,*m_pFnt); - return aSize; + return m_pFnt->_GetTxtSize( aDrawInf ); } SwPosSize SwTxtSizeInfo::GetTxtSize() const @@ -441,9 +393,7 @@ SwPosSize SwTxtSizeInfo::GetTxtSize() const aDrawInf.SetFont( m_pFnt ); aDrawInf.SetSnapToGrid( SnapToGrid() ); aDrawInf.SetKanaComp( nComp ); - SwPosSize aSize = m_pFnt->_GetTxtSize( aDrawInf ); - lcl_IncreaseSizeWithBorders(aSize,*m_pFnt); - return aSize; + return m_pFnt->_GetTxtSize( aDrawInf ); } void SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIndex, @@ -456,7 +406,6 @@ void SwTxtSizeInfo::GetTxtSize( const SwScriptInfo* pSI, const xub_StrLen nIndex aDrawInf.SetSnapToGrid( SnapToGrid() ); aDrawInf.SetKanaComp( nComp ); SwPosSize aSize = m_pFnt->_GetTxtSize( aDrawInf ); - lcl_IncreaseSizeWithBorders(aSize,*m_pFnt); nMaxSizeDiff = (sal_uInt16)aDrawInf.GetKanaDiff(); nMinSize = aSize.Width(); } @@ -689,8 +638,7 @@ void SwTxtPaintInfo::_DrawText( const XubString &rText, const SwLinePortion &rPo // Draw text next to the left border Point aFontPos(aPos); - if( m_pFnt->GetLeftBorder() && rPor.InTxtGrp() && - !static_cast<const SwTxtPortion&>(rPor).GetJoinBorderWithPrev() ) + if( !static_cast<const SwTxtPortion&>(rPor).GetJoinBorderWithPrev() ) { const sal_uInt16 nLeftBorderSpace = m_pFnt->GetLeftBorderSpace(); switch( m_pFnt->GetOrientation(GetTxtFrm()->IsVertical()) ) @@ -1222,13 +1170,15 @@ void SwTxtPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const } } -void SwTxtPaintInfo::DrawBorder( const SwLinePortion &rPor ) const +void SwTxtPaintInfo::DrawBorder( const SwTxtPortion &rPor ) const { SwRect aDrawArea; CalcRect( rPor, &aDrawArea ); if ( aDrawArea.HasArea() ) { - PaintCharacterBorder(*m_pFnt, aDrawArea, GetTxtFrm()->IsVertical()); + PaintCharacterBorder( + *m_pFnt, aDrawArea, GetTxtFrm()->IsVertical(), + rPor.GetJoinBorderWithPrev(), rPor.GetJoinBorderWithNext()); } } diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 3ad44b31b01f..d682c8bf9ac1 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -440,7 +440,7 @@ public: void DrawViewOpt( const SwLinePortion &rPor, const MSHORT nWhich ) const; void DrawBackBrush( const SwLinePortion &rPor ) const; - void DrawBorder( const SwLinePortion &rPor ) const; + void DrawBorder( const SwTxtPortion &rPor ) const; void DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const; @@ -778,6 +778,20 @@ public: /************************************************************************* * Inline implementations of SwTxtSizeInfo *************************************************************************/ +inline KSHORT SwTxtSizeInfo::GetAscent() const +{ + SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetAscent() without m_pOut" ); + + return ((SwFont*)GetFont())->GetAscent( m_pVsh, *GetOut() ); +} + +inline KSHORT SwTxtSizeInfo::GetTxtHeight() const +{ + SAL_WARN_IF( !GetOut(), "sw.core", "SwTxtSizeInfo::GetTxtHeight() without m_pOut" ); + + return ((SwFont*)GetFont())->GetHeight( m_pVsh, *GetOut() ); +} + inline SwPosSize SwTxtSizeInfo::GetTxtSize( const XubString &rTxt ) const { return GetTxtSize( m_pOut, 0, rTxt, 0, rTxt.Len(), 0 ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 0c3f62f8a14a..8b1aba857ea3 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, { pCurrPart = pCurrPart->GetFollow(); } - if( pCurrPart && nSumLength != nOfst - aInf.GetIdx() && pCurrPart->GetFont().GetRightBorder() ) + if( pCurrPart && nSumLength != nOfst - aInf.GetIdx() && !pCurrPart->GetJoinBorderWithNext() ) { nX -= pCurrPart->GetFont().GetRightBorderSpace(); } } - else if( GetInfo().GetFont()->GetRightBorder() && pPor->InTxtGrp() && + else if( pPor->InTxtGrp() && !static_cast<const SwTxtPortion*>(pPor)->GetJoinBorderWithNext()) { nX -= GetInfo().GetFont()->GetRightBorderSpace(); @@ -1651,11 +1651,11 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, while( pCurrPart && nSumWidth <= nX - nCurrStart ) { nSumWidth += pCurrPart->GetWidth(); - if( pCurrPart->GetFont().GetLeftBorder() ) + if( !pCurrPart->GetJoinBorderWithPrev() ) { nSumBorderWidth += pCurrPart->GetFont().GetLeftBorderSpace(); } - if( nSumWidth <= nX - nCurrStart && pCurrPart->GetFont().GetRightBorder() ) + if( nSumWidth <= nX - nCurrStart && !pCurrPart->GetJoinBorderWithNext() ) { nSumBorderWidth += pCurrPart->GetFont().GetRightBorderSpace(); } @@ -1664,8 +1664,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint, nX = std::max(0, nX - nSumBorderWidth); } // Shift the offset with the left border width - else if ( GetInfo().GetFont()->GetLeftBorder() && - !static_cast<const SwTxtPortion*>(pPor)->GetJoinBorderWithPrev() ) + else if( !static_cast<const SwTxtPortion*>(pPor)->GetJoinBorderWithPrev() ) { nX = std::max(0, nX - GetInfo().GetFont()->GetLeftBorderSpace()); } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index c7442e6db793..97929cd45c9d 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -765,6 +765,7 @@ void SwTxtFormatter::CalcAdjustLine( SwLineLayout *pCurrent ) void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) { + bool bCalc = false; if ( pPor->InFldGrp() && ((SwFldPortion*)pPor)->GetFont() ) { // Numbering + InterNetFlds can keep an own font, then their size is @@ -773,6 +774,7 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) SwFontSave aSave( rInf, pFldFnt ); pPor->Height( rInf.GetTxtHeight() ); pPor->SetAscent( rInf.GetAscent() ); + bCalc = true; } // #i89179# // tab portion representing the list tab of a list label gets the @@ -825,6 +827,7 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) { pPor->SetAscent( rInf.GetAscent() ); pPor->Height( rInf.GetTxtHeight() ); + bCalc = true; } else { @@ -832,6 +835,15 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) pPor->SetAscent( pLast->GetAscent() ); } } + + if( pPor->InTxtGrp() && bCalc ) + { + pPor->SetAscent(pPor->GetAscent() + + rInf.GetFont()->GetTopBorderSpace()); + pPor->Height(pPor->Height() + + rInf.GetFont()->GetTopBorderSpace() + + rInf.GetFont()->GetBottomBorderSpace() ); + } } /************************************************************************* @@ -2606,24 +2618,13 @@ void SwTxtFormatter::MergeCharacterBorder( SwDropPortion& rPortion ) if( rPortion.GetLines() > 1 ) { SwDropPortionPart* pCurrPart = rPortion.GetPart(); - bool bJoinWithPrev = false; while( pCurrPart ) { - const bool bJoinWithNext = - pCurrPart->GetFollow() && - ::lcl_HasSameBorder(pCurrPart->GetFont(), pCurrPart->GetFollow()->GetFont()); - - if( bJoinWithPrev ) - pCurrPart->GetFont().SetLeftBorder(0); - - if( bJoinWithNext ) - { - pCurrPart->GetFont().SetRightBorder(0); - bJoinWithPrev = true; - } - else + if( pCurrPart->GetFollow() && + ::lcl_HasSameBorder(pCurrPart->GetFont(), pCurrPart->GetFollow()->GetFont()) ) { - bJoinWithPrev = false; + pCurrPart->SetJoinBorderWithNext(true); + pCurrPart->GetFollow()->SetJoinBorderWithPrev(true); } pCurrPart = pCurrPart->GetFollow(); } diff --git a/sw/source/core/text/pordrop.hxx b/sw/source/core/text/pordrop.hxx index 96c8d98853b7..a462e6bfe839 100644 --- a/sw/source/core/text/pordrop.hxx +++ b/sw/source/core/text/pordrop.hxx @@ -42,10 +42,12 @@ class SwDropPortionPart SwFont* pFnt; xub_StrLen nLen; sal_uInt16 nWidth; + bool m_bJoinBorderWithNext; + bool m_bJoinBorderWithPrev; public: SwDropPortionPart( SwFont& rFont, const xub_StrLen nL ) - : pFollow( 0 ), pFnt( &rFont ), nLen( nL ), nWidth( 0 ) {}; + : pFollow( 0 ), pFnt( &rFont ), nLen( nL ), nWidth( 0 ), m_bJoinBorderWithNext(false), m_bJoinBorderWithPrev(false) {}; ~SwDropPortionPart(); inline SwDropPortionPart* GetFollow() const { return pFollow; }; @@ -54,6 +56,11 @@ public: inline xub_StrLen GetLen() const { return nLen; } inline sal_uInt16 GetWidth() const { return nWidth; } inline void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; } + + bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; } + bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; } + void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; } + void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; } }; /************************************************************************* diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 80fb84d267fa..09f75bd5dc5e 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -348,10 +348,11 @@ sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf ) // the height depending on the fields font is set, // this is required for SwTxtGuess::Guess - Height( rInf.GetTxtHeight() ); + Height( rInf.GetTxtHeight() + rInf.GetFont()->GetTopBorderSpace() + + rInf.GetFont()->GetBottomBorderSpace() ); // If a kerning portion is inserted after our field portion, // the ascent and height must be known - SetAscent( rInf.GetAscent() ); + SetAscent( rInf.GetAscent() + rInf.GetFont()->GetTopBorderSpace() ); bFull = SwTxtPortion::Format( rInf ); rInf.SetNotEOL( false ); rInf.SetLineStart( nOldLineStart ); diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index c04c60bcebf1..d41649b3ff50 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -543,16 +543,15 @@ xub_StrLen SwTxtPortion::GetCrsrOfst( const KSHORT nOfst ) const SwPosSize SwTxtPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const { - const SwFont aOldFont = *rInf.GetFont(); - if( m_bJoinBorderWithPrev ) - const_cast<SwTxtSizeInfo&>(rInf).GetFont()->SetLeftBorder(0); - if( m_bJoinBorderWithNext ) - const_cast<SwTxtSizeInfo&>(rInf).GetFont()->SetRightBorder(0); + SwPosSize aSize = rInf.GetTxtSize(); + if( !m_bJoinBorderWithPrev ) + aSize.Width(aSize.Width() + rInf.GetFont()->GetLeftBorderSpace() ); + if( !m_bJoinBorderWithNext ) + aSize.Width(aSize.Width() + rInf.GetFont()->GetRightBorderSpace() ); - const SwPosSize aSize = rInf.GetTxtSize(); - - if( m_bJoinBorderWithPrev || m_bJoinBorderWithNext ) - *const_cast<SwTxtSizeInfo&>(rInf).GetFont() = aOldFont; + aSize.Height(aSize.Height() + + rInf.GetFont()->GetTopBorderSpace() + + rInf.GetFont()->GetBottomBorderSpace() ); return aSize; } @@ -562,12 +561,6 @@ SwPosSize SwTxtPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const *************************************************************************/ void SwTxtPortion::Paint( const SwTxtPaintInfo &rInf ) const { - const SwFont aOldFont = *rInf.GetFont(); - if( m_bJoinBorderWithPrev ) - const_cast<SwTxtPaintInfo&>(rInf).GetFont()->SetLeftBorder(0); - if( m_bJoinBorderWithNext ) - const_cast<SwTxtPaintInfo&>(rInf).GetFont()->SetRightBorder(0); - if (rInf.OnWin() && 1==rInf.GetLen() && CH_TXT_ATR_FIELDEND==rInf.GetTxt()[rInf.GetIdx()]) { rInf.DrawBackBrush( *this ); @@ -603,9 +596,6 @@ void SwTxtPortion::Paint( const SwTxtPaintInfo &rInf ) const else rInf.DrawText( *this, rInf.GetLen(), sal_False ); } - - if( m_bJoinBorderWithPrev || m_bJoinBorderWithNext ) - *const_cast<SwTxtPaintInfo&>(rInf).GetFont() = aOldFont; } /************************************************************************* diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index db5e3ca4088c..7bc63b013c09 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -294,6 +294,8 @@ void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const ((SwDropPortion*)this)->Width( pCurrPart->GetWidth() ); ((SwTxtPaintInfo&)rInf).SetLen( pCurrPart->GetLen() ); SwFontSave aFontSave( rInf, &pCurrPart->GetFont() ); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(pCurrPart->GetJoinBorderWithNext()); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(pCurrPart->GetJoinBorderWithPrev()); if ( rInf.OnWin() && !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() && @@ -313,6 +315,8 @@ void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const ((SwDropPortion*)this)->Width( nOldWidth ); ((SwDropPortion*)this)->SetLen( nOldLen ); ((SwDropPortion*)this)->SetAscent( nOldAscent ); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(false); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(false); } /************************************************************************* @@ -444,6 +448,12 @@ SwPosSize SwDropPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const ((SwTxtSizeInfo&)rInf).SetIdx( nIdx ); ((SwTxtSizeInfo&)rInf).SetLen( rInf.GetLen() - nIdx ); + if( pCurrPart ) + { + const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(pCurrPart->GetJoinBorderWithNext()); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(pCurrPart->GetJoinBorderWithPrev()); + } + // robust SwFontSave aFontSave( rInf, pCurrPart ? &pCurrPart->GetFont() : 0 ); SwPosSize aPosSize( SwTxtPortion::GetTxtSize( rInf ) ); @@ -451,6 +461,11 @@ SwPosSize SwDropPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const ((SwTxtSizeInfo&)rInf).SetIdx( nOldIdx ); ((SwTxtSizeInfo&)rInf).SetLen( nOldLen ); + if( pCurrPart ) + { + const_cast<SwDropPortion*>(this)->SetJoinBorderWithNext(false); + const_cast<SwDropPortion*>(this)->SetJoinBorderWithPrev(false); + } return aPosSize; } @@ -1038,6 +1053,8 @@ sal_Bool SwDropPortion::Format( SwTxtFormatInfo &rInf ) SwFont& rFnt = pCurrPart->GetFont(); { SwFontSave aFontSave( rInf, &rFnt ); + SetJoinBorderWithNext(pCurrPart->GetJoinBorderWithNext()); + SetJoinBorderWithPrev(pCurrPart->GetJoinBorderWithPrev()); bFull = FormatTxt( rInf ); if ( bFull ) @@ -1057,7 +1074,8 @@ sal_Bool SwDropPortion::Format( SwTxtFormatInfo &rInf ) rInf.X( rInf.X() + nTmpWidth ); pCurrPart = pCurrPart->GetFollow(); } - + SetJoinBorderWithNext(false); + SetJoinBorderWithPrev(false); Width( (sal_uInt16)(rInf.X() - nOldX) ); } diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 7ba828363028..4c2f970e934f 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -129,7 +129,8 @@ 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 +const boost::optional<editeng::SvxBorderLine>& +SwFont::GetAbsTopBorder( const bool bVertLayout ) const { switch( GetOrientation( bVertLayout ) ) { @@ -152,7 +153,8 @@ const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsTopBorder( const bo } } -const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsBottomBorder( const bool bVertLayout ) const +const boost::optional<editeng::SvxBorderLine>& +SwFont::GetAbsBottomBorder( const bool bVertLayout ) const { switch( GetOrientation( bVertLayout ) ) { @@ -175,7 +177,8 @@ const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsBottomBorder( const } } -const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsLeftBorder( const bool bVertLayout ) const +const boost::optional<editeng::SvxBorderLine>& +SwFont::GetAbsLeftBorder( const bool bVertLayout ) const { switch( GetOrientation( bVertLayout ) ) { @@ -198,7 +201,8 @@ const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsLeftBorder( const b } } -const boost::optional<editeng::SvxBorderLine>& SwFont::GetAbsRightBorder( const bool bVertLayout ) const +const boost::optional<editeng::SvxBorderLine>& +SwFont::GetAbsRightBorder( const bool bVertLayout ) const { switch( GetOrientation( bVertLayout ) ) { |