diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 10:36:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-31 20:06:38 +0200 |
commit | fb8371400e4b2d32b3981b42c910e04f35ab166b (patch) | |
tree | 4507e27252cd96ef7b5da27e062f893cba5f0f46 /sw | |
parent | 6e717f4552aa937cd2609a79199a5b40b38789a4 (diff) |
loplugin:flatten in sw/core/text
Change-Id: I086860cefe9f26c3728fe0d8266c35dae37b9570
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99887
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/EnhancedPDFExportHelper.cxx | 51 | ||||
-rw-r--r-- | sw/source/core/text/frmform.cxx | 110 | ||||
-rw-r--r-- | sw/source/core/text/frmpaint.cxx | 30 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 594 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 160 | ||||
-rw-r--r-- | sw/source/core/text/porexp.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/text/porfld.cxx | 232 | ||||
-rw-r--r-- | sw/source/core/text/porfly.cxx | 80 | ||||
-rw-r--r-- | sw/source/core/text/porglue.cxx | 48 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 74 | ||||
-rw-r--r-- | sw/source/core/text/pormulti.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/text/porrst.cxx | 136 | ||||
-rw-r--r-- | sw/source/core/text/redlnitr.cxx | 72 | ||||
-rw-r--r-- | sw/source/core/text/txtdrop.cxx | 36 | ||||
-rw-r--r-- | sw/source/core/text/txtfld.cxx | 84 | ||||
-rw-r--r-- | sw/source/core/text/txtfrm.cxx | 284 | ||||
-rw-r--r-- | sw/source/core/text/txthyph.cxx | 42 | ||||
-rw-r--r-- | sw/source/core/text/txtpaint.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/text/txttab.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/text/widorp.cxx | 60 | ||||
-rw-r--r-- | sw/source/core/tox/txmsrt.cxx | 68 |
21 files changed, 1131 insertions, 1132 deletions
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index b54877aedef6..1fc61a93e765 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -295,46 +295,45 @@ SwTaggedPDFHelper::SwTaggedPDFHelper( const Num_Info* pNumInfo, mpPDFExtOutDevData = dynamic_cast< vcl::PDFExtOutDevData*>( rOut.GetExtOutDevData() ); - if ( mpPDFExtOutDevData && mpPDFExtOutDevData->GetIsExportTaggedPDF() ) - { + if ( !(mpPDFExtOutDevData && mpPDFExtOutDevData->GetIsExportTaggedPDF()) ) + return; + #if OSL_DEBUG_LEVEL > 1 - sal_Int32 nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); - lcl_DBGCheckStack(); + sal_Int32 nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); + lcl_DBGCheckStack(); #endif - if ( mpNumInfo ) - BeginNumberedListStructureElements(); - else if ( mpFrameInfo ) - BeginBlockStructureElements(); - else if ( mpPorInfo ) - BeginInlineStructureElements(); - else - BeginTag( vcl::PDFWriter::NonStructElement, OUString() ); + if ( mpNumInfo ) + BeginNumberedListStructureElements(); + else if ( mpFrameInfo ) + BeginBlockStructureElements(); + else if ( mpPorInfo ) + BeginInlineStructureElements(); + else + BeginTag( vcl::PDFWriter::NonStructElement, OUString() ); #if OSL_DEBUG_LEVEL > 1 - nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); - lcl_DBGCheckStack(); - (void)nCurrentStruct; + nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); + lcl_DBGCheckStack(); + (void)nCurrentStruct; #endif - } } SwTaggedPDFHelper::~SwTaggedPDFHelper() { - if ( mpPDFExtOutDevData && mpPDFExtOutDevData->GetIsExportTaggedPDF() ) - { + if ( !(mpPDFExtOutDevData && mpPDFExtOutDevData->GetIsExportTaggedPDF()) ) + return; + #if OSL_DEBUG_LEVEL > 1 - sal_Int32 nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); - lcl_DBGCheckStack(); + sal_Int32 nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); + lcl_DBGCheckStack(); #endif - EndStructureElements(); + EndStructureElements(); #if OSL_DEBUG_LEVEL > 1 - nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); - lcl_DBGCheckStack(); - (void)nCurrentStruct; + nCurrentStruct = mpPDFExtOutDevData->GetCurrentStructureElement(); + lcl_DBGCheckStack(); + (void)nCurrentStruct; #endif - - } } bool SwTaggedPDFHelper::CheckReopenTag() diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index 71e417c3ad54..8513f33b078c 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -116,20 +116,20 @@ void SwTextFrame::ValidateFrame() static void ValidateBodyFrame_( SwFrame *pFrame ) { vcl::RenderContext* pRenderContext = pFrame ? pFrame->getRootFrame()->GetCurrShell()->GetOut() : nullptr; - if( pFrame && !pFrame->IsCellFrame() ) + if( !(pFrame && !pFrame->IsCellFrame()) ) + return; + + if( !pFrame->IsBodyFrame() && pFrame->GetUpper() ) + ValidateBodyFrame_( pFrame->GetUpper() ); + if( !pFrame->IsSctFrame() ) + pFrame->Calc(pRenderContext); + else { - if( !pFrame->IsBodyFrame() && pFrame->GetUpper() ) - ValidateBodyFrame_( pFrame->GetUpper() ); - if( !pFrame->IsSctFrame() ) - pFrame->Calc(pRenderContext); - else - { - const bool bOld = static_cast<SwSectionFrame*>(pFrame)->IsContentLocked(); - static_cast<SwSectionFrame*>(pFrame)->SetContentLock( true ); - pFrame->Calc(pRenderContext); - if( !bOld ) - static_cast<SwSectionFrame*>(pFrame)->SetContentLock( false ); - } + const bool bOld = static_cast<SwSectionFrame*>(pFrame)->IsContentLocked(); + static_cast<SwSectionFrame*>(pFrame)->SetContentLock( true ); + pFrame->Calc(pRenderContext); + if( !bOld ) + static_cast<SwSectionFrame*>(pFrame)->SetContentLock( false ); } } @@ -338,22 +338,22 @@ void SwTextFrame::MakePos() { SwFrame::MakePos(); // Inform LOK clients about change in position of redlines (if any) - if(comphelper::LibreOfficeKit::isActive()) + if(!comphelper::LibreOfficeKit::isActive()) + return; + + SwTextNode const* pTextNode = GetTextNodeFirst(); + const SwRedlineTable& rTable = pTextNode->getIDocumentRedlineAccess().GetRedlineTable(); + for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos) { - SwTextNode const* pTextNode = GetTextNodeFirst(); - const SwRedlineTable& rTable = pTextNode->getIDocumentRedlineAccess().GetRedlineTable(); - for (SwRedlineTable::size_type nRedlnPos = 0; nRedlnPos < rTable.size(); ++nRedlnPos) + SwRangeRedline* pRedln = rTable[nRedlnPos]; + if (pTextNode->GetIndex() == pRedln->GetPoint()->nNode.GetNode().GetIndex()) { - SwRangeRedline* pRedln = rTable[nRedlnPos]; - if (pTextNode->GetIndex() == pRedln->GetPoint()->nNode.GetNode().GetIndex()) + pRedln->MaybeNotifyRedlinePositionModification(getFrameArea().Top()); + if (GetMergedPara() + && pRedln->GetType() == RedlineType::Delete + && pRedln->GetPoint()->nNode != pRedln->GetMark()->nNode) { - pRedln->MaybeNotifyRedlinePositionModification(getFrameArea().Top()); - if (GetMergedPara() - && pRedln->GetType() == RedlineType::Delete - && pRedln->GetPoint()->nNode != pRedln->GetMark()->nNode) - { - pTextNode = pRedln->End()->nNode.GetNode().GetTextNode(); - } + pTextNode = pRedln->End()->nNode.GetNode().GetTextNode(); } } } @@ -1603,24 +1603,24 @@ void SwTextFrame::Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf, } } - if( !rInf.IsTest() ) + if( rInf.IsTest() ) + return; + + // FormatAdjust does not pay off at OnceMore + if( bAdjust || !rLine.GetDropFormat() || !rLine.CalcOnceMore() ) { - // FormatAdjust does not pay off at OnceMore - if( bAdjust || !rLine.GetDropFormat() || !rLine.CalcOnceMore() ) - { - FormatAdjust( rLine, aFrameBreak, nStrLen, rInf.IsStop() ); - } - if( rRepaint.HasArea() ) - SetRepaint(); - rLine.SetTruncLines( false ); - if( nOldBottom ) // We check whether paragraphs that need scrolling can - // be shrunk, so that they don't need scrolling anymore - { - rLine.Bottom(); - SwTwips nNewBottom = rLine.Y(); - if( nNewBottom < nOldBottom ) - SetOffset_(TextFrameIndex(0)); - } + FormatAdjust( rLine, aFrameBreak, nStrLen, rInf.IsStop() ); + } + if( rRepaint.HasArea() ) + SetRepaint(); + rLine.SetTruncLines( false ); + if( nOldBottom ) // We check whether paragraphs that need scrolling can + // be shrunk, so that they don't need scrolling anymore + { + rLine.Bottom(); + SwTwips nNewBottom = rLine.Y(); + if( nNewBottom < nOldBottom ) + SetOffset_(TextFrameIndex(0)); } } @@ -1726,20 +1726,20 @@ void SwTextFrame::Format_( vcl::RenderContext* pRenderContext, SwParaPortion *pP OSL_ENSURE( ! IsSwapped(), "A frame is swapped after Format_" ); - if( 1 < aLine.GetDropLines() ) + if( 1 >= aLine.GetDropLines() ) + return; + + if( SvxAdjust::Left != aLine.GetAdjust() && + SvxAdjust::Block != aLine.GetAdjust() ) { - if( SvxAdjust::Left != aLine.GetAdjust() && - SvxAdjust::Block != aLine.GetAdjust() ) - { - aLine.CalcDropAdjust(); - aLine.SetPaintDrop( true ); - } + aLine.CalcDropAdjust(); + aLine.SetPaintDrop( true ); + } - if( aLine.IsPaintDrop() ) - { - aLine.CalcDropRepaint(); - aLine.SetPaintDrop( false ); - } + if( aLine.IsPaintDrop() ) + { + aLine.CalcDropRepaint(); + aLine.SetPaintDrop( false ); } } diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index ea54168b379f..4704b55044e4 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -160,23 +160,23 @@ SwExtraPainter::SwExtraPainter( const SwTextFrame *pFrame, SwViewShell *pVwSh, m_nX += pFrame->getFrameArea().Width() + m_rLineInf.GetPosFromLeft(); } } - if( eHor != text::HoriOrientation::NONE ) + if( eHor == text::HoriOrientation::NONE ) + return; + + if( text::HoriOrientation::INSIDE == eHor || text::HoriOrientation::OUTSIDE == eHor ) { - if( text::HoriOrientation::INSIDE == eHor || text::HoriOrientation::OUTSIDE == eHor ) - { - if (!oIsRightPage) - oIsRightPage = pFrame->FindPageFrame()->OnRightPage(); - if (*oIsRightPage) - eHor = eHor == text::HoriOrientation::INSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT; - else - eHor = eHor == text::HoriOrientation::OUTSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT; - } - const SwFrame* pTmpFrame = pFrame->FindTabFrame(); - if( !pTmpFrame ) - pTmpFrame = pFrame; - m_nRedX = text::HoriOrientation::LEFT == eHor ? pTmpFrame->getFrameArea().Left() - REDLINE_DISTANCE : - pTmpFrame->getFrameArea().Right() + REDLINE_DISTANCE; + if (!oIsRightPage) + oIsRightPage = pFrame->FindPageFrame()->OnRightPage(); + if (*oIsRightPage) + eHor = eHor == text::HoriOrientation::INSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT; + else + eHor = eHor == text::HoriOrientation::OUTSIDE ? text::HoriOrientation::LEFT : text::HoriOrientation::RIGHT; } + const SwFrame* pTmpFrame = pFrame->FindTabFrame(); + if( !pTmpFrame ) + pTmpFrame = pFrame; + m_nRedX = text::HoriOrientation::LEFT == eHor ? pTmpFrame->getFrameArea().Left() - REDLINE_DISTANCE : + pTmpFrame->getFrameArea().Right() + REDLINE_DISTANCE; } void SwExtraPainter::PaintExtra( SwTwips nY, long nAsc, long nMax, bool bRed ) diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index a6903b9aab75..a167af3ce922 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -976,42 +976,42 @@ void SwTextPaintInfo::DrawRect( const SwRect &rRect, bool bRetouche ) const void SwTextPaintInfo::DrawTab( const SwLinePortion &rPor ) const { - if( OnWin() ) - { - SwRect aRect; - CalcRect( rPor, &aRect ); + if( !OnWin() ) + return; - if ( ! aRect.HasArea() ) - return; + SwRect aRect; + CalcRect( rPor, &aRect ); + + if ( ! aRect.HasArea() ) + return; - const sal_Unicode cChar = GetTextFrame()->IsRightToLeft() ? CHAR_TAB_RTL : CHAR_TAB; - const sal_uInt8 nOptions = DRAW_SPECIAL_OPTIONS_CENTER | DRAW_SPECIAL_OPTIONS_ROTATE; + const sal_Unicode cChar = GetTextFrame()->IsRightToLeft() ? CHAR_TAB_RTL : CHAR_TAB; + const sal_uInt8 nOptions = DRAW_SPECIAL_OPTIONS_CENTER | DRAW_SPECIAL_OPTIONS_ROTATE; - lcl_DrawSpecial( *this, rPor, aRect, NON_PRINTING_CHARACTER_COLOR, cChar, nOptions ); - } + lcl_DrawSpecial( *this, rPor, aRect, NON_PRINTING_CHARACTER_COLOR, cChar, nOptions ); } void SwTextPaintInfo::DrawLineBreak( const SwLinePortion &rPor ) const { - if( OnWin() ) - { - sal_uInt16 nOldWidth = rPor.Width(); - const_cast<SwLinePortion&>(rPor).Width( LINE_BREAK_WIDTH ); + if( !OnWin() ) + return; - SwRect aRect; - CalcRect( rPor, &aRect ); + sal_uInt16 nOldWidth = rPor.Width(); + const_cast<SwLinePortion&>(rPor).Width( LINE_BREAK_WIDTH ); - if( aRect.HasArea() ) - { - const sal_Unicode cChar = GetTextFrame()->IsRightToLeft() ? - CHAR_LINEBREAK_RTL : CHAR_LINEBREAK; - const sal_uInt8 nOptions = 0; + SwRect aRect; + CalcRect( rPor, &aRect ); - lcl_DrawSpecial( *this, rPor, aRect, NON_PRINTING_CHARACTER_COLOR, cChar, nOptions ); - } + if( aRect.HasArea() ) + { + const sal_Unicode cChar = GetTextFrame()->IsRightToLeft() ? + CHAR_LINEBREAK_RTL : CHAR_LINEBREAK; + const sal_uInt8 nOptions = 0; - const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); + lcl_DrawSpecial( *this, rPor, aRect, NON_PRINTING_CHARACTER_COLOR, cChar, nOptions ); } + + const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); } void SwTextPaintInfo::DrawRedArrow( const SwLinePortion &rPor ) const @@ -1098,31 +1098,31 @@ void SwTextPaintInfo::DrawCheckBox(const SwFieldFormCheckboxPortion &rPor, bool { SwRect aIntersect; CalcRect( rPor, &aIntersect ); - if ( aIntersect.HasArea() ) + if ( !aIntersect.HasArea() ) + return; + + if (OnWin() && SwViewOption::IsFieldShadings() && + !GetOpt().IsPagePreview()) { - if (OnWin() && SwViewOption::IsFieldShadings() && - !GetOpt().IsPagePreview()) - { - OutputDevice* pOut = const_cast<OutputDevice*>(GetOut()); - pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); - pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() ); - pOut->SetLineColor(); - pOut->DrawRect( aIntersect.SVRect() ); - pOut->Pop(); - } - const int delta=10; - tools::Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta); - m_pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); - m_pOut->SetLineColor( Color(0, 0, 0)); - m_pOut->SetFillColor(); - m_pOut->DrawRect( r ); - if (bChecked) - { - m_pOut->DrawLine(r.TopLeft(), r.BottomRight()); - m_pOut->DrawLine(r.TopRight(), r.BottomLeft()); - } - m_pOut->Pop(); + OutputDevice* pOut = const_cast<OutputDevice*>(GetOut()); + pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); + pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() ); + pOut->SetLineColor(); + pOut->DrawRect( aIntersect.SVRect() ); + pOut->Pop(); } + const int delta=10; + tools::Rectangle r(aIntersect.Left()+delta, aIntersect.Top()+delta, aIntersect.Right()-delta, aIntersect.Bottom()-delta); + m_pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); + m_pOut->SetLineColor( Color(0, 0, 0)); + m_pOut->SetFillColor(); + m_pOut->DrawRect( r ); + if (bChecked) + { + m_pOut->DrawLine(r.TopLeft(), r.BottomRight()); + m_pOut->DrawLine(r.TopRight(), r.BottomLeft()); + } + m_pOut->Pop(); } void SwTextPaintInfo::DrawBackground( const SwLinePortion &rPor ) const @@ -1132,25 +1132,25 @@ void SwTextPaintInfo::DrawBackground( const SwLinePortion &rPor ) const SwRect aIntersect; CalcRect( rPor, nullptr, &aIntersect, true ); - if ( aIntersect.HasArea() ) - { - OutputDevice* pOut = const_cast<OutputDevice*>(GetOut()); - pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); + if ( !aIntersect.HasArea() ) + return; - // For dark background we do not want to have a filled rectangle - if ( GetVsh() && GetVsh()->GetWin() && lcl_IsDarkBackground( *this ) ) - { - pOut->SetLineColor( SwViewOption::GetFontColor() ); - } - else - { - pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() ); - pOut->SetLineColor(); - } + OutputDevice* pOut = const_cast<OutputDevice*>(GetOut()); + pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); - DrawRect( aIntersect, true ); - pOut->Pop(); + // For dark background we do not want to have a filled rectangle + if ( GetVsh() && GetVsh()->GetWin() && lcl_IsDarkBackground( *this ) ) + { + pOut->SetLineColor( SwViewOption::GetFontColor() ); + } + else + { + pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() ); + pOut->SetLineColor(); } + + DrawRect( aIntersect, true ); + pOut->Pop(); } void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const @@ -1187,117 +1187,117 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const SwRect aIntersect; CalcRect( rPor, nullptr, &aIntersect, true ); - if ( aIntersect.HasArea() ) - { - OutputDevice* pTmpOut = const_cast<OutputDevice*>(GetOut()); + if ( !aIntersect.HasArea() ) + return; - // #i16816# tagged pdf support - SwTaggedPDFHelper aTaggedPDFHelper( nullptr, nullptr, nullptr, *pTmpOut ); + OutputDevice* pTmpOut = const_cast<OutputDevice*>(GetOut()); - Color aFillColor; + // #i16816# tagged pdf support + SwTaggedPDFHelper aTaggedPDFHelper( nullptr, nullptr, nullptr, *pTmpOut ); - if( m_pFnt->GetHighlightColor() != COL_TRANSPARENT ) - { - aFillColor = m_pFnt->GetHighlightColor(); - } - else - { - if( !m_pFnt->GetBackColor() ) - return; - aFillColor = *m_pFnt->GetBackColor(); - } + Color aFillColor; - // tdf#104349 do not highlight portions of space chars before end of line if the compatibility option is enabled - // for LTR mode only - if ( !GetTextFrame()->IsRightToLeft() ) + if( m_pFnt->GetHighlightColor() != COL_TRANSPARENT ) + { + aFillColor = m_pFnt->GetHighlightColor(); + } + else + { + if( !m_pFnt->GetBackColor() ) + return; + aFillColor = *m_pFnt->GetBackColor(); + } + + // tdf#104349 do not highlight portions of space chars before end of line if the compatibility option is enabled + // for LTR mode only + if ( !GetTextFrame()->IsRightToLeft() ) + { + if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS)) { - if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS)) - { - bool draw = false; - bool full = false; - SwLinePortion *pPos = const_cast<SwLinePortion *>(&rPor); - TextFrameIndex nIdx = GetIdx(); - TextFrameIndex nLen; + bool draw = false; + bool full = false; + SwLinePortion *pPos = const_cast<SwLinePortion *>(&rPor); + TextFrameIndex nIdx = GetIdx(); + TextFrameIndex nLen; - do + do + { + nLen = pPos->GetLen(); + for (TextFrameIndex i = nIdx; i < (nIdx + nLen); ++i) { - nLen = pPos->GetLen(); - for (TextFrameIndex i = nIdx; i < (nIdx + nLen); ++i) + if (i < TextFrameIndex(GetText().getLength()) + && GetText()[sal_Int32(i)] == CH_TXTATR_NEWLINE) { - if (i < TextFrameIndex(GetText().getLength()) - && GetText()[sal_Int32(i)] == CH_TXTATR_NEWLINE) + if ( i >= (GetIdx() + rPor.GetLen()) ) { - if ( i >= (GetIdx() + rPor.GetLen()) ) - { - goto drawcontinue; - } + goto drawcontinue; } - if (i >= TextFrameIndex(GetText().getLength()) - || GetText()[sal_Int32(i)] != CH_BLANK) + } + if (i >= TextFrameIndex(GetText().getLength()) + || GetText()[sal_Int32(i)] != CH_BLANK) + { + draw = true; + if ( i >= (GetIdx() + rPor.GetLen()) ) { - draw = true; - if ( i >= (GetIdx() + rPor.GetLen()) ) - { - full = true; - goto drawcontinue; - } + full = true; + goto drawcontinue; } } - nIdx += nLen; - pPos = pPos->GetNextPortion(); - } while ( pPos ); + } + nIdx += nLen; + pPos = pPos->GetNextPortion(); + } while ( pPos ); - drawcontinue: + drawcontinue: - if ( !draw ) - return; + if ( !draw ) + return; - if ( !full ) - { - pPos = const_cast<SwLinePortion *>(&rPor); - nIdx = GetIdx(); + if ( !full ) + { + pPos = const_cast<SwLinePortion *>(&rPor); + nIdx = GetIdx(); - nLen = pPos->GetLen(); - for (TextFrameIndex i = nIdx + nLen - TextFrameIndex(1); - i >= nIdx; --i) + nLen = pPos->GetLen(); + for (TextFrameIndex i = nIdx + nLen - TextFrameIndex(1); + i >= nIdx; --i) + { + if (i < TextFrameIndex(GetText().getLength()) + && GetText()[sal_Int32(i)] == CH_TXTATR_NEWLINE) { - if (i < TextFrameIndex(GetText().getLength()) - && GetText()[sal_Int32(i)] == CH_TXTATR_NEWLINE) - { - continue; - } - if (i >= TextFrameIndex(GetText().getLength()) - || GetText()[sal_Int32(i)] != CH_BLANK) - { - sal_uInt16 nOldWidth = rPor.Width(); - sal_uInt16 nNewWidth = GetTextSize(m_pOut, nullptr, - GetText(), nIdx, (i + TextFrameIndex(1) - nIdx)).Width(); - - const_cast<SwLinePortion&>(rPor).Width( nNewWidth ); - CalcRect( rPor, nullptr, &aIntersect, true ); - const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); + continue; + } + if (i >= TextFrameIndex(GetText().getLength()) + || GetText()[sal_Int32(i)] != CH_BLANK) + { + sal_uInt16 nOldWidth = rPor.Width(); + sal_uInt16 nNewWidth = GetTextSize(m_pOut, nullptr, + GetText(), nIdx, (i + TextFrameIndex(1) - nIdx)).Width(); - if ( !aIntersect.HasArea() ) - { - return; - } + const_cast<SwLinePortion&>(rPor).Width( nNewWidth ); + CalcRect( rPor, nullptr, &aIntersect, true ); + const_cast<SwLinePortion&>(rPor).Width( nOldWidth ); - break; + if ( !aIntersect.HasArea() ) + { + return; } + + break; } } } } + } - pTmpOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); + pTmpOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR ); - pTmpOut->SetFillColor(aFillColor); - pTmpOut->SetLineColor(); + pTmpOut->SetFillColor(aFillColor); + pTmpOut->SetLineColor(); - DrawRect( aIntersect, false ); + DrawRect( aIntersect, false ); - pTmpOut->Pop(); - } + pTmpOut->Pop(); } void SwTextPaintInfo::DrawBorder( const SwLinePortion &rPor ) const @@ -1315,58 +1315,58 @@ void SwTextPaintInfo::DrawBorder( const SwLinePortion &rPor ) const void SwTextPaintInfo::DrawViewOpt( const SwLinePortion &rPor, PortionType nWhich ) const { - if( OnWin() && !IsMulti() ) + if( !(OnWin() && !IsMulti()) ) + return; + + bool bDraw = false; + switch( nWhich ) { - bool bDraw = false; - switch( nWhich ) + case PortionType::Footnote: + case PortionType::QuoVadis: + case PortionType::Number: + case PortionType::Field: + case PortionType::Hidden: + case PortionType::Tox: + case PortionType::Ref: + case PortionType::Meta: + case PortionType::ControlChar: + if ( !GetOpt().IsPagePreview() + && !GetOpt().IsReadonly() + && SwViewOption::IsFieldShadings() + && ( PortionType::Number != nWhich + || m_pFrame->GetTextNodeForParaProps()->HasMarkedLabel())) // #i27615# { - case PortionType::Footnote: - case PortionType::QuoVadis: - case PortionType::Number: - case PortionType::Field: - case PortionType::Hidden: - case PortionType::Tox: - case PortionType::Ref: - case PortionType::Meta: - case PortionType::ControlChar: - if ( !GetOpt().IsPagePreview() - && !GetOpt().IsReadonly() - && SwViewOption::IsFieldShadings() - && ( PortionType::Number != nWhich - || m_pFrame->GetTextNodeForParaProps()->HasMarkedLabel())) // #i27615# - { - bDraw = PortionType::Footnote != nWhich || m_pFrame->IsFootnoteAllowed(); - } - break; - case PortionType::Bookmark: - // no shading - break; - case PortionType::InputField: - // input field shading also in read-only mode - if ( !GetOpt().IsPagePreview() - && SwViewOption::IsFieldShadings() ) - { - bDraw = true; - } - break; - case PortionType::Table: - if ( GetOpt().IsTab() ) bDraw = true; - break; - case PortionType::SoftHyphen: - if ( GetOpt().IsSoftHyph() )bDraw = true; - break; - case PortionType::Blank: - if ( GetOpt().IsHardBlank())bDraw = true; + bDraw = PortionType::Footnote != nWhich || m_pFrame->IsFootnoteAllowed(); + } + break; + case PortionType::Bookmark: + // no shading + break; + case PortionType::InputField: + // input field shading also in read-only mode + if ( !GetOpt().IsPagePreview() + && SwViewOption::IsFieldShadings() ) + { + bDraw = true; + } + break; + case PortionType::Table: + if ( GetOpt().IsTab() ) bDraw = true; + break; + case PortionType::SoftHyphen: + if ( GetOpt().IsSoftHyph() )bDraw = true; + break; + case PortionType::Blank: + if ( GetOpt().IsHardBlank())bDraw = true; + break; + default: + { + OSL_ENSURE( false, "SwTextPaintInfo::DrawViewOpt: don't know how to draw this" ); break; - default: - { - OSL_ENSURE( false, "SwTextPaintInfo::DrawViewOpt: don't know how to draw this" ); - break; - } } - if ( bDraw ) - DrawBackground( rPor ); } + if ( bDraw ) + DrawBackground( rPor ); } static void lcl_InitHyphValues( PropertyValues &rVals, @@ -1816,97 +1816,97 @@ SwTextSlot::SwTextSlot( } // The text is replaced ... - if( bOn ) + if( !bOn ) + return; + + pInf = const_cast<SwTextSizeInfo*>(pNew); + nIdx = pInf->GetIdx(); + nLen = pInf->GetLen(); + pOldText = &(pInf->GetText()); + m_pOldCachedVclData = pInf->GetCachedVclData(); + pInf->SetText( aText ); + pInf->SetIdx(TextFrameIndex(0)); + pInf->SetLen(bTextLen ? TextFrameIndex(pInf->GetText().getLength()) : pPor->GetLen()); + pInf->SetCachedVclData(nullptr); + + // ST2 + if ( !bExgLists ) + return; + + m_pOldSmartTagList = static_cast<SwTextPaintInfo*>(pInf)->GetSmartTags(); + if (m_pOldSmartTagList) { - pInf = const_cast<SwTextSizeInfo*>(pNew); - nIdx = pInf->GetIdx(); - nLen = pInf->GetLen(); - pOldText = &(pInf->GetText()); - m_pOldCachedVclData = pInf->GetCachedVclData(); - pInf->SetText( aText ); - pInf->SetIdx(TextFrameIndex(0)); - pInf->SetLen(bTextLen ? TextFrameIndex(pInf->GetText().getLength()) : pPor->GetLen()); - pInf->SetCachedVclData(nullptr); - - // ST2 - if ( bExgLists ) + std::pair<SwTextNode const*, sal_Int32> pos(pNew->GetTextFrame()->MapViewToModel(nIdx)); + SwWrongList const*const pSmartTags(pos.first->GetSmartTags()); + if (pSmartTags) { - m_pOldSmartTagList = static_cast<SwTextPaintInfo*>(pInf)->GetSmartTags(); - if (m_pOldSmartTagList) + const sal_uInt16 nPos = pSmartTags->GetWrongPos(pos.second); + const sal_Int32 nListPos = pSmartTags->Pos(nPos); + if (nListPos == pos.second && pSmartTags->SubList(nPos) != nullptr) { - std::pair<SwTextNode const*, sal_Int32> pos(pNew->GetTextFrame()->MapViewToModel(nIdx)); - SwWrongList const*const pSmartTags(pos.first->GetSmartTags()); - if (pSmartTags) - { - const sal_uInt16 nPos = pSmartTags->GetWrongPos(pos.second); - const sal_Int32 nListPos = pSmartTags->Pos(nPos); - if (nListPos == pos.second && pSmartTags->SubList(nPos) != nullptr) - { - m_pTempIter.reset(new sw::WrongListIterator(*pSmartTags->SubList(nPos))); - static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pTempIter.get()); - } - else if (!m_pTempList && nPos < pSmartTags->Count() - && nListPos < pos.second && !aText.isEmpty()) - { - m_pTempList.reset(new SwWrongList( WRONGLIST_SMARTTAG )); - m_pTempList->Insert( OUString(), nullptr, 0, aText.getLength(), 0 ); - m_pTempIter.reset(new sw::WrongListIterator(*m_pTempList)); - static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pTempIter.get()); - } - else - static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(nullptr); - } - else - static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(nullptr); + m_pTempIter.reset(new sw::WrongListIterator(*pSmartTags->SubList(nPos))); + static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pTempIter.get()); } - m_pOldGrammarCheckList = static_cast<SwTextPaintInfo*>(pInf)->GetGrammarCheckList(); - if (m_pOldGrammarCheckList) + else if (!m_pTempList && nPos < pSmartTags->Count() + && nListPos < pos.second && !aText.isEmpty()) { - std::pair<SwTextNode const*, sal_Int32> pos(pNew->GetTextFrame()->MapViewToModel(nIdx)); - SwWrongList const*const pGrammar(pos.first->GetGrammarCheck()); - if (pGrammar) - { - const sal_uInt16 nPos = pGrammar->GetWrongPos(pos.second); - const sal_Int32 nListPos = pGrammar->Pos(nPos); - if (nListPos == pos.second && pGrammar->SubList(nPos) != nullptr) - { - m_pTempIter.reset(new sw::WrongListIterator(*pGrammar->SubList(nPos))); - static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pTempIter.get()); - } - else if (!m_pTempList && nPos < pGrammar->Count() - && nListPos < pos.second && !aText.isEmpty()) - { - m_pTempList.reset(new SwWrongList( WRONGLIST_GRAMMAR )); - m_pTempList->Insert( OUString(), nullptr, 0, aText.getLength(), 0 ); - m_pTempIter.reset(new sw::WrongListIterator(*m_pTempList)); - static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pTempIter.get()); - } - else - static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(nullptr); - } - else - static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(nullptr); + m_pTempList.reset(new SwWrongList( WRONGLIST_SMARTTAG )); + m_pTempList->Insert( OUString(), nullptr, 0, aText.getLength(), 0 ); + m_pTempIter.reset(new sw::WrongListIterator(*m_pTempList)); + static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pTempIter.get()); } + else + static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(nullptr); } + else + static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(nullptr); } + m_pOldGrammarCheckList = static_cast<SwTextPaintInfo*>(pInf)->GetGrammarCheckList(); + if (!m_pOldGrammarCheckList) + return; + + std::pair<SwTextNode const*, sal_Int32> pos(pNew->GetTextFrame()->MapViewToModel(nIdx)); + SwWrongList const*const pGrammar(pos.first->GetGrammarCheck()); + if (pGrammar) + { + const sal_uInt16 nPos = pGrammar->GetWrongPos(pos.second); + const sal_Int32 nListPos = pGrammar->Pos(nPos); + if (nListPos == pos.second && pGrammar->SubList(nPos) != nullptr) + { + m_pTempIter.reset(new sw::WrongListIterator(*pGrammar->SubList(nPos))); + static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pTempIter.get()); + } + else if (!m_pTempList && nPos < pGrammar->Count() + && nListPos < pos.second && !aText.isEmpty()) + { + m_pTempList.reset(new SwWrongList( WRONGLIST_GRAMMAR )); + m_pTempList->Insert( OUString(), nullptr, 0, aText.getLength(), 0 ); + m_pTempIter.reset(new sw::WrongListIterator(*m_pTempList)); + static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pTempIter.get()); + } + else + static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(nullptr); + } + else + static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(nullptr); } SwTextSlot::~SwTextSlot() { - if( bOn ) - { - pInf->SetCachedVclData(m_pOldCachedVclData); - pInf->SetText( *pOldText ); - pInf->SetIdx( nIdx ); - pInf->SetLen( nLen ); - - // ST2 - // Restore old smart tag list - if (m_pOldSmartTagList) - static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pOldSmartTagList); - if (m_pOldGrammarCheckList) - static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pOldGrammarCheckList); - } + if( !bOn ) + return; + + pInf->SetCachedVclData(m_pOldCachedVclData); + pInf->SetText( *pOldText ); + pInf->SetIdx( nIdx ); + pInf->SetLen( nLen ); + + // ST2 + // Restore old smart tag list + if (m_pOldSmartTagList) + static_cast<SwTextPaintInfo*>(pInf)->SetSmartTags(m_pOldSmartTagList); + if (m_pOldGrammarCheckList) + static_cast<SwTextPaintInfo*>(pInf)->SetGrammarCheckList(m_pOldGrammarCheckList); } SwFontSave::SwFontSave(const SwTextSizeInfo &rInf, SwFont *pNew, @@ -1915,33 +1915,33 @@ SwFontSave::SwFontSave(const SwTextSizeInfo &rInf, SwFont *pNew, , pFnt(pNew ? const_cast<SwTextSizeInfo&>(rInf).GetFont() : nullptr) , pIter(nullptr) { - if( pFnt ) + if( !pFnt ) + return; + + pInf = &const_cast<SwTextSizeInfo&>(rInf); + // In these cases we temporarily switch to the new font: + // 1. the fonts have a different magic number + // 2. they have different script types + // 3. their background colors differ (this is not covered by 1.) + if( pFnt->DifferentFontCacheId( pNew, pFnt->GetActual() ) || + pNew->GetActual() != pFnt->GetActual() || + ( ! pNew->GetBackColor() && pFnt->GetBackColor() ) || + ( pNew->GetBackColor() && ! pFnt->GetBackColor() ) || + ( pNew->GetBackColor() && pFnt->GetBackColor() && + ( *pNew->GetBackColor() != *pFnt->GetBackColor() ) ) ) { - pInf = &const_cast<SwTextSizeInfo&>(rInf); - // In these cases we temporarily switch to the new font: - // 1. the fonts have a different magic number - // 2. they have different script types - // 3. their background colors differ (this is not covered by 1.) - if( pFnt->DifferentFontCacheId( pNew, pFnt->GetActual() ) || - pNew->GetActual() != pFnt->GetActual() || - ( ! pNew->GetBackColor() && pFnt->GetBackColor() ) || - ( pNew->GetBackColor() && ! pFnt->GetBackColor() ) || - ( pNew->GetBackColor() && pFnt->GetBackColor() && - ( *pNew->GetBackColor() != *pFnt->GetBackColor() ) ) ) - { - pNew->SetTransparent( true ); - pNew->SetAlign( ALIGN_BASELINE ); - pInf->SetFont( pNew ); - } - else - pFnt = nullptr; - pNew->Invalidate(); - pNew->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() ); - if( pItr && pItr->GetFnt() == pFnt ) - { - pIter = pItr; - pIter->SetFnt( pNew ); - } + pNew->SetTransparent( true ); + pNew->SetAlign( ALIGN_BASELINE ); + pInf->SetFont( pNew ); + } + else + pFnt = nullptr; + pNew->Invalidate(); + pNew->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() ); + if( pItr && pItr->GetFnt() == pFnt ) + { + pIter = pItr; + pIter->SetFnt( pNew ); } } diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index aec314e56b8b..fd7bdc577efb 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -2635,111 +2635,111 @@ SwFlyCntPortion *SwTextFormatter::NewFlyCntPortion( SwTextFormatInfo &rInf, but we have handle them just like portions */ void SwTextFormatter::MergeCharacterBorder( SwDropPortion const & rPortion ) { - if( rPortion.GetLines() > 1 ) + if( rPortion.GetLines() <= 1 ) + return; + + SwDropPortionPart* pCurrPart = rPortion.GetPart(); + while( pCurrPart ) { - SwDropPortionPart* pCurrPart = rPortion.GetPart(); - while( pCurrPart ) + if( pCurrPart->GetFollow() && + ::lcl_HasSameBorder(pCurrPart->GetFont(), pCurrPart->GetFollow()->GetFont()) ) { - if( pCurrPart->GetFollow() && - ::lcl_HasSameBorder(pCurrPart->GetFont(), pCurrPart->GetFollow()->GetFont()) ) - { - pCurrPart->SetJoinBorderWithNext(true); - pCurrPart->GetFollow()->SetJoinBorderWithPrev(true); - } - pCurrPart = pCurrPart->GetFollow(); + pCurrPart->SetJoinBorderWithNext(true); + pCurrPart->GetFollow()->SetJoinBorderWithPrev(true); } + pCurrPart = pCurrPart->GetFollow(); } } void SwTextFormatter::MergeCharacterBorder( SwLinePortion& rPortion, SwLinePortion const *pPrev, SwTextFormatInfo& rInf ) { const SwFont aCurFont = *rInf.GetFont(); - if( aCurFont.HasBorder() ) + if( !aCurFont.HasBorder() ) + return; + + if (pPrev && pPrev->GetJoinBorderWithNext() ) { - if (pPrev && pPrev->GetJoinBorderWithNext() ) + // In some case border merge is called twice to the portion + if( !rPortion.GetJoinBorderWithPrev() ) { - // In some case border merge is called twice to the portion - if( !rPortion.GetJoinBorderWithPrev() ) - { - rPortion.SetJoinBorderWithPrev(true); - if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetLeftBorderSpace() ) - rPortion.Width(rPortion.Width() - aCurFont.GetLeftBorderSpace()); - } - } - else - { - rPortion.SetJoinBorderWithPrev(false); - m_pFirstOfBorderMerge = &rPortion; + rPortion.SetJoinBorderWithPrev(true); + if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetLeftBorderSpace() ) + rPortion.Width(rPortion.Width() - aCurFont.GetLeftBorderSpace()); } + } + else + { + rPortion.SetJoinBorderWithPrev(false); + m_pFirstOfBorderMerge = &rPortion; + } - // Get next portion's font - bool bSeek = false; - if (!rInf.IsFull() && // Not the last portion of the line (in case of line break) - rInf.GetIdx() + rPortion.GetLen() != TextFrameIndex(rInf.GetText().getLength())) // Not the last portion of the paragraph - { - bSeek = Seek(rInf.GetIdx() + rPortion.GetLen()); - } - // Don't join the next portion if SwKernPortion sits between two different boxes. - bool bDisconnect = rPortion.IsKernPortion() && !rPortion.GetJoinBorderWithPrev(); - // If next portion has the same border then merge - if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, *GetFnt()) && !bDisconnect ) + // Get next portion's font + bool bSeek = false; + if (!rInf.IsFull() && // Not the last portion of the line (in case of line break) + rInf.GetIdx() + rPortion.GetLen() != TextFrameIndex(rInf.GetText().getLength())) // Not the last portion of the paragraph + { + bSeek = Seek(rInf.GetIdx() + rPortion.GetLen()); + } + // Don't join the next portion if SwKernPortion sits between two different boxes. + bool bDisconnect = rPortion.IsKernPortion() && !rPortion.GetJoinBorderWithPrev(); + // If next portion has the same border then merge + if( bSeek && GetFnt()->HasBorder() && ::lcl_HasSameBorder(aCurFont, *GetFnt()) && !bDisconnect ) + { + // In some case border merge is called twice to the portion + if( !rPortion.GetJoinBorderWithNext() ) { - // In some case border merge is called twice to the portion - if( !rPortion.GetJoinBorderWithNext() ) - { - rPortion.SetJoinBorderWithNext(true); - if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetRightBorderSpace() ) - rPortion.Width(rPortion.Width() - aCurFont.GetRightBorderSpace()); - } + rPortion.SetJoinBorderWithNext(true); + if( rPortion.InTextGrp() && rPortion.Width() > aCurFont.GetRightBorderSpace() ) + rPortion.Width(rPortion.Width() - aCurFont.GetRightBorderSpace()); } - // If this is the last portion of the merge group then make the real height merge - else + } + // If this is the last portion of the merge group then make the real height merge + else + { + rPortion.SetJoinBorderWithNext(false); + if( m_pFirstOfBorderMerge != &rPortion ) { - rPortion.SetJoinBorderWithNext(false); - if( m_pFirstOfBorderMerge != &rPortion ) + // Calculate maximum height and ascent + SwLinePortion* pActPor = m_pFirstOfBorderMerge; + sal_uInt16 nMaxAscent = 0; + sal_uInt16 nMaxHeight = 0; + bool bReachCurrent = false; + while( pActPor ) { - // Calculate maximum height and ascent - SwLinePortion* pActPor = m_pFirstOfBorderMerge; - sal_uInt16 nMaxAscent = 0; - sal_uInt16 nMaxHeight = 0; - bool bReachCurrent = false; - while( pActPor ) - { - if( nMaxHeight < pActPor->Height() ) - nMaxHeight = pActPor->Height(); - if( nMaxAscent < pActPor->GetAscent() ) - nMaxAscent = pActPor->GetAscent(); + if( nMaxHeight < pActPor->Height() ) + nMaxHeight = pActPor->Height(); + if( nMaxAscent < pActPor->GetAscent() ) + nMaxAscent = pActPor->GetAscent(); - pActPor = pActPor->GetNextPortion(); - if( !pActPor && !bReachCurrent ) - { - pActPor = &rPortion; - bReachCurrent = true; - } + pActPor = pActPor->GetNextPortion(); + if( !pActPor && !bReachCurrent ) + { + pActPor = &rPortion; + bReachCurrent = true; } + } - // Change all portion's height and ascent - pActPor = m_pFirstOfBorderMerge; - bReachCurrent = false; - while( pActPor ) - { - if( nMaxHeight > pActPor->Height() ) - pActPor->Height(nMaxHeight); - if( nMaxAscent > pActPor->GetAscent() ) - pActPor->SetAscent(nMaxAscent); + // Change all portion's height and ascent + pActPor = m_pFirstOfBorderMerge; + bReachCurrent = false; + while( pActPor ) + { + if( nMaxHeight > pActPor->Height() ) + pActPor->Height(nMaxHeight); + if( nMaxAscent > pActPor->GetAscent() ) + pActPor->SetAscent(nMaxAscent); - pActPor = pActPor->GetNextPortion(); - if( !pActPor && !bReachCurrent ) - { - pActPor = &rPortion; - bReachCurrent = true; - } + pActPor = pActPor->GetNextPortion(); + if( !pActPor && !bReachCurrent ) + { + pActPor = &rPortion; + bReachCurrent = true; } - m_pFirstOfBorderMerge = nullptr; } + m_pFirstOfBorderMerge = nullptr; } - Seek(rInf.GetIdx()); } + Seek(rInf.GetIdx()); } namespace { diff --git a/sw/source/core/text/porexp.cxx b/sw/source/core/text/porexp.cxx index 659b5532d3b9..0e79a2145e7b 100644 --- a/sw/source/core/text/porexp.cxx +++ b/sw/source/core/text/porexp.cxx @@ -160,20 +160,20 @@ sal_uInt16 SwBlankPortion::MayUnderflow( const SwTextFormatInfo &rInf, void SwBlankPortion::FormatEOL( SwTextFormatInfo &rInf ) { sal_uInt16 nMay = MayUnderflow( rInf, rInf.GetIdx() - nLineLength, true ); - if( nMay ) + if( !nMay ) + return; + + if( nMay > 1 ) { - if( nMay > 1 ) - { - if( rInf.GetLast() == this ) - rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) ); - rInf.X( rInf.X() - PrtWidth() ); - rInf.SetIdx( rInf.GetIdx() - GetLen() ); - } - Truncate(); - rInf.SetUnderflow( this ); - if( rInf.GetLast()->IsKernPortion() ) - rInf.SetUnderflow( rInf.GetLast() ); + if( rInf.GetLast() == this ) + rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) ); + rInf.X( rInf.X() - PrtWidth() ); + rInf.SetIdx( rInf.GetIdx() - GetLen() ); } + Truncate(); + rInf.SetUnderflow( this ); + if( rInf.GetLast()->IsKernPortion() ) + rInf.SetUnderflow( rInf.GetLast() ); } /** diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index fb414dc8772e..d411c9e17377 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -158,26 +158,26 @@ SwFieldSlot::SwFieldSlot( const SwTextFormatInfo* pNew, const SwFieldPortion *pP bOn = pPor->GetExpText( *pNew, aText ); // The text will be replaced ... - if( bOn ) + if( !bOn ) + return; + + pInf = const_cast<SwTextFormatInfo*>(pNew); + nIdx = pInf->GetIdx(); + nLen = pInf->GetLen(); + pOldText = &(pInf->GetText()); + m_pOldCachedVclData = pInf->GetCachedVclData(); + pInf->SetLen(TextFrameIndex(aText.getLength())); + pInf->SetCachedVclData(nullptr); + if( pPor->IsFollow() ) { - pInf = const_cast<SwTextFormatInfo*>(pNew); - nIdx = pInf->GetIdx(); - nLen = pInf->GetLen(); - pOldText = &(pInf->GetText()); - m_pOldCachedVclData = pInf->GetCachedVclData(); - pInf->SetLen(TextFrameIndex(aText.getLength())); - pInf->SetCachedVclData(nullptr); - if( pPor->IsFollow() ) - { - pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() ); - pInf->SetIdx(TextFrameIndex(0)); - } - else if (nIdx < TextFrameIndex(pOldText->getLength())) - { - aText = (*pOldText).replaceAt(sal_Int32(nIdx), 1, aText); - } - pInf->SetText( aText ); + pInf->SetFakeLineStart( nIdx > pInf->GetLineStart() ); + pInf->SetIdx(TextFrameIndex(0)); + } + else if (nIdx < TextFrameIndex(pOldText->getLength())) + { + aText = (*pOldText).replaceAt(sal_Int32(nIdx), 1, aText); } + pInf->SetText( aText ); } SwFieldSlot::~SwFieldSlot() @@ -660,77 +660,77 @@ void SwNumberPortion::Paint( const SwTextPaintInfo &rInf ) const pThis->Width( nOldWidth ); } - if( !m_aExpand.isEmpty() ) - { - const SwFont *pTmpFnt = rInf.GetFont(); - bool bPaintSpace = ( LINESTYLE_NONE != pTmpFnt->GetUnderline() || - LINESTYLE_NONE != pTmpFnt->GetOverline() || - STRIKEOUT_NONE != pTmpFnt->GetStrikeout() ) && - !pTmpFnt->IsWordLineMode(); - if( bPaintSpace && m_pFont ) - bPaintSpace = ( LINESTYLE_NONE != m_pFont->GetUnderline() || - LINESTYLE_NONE != m_pFont->GetOverline() || - STRIKEOUT_NONE != m_pFont->GetStrikeout() ) && - !m_pFont->IsWordLineMode(); + if( m_aExpand.isEmpty() ) + return; - SwFontSave aSave( rInf, m_pFont.get() ); + const SwFont *pTmpFnt = rInf.GetFont(); + bool bPaintSpace = ( LINESTYLE_NONE != pTmpFnt->GetUnderline() || + LINESTYLE_NONE != pTmpFnt->GetOverline() || + STRIKEOUT_NONE != pTmpFnt->GetStrikeout() ) && + !pTmpFnt->IsWordLineMode(); + if( bPaintSpace && m_pFont ) + bPaintSpace = ( LINESTYLE_NONE != m_pFont->GetUnderline() || + LINESTYLE_NONE != m_pFont->GetOverline() || + STRIKEOUT_NONE != m_pFont->GetStrikeout() ) && + !m_pFont->IsWordLineMode(); + + SwFontSave aSave( rInf, m_pFont.get() ); - if( nFixWidth == Width() && ! HasFollow() ) + if( nFixWidth == Width() && ! HasFollow() ) + SwExpandPortion::Paint( rInf ); + else + { + // logical const: reset width + SwNumberPortion *pThis = const_cast<SwNumberPortion*>(this); + bPaintSpace = bPaintSpace && nFixWidth < nOldWidth; + sal_uInt16 nSpaceOffs = nFixWidth; + pThis->Width( nFixWidth ); + + if( ( IsLeft() && ! rInf.GetTextFrame()->IsRightToLeft() ) || + ( ! IsLeft() && ! IsCenter() && rInf.GetTextFrame()->IsRightToLeft() ) ) SwExpandPortion::Paint( rInf ); else { - // logical const: reset width - SwNumberPortion *pThis = const_cast<SwNumberPortion*>(this); - bPaintSpace = bPaintSpace && nFixWidth < nOldWidth; - sal_uInt16 nSpaceOffs = nFixWidth; - pThis->Width( nFixWidth ); - - if( ( IsLeft() && ! rInf.GetTextFrame()->IsRightToLeft() ) || - ( ! IsLeft() && ! IsCenter() && rInf.GetTextFrame()->IsRightToLeft() ) ) - SwExpandPortion::Paint( rInf ); + SwTextPaintInfo aInf( rInf ); + if( nOffset < nMinDist ) + nOffset = 0; else { - SwTextPaintInfo aInf( rInf ); - if( nOffset < nMinDist ) - nOffset = 0; - else + if( IsCenter() ) { - if( IsCenter() ) - { - /* #110778# a / 2 * 2 == a is not a tautology */ - sal_uInt16 nTmpOffset = nOffset; - nOffset /= 2; - if( nOffset < nMinDist ) - nOffset = nTmpOffset - nMinDist; - } - else - nOffset = nOffset - nMinDist; + /* #110778# a / 2 * 2 == a is not a tautology */ + sal_uInt16 nTmpOffset = nOffset; + nOffset /= 2; + if( nOffset < nMinDist ) + nOffset = nTmpOffset - nMinDist; } - aInf.X( aInf.X() + nOffset ); - SwExpandPortion::Paint( aInf ); - if( bPaintSpace ) - nSpaceOffs = nSpaceOffs + nOffset; + else + nOffset = nOffset - nMinDist; } - if( bPaintSpace && nOldWidth > nSpaceOffs ) - { - SwTextPaintInfo aInf( rInf ); - aInf.X( aInf.X() + nSpaceOffs ); + aInf.X( aInf.X() + nOffset ); + SwExpandPortion::Paint( aInf ); + if( bPaintSpace ) + nSpaceOffs = nSpaceOffs + nOffset; + } + if( bPaintSpace && nOldWidth > nSpaceOffs ) + { + SwTextPaintInfo aInf( rInf ); + aInf.X( aInf.X() + nSpaceOffs ); - // #i53199# Adjust position of underline: - if ( rInf.GetUnderFnt() ) - { - const Point aNewPos( aInf.GetPos().X(), rInf.GetUnderFnt()->GetPos().Y() ); - rInf.GetUnderFnt()->SetPos( aNewPos ); - } + // #i53199# Adjust position of underline: + if ( rInf.GetUnderFnt() ) + { + const Point aNewPos( aInf.GetPos().X(), rInf.GetUnderFnt()->GetPos().Y() ); + rInf.GetUnderFnt()->SetPos( aNewPos ); + } - pThis->Width( nOldWidth - nSpaceOffs + 12 ); - { - SwTextSlot aDiffText( &aInf, this, true, false, " " ); - aInf.DrawText( *this, aInf.GetLen(), true ); - } + pThis->Width( nOldWidth - nSpaceOffs + 12 ); + { + SwTextSlot aDiffText( &aInf, this, true, false, " " ); + aInf.DrawText( *this, aInf.GetLen(), true ); } - pThis->Width( nOldWidth ); } + pThis->Width( nOldWidth ); } } @@ -998,59 +998,59 @@ void SwGrfNumPortion::Paint( const SwTextPaintInfo &rInf ) const void SwGrfNumPortion::SetBase( long nLnAscent, long nLnDescent, long nFlyAsc, long nFlyDesc ) { - if ( GetOrient() != text::VertOrientation::NONE ) + if ( GetOrient() == text::VertOrientation::NONE ) + return; + + SetRelPos( 0 ); + if ( GetOrient() == text::VertOrientation::CENTER ) + SetRelPos( GetGrfHeight() / 2 ); + else if ( GetOrient() == text::VertOrientation::TOP ) + SetRelPos( GetGrfHeight() - GRFNUM_SECURE ); + else if ( GetOrient() == text::VertOrientation::BOTTOM ) + ; + else if ( GetOrient() == text::VertOrientation::CHAR_CENTER ) + SetRelPos( ( GetGrfHeight() + nLnAscent - nLnDescent ) / 2 ); + else if ( GetOrient() == text::VertOrientation::CHAR_TOP ) + SetRelPos( nLnAscent ); + else if ( GetOrient() == text::VertOrientation::CHAR_BOTTOM ) + SetRelPos( GetGrfHeight() - nLnDescent ); + else { - SetRelPos( 0 ); - if ( GetOrient() == text::VertOrientation::CENTER ) - SetRelPos( GetGrfHeight() / 2 ); - else if ( GetOrient() == text::VertOrientation::TOP ) - SetRelPos( GetGrfHeight() - GRFNUM_SECURE ); - else if ( GetOrient() == text::VertOrientation::BOTTOM ) - ; - else if ( GetOrient() == text::VertOrientation::CHAR_CENTER ) - SetRelPos( ( GetGrfHeight() + nLnAscent - nLnDescent ) / 2 ); - else if ( GetOrient() == text::VertOrientation::CHAR_TOP ) - SetRelPos( nLnAscent ); - else if ( GetOrient() == text::VertOrientation::CHAR_BOTTOM ) - SetRelPos( GetGrfHeight() - nLnDescent ); - else + if( GetGrfHeight() >= nFlyAsc + nFlyDesc ) { - if( GetGrfHeight() >= nFlyAsc + nFlyDesc ) - { - // If I'm as large as the line, I do not need to adjust - // at the line; I'll leave the max. ascent unchanged - SetRelPos( nFlyAsc ); - } - else if ( GetOrient() == text::VertOrientation::LINE_CENTER ) - SetRelPos( ( GetGrfHeight() + nFlyAsc - nFlyDesc ) / 2 ); - else if ( GetOrient() == text::VertOrientation::LINE_TOP ) - SetRelPos( nFlyAsc ); - else if ( GetOrient() == text::VertOrientation::LINE_BOTTOM ) - SetRelPos( GetGrfHeight() - nFlyDesc ); + // If I'm as large as the line, I do not need to adjust + // at the line; I'll leave the max. ascent unchanged + SetRelPos( nFlyAsc ); } + else if ( GetOrient() == text::VertOrientation::LINE_CENTER ) + SetRelPos( ( GetGrfHeight() + nFlyAsc - nFlyDesc ) / 2 ); + else if ( GetOrient() == text::VertOrientation::LINE_TOP ) + SetRelPos( nFlyAsc ); + else if ( GetOrient() == text::VertOrientation::LINE_BOTTOM ) + SetRelPos( GetGrfHeight() - nFlyDesc ); } } void SwTextFrame::StopAnimation( OutputDevice* pOut ) { OSL_ENSURE( HasAnimation(), "SwTextFrame::StopAnimation: Which Animation?" ); - if( HasPara() ) + if( !HasPara() ) + return; + + SwLineLayout *pLine = GetPara(); + while( pLine ) { - SwLineLayout *pLine = GetPara(); - while( pLine ) + SwLinePortion *pPor = pLine->GetNextPortion(); + while( pPor ) { - SwLinePortion *pPor = pLine->GetNextPortion(); - while( pPor ) - { - if( pPor->IsGrfNumPortion() ) - static_cast<SwGrfNumPortion*>(pPor)->StopAnimation( pOut ); - // The NumberPortion is always at the first char, - // which means we can cancel as soon as we've reached a portion - // with a length > 0 - pPor = pPor->GetLen() ? nullptr : pPor->GetNextPortion(); - } - pLine = pLine->GetLen() ? nullptr : pLine->GetNext(); + if( pPor->IsGrfNumPortion() ) + static_cast<SwGrfNumPortion*>(pPor)->StopAnimation( pOut ); + // The NumberPortion is always at the first char, + // which means we can cancel as soon as we've reached a portion + // with a length > 0 + pPor = pPor->GetLen() ? nullptr : pPor->GetNextPortion(); } + pLine = pLine->GetLen() ? nullptr : pLine->GetNext(); } } diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 31602d3c3ac6..8a34966b7873 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -149,31 +149,31 @@ void SwTextFrame::MoveFlyInCnt(SwTextFrame *pNew, TextFrameIndex const nStart, TextFrameIndex const nEnd) { SwSortedObjs *pObjs = GetDrawObjs(); - if ( nullptr != pObjs ) + if ( nullptr == pObjs ) + return; + + for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i ) { - for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i ) + // Consider changed type of <SwSortedList> entries + SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; + const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor(); + if (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR) { - // Consider changed type of <SwSortedList> entries - SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; - const SwFormatAnchor& rAnch = pAnchoredObj->GetFrameFormat().GetAnchor(); - if (rAnch.GetAnchorId() == RndStdIds::FLY_AS_CHAR) + const SwPosition* pPos = rAnch.GetContentAnchor(); + TextFrameIndex const nIndex(MapModelToViewPos(*pPos)); + if (nStart <= nIndex && nIndex < nEnd) { - const SwPosition* pPos = rAnch.GetContentAnchor(); - TextFrameIndex const nIndex(MapModelToViewPos(*pPos)); - if (nStart <= nIndex && nIndex < nEnd) + if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr ) + { + RemoveFly( static_cast<SwFlyFrame*>(pAnchoredObj) ); + pNew->AppendFly( static_cast<SwFlyFrame*>(pAnchoredObj) ); + } + else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchoredObj ) != nullptr ) { - if ( dynamic_cast< const SwFlyFrame *>( pAnchoredObj ) != nullptr ) - { - RemoveFly( static_cast<SwFlyFrame*>(pAnchoredObj) ); - pNew->AppendFly( static_cast<SwFlyFrame*>(pAnchoredObj) ); - } - else if ( dynamic_cast< const SwAnchoredDrawObject *>( pAnchoredObj ) != nullptr ) - { - RemoveDrawObj( *pAnchoredObj ); - pNew->AppendDrawObj( *pAnchoredObj ); - } - --i; + RemoveDrawObj( *pAnchoredObj ); + pNew->AppendDrawObj( *pAnchoredObj ); } + --i; } } } @@ -209,30 +209,30 @@ void sw::FlyContentPortion::Paint(const SwTextPaintInfo& rInf) const if(rInf.GetTextFrame()->IsVertical()) rInf.GetTextFrame()->SwitchHorizontalToVertical(aRepaintRect); - if((m_pFly->IsCompletePaint() || + if(!((m_pFly->IsCompletePaint() || m_pFly->getFrameArea().IsOver(aRepaintRect)) && - SwFlyFrame::IsPaint(m_pFly->GetVirtDrawObj(), m_pFly->getRootFrame()->GetCurrShell())) - { - SwRect aRect(m_pFly->getFrameArea()); - if(!m_pFly->IsCompletePaint()) - aRect.Intersection_(aRepaintRect); - - // GetFlyFrame() may change the layout mode at the output device. - { - SwLayoutModeModifier aLayoutModeModifier(*rInf.GetOut()); - m_pFly->PaintSwFrame(const_cast<vcl::RenderContext&>(*rInf.GetOut()), aRect); - } - const_cast<SwTextPaintInfo&>(rInf).GetRefDev()->SetLayoutMode(rInf.GetOut()->GetLayoutMode()); + SwFlyFrame::IsPaint(m_pFly->GetVirtDrawObj(), m_pFly->getRootFrame()->GetCurrShell()))) + return; - // As the OutputDevice might be anything, the font must be re-selected. - // Being in const method should not be a problem. - const_cast<SwTextPaintInfo&>(rInf).SelectFont(); + SwRect aRect(m_pFly->getFrameArea()); + if(!m_pFly->IsCompletePaint()) + aRect.Intersection_(aRepaintRect); - assert(rInf.GetVsh()); - SAL_WARN_IF(rInf.GetVsh()->GetOut() != rInf.GetOut(), "sw.core", "SwFlyCntPortion::Paint: Outdev has changed"); - if(rInf.GetVsh()) - const_cast<SwTextPaintInfo&>(rInf).SetOut(rInf.GetVsh()->GetOut()); + // GetFlyFrame() may change the layout mode at the output device. + { + SwLayoutModeModifier aLayoutModeModifier(*rInf.GetOut()); + m_pFly->PaintSwFrame(const_cast<vcl::RenderContext&>(*rInf.GetOut()), aRect); } + const_cast<SwTextPaintInfo&>(rInf).GetRefDev()->SetLayoutMode(rInf.GetOut()->GetLayoutMode()); + + // As the OutputDevice might be anything, the font must be re-selected. + // Being in const method should not be a problem. + const_cast<SwTextPaintInfo&>(rInf).SelectFont(); + + assert(rInf.GetVsh()); + SAL_WARN_IF(rInf.GetVsh()->GetOut() != rInf.GetOut(), "sw.core", "SwFlyCntPortion::Paint: Outdev has changed"); + if(rInf.GetVsh()) + const_cast<SwTextPaintInfo&>(rInf).SetOut(rInf.GetVsh()->GetOut()); } void sw::DrawFlyCntPortion::Paint(const SwTextPaintInfo&) const diff --git a/sw/source/core/text/porglue.cxx b/sw/source/core/text/porglue.cxx index 0d34ea304919..822da9ef1672 100644 --- a/sw/source/core/text/porglue.cxx +++ b/sw/source/core/text/porglue.cxx @@ -76,32 +76,32 @@ void SwGluePortion::Paint( const SwTextPaintInfo &rInf ) const aInf.DrawText(*this, TextFrameIndex(aText.getLength()), true); } - if( rInf.OnWin() && rInf.GetOpt().IsBlank() && rInf.IsNoSymbol() ) - { + if( !(rInf.OnWin() && rInf.GetOpt().IsBlank() && rInf.IsNoSymbol()) ) + return; + #if OSL_DEBUG_LEVEL > 0 - const sal_Unicode cChar = rInf.GetChar( rInf.GetIdx() ); - OSL_ENSURE( CH_BLANK == cChar || CH_BULLET == cChar, - "SwGluePortion::Paint: blank expected" ); + const sal_Unicode cChar = rInf.GetChar( rInf.GetIdx() ); + OSL_ENSURE( CH_BLANK == cChar || CH_BULLET == cChar, + "SwGluePortion::Paint: blank expected" ); #endif - if (TextFrameIndex(1) == GetLen()) - { - OUString aBullet( CH_BULLET ); - SwPosSize aBulletSize( rInf.GetTextSize( aBullet ) ); - Point aPos( rInf.GetPos() ); - aPos.AdjustX((Width()/2) - (aBulletSize.Width()/2) ); - SwTextPaintInfo aInf( rInf, &aBullet ); - aInf.SetPos( aPos ); - SwTextPortion aBulletPor; - aBulletPor.Width( aBulletSize.Width() ); - aBulletPor.Height( aBulletSize.Height() ); - aBulletPor.SetAscent( GetAscent() ); - aInf.DrawText(aBulletPor, TextFrameIndex(aBullet.getLength()), true); - } - else - { - SwTextSlot aSlot( &rInf, this, true, false ); - rInf.DrawText( *this, rInf.GetLen(), true ); - } + if (TextFrameIndex(1) == GetLen()) + { + OUString aBullet( CH_BULLET ); + SwPosSize aBulletSize( rInf.GetTextSize( aBullet ) ); + Point aPos( rInf.GetPos() ); + aPos.AdjustX((Width()/2) - (aBulletSize.Width()/2) ); + SwTextPaintInfo aInf( rInf, &aBullet ); + aInf.SetPos( aPos ); + SwTextPortion aBulletPor; + aBulletPor.Width( aBulletSize.Width() ); + aBulletPor.Height( aBulletSize.Height() ); + aBulletPor.SetAscent( GetAscent() ); + aInf.DrawText(aBulletPor, TextFrameIndex(aBullet.getLength()), true); + } + else + { + SwTextSlot aSlot( &rInf, this, true, false ); + rInf.DrawText( *this, rInf.GetLen(), true ); } } diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 5f2b74368feb..5a023427fee4 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -2561,30 +2561,30 @@ void SwScriptInfo::selectRedLineDeleted(const SwTextNode& rNode, MultiSelection || (rNode.GetText().getLength() == rHiddenMulti.GetTotalRange().Len())); const IDocumentRedlineAccess& rIDRA = rNode.getIDocumentRedlineAccess(); - if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) - { - SwRedlineTable::size_type nAct = rIDRA.GetRedlinePos( rNode, RedlineType::Any ); + if ( !IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) + return; - for ( ; nAct < rIDRA.GetRedlineTable().size(); nAct++ ) - { - const SwRangeRedline* pRed = rIDRA.GetRedlineTable()[ nAct ]; + SwRedlineTable::size_type nAct = rIDRA.GetRedlinePos( rNode, RedlineType::Any ); - if (pRed->Start()->nNode > rNode.GetIndex()) - break; + for ( ; nAct < rIDRA.GetRedlineTable().size(); nAct++ ) + { + const SwRangeRedline* pRed = rIDRA.GetRedlineTable()[ nAct ]; - if (pRed->GetType() != RedlineType::Delete) - continue; + if (pRed->Start()->nNode > rNode.GetIndex()) + break; - sal_Int32 nRedlStart; - sal_Int32 nRedlnEnd; - pRed->CalcStartEnd( rNode.GetIndex(), nRedlStart, nRedlnEnd ); - //clip it if the redline extends past the end of the nodes text - nRedlnEnd = std::min<sal_Int32>(nRedlnEnd, rNode.GetText().getLength()); - if ( nRedlnEnd > nRedlStart ) - { - Range aTmp( nRedlStart, nRedlnEnd - 1 ); - rHiddenMulti.Select( aTmp, bSelect ); - } + if (pRed->GetType() != RedlineType::Delete) + continue; + + sal_Int32 nRedlStart; + sal_Int32 nRedlnEnd; + pRed->CalcStartEnd( rNode.GetIndex(), nRedlStart, nRedlnEnd ); + //clip it if the redline extends past the end of the nodes text + nRedlnEnd = std::min<sal_Int32>(nRedlnEnd, rNode.GetText().getLength()); + if ( nRedlnEnd > nRedlStart ) + { + Range aTmp( nRedlStart, nRedlnEnd - 1 ); + rHiddenMulti.Select( aTmp, bSelect ); } } } @@ -2644,26 +2644,26 @@ void SwScriptInfo::CJKJustify( const OUString& rText, long* pKernArray, long nSpaceAdd, bool bIsSpaceStop ) { assert( pKernArray != nullptr && sal_Int32(nStt) >= 0 ); - if (sal_Int32(nLen) > 0) + if (sal_Int32(nLen) <= 0) + return; + + long nSpaceSum = 0; + const lang::Locale &rLocale = g_pBreakIt->GetLocale( aLang ); + sal_Int32 nDone = 0; + sal_Int32 nNext(nStt); + for ( sal_Int32 nI = 0; nI < sal_Int32(nLen); ++nI ) { - long nSpaceSum = 0; - const lang::Locale &rLocale = g_pBreakIt->GetLocale( aLang ); - sal_Int32 nDone = 0; - sal_Int32 nNext(nStt); - for ( sal_Int32 nI = 0; nI < sal_Int32(nLen); ++nI ) + if (nI + sal_Int32(nStt) == nNext) { - if (nI + sal_Int32(nStt) == nNext) - { - nNext = g_pBreakIt->GetBreakIter()->nextCharacters( rText, nNext, - rLocale, - i18n::CharacterIteratorMode::SKIPCELL, 1, nDone ); - if (nNext < sal_Int32(nStt + nLen) || !bIsSpaceStop) - nSpaceSum += nSpaceAdd; - } - pKernArray[ nI ] += nSpaceSum; - if ( pScrArray ) - pScrArray[ nI ] += nSpaceSum; + nNext = g_pBreakIt->GetBreakIter()->nextCharacters( rText, nNext, + rLocale, + i18n::CharacterIteratorMode::SKIPCELL, 1, nDone ); + if (nNext < sal_Int32(nStt + nLen) || !bIsSpaceStop) + nSpaceSum += nSpaceAdd; } + pKernArray[ nI ] += nSpaceSum; + if ( pScrArray ) + pScrArray[ nI ] += nSpaceSum; } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 2154eba1df73..925f5f4e354a 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -103,20 +103,20 @@ void SwMultiPortion::CalcSize( SwTextFormatter& rLine, SwTextFormatInfo &rInf ) Width( pLay->Width() ); pLay = pLay->GetNext(); } while ( pLay ); - if( HasBrackets() ) + if( !HasBrackets() ) + return; + + sal_uInt16 nTmp = static_cast<SwDoubleLinePortion*>(this)->GetBrackets()->nHeight; + if( nTmp > Height() ) { - sal_uInt16 nTmp = static_cast<SwDoubleLinePortion*>(this)->GetBrackets()->nHeight; - if( nTmp > Height() ) - { - const sal_uInt16 nAdd = ( nTmp - Height() ) / 2; - GetRoot().SetAscent( GetRoot().GetAscent() + nAdd ); - GetRoot().Height( GetRoot().Height() + nAdd ); - Height( nTmp ); - } - nTmp = static_cast<SwDoubleLinePortion*>(this)->GetBrackets()->nAscent; - if( nTmp > GetAscent() ) - SetAscent( nTmp ); + const sal_uInt16 nAdd = ( nTmp - Height() ) / 2; + GetRoot().SetAscent( GetRoot().GetAscent() + nAdd ); + GetRoot().Height( GetRoot().Height() + nAdd ); + Height( nTmp ); } + nTmp = static_cast<SwDoubleLinePortion*>(this)->GetBrackets()->nAscent; + if( nTmp > GetAscent() ) + SetAscent( nTmp ); } long SwMultiPortion::CalcSpacing( long , const SwTextSizeInfo & ) const diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 1e2d24cfe8ec..c37e03e7b3a4 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -55,19 +55,19 @@ SwTmpEndPortion::SwTmpEndPortion( const SwLinePortion &rPortion ) void SwTmpEndPortion::Paint( const SwTextPaintInfo &rInf ) const { - if (rInf.OnWin() && rInf.GetOpt().IsParagraph()) - { - const SwFont* pOldFnt = rInf.GetFont(); + if (!(rInf.OnWin() && rInf.GetOpt().IsParagraph())) + return; - SwFont aFont(*pOldFnt); - aFont.SetColor(NON_PRINTING_CHARACTER_COLOR); - const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); + const SwFont* pOldFnt = rInf.GetFont(); - // draw the pilcrow - rInf.DrawText(CH_PAR, *this); + SwFont aFont(*pOldFnt); + aFont.SetColor(NON_PRINTING_CHARACTER_COLOR); + const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); - const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); - } + // draw the pilcrow + rInf.DrawText(CH_PAR, *this); + + const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); } SwBreakPortion::SwBreakPortion( const SwLinePortion &rPortion ) @@ -135,28 +135,28 @@ SwKernPortion::SwKernPortion( const SwLinePortion& rPortion ) : void SwKernPortion::Paint( const SwTextPaintInfo &rInf ) const { - if( Width() ) - { - // bBackground is set for Kerning Portions between two fields - if ( bBackground ) - rInf.DrawViewOpt( *this, PortionType::Field ); + if( !Width() ) + return; - rInf.DrawBackBrush( *this ); - if (GetJoinBorderWithNext() ||GetJoinBorderWithPrev()) - rInf.DrawBorder( *this ); + // bBackground is set for Kerning Portions between two fields + if ( bBackground ) + rInf.DrawViewOpt( *this, PortionType::Field ); - // do we have to repaint a post it portion? - if( rInf.OnWin() && mpNextPortion && !mpNextPortion->Width() ) - mpNextPortion->PrePaint( rInf, this ); + rInf.DrawBackBrush( *this ); + if (GetJoinBorderWithNext() ||GetJoinBorderWithPrev()) + rInf.DrawBorder( *this ); - if( rInf.GetFont()->IsPaintBlank() ) - { - SwRect aClipRect; - rInf.CalcRect( *this, &aClipRect ); - SwSaveClip aClip( const_cast<OutputDevice*>(rInf.GetOut()) ); - aClip.ChgClip( aClipRect ); - rInf.DrawText(" ", *this, TextFrameIndex(0), TextFrameIndex(2), true ); - } + // do we have to repaint a post it portion? + if( rInf.OnWin() && mpNextPortion && !mpNextPortion->Width() ) + mpNextPortion->PrePaint( rInf, this ); + + if( rInf.GetFont()->IsPaintBlank() ) + { + SwRect aClipRect; + rInf.CalcRect( *this, &aClipRect ); + SwSaveClip aClip( const_cast<OutputDevice*>(rInf.GetOut()) ); + aClip.ChgClip( aClipRect ); + rInf.DrawText(" ", *this, TextFrameIndex(0), TextFrameIndex(2), true ); } } @@ -564,52 +564,52 @@ bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& rTextPaintInfo, void SwControlCharPortion::Paint( const SwTextPaintInfo &rInf ) const { - if ( Width() ) // is only set during prepaint mode - { - rInf.DrawViewOpt(*this, GetWhichPor()); + if ( !Width() ) // is only set during prepaint mode + return; - int deltaY(0); - SwFont aTmpFont( *rInf.GetFont() ); - OUString aOutString; + rInf.DrawViewOpt(*this, GetWhichPor()); - if (rInf.OnWin() - && !rInf.GetOpt().IsPagePreview() - && !rInf.GetOpt().IsReadonly() - && DoPaint(rInf, aOutString, aTmpFont, deltaY)) - { - SwFontSave aFontSave( rInf, &aTmpFont ); + int deltaY(0); + SwFont aTmpFont( *rInf.GetFont() ); + OUString aOutString; - if ( !mnHalfCharWidth ) - mnHalfCharWidth = rInf.GetTextSize( aOutString ).Width() / 2; + if (!(rInf.OnWin() + && !rInf.GetOpt().IsPagePreview() + && !rInf.GetOpt().IsReadonly() + && DoPaint(rInf, aOutString, aTmpFont, deltaY))) + return; - Point aOldPos = rInf.GetPos(); - Point aNewPos( aOldPos ); - auto const deltaX((Width() / 2) - mnHalfCharWidth); - switch (rInf.GetFont()->GetOrientation(rInf.GetTextFrame()->IsVertical())) - { - case 0: - aNewPos.AdjustX(deltaX); - aNewPos.AdjustY(deltaY); - break; - case 900: - aNewPos.AdjustY(-deltaX); - aNewPos.AdjustX(deltaY); - break; - case 2700: - aNewPos.AdjustY(deltaX); - aNewPos.AdjustX(-deltaY); - break; - default: - assert(false); - break; - } - const_cast< SwTextPaintInfo& >( rInf ).SetPos( aNewPos ); + SwFontSave aFontSave( rInf, &aTmpFont ); - rInf.DrawText( aOutString, *this ); + if ( !mnHalfCharWidth ) + mnHalfCharWidth = rInf.GetTextSize( aOutString ).Width() / 2; - const_cast< SwTextPaintInfo& >( rInf ).SetPos( aOldPos ); - } + Point aOldPos = rInf.GetPos(); + Point aNewPos( aOldPos ); + auto const deltaX((Width() / 2) - mnHalfCharWidth); + switch (rInf.GetFont()->GetOrientation(rInf.GetTextFrame()->IsVertical())) + { + case 0: + aNewPos.AdjustX(deltaX); + aNewPos.AdjustY(deltaY); + break; + case 900: + aNewPos.AdjustY(-deltaX); + aNewPos.AdjustX(deltaY); + break; + case 2700: + aNewPos.AdjustY(deltaX); + aNewPos.AdjustX(-deltaY); + break; + default: + assert(false); + break; } + const_cast< SwTextPaintInfo& >( rInf ).SetPos( aNewPos ); + + rInf.DrawText( aOutString, *this ); + + const_cast< SwTextPaintInfo& >( rInf ).SetPos( aOldPos ); } bool SwControlCharPortion::Format( SwTextFormatInfo &rInf ) diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index d4be4a1d3d8d..2aeaef5f0831 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -444,47 +444,47 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode, } const bool bShow = IDocumentRedlineAccess::IsShowChanges(rIDRA.GetRedlineFlags()) && pRootFrame && !pRootFrame->IsHideRedlines(); - if (pExtInp || m_pMergedPara || bShow) + if (!(pExtInp || m_pMergedPara || bShow)) + return; + + SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, RedlineType::Any ); + if (SwRedlineTable::npos == nRedlPos && m_pMergedPara) { - SwRedlineTable::size_type nRedlPos = rIDRA.GetRedlinePos( rTextNode, RedlineType::Any ); - if (SwRedlineTable::npos == nRedlPos && m_pMergedPara) - { - SwTextNode const* pNode(&rTextNode); - for (auto const& rExtent : m_pMergedPara->extents) - { // note: have to search because extents based only on Delete - if (rExtent.pNode != pNode) - { - pNode = rExtent.pNode; - nRedlPos = rIDRA.GetRedlinePos(*pNode, RedlineType::Any); - if (SwRedlineTable::npos != nRedlPos) - break; - } - } - // TODO this is true initially but after delete ops it may be false... need to delete m_pMerged somewhere? - // assert(SwRedlineTable::npos != nRedlPos); - assert(SwRedlineTable::npos != nRedlPos || m_pMergedPara->extents.size() <= 1); - } - if (pExtInp || m_pMergedPara || SwRedlineTable::npos != nRedlPos) - { - const std::vector<ExtTextInputAttr> *pArr = nullptr; - if( pExtInp ) + SwTextNode const* pNode(&rTextNode); + for (auto const& rExtent : m_pMergedPara->extents) + { // note: have to search because extents based only on Delete + if (rExtent.pNode != pNode) { - pArr = &pExtInp->GetAttrs(); - Seek( TextFrameIndex(0) ); + pNode = rExtent.pNode; + nRedlPos = rIDRA.GetRedlinePos(*pNode, RedlineType::Any); + if (SwRedlineTable::npos != nRedlPos) + break; } - - m_pRedline.reset(new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos, - m_pMergedPara - ? SwRedlineItr::Mode::Hide - : bShow - ? SwRedlineItr::Mode::Show - : SwRedlineItr::Mode::Ignore, - pArr, pExtInp ? pExtInp->Start() : nullptr)); - - if( m_pRedline->IsOn() ) - ++m_nChgCnt; } + // TODO this is true initially but after delete ops it may be false... need to delete m_pMerged somewhere? + // assert(SwRedlineTable::npos != nRedlPos); + assert(SwRedlineTable::npos != nRedlPos || m_pMergedPara->extents.size() <= 1); + } + if (!(pExtInp || m_pMergedPara || SwRedlineTable::npos != nRedlPos)) + return; + + const std::vector<ExtTextInputAttr> *pArr = nullptr; + if( pExtInp ) + { + pArr = &pExtInp->GetAttrs(); + Seek( TextFrameIndex(0) ); } + + m_pRedline.reset(new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos, + m_pMergedPara + ? SwRedlineItr::Mode::Hide + : bShow + ? SwRedlineItr::Mode::Show + : SwRedlineItr::Mode::Ignore, + pArr, pExtInp ? pExtInp->Start() : nullptr)); + + if( m_pRedline->IsOn() ) + ++m_nChgCnt; } // The Redline-Iterator diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index b1a3bb1214af..38b6c8be3457 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -393,27 +393,27 @@ void SwDropPortion::PaintDrop( const SwTextPaintInfo &rInf ) const void SwDropPortion::Paint( const SwTextPaintInfo &rInf ) const { // normal output is being done here - if( ! nDropHeight || ! pPart || 1 == nLines ) - { - if ( rInf.OnWin() && - !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) - rInf.DrawBackground( *this ); - - // make sure that font is not rotated - std::unique_ptr<SwFont> pTmpFont; - if ( rInf.GetFont()->GetOrientation( rInf.GetTextFrame()->IsVertical() ) ) - { - pTmpFont.reset(new SwFont( *rInf.GetFont() )); - pTmpFont->SetVertical( 0, rInf.GetTextFrame()->IsVertical() ); - } + if( !(! nDropHeight || ! pPart || 1 == nLines) ) + return; - SwFontSave aFontSave( rInf, pTmpFont.get() ); - // for text inside drop portions we let vcl handle the text directions - SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); - aLayoutModeModifier.SetAuto(); + if ( rInf.OnWin() && + !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) + rInf.DrawBackground( *this ); - SwTextPortion::Paint( rInf ); + // make sure that font is not rotated + std::unique_ptr<SwFont> pTmpFont; + if ( rInf.GetFont()->GetOrientation( rInf.GetTextFrame()->IsVertical() ) ) + { + pTmpFont.reset(new SwFont( *rInf.GetFont() )); + pTmpFont->SetVertical( 0, rInf.GetTextFrame()->IsVertical() ); } + + SwFontSave aFontSave( rInf, pTmpFont.get() ); + // for text inside drop portions we let vcl handle the text directions + SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); + aLayoutModeModifier.SetAuto(); + + SwTextPortion::Paint( rInf ); } bool SwDropPortion::FormatText( SwTextFormatInfo &rInf ) diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 6e0e6f33decb..c4a98b71a1c9 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -457,26 +457,26 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm // TODO: apparently Word can apply Character Style too, see testParagraphMark // Check each item and in case it should be ignored, then clear it. - if (pSet) - { - std::unique_ptr<SfxItemSet> const pCleanedSet = pSet->Clone(); + if (!pSet) + return; + + std::unique_ptr<SfxItemSet> const pCleanedSet = pSet->Clone(); - SfxItemIter aIter(*pSet); - const SfxPoolItem* pItem = aIter.GetCurItem(); - do + SfxItemIter aIter(*pSet); + const SfxPoolItem* pItem = aIter.GetCurItem(); + do + { + if (pItem->Which() != RES_CHRATR_BACKGROUND) { - if (pItem->Which() != RES_CHRATR_BACKGROUND) - { - if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which())) - pCleanedSet->ClearItem(pItem->Which()); - else if (pFormat && pFormat->HasItem(pItem->Which())) - pCleanedSet->ClearItem(pItem->Which()); - } + if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which())) + pCleanedSet->ClearItem(pItem->Which()); + else if (pFormat && pFormat->HasItem(pItem->Which())) + pCleanedSet->ClearItem(pItem->Which()); + } - pItem = aIter.NextItem(); - } while (pItem); - pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA); - } + pItem = aIter.NextItem(); + } while (pItem); + pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA); } static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTextNode& rTextNode ) @@ -504,34 +504,34 @@ static const SwRangeRedline* lcl_GetRedlineAtNodeInsertionOrDeletion( const SwTe static void lcl_setRedlineAttr( SwTextFormatInfo &rInf, const SwTextNode& rTextNode, std::unique_ptr<SwFont>& pNumFnt ) { - if ( !rInf.GetVsh()->GetLayout()->IsHideRedlines() ) - { - const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode ); - if (pRedlineNum) - { - std::unique_ptr<SfxItemSet> pSet; + if ( rInf.GetVsh()->GetLayout()->IsHideRedlines() ) + return; - SwAttrPool& rPool = rInf.GetVsh()->GetDoc()->GetAttrPool(); - pSet = std::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{}); + const SwRangeRedline* pRedlineNum = lcl_GetRedlineAtNodeInsertionOrDeletion( rTextNode ); + if (!pRedlineNum) + return; - std::size_t aAuthor = (1 < pRedlineNum->GetStackCount()) - ? pRedlineNum->GetAuthor( 1 ) - : pRedlineNum->GetAuthor(); + std::unique_ptr<SfxItemSet> pSet; - if ( RedlineType::Delete == pRedlineNum->GetType() ) - SW_MOD()->GetDeletedAuthorAttr(aAuthor, *pSet); - else - SW_MOD()->GetInsertAuthorAttr(aAuthor, *pSet); - - const SfxPoolItem* pItem = nullptr; - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_COLOR, true, &pItem)) - pNumFnt->SetColor(static_cast<const SvxColorItem*>(pItem)->GetValue()); - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_UNDERLINE, true, &pItem)) - pNumFnt->SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle()); - if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_CROSSEDOUT, true, &pItem)) - pNumFnt->SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() ); - } - } + SwAttrPool& rPool = rInf.GetVsh()->GetDoc()->GetAttrPool(); + pSet = std::make_unique<SfxItemSet>(rPool, svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{}); + + std::size_t aAuthor = (1 < pRedlineNum->GetStackCount()) + ? pRedlineNum->GetAuthor( 1 ) + : pRedlineNum->GetAuthor(); + + if ( RedlineType::Delete == pRedlineNum->GetType() ) + SW_MOD()->GetDeletedAuthorAttr(aAuthor, *pSet); + else + SW_MOD()->GetInsertAuthorAttr(aAuthor, *pSet); + + const SfxPoolItem* pItem = nullptr; + if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_COLOR, true, &pItem)) + pNumFnt->SetColor(static_cast<const SvxColorItem*>(pItem)->GetValue()); + if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_UNDERLINE, true, &pItem)) + pNumFnt->SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle()); + if (SfxItemState::SET == pSet->GetItemState(RES_CHRATR_CROSSEDOUT, true, &pItem)) + pNumFnt->SetStrikeout( static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout() ); } SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) const diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 00f73d4faafb..1325122c7ca8 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1768,20 +1768,20 @@ void SwTextFrame::CalcLineSpace() } } - if( nDelta ) + if( !nDelta ) + return; + + SwTextFrameBreak aBreak( this ); + if( GetFollow() || aBreak.IsBreakNow( aLine ) ) { - SwTextFrameBreak aBreak( this ); - if( GetFollow() || aBreak.IsBreakNow( aLine ) ) - { - // if there is a Follow() or if we need to break here, reformat - Init(); - } - else - { - // everything is business as usual... - pPara->SetPrepAdjust(); - pPara->SetPrep(); - } + // if there is a Follow() or if we need to break here, reformat + Init(); + } + else + { + // everything is business as usual... + pPara->SetPrepAdjust(); + pPara->SetPrep(); } } @@ -1912,23 +1912,23 @@ void UpdateMergedParaForMove(sw::MergedPara & rMerged, deleted.emplace_back(std::max(nLastEnd, nSourceStart), nSourceEnd); } } - if (!deleted.empty()) + if (deleted.empty()) + return; + + o_rbRecalcFootnoteFlag = true; + for (auto const& it : deleted) { - o_rbRecalcFootnoteFlag = true; - for (auto const& it : deleted) - { - sal_Int32 const nStart(it.first - nSourceStart + nDestStart); - TextFrameIndex const nDeleted = UpdateMergedParaForDelete(rMerged, false, - rDestNode, nStart, it.second - it.first); + sal_Int32 const nStart(it.first - nSourceStart + nDestStart); + TextFrameIndex const nDeleted = UpdateMergedParaForDelete(rMerged, false, + rDestNode, nStart, it.second - it.first); //FIXME asserts valid for join - but if called from split, the new node isn't there yet and it will be added later... assert(nDeleted); // assert(nDeleted == it.second - it.first); - if(nDeleted) - { - // InvalidateRange/lcl_SetScriptInval was called sufficiently for SwInsText - lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false); - TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart)); - lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>); - } + if(nDeleted) + { + // InvalidateRange/lcl_SetScriptInval was called sufficiently for SwInsText + lcl_SetWrong(rTextFrame, rDestNode, nStart, it.first - it.second, false); + TextFrameIndex const nIndex(sw::MapModelToView(rMerged, &rDestNode, nStart)); + lcl_ModifyOfst(rTextFrame, nIndex, nDeleted, &o3tl::operator-<sal_Int32, Tag_TextFrameIndex>); } } } @@ -3461,67 +3461,67 @@ void SwTextFrame::CalcAdditionalFirstLineOffset() const SwTextNode* pTextNode( GetTextNodeForParaProps() ); // sw_redlinehide: check that pParaPropsNode is the correct one assert(pTextNode->IsNumbered(getRootFrame()) == pTextNode->IsNumbered(nullptr)); - if (pTextNode->IsNumbered(getRootFrame()) && - pTextNode->IsCountedInList() && pTextNode->GetNumRule()) - { - int nListLevel = pTextNode->GetActualListLevel(); + if (!(pTextNode->IsNumbered(getRootFrame()) && + pTextNode->IsCountedInList() && pTextNode->GetNumRule())) + return; - if (nListLevel < 0) - nListLevel = 0; + int nListLevel = pTextNode->GetActualListLevel(); - if (nListLevel >= MAXLEVEL) - nListLevel = MAXLEVEL - 1; + if (nListLevel < 0) + nListLevel = 0; - const SwNumFormat& rNumFormat = - pTextNode->GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) ); - if ( rNumFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) - { - // keep current paragraph portion and apply dummy paragraph portion - SwParaPortion* pOldPara = GetPara(); - SwParaPortion *pDummy = new SwParaPortion(); - SetPara( pDummy, false ); + if (nListLevel >= MAXLEVEL) + nListLevel = MAXLEVEL - 1; - // lock paragraph - TextFrameLockGuard aLock( this ); + const SwNumFormat& rNumFormat = + pTextNode->GetNumRule()->Get( static_cast<sal_uInt16>(nListLevel) ); + if ( rNumFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_ALIGNMENT ) + return; - // simulate text formatting - SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true ); - aInf.SetIgnoreFly( true ); - SwTextFormatter aLine( this, &aInf ); - SwHookOut aHook( aInf ); - aLine.CalcFitToContent_(); + // keep current paragraph portion and apply dummy paragraph portion + SwParaPortion* pOldPara = GetPara(); + SwParaPortion *pDummy = new SwParaPortion(); + SetPara( pDummy, false ); - // determine additional first line offset - const SwLinePortion* pFirstPortion = aLine.GetCurr()->GetFirstPortion(); - if ( pFirstPortion->InNumberGrp() && !pFirstPortion->IsFootnoteNumPortion() ) - { - SwTwips nNumberPortionWidth( pFirstPortion->Width() ); + // lock paragraph + TextFrameLockGuard aLock( this ); - const SwLinePortion* pPortion = pFirstPortion->GetNextPortion(); - while ( pPortion && - pPortion->InNumberGrp() && !pPortion->IsFootnoteNumPortion()) - { - nNumberPortionWidth += pPortion->Width(); - pPortion = pPortion->GetNextPortion(); - } + // simulate text formatting + SwTextFormatInfo aInf( getRootFrame()->GetCurrShell()->GetOut(), this, false, true, true ); + aInf.SetIgnoreFly( true ); + SwTextFormatter aLine( this, &aInf ); + SwHookOut aHook( aInf ); + aLine.CalcFitToContent_(); - if ( ( IsRightToLeft() && - rNumFormat.GetNumAdjust() == SvxAdjust::Left ) || - ( !IsRightToLeft() && - rNumFormat.GetNumAdjust() == SvxAdjust::Right ) ) - { - mnAdditionalFirstLineOffset = -nNumberPortionWidth; - } - else if ( rNumFormat.GetNumAdjust() == SvxAdjust::Center ) - { - mnAdditionalFirstLineOffset = -(nNumberPortionWidth/2); - } - } + // determine additional first line offset + const SwLinePortion* pFirstPortion = aLine.GetCurr()->GetFirstPortion(); + if ( pFirstPortion->InNumberGrp() && !pFirstPortion->IsFootnoteNumPortion() ) + { + SwTwips nNumberPortionWidth( pFirstPortion->Width() ); + + const SwLinePortion* pPortion = pFirstPortion->GetNextPortion(); + while ( pPortion && + pPortion->InNumberGrp() && !pPortion->IsFootnoteNumPortion()) + { + nNumberPortionWidth += pPortion->Width(); + pPortion = pPortion->GetNextPortion(); + } - // restore paragraph portion - SetPara( pOldPara ); + if ( ( IsRightToLeft() && + rNumFormat.GetNumAdjust() == SvxAdjust::Left ) || + ( !IsRightToLeft() && + rNumFormat.GetNumAdjust() == SvxAdjust::Right ) ) + { + mnAdditionalFirstLineOffset = -nNumberPortionWidth; + } + else if ( rNumFormat.GetNumAdjust() == SvxAdjust::Center ) + { + mnAdditionalFirstLineOffset = -(nNumberPortionWidth/2); } } + + // restore paragraph portion + SetPara( pOldPara ); } /** @@ -3778,87 +3778,87 @@ void SwTextFrame::ChgThisLines() else if ( rInf.IsCountBlankLines() ) nNew = 1; - if ( nNew != mnThisLines ) + if ( nNew == mnThisLines ) + return; + + if (!IsInTab() && GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber().IsCount()) { - if (!IsInTab() && GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber().IsCount()) + mnAllLines -= mnThisLines; + mnThisLines = nNew; + mnAllLines += mnThisLines; + SwFrame *pNxt = GetNextContentFrame(); + while( pNxt && pNxt->IsInTab() ) { - mnAllLines -= mnThisLines; - mnThisLines = nNew; - mnAllLines += mnThisLines; - SwFrame *pNxt = GetNextContentFrame(); - while( pNxt && pNxt->IsInTab() ) - { - pNxt = pNxt->FindTabFrame(); - if( nullptr != pNxt ) - pNxt = pNxt->FindNextCnt(); - } - if( pNxt ) - pNxt->InvalidateLineNum(); + pNxt = pNxt->FindTabFrame(); + if( nullptr != pNxt ) + pNxt = pNxt->FindNextCnt(); + } + if( pNxt ) + pNxt->InvalidateLineNum(); - // Extend repaint to the bottom. - if ( HasPara() ) - { - SwRepaint& rRepaint = GetPara()->GetRepaint(); - rRepaint.Bottom( std::max( rRepaint.Bottom(), - getFrameArea().Top()+getFramePrintArea().Bottom())); - } + // Extend repaint to the bottom. + if ( HasPara() ) + { + SwRepaint& rRepaint = GetPara()->GetRepaint(); + rRepaint.Bottom( std::max( rRepaint.Bottom(), + getFrameArea().Top()+getFramePrintArea().Bottom())); } - else // Paragraphs which are not counted should not manipulate the AllLines. - mnThisLines = nNew; } + else // Paragraphs which are not counted should not manipulate the AllLines. + mnThisLines = nNew; } void SwTextFrame::RecalcAllLines() { ValidateLineNum(); - if ( !IsInTab() ) + if ( IsInTab() ) + return; + + const sal_uLong nOld = GetAllLines(); + const SwFormatLineNumber &rLineNum = GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber(); + sal_uLong nNewNum; + const bool bRestart = GetDoc().GetLineNumberInfo().IsRestartEachPage(); + + if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() ) + nNewNum = rLineNum.GetStartValue() - 1; + // If it is a follow or not has not be considered if it is a restart at each page; the + // restart should also take effect at follows. + else if ( bRestart && FindPageFrame()->FindFirstBodyContent() == this ) + { + nNewNum = 0; + } + else { - const sal_uLong nOld = GetAllLines(); - const SwFormatLineNumber &rLineNum = GetTextNodeForParaProps()->GetSwAttrSet().GetLineNumber(); - sal_uLong nNewNum; - const bool bRestart = GetDoc().GetLineNumberInfo().IsRestartEachPage(); + SwContentFrame *pPrv = GetPrevContentFrame(); + while ( pPrv && + (pPrv->IsInTab() || pPrv->IsInDocBody() != IsInDocBody()) ) + pPrv = pPrv->GetPrevContentFrame(); - if ( !IsFollow() && rLineNum.GetStartValue() && rLineNum.IsCount() ) - nNewNum = rLineNum.GetStartValue() - 1; - // If it is a follow or not has not be considered if it is a restart at each page; the - // restart should also take effect at follows. - else if ( bRestart && FindPageFrame()->FindFirstBodyContent() == this ) - { - nNewNum = 0; - } - else - { - SwContentFrame *pPrv = GetPrevContentFrame(); - while ( pPrv && - (pPrv->IsInTab() || pPrv->IsInDocBody() != IsInDocBody()) ) - pPrv = pPrv->GetPrevContentFrame(); + // i#78254 Restart line numbering at page change + // First body content may be in table! + if ( bRestart && pPrv && pPrv->FindPageFrame() != FindPageFrame() ) + pPrv = nullptr; - // i#78254 Restart line numbering at page change - // First body content may be in table! - if ( bRestart && pPrv && pPrv->FindPageFrame() != FindPageFrame() ) - pPrv = nullptr; + nNewNum = pPrv ? static_cast<SwTextFrame*>(pPrv)->GetAllLines() : 0; + } + if ( rLineNum.IsCount() ) + nNewNum += GetThisLines(); - nNewNum = pPrv ? static_cast<SwTextFrame*>(pPrv)->GetAllLines() : 0; - } - if ( rLineNum.IsCount() ) - nNewNum += GetThisLines(); + if ( nOld == nNewNum ) + return; - if ( nOld != nNewNum ) - { - mnAllLines = nNewNum; - SwContentFrame *pNxt = GetNextContentFrame(); - while ( pNxt && - (pNxt->IsInTab() || pNxt->IsInDocBody() != IsInDocBody()) ) - pNxt = pNxt->GetNextContentFrame(); - if ( pNxt ) - { - if ( pNxt->GetUpper() != GetUpper() ) - pNxt->InvalidateLineNum(); - else - pNxt->InvalidateLineNum_(); - } - } + mnAllLines = nNewNum; + SwContentFrame *pNxt = GetNextContentFrame(); + while ( pNxt && + (pNxt->IsInTab() || pNxt->IsInDocBody() != IsInDocBody()) ) + pNxt = pNxt->GetNextContentFrame(); + if ( pNxt ) + { + if ( pNxt->GetUpper() != GetUpper() ) + pNxt->InvalidateLineNum(); + else + pNxt->InvalidateLineNum_(); } } diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index 215cc019b89b..d0b411fa2a14 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -505,27 +505,27 @@ bool SwSoftHyphPortion::Format( SwTextFormatInfo &rInf ) */ void SwSoftHyphPortion::FormatEOL( SwTextFormatInfo &rInf ) { - if( !IsExpand() ) - { - SetExpand( true ); - if( rInf.GetLast() == this ) - rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) ); - - // We need to reset the old values - const SwTwips nOldX = rInf.X(); - TextFrameIndex const nOldIdx = rInf.GetIdx(); - rInf.X( rInf.X() - PrtWidth() ); - rInf.SetIdx( rInf.GetIdx() - GetLen() ); - const bool bFull = SwHyphPortion::Format( rInf ); - - // Shady business: We're allowed to get wider, but a Fly is also - // being processed, which needs a correct X position - if( bFull || !rInf.GetFly() ) - rInf.X( nOldX ); - else - rInf.X( nOldX + Width() ); - rInf.SetIdx( nOldIdx ); - } + if( IsExpand() ) + return; + + SetExpand( true ); + if( rInf.GetLast() == this ) + rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) ); + + // We need to reset the old values + const SwTwips nOldX = rInf.X(); + TextFrameIndex const nOldIdx = rInf.GetIdx(); + rInf.X( rInf.X() - PrtWidth() ); + rInf.SetIdx( rInf.GetIdx() - GetLen() ); + const bool bFull = SwHyphPortion::Format( rInf ); + + // Shady business: We're allowed to get wider, but a Fly is also + // being processed, which needs a correct X position + if( bFull || !rInf.GetFly() ) + rInf.X( nOldX ); + else + rInf.X( nOldX + Width() ); + rInf.SetIdx( nOldIdx ); } /** diff --git a/sw/source/core/text/txtpaint.cxx b/sw/source/core/text/txtpaint.cxx index e2292d70beef..45808338919e 100644 --- a/sw/source/core/text/txtpaint.cxx +++ b/sw/source/core/text/txtpaint.cxx @@ -25,19 +25,19 @@ SwSaveClip::~SwSaveClip() { // We recover the old state - if( pOut && bChg ) + if( !(pOut && bChg) ) + return; + + if ( pOut->GetConnectMetaFile() ) + pOut->Pop(); + else { - if ( pOut->GetConnectMetaFile() ) - pOut->Pop(); + if( bOn ) + pOut->SetClipRegion( aClip ); else - { - if( bOn ) - pOut->SetClipRegion( aClip ); - else - pOut->SetClipRegion(); - } - bChg = false; + pOut->SetClipRegion(); } + bChg = false; } void SwSaveClip::ChgClip_( const SwRect &rRect, const SwTextFrame* pFrame, diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx index a38cbe048d44..02d948c795cf 100644 --- a/sw/source/core/text/txttab.cxx +++ b/sw/source/core/text/txttab.cxx @@ -567,24 +567,24 @@ void SwTabPortion::Paint( const SwTextPaintInfo &rInf ) const } // Display fill characters - if( IsFilled() ) - { - // Tabs with filling/filled tabs - const sal_uInt16 nCharWidth = rInf.GetTextSize(OUString(cFill)).Width(); - OSL_ENSURE( nCharWidth, "!SwTabPortion::Paint: sophisticated tabchar" ); + if( !IsFilled() ) + return; - // Robust: - if( nCharWidth ) - { - // Always with kerning, also on printer! - sal_uInt16 nChar = Width() / nCharWidth; - if ( cFill == '_' ) - ++nChar; // to avoid gaps - OUStringBuffer aBuf; - comphelper::string::padToLength(aBuf, nChar, cFill); - rInf.DrawText(aBuf.makeStringAndClear(), *this, TextFrameIndex(0), - TextFrameIndex(nChar), true); - } + // Tabs with filling/filled tabs + const sal_uInt16 nCharWidth = rInf.GetTextSize(OUString(cFill)).Width(); + OSL_ENSURE( nCharWidth, "!SwTabPortion::Paint: sophisticated tabchar" ); + + // Robust: + if( nCharWidth ) + { + // Always with kerning, also on printer! + sal_uInt16 nChar = Width() / nCharWidth; + if ( cFill == '_' ) + ++nChar; // to avoid gaps + OUStringBuffer aBuf; + comphelper::string::padToLength(aBuf, nChar, cFill); + rInf.DrawText(aBuf.makeStringAndClear(), *this, TextFrameIndex(0), + TextFrameIndex(nChar), true); } } diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx index c38aab287007..cdbbc2cc4e81 100644 --- a/sw/source/core/text/widorp.cxx +++ b/sw/source/core/text/widorp.cxx @@ -262,45 +262,45 @@ WidowsAndOrphans::WidowsAndOrphans( SwTextFrame *pNewFrame, const SwTwips nRst, } - if ( m_bKeep || nWidLines || nOrphLines ) - { - bool bResetFlags = false; + if ( !(m_bKeep || nWidLines || nOrphLines) ) + return; - if ( m_pFrame->IsInTab() ) - { - // For compatibility reasons, we disable Keep/Widows/Orphans - // inside splittable row frames: - if ( m_pFrame->GetNextCellLeaf() || m_pFrame->IsInFollowFlowRow() ) - { - const SwFrame* pTmpFrame = m_pFrame->GetUpper(); - while ( !pTmpFrame->IsRowFrame() ) - pTmpFrame = pTmpFrame->GetUpper(); - if ( static_cast<const SwRowFrame*>(pTmpFrame)->IsRowSplitAllowed() ) - bResetFlags = true; - } - } + bool bResetFlags = false; - if( m_pFrame->IsInFootnote() && !m_pFrame->GetIndPrev() ) + if ( m_pFrame->IsInTab() ) + { + // For compatibility reasons, we disable Keep/Widows/Orphans + // inside splittable row frames: + if ( m_pFrame->GetNextCellLeaf() || m_pFrame->IsInFollowFlowRow() ) { - // Inside of footnotes there are good reasons to turn off the Keep attribute - // as well as Widows/Orphans. - SwFootnoteFrame *pFootnote = m_pFrame->FindFootnoteFrame(); - const bool bFt = !pFootnote->GetAttr()->GetFootnote().IsEndNote(); - if( !pFootnote->GetPrev() && - pFootnote->FindFootnoteBossFrame( bFt ) != pFootnote->GetRef()->FindFootnoteBossFrame( bFt ) - && ( !m_pFrame->IsInSct() || m_pFrame->FindSctFrame()->MoveAllowed(m_pFrame) ) ) - { + const SwFrame* pTmpFrame = m_pFrame->GetUpper(); + while ( !pTmpFrame->IsRowFrame() ) + pTmpFrame = pTmpFrame->GetUpper(); + if ( static_cast<const SwRowFrame*>(pTmpFrame)->IsRowSplitAllowed() ) bResetFlags = true; - } } + } - if ( bResetFlags ) + if( m_pFrame->IsInFootnote() && !m_pFrame->GetIndPrev() ) + { + // Inside of footnotes there are good reasons to turn off the Keep attribute + // as well as Widows/Orphans. + SwFootnoteFrame *pFootnote = m_pFrame->FindFootnoteFrame(); + const bool bFt = !pFootnote->GetAttr()->GetFootnote().IsEndNote(); + if( !pFootnote->GetPrev() && + pFootnote->FindFootnoteBossFrame( bFt ) != pFootnote->GetRef()->FindFootnoteBossFrame( bFt ) + && ( !m_pFrame->IsInSct() || m_pFrame->FindSctFrame()->MoveAllowed(m_pFrame) ) ) { - m_bKeep = false; - nOrphLines = 0; - nWidLines = 0; + bResetFlags = true; } } + + if ( bResetFlags ) + { + m_bKeep = false; + nOrphLines = 0; + nWidLines = 0; + } } /** diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index cc77ef66e10d..2ed59c86dcc8 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -135,46 +135,46 @@ SwTOXSortTabBase::SwTOXSortTabBase( TOXSortType nTyp, const SwContentNode* pNd, if ( pLocale ) aLocale = *pLocale; - if( pNd ) - { - sal_Int32 n = 0; - if( pTextMark ) - n = pTextMark->GetStart(); - SwTOXSource aTmp( pNd, n, pTextMark && pTextMark->GetTOXMark().IsMainEntry() ); - aTOXSources.push_back(aTmp); + if( !pNd ) + return; + + sal_Int32 n = 0; + if( pTextMark ) + n = pTextMark->GetStart(); + SwTOXSource aTmp( pNd, n, pTextMark && pTextMark->GetTOXMark().IsMainEntry() ); + aTOXSources.push_back(aTmp); - nPos = pNd->GetIndex(); + nPos = pNd->GetIndex(); - switch( nTyp ) + switch( nTyp ) + { + case TOX_SORT_CONTENT: + case TOX_SORT_PARA: + case TOX_SORT_TABLE: + // If they are in a special areas, we should get the position at the + // body + if( nPos < pNd->GetNodes().GetEndOfExtras().GetIndex() ) { - case TOX_SORT_CONTENT: - case TOX_SORT_PARA: - case TOX_SORT_TABLE: - // If they are in a special areas, we should get the position at the - // body - if( nPos < pNd->GetNodes().GetEndOfExtras().GetIndex() ) + // Then get the 'anchor' (body) position + Point aPt; + std::pair<Point, bool> tmp(aPt, false); + const SwContentFrame *const pFrame = pNd->getLayoutFrame( + pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), + nullptr, &tmp); + if( pFrame ) { - // Then get the 'anchor' (body) position - Point aPt; - std::pair<Point, bool> tmp(aPt, false); - const SwContentFrame *const pFrame = pNd->getLayoutFrame( - pNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(), - nullptr, &tmp); - if( pFrame ) - { - SwPosition aPos( *pNd ); - const SwDoc& rDoc = *pNd->GetDoc(); - bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame ); - OSL_ENSURE(bResult, "where is the text node"); - nPos = aPos.nNode.GetIndex(); - nCntPos = aPos.nContent.GetIndex(); - } + SwPosition aPos( *pNd ); + const SwDoc& rDoc = *pNd->GetDoc(); + bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame ); + OSL_ENSURE(bResult, "where is the text node"); + nPos = aPos.nNode.GetIndex(); + nCntPos = aPos.nContent.GetIndex(); } - else - nCntPos = n; - break; - default: break; } + else + nCntPos = n; + break; + default: break; } } |