sw/source/core/text/itratr.cxx | 185 +++++++++++++++++++++------------------- sw/source/core/text/itrcrsr.cxx | 6 - sw/source/core/text/itrtxt.cxx | 4 sw/source/core/text/itrtxt.hxx | 6 - sw/source/core/text/porhyph.hxx | 4 sw/source/core/text/txthyph.cxx | 4 6 files changed, 110 insertions(+), 99 deletions(-)
New commits: commit d98920c99f374c83023b0de4e955f22ae6673ca7 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Mar 8 09:05:16 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Mar 8 09:58:12 2021 +0100 sw: prefix members of SwHyphStrPortion, SwMinMaxArgs, SwMinMaxNodeArgs ... ... and SwTextCursor See tdf#94879 for motivation. Change-Id: Id226a5b30fae4c29476aebc6edf7fb180726eb4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112153 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index bc39bccc995e..a0ae8073c27b 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -783,20 +783,29 @@ namespace { class SwMinMaxArgs { public: - VclPtr<OutputDevice> pOut; - SwViewShell const * pSh; - sal_uLong &rMin; - sal_uLong &rAbsMin; - tools::Long nRowWidth; - tools::Long nWordWidth; - tools::Long nWordAdd; - sal_Int32 nNoLineBreak; - SwMinMaxArgs( OutputDevice* pOutI, SwViewShell const * pShI, sal_uLong& rMinI, sal_uLong &rAbsI ) - : pOut( pOutI ), pSh( pShI ), rMin( rMinI ), rAbsMin( rAbsI ), nRowWidth(0), - nWordWidth(0), nWordAdd(0), nNoLineBreak(COMPLETE_STRING) - { } - void Minimum( tools::Long nNew ) const { if( static_cast<tools::Long>(rMin) < nNew ) rMin = nNew; } - void NewWord() { nWordAdd = nWordWidth = 0; } + VclPtr<OutputDevice> m_pOut; + SwViewShell const* m_pSh; + sal_uLong& m_rMin; + sal_uLong& m_rAbsMin; + tools::Long m_nRowWidth; + tools::Long m_nWordWidth; + tools::Long m_nWordAdd; + sal_Int32 m_nNoLineBreak; + SwMinMaxArgs(OutputDevice* pOutI, SwViewShell const* pShI, sal_uLong& rMinI, sal_uLong& rAbsI) + : m_pOut(pOutI) + , m_pSh(pShI) + , m_rMin(rMinI) + , m_rAbsMin(rAbsI) + , m_nRowWidth(0) + , m_nWordWidth(0) + , m_nWordAdd(0) + , m_nNoLineBreak(COMPLETE_STRING) + { } + void Minimum( tools::Long nNew ) const { + if (static_cast<tools::Long>(m_rMin) < nNew) + m_rMin = nNew; + } + void NewWord() { m_nWordAdd = m_nWordWidth = 0; } }; } @@ -816,24 +825,24 @@ static bool lcl_MinMaxString( SwMinMaxArgs& rArg, SwFont* pFnt, const OUString & g_pBreakIt->GetLocale( eLang ), WordType::DICTIONARY_WORD, true ) ); nStop = aBndry.endPos; - if( nIdx <= aBndry.startPos && nIdx && nIdx-1 != rArg.nNoLineBreak ) + if (nIdx <= aBndry.startPos && nIdx && nIdx - 1 != rArg.m_nNoLineBreak) rArg.NewWord(); if( nStop == nIdx ) ++nStop; if( nStop > nEnd ) nStop = nEnd; - SwDrawTextInfo aDrawInf(rArg.pSh, *rArg.pOut, rText, nIdx, nStop - nIdx); + SwDrawTextInfo aDrawInf(rArg.m_pSh, *rArg.m_pOut, rText, nIdx, nStop - nIdx); tools::Long nCurrentWidth = pFnt->GetTextSize_( aDrawInf ).Width(); - rArg.nRowWidth += nCurrentWidth; + rArg.m_nRowWidth += nCurrentWidth; if( bClear ) rArg.NewWord(); else { - rArg.nWordWidth += nCurrentWidth; - if( static_cast<tools::Long>(rArg.rAbsMin) < rArg.nWordWidth ) - rArg.rAbsMin = rArg.nWordWidth; - rArg.Minimum( rArg.nWordWidth + rArg.nWordAdd ); + rArg.m_nWordWidth += nCurrentWidth; + if (static_cast<tools::Long>(rArg.m_rAbsMin) < rArg.m_nWordWidth) + rArg.m_rAbsMin = rArg.m_nWordWidth; + rArg.Minimum(rArg.m_nWordWidth + rArg.m_nWordAdd); bRet = true; } nIdx = nStop; @@ -854,14 +863,17 @@ namespace { class SwMinMaxNodeArgs { public: - sal_uLong nMaxWidth; // sum of all frame widths - tools::Long nMinWidth; // biggest frame - tools::Long nLeftRest; // space not already covered by frames in the left margin - tools::Long nRightRest; // space not already covered by frames in the right margin - tools::Long nLeftDiff; // Min/Max-difference of the frame in the left margin - tools::Long nRightDiff; // Min/Max-difference of the frame in the right margin - sal_uLong nIndx; // index of the node - void Minimum( tools::Long nNew ) { if( nNew > nMinWidth ) nMinWidth = nNew; } + sal_uLong m_nMaxWidth; // sum of all frame widths + tools::Long m_nMinWidth; // biggest frame + tools::Long m_nLeftRest; // space not already covered by frames in the left margin + tools::Long m_nRightRest; // space not already covered by frames in the right margin + tools::Long m_nLeftDiff; // Min/Max-difference of the frame in the left margin + tools::Long m_nRightDiff; // Min/Max-difference of the frame in the right margin + sal_uLong m_nIndex; // index of the node + void Minimum( tools::Long nNew ) { + if (nNew > m_nMinWidth) + m_nMinWidth = nNew; + } }; } @@ -878,7 +890,7 @@ static void lcl_MinMaxNode( SwFrameFormat* pNd, SwMinMaxNodeArgs* pIn ) const SwPosition *pPos = rFormatA.GetContentAnchor(); OSL_ENSURE(pPos && pIn, "Unexpected NULL arguments"); - if (!pPos || !pIn || pIn->nIndx != pPos->nNode.GetIndex()) + if (!pPos || !pIn || pIn->m_nIndex != pPos->nNode.GetIndex()) return; tools::Long nMin, nMax; @@ -954,33 +966,32 @@ static void lcl_MinMaxNode( SwFrameFormat* pNd, SwMinMaxNodeArgs* pIn ) { if( nDiff ) { - pIn->nRightRest -= pIn->nRightDiff; - pIn->nRightDiff = nDiff; + pIn->m_nRightRest -= pIn->m_nRightDiff; + pIn->m_nRightDiff = nDiff; } if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() ) { - if( pIn->nRightRest > 0 ) - pIn->nRightRest = 0; + if (pIn->m_nRightRest > 0) + pIn->m_nRightRest = 0; } - pIn->nRightRest -= nMin; + pIn->m_nRightRest -= nMin; break; } case text::HoriOrientation::LEFT: { if( nDiff ) { - pIn->nLeftRest -= pIn->nLeftDiff; - pIn->nLeftDiff = nDiff; + pIn->m_nLeftRest -= pIn->m_nLeftDiff; + pIn->m_nLeftDiff = nDiff; } - if( text::RelOrientation::FRAME != rOrient.GetRelationOrient() && - pIn->nLeftRest < 0 ) - pIn->nLeftRest = 0; - pIn->nLeftRest -= nMin; + if (text::RelOrientation::FRAME != rOrient.GetRelationOrient() && pIn->m_nLeftRest < 0) + pIn->m_nLeftRest = 0; + pIn->m_nLeftRest -= nMin; break; } default: { - pIn->nMaxWidth += nMax; + pIn->m_nMaxWidth += nMax; pIn->Minimum( nMin ); } } @@ -1017,33 +1028,33 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM nLROffset = nFLOffs; SwMinMaxNodeArgs aNodeArgs; - aNodeArgs.nMinWidth = 0; - aNodeArgs.nMaxWidth = 0; - aNodeArgs.nLeftRest = nLROffset; - aNodeArgs.nRightRest = rSpace.GetRight(); - aNodeArgs.nLeftDiff = 0; - aNodeArgs.nRightDiff = 0; + aNodeArgs.m_nMinWidth = 0; + aNodeArgs.m_nMaxWidth = 0; + aNodeArgs.m_nLeftRest = nLROffset; + aNodeArgs.m_nRightRest = rSpace.GetRight(); + aNodeArgs.m_nLeftDiff = 0; + aNodeArgs.m_nRightDiff = 0; if( nIndex ) { SwFrameFormats* pTmp = const_cast<SwFrameFormats*>(GetDoc().GetSpzFrameFormats()); if( pTmp ) { - aNodeArgs.nIndx = nIndex; + aNodeArgs.m_nIndex = nIndex; for( SwFrameFormat *pFormat : *pTmp ) lcl_MinMaxNode( pFormat, &aNodeArgs ); } } - if( aNodeArgs.nLeftRest < 0 ) - aNodeArgs.Minimum( nLROffset - aNodeArgs.nLeftRest ); - aNodeArgs.nLeftRest -= aNodeArgs.nLeftDiff; - if( aNodeArgs.nLeftRest < 0 ) - aNodeArgs.nMaxWidth -= aNodeArgs.nLeftRest; - - if( aNodeArgs.nRightRest < 0 ) - aNodeArgs.Minimum( rSpace.GetRight() - aNodeArgs.nRightRest ); - aNodeArgs.nRightRest -= aNodeArgs.nRightDiff; - if( aNodeArgs.nRightRest < 0 ) - aNodeArgs.nMaxWidth -= aNodeArgs.nRightRest; + if (aNodeArgs.m_nLeftRest < 0) + aNodeArgs.Minimum(nLROffset - aNodeArgs.m_nLeftRest); + aNodeArgs.m_nLeftRest -= aNodeArgs.m_nLeftDiff; + if (aNodeArgs.m_nLeftRest < 0) + aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nLeftRest; + + if (aNodeArgs.m_nRightRest < 0) + aNodeArgs.Minimum(rSpace.GetRight() - aNodeArgs.m_nRightRest); + aNodeArgs.m_nRightRest -= aNodeArgs.m_nRightDiff; + if (aNodeArgs.m_nRightRest < 0) + aNodeArgs.m_nMaxWidth -= aNodeArgs.m_nRightRest; SwScriptInfo aScriptInfo; SwAttrIter aIter( *const_cast<SwTextNode*>(this), aScriptInfo ); @@ -1091,9 +1102,9 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM { case CH_BREAK : { - if( static_cast<tools::Long>(rMax) < aArg.nRowWidth ) - rMax = aArg.nRowWidth; - aArg.nRowWidth = 0; + if (static_cast<tools::Long>(rMax) < aArg.m_nRowWidth) + rMax = aArg.m_nRowWidth; + aArg.m_nRowWidth = 0; aArg.NewWord(); aIter.SeekAndChgAttrIter( ++nIdx, pOut ); } @@ -1114,12 +1125,12 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM SwDrawTextInfo aDrawInf( pSh, *pOut, sTmp, 0, 1, 0, false ); nCurrentWidth = aIter.GetFnt()->GetTextSize_( aDrawInf ).Width(); - aArg.nWordWidth += nCurrentWidth; - aArg.nRowWidth += nCurrentWidth; - if( static_cast<tools::Long>(rAbsMin) < aArg.nWordWidth ) - rAbsMin = aArg.nWordWidth; - aArg.Minimum( aArg.nWordWidth + aArg.nWordAdd ); - aArg.nNoLineBreak = sal_Int32(nIdx++); + aArg.m_nWordWidth += nCurrentWidth; + aArg.m_nRowWidth += nCurrentWidth; + if (static_cast<tools::Long>(rAbsMin) < aArg.m_nWordWidth) + rAbsMin = aArg.m_nWordWidth; + aArg.Minimum(aArg.m_nWordWidth + aArg.m_nWordAdd); + aArg.m_nNoLineBreak = sal_Int32(nIdx++); } break; case CH_TXTATR_BREAKWORD: @@ -1127,8 +1138,8 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM { if( !pHint ) break; - tools::Long nOldWidth = aArg.nWordWidth; - tools::Long nOldAdd = aArg.nWordAdd; + tools::Long nOldWidth = aArg.m_nWordWidth; + tools::Long nOldAdd = aArg.m_nWordAdd; aArg.NewWord(); switch( pHint->Which() ) @@ -1164,12 +1175,12 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM } nCurrentWidth += rLR.GetLeft(); nCurrentWidth += rLR.GetRight(); - aArg.nWordAdd = nOldWidth + nOldAdd; - aArg.nWordWidth = nCurrentWidth; - aArg.nRowWidth += nCurrentWidth; - if( static_cast<tools::Long>(rAbsMin) < aArg.nWordWidth ) - rAbsMin = aArg.nWordWidth; - aArg.Minimum( aArg.nWordWidth + aArg.nWordAdd ); + aArg.m_nWordAdd = nOldWidth + nOldAdd; + aArg.m_nWordWidth = nCurrentWidth; + aArg.m_nRowWidth += nCurrentWidth; + if (static_cast<tools::Long>(rAbsMin) < aArg.m_nWordWidth) + rAbsMin = aArg.m_nWordWidth; + aArg.Minimum(aArg.m_nWordWidth + aArg.m_nWordAdd); break; } case RES_TXTATR_FTN : @@ -1191,9 +1202,9 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM nAdd = 20; break; } - default: aArg.nWordWidth = nOldWidth; - aArg.nWordAdd = nOldAdd; - + default: + aArg.m_nWordWidth = nOldWidth; + aArg.m_nWordAdd = nOldAdd; } aIter.SeekAndChgAttrIter( ++nIdx, pOut ); } @@ -1210,8 +1221,8 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM break; } } - if( static_cast<tools::Long>(rMax) < aArg.nRowWidth ) - rMax = aArg.nRowWidth; + if (static_cast<tools::Long>(rMax) < aArg.m_nRowWidth) + rMax = aArg.m_nRowWidth; nLROffset += rSpace.GetRight(); @@ -1219,11 +1230,11 @@ void SwTextNode::GetMinMaxSize( sal_uLong nIndex, sal_uLong& rMin, sal_uLong &rM rAbsMin += nAdd; rMin += nLROffset; rMin += nAdd; - if( static_cast<tools::Long>(rMin) < aNodeArgs.nMinWidth ) - rMin = aNodeArgs.nMinWidth; - if( static_cast<tools::Long>(rAbsMin) < aNodeArgs.nMinWidth ) - rAbsMin = aNodeArgs.nMinWidth; - rMax += aNodeArgs.nMaxWidth; + if (static_cast<tools::Long>(rMin) < aNodeArgs.m_nMinWidth) + rMin = aNodeArgs.m_nMinWidth; + if (static_cast<tools::Long>(rAbsMin) < aNodeArgs.m_nMinWidth) + rAbsMin = aNodeArgs.m_nMinWidth; + rMax += aNodeArgs.m_nMaxWidth; rMax += nLROffset; rMax += nAdd; if( rMax < rMin ) // e.g. Frames with flow through only contribute to the minimum diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 327c178497e2..9a1f7140b52f 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -45,7 +45,7 @@ // Not reentrant !!! // is set in GetCharRect and is interpreted in UnitUp/Down. -bool SwTextCursor::bRightMargin = false; +bool SwTextCursor::s_bRightMargin = false; // After calculating the position of a character during GetCharRect // this function allows to find the coordinates of a position (defined @@ -401,7 +401,7 @@ void SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, SwCursorMoveState* pCMS, const tools::Long nMax ) { // 1170: Ambiguity of document positions - bRightMargin = true; + s_bRightMargin = true; CharCursorToLine(nOfst); // Somehow twisted: nOfst names the position behind the last @@ -411,7 +411,7 @@ void SwTextCursor::GetEndCharRect(SwRect* pOrig, const TextFrameIndex nOfst, { // 8810: Master line RightMargin, after that LeftMargin GetCharRect( pOrig, nOfst, pCMS, nMax ); - bRightMargin = nOfst >= GetEnd() && nOfst < TextFrameIndex(GetInfo().GetText().getLength()); + s_bRightMargin = nOfst >= GetEnd() && nOfst < TextFrameIndex(GetInfo().GetText().getLength()); return; } diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx index 087a3dd76c7a..220977a24d6d 100644 --- a/sw/source/core/text/itrtxt.cxx +++ b/sw/source/core/text/itrtxt.cxx @@ -203,8 +203,8 @@ const SwLineLayout *SwTextCursor::CharCursorToLine(TextFrameIndex const nPositio { CharToLine( nPosition ); if( nPosition != m_nStart ) - bRightMargin = false; - bool bPrevious = bRightMargin && m_pCurr->GetLen() && GetPrev() && + s_bRightMargin = false; + bool bPrevious = s_bRightMargin && m_pCurr->GetLen() && GetPrev() && GetPrev()->GetLen(); if (bPrevious && nPosition && CH_BREAK == GetInfo().GetChar(nPosition - TextFrameIndex(1))) bPrevious = false; diff --git a/sw/source/core/text/itrtxt.hxx b/sw/source/core/text/itrtxt.hxx index 8090b23a60a8..f155ee6cc484 100644 --- a/sw/source/core/text/itrtxt.hxx +++ b/sw/source/core/text/itrtxt.hxx @@ -265,7 +265,7 @@ class SwTextCursor : public SwTextAdjuster friend class SwTextCursorSave; // Ambiguities - static bool bRightMargin; + static bool s_bRightMargin; void GetCharRect_(SwRect *, TextFrameIndex, SwCursorMoveState *); protected: void CtorInitTextCursor( SwTextFrame *pFrame, SwTextSizeInfo *pInf ); @@ -291,8 +291,8 @@ public: sal_uInt16 nPorHeight = 0, sal_uInt16 nAscent = 0, const bool bAutoToCentered = false ) const; - static void SetRightMargin( const bool bNew ){ bRightMargin = bNew; } - static bool IsRightMargin() { return bRightMargin; } + static void SetRightMargin( const bool bNew ){ s_bRightMargin = bNew; } + static bool IsRightMargin() { return s_bRightMargin; } }; // Change current output device to printer, this has to be done before diff --git a/sw/source/core/text/porhyph.hxx b/sw/source/core/text/porhyph.hxx index 4227336918d3..bbc799349752 100644 --- a/sw/source/core/text/porhyph.hxx +++ b/sw/source/core/text/porhyph.hxx @@ -41,10 +41,10 @@ public: class SwHyphStrPortion : public SwHyphPortion { - OUString aExpand; + OUString m_aExpand; public: explicit SwHyphStrPortion(std::u16string_view rStr) - : aExpand(OUString::Concat(rStr) + "-") + : m_aExpand(OUString::Concat(rStr) + "-") { SetWhichPor( PortionType::HyphenStr ); } diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index b88d34df4610..aafcb501b8ad 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -377,13 +377,13 @@ bool SwHyphPortion::Format( SwTextFormatInfo &rInf ) bool SwHyphStrPortion::GetExpText( const SwTextSizeInfo &, OUString &rText ) const { - rText = aExpand; + rText = m_aExpand; return true; } void SwHyphStrPortion::HandlePortion( SwPortionHandler& rPH ) const { - rPH.Special( GetLen(), aExpand, GetWhichPor() ); + rPH.Special( GetLen(), m_aExpand, GetWhichPor() ); } SwLinePortion *SwSoftHyphPortion::Compress() { return this; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits