From 58e4ff203e8f2703ab9433a3f49861ab306c8e4b Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Thu, 29 Aug 2013 08:27:54 +0200 Subject: Paint character border for tabulator It seems tab portion is not a text portion so we have to move text portion join members to line portion. Avoid painting border for tabulator after numbering portion. Change-Id: Ic773dd14a8e90fd68980c5a0220c6ac14da0a693 --- sw/source/core/text/inftxt.cxx | 2 +- sw/source/core/text/inftxt.hxx | 2 +- sw/source/core/text/itrcrsr.cxx | 5 ++--- sw/source/core/text/itrform2.cxx | 22 +++++++++++----------- sw/source/core/text/itrform2.hxx | 10 +++++----- sw/source/core/text/porlin.cxx | 4 +++- sw/source/core/text/porlin.hxx | 13 ++++++++++++- sw/source/core/text/portxt.cxx | 10 ++-------- sw/source/core/text/portxt.hxx | 11 +---------- sw/source/core/text/txttab.cxx | 4 ++++ 10 files changed, 42 insertions(+), 41 deletions(-) (limited to 'sw') diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 75085e18ee81..ece87be69bd0 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1185,7 +1185,7 @@ void SwTxtPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const } } -void SwTxtPaintInfo::DrawBorder( const SwTxtPortion &rPor ) const +void SwTxtPaintInfo::DrawBorder( const SwLinePortion &rPor ) const { SwRect aDrawArea; CalcRect( rPor, &aDrawArea ); diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 544f56fff33b..1396c7a52ab0 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 SwTxtPortion &rPor ) const; + void DrawBorder( const SwLinePortion &rPor ) const; void DrawCheckBox( const SwFieldFormPortion &rPor, bool checked) const; diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 8b1aba857ea3..e524c5eb491a 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -945,8 +945,7 @@ void SwTxtCursor::_GetCharRect( SwRect* pOrig, const xub_StrLen nOfst, nX -= pCurrPart->GetFont().GetRightBorderSpace(); } } - else if( pPor->InTxtGrp() && - !static_cast(pPor)->GetJoinBorderWithNext()) + else if( !pPor->GetJoinBorderWithNext()) { nX -= GetInfo().GetFont()->GetRightBorderSpace(); } @@ -1664,7 +1663,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( !static_cast(pPor)->GetJoinBorderWithPrev() ) + else if( !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 ef2cbc5d56e6..6408d5d828d6 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -707,8 +707,8 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf ) rInf.SetFull( bFull ); - if( pPor->InTxtGrp() && !pPor->IsDropPortion() ) - MergeCharacterBorder(*static_cast(pPor), rInf); + if( !pPor->IsDropPortion() ) + MergeCharacterBorder(*pPor, rInf); // Restportions from fields with multiple lines don't yet have the right ascent if ( !pPor->GetLen() && !pPor->IsFlyPortion() @@ -2631,20 +2631,19 @@ void SwTxtFormatter::MergeCharacterBorder( SwDropPortion& rPortion ) } } -void SwTxtFormatter::MergeCharacterBorder( SwTxtPortion& rPortion, SwTxtFormatInfo& rInf ) +void SwTxtFormatter::MergeCharacterBorder( SwLinePortion& rPortion, SwTxtFormatInfo& 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()->InTxtGrp() && - rInf.GetLast() != &rPortion && // For para portion (special case) - static_cast(rInf.GetLast())->GetJoinBorderWithNext()) + if( rInf.GetLast() && rInf.GetLast() != &rPortion && // For para portion (special case) + rInf.GetLast()->GetJoinBorderWithNext()) { rPortion.SetJoinBorderWithPrev(true); - rPortion.Width(rPortion.Width() - aCurFont.GetLeftBorderSpace()); + if( rPortion.InTxtGrp() && rPortion.Width() > aCurFont.GetLeftBorderSpace() ) + rPortion.Width(rPortion.Width() - aCurFont.GetLeftBorderSpace()); } else { @@ -2655,14 +2654,15 @@ void SwTxtFormatter::MergeCharacterBorder( SwTxtPortion& rPortion, SwTxtFormatIn // Get next portion's font bool bSeek = false; if( !rInf.IsFull() // Last portion of the line (in case of line break) - && rInf.GetIdx() + rInf.GetLen() != rInf.GetTxt().getLength() ) // Last portion of the paragraph - bSeek = Seek(rInf.GetIdx() + rInf.GetLen()); + && rInf.GetIdx() + rPortion.GetLen() != rInf.GetTxt().getLength() ) // Last portion of the paragraph + bSeek = Seek(rInf.GetIdx() + rPortion.GetLen()); // If next portion has the same font then merge if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, *GetFnt()) ) { rPortion.SetJoinBorderWithNext(true); - rPortion.Width(rPortion.Width() - aCurFont.GetRightBorderSpace()); + if( rPortion.InTxtGrp() && rPortion.Width() > aCurFont.GetRightBorderSpace() ) + rPortion.Width(rPortion.Width() - aCurFont.GetRightBorderSpace()); } // If this is the last portion of the merge group than make the real height merge else diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx index 786276bc032b..d4633173c9dc 100644 --- a/sw/source/core/text/itrform2.hxx +++ b/sw/source/core/text/itrform2.hxx @@ -46,7 +46,7 @@ class SwTxtFormatter : public SwTxtPainter sal_Bool bTruncLines : 1; // Flag for extending the repaint rect, if needed sal_Bool bUnclipped : 1; // Flag whether repaint is larger than the fixed line height sal_uInt16 m_nHintEndIndex; // HACK for TryNewNoLengthPortion - SwTxtPortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion bulding) + SwLinePortion* m_pFirstOfBorderMerge; // The first text portion of a joined border (during portion bulding) SwLinePortion *NewPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *NewTxtPortion( SwTxtFormatInfo &rInf ); @@ -231,14 +231,14 @@ public: void MergeCharacterBorder( SwDropPortion& rPortion ); /** - * Merge border of the text portion with setting the text portions + * Merge border of the line portion with setting the portion's * m_bJoinBorderWidthNext and m_bJoinBorderWidthPrev members and - * changing the size (width, height and ascent) of the text portion + * changing the size (width, height and ascent) of the portion * to get a merged border. - * @param rPortion text portion for merge + * @param rPortion portion for merge * @param rInf contain information **/ - void MergeCharacterBorder( SwTxtPortion& rPortion, SwTxtFormatInfo& rInf ); + void MergeCharacterBorder( SwLinePortion& rPortion, SwTxtFormatInfo& rInf ); }; diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 586f03763084..adbc4ac88715 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -76,7 +76,9 @@ KSHORT SwLinePortion::GetViewWidth( const SwTxtSizeInfo & ) const SwLinePortion::SwLinePortion( ) : pPortion( NULL ), nLineLength( 0 ), - nAscent( 0 ) + nAscent( 0 ), + m_bJoinBorderWithPrev(false), + m_bJoinBorderWithNext(false) { } diff --git a/sw/source/core/text/porlin.hxx b/sw/source/core/text/porlin.hxx index 68b93d76a5ac..fb8065c7a6eb 100644 --- a/sw/source/core/text/porlin.hxx +++ b/sw/source/core/text/porlin.hxx @@ -72,6 +72,8 @@ protected: SwLinePortion(); private: MSHORT nWhichPor; // Who's who? + bool m_bJoinBorderWithPrev; + bool m_bJoinBorderWithNext; void _Truncate(); @@ -186,6 +188,11 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const; + 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; } + OUTPUT_OPERATOR }; @@ -200,6 +207,8 @@ inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion) nLineLength = rPortion.nLineLength; nAscent = rPortion.nAscent; nWhichPor = rPortion.nWhichPor; + m_bJoinBorderWithPrev = rPortion.m_bJoinBorderWithPrev; + m_bJoinBorderWithNext = rPortion.m_bJoinBorderWithNext; return *this; } @@ -216,7 +225,9 @@ inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) : pPortion( 0 ), nLineLength( rPortion.nLineLength ), nAscent( rPortion.nAscent ), - nWhichPor( rPortion.nWhichPor ) + nWhichPor( rPortion.nWhichPor ), + m_bJoinBorderWithPrev( rPortion.m_bJoinBorderWithPrev ), + m_bJoinBorderWithNext( rPortion.m_bJoinBorderWithNext ) { } diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index d41649b3ff50..31c93f1ec5ab 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -219,12 +219,6 @@ SwTxtPortion::SwTxtPortion( const SwLinePortion &rPortion ) : SwLinePortion( rPortion ) { SetWhichPor( POR_TXT ); - if( rPortion.InTxtGrp() ) - { - const SwTxtPortion& rPor = static_cast(rPortion); - m_bJoinBorderWithPrev = rPor.m_bJoinBorderWithPrev; - m_bJoinBorderWithNext = rPor.m_bJoinBorderWithNext; - } } /************************************************************************* @@ -544,9 +538,9 @@ xub_StrLen SwTxtPortion::GetCrsrOfst( const KSHORT nOfst ) const SwPosSize SwTxtPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const { SwPosSize aSize = rInf.GetTxtSize(); - if( !m_bJoinBorderWithPrev ) + if( !GetJoinBorderWithPrev() ) aSize.Width(aSize.Width() + rInf.GetFont()->GetLeftBorderSpace() ); - if( !m_bJoinBorderWithNext ) + if( !GetJoinBorderWithNext() ) aSize.Width(aSize.Width() + rInf.GetFont()->GetRightBorderSpace() ); aSize.Height(aSize.Height() + diff --git a/sw/source/core/text/portxt.hxx b/sw/source/core/text/portxt.hxx index 4c029a3db8e8..d201c747ccbb 100644 --- a/sw/source/core/text/portxt.hxx +++ b/sw/source/core/text/portxt.hxx @@ -36,11 +36,8 @@ class SwTxtPortion : public SwLinePortion void BreakUnderflow( SwTxtFormatInfo &rInf ); sal_Bool _Format( SwTxtFormatInfo &rInf ); - bool m_bJoinBorderWithPrev; - bool m_bJoinBorderWithNext; - public: - inline SwTxtPortion(): m_bJoinBorderWithPrev(false), m_bJoinBorderWithNext(false) { SetWhichPor( POR_TXT ); } + inline SwTxtPortion(){ SetWhichPor( POR_TXT ); } SwTxtPortion( const SwLinePortion &rPortion ); virtual void Paint( const SwTxtPaintInfo &rInf ) const; virtual sal_Bool Format( SwTxtFormatInfo &rInf ); @@ -58,12 +55,6 @@ public: // Accessibility: pass information about this portion to the PortionHandler virtual void HandlePortion( SwPortionHandler& rPH ) const; - 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; } - OUTPUT_OPERATOR DECL_FIXEDMEMPOOL_NEWDEL(SwTxtPortion) }; diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index 363ffde2e575..bafe565e5b0b 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -575,6 +575,7 @@ void SwTabPortion::Paint( const SwTxtPaintInfo &rInf ) const SAL_WNODEPRECATED_DECLARATIONS_PUSH std::auto_ptr< SwFontSave > pSave( 0 ); SAL_WNODEPRECATED_DECLARATIONS_POP + bool bAfterNumbering = false; if ( GetLen() == 0 ) { const SwLinePortion* pPrevPortion = @@ -586,9 +587,12 @@ void SwTabPortion::Paint( const SwTxtPaintInfo &rInf ) const const SwFont* pNumberPortionFont = static_cast(pPrevPortion)->GetFont(); pSave.reset( new SwFontSave( rInf, const_cast(pNumberPortionFont) ) ); + bAfterNumbering = true; } } rInf.DrawBackBrush( *this ); + if( !bAfterNumbering ) + rInf.DrawBorder( *this ); // do we have to repaint a post it portion? if( rInf.OnWin() && pPortion && !pPortion->Width() ) -- cgit