sw/source/core/doc/doccomp.cxx | 228 ++++++++++++++++++++--------------------- 1 file changed, 114 insertions(+), 114 deletions(-)
New commits: commit 525f75b78f96cf8fbf51498a52f16490ff307cee Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Mar 30 09:08:48 2020 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Mar 30 09:48:12 2020 +0200 sw: prefix members of Compare::MovedData, CompareData, Hash and ... ... LgstCommonSubseq See tdf#94879 for motivation. Change-Id: I1c109ffd62dd1cd14f35e798cd18c8cd8b2d48bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91344 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 57486d02849c..274e330abcca 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -82,17 +82,17 @@ public: class CompareData { protected: - SwDoc& rDoc; + SwDoc& m_rDoc; private: - std::unique_ptr<size_t[]> pIndex; - std::unique_ptr<bool[]> pChangedFlag; + std::unique_ptr<size_t[]> m_pIndex; + std::unique_ptr<bool[]> m_pChangedFlag; - std::unique_ptr<SwPaM> pInsRing, pDelRing; + std::unique_ptr<SwPaM> m_pInsertRing, m_pDelRing; static sal_uLong PrevIdx( const SwNode* pNd ); static sal_uLong NextIdx( const SwNode* pNd ); - vector< SwCompareLine* > aLines; + vector< SwCompareLine* > m_aLines; bool m_bRecordDiff; // Truncate beginning and end and add all others to the LinesArray @@ -102,7 +102,7 @@ private: public: CompareData(SwDoc& rD, bool bRecordDiff) - : rDoc( rD ) + : m_rDoc( rD ) , m_bRecordDiff(bRecordDiff) { } @@ -128,21 +128,21 @@ public: // Set non-ambiguous index for a line. Same lines have the same index, even in the other CompareData! void SetIndex( size_t nLine, size_t nIndex ); size_t GetIndex( size_t nLine ) const - { return nLine < aLines.size() ? pIndex[ nLine ] : 0; } + { return nLine < m_aLines.size() ? m_pIndex[ nLine ] : 0; } // Set/get of a line has changed void SetChanged( size_t nLine, bool bFlag = true ); bool GetChanged( size_t nLine ) const { - return (pChangedFlag && nLine < aLines.size()) - && pChangedFlag[ nLine ]; + return (m_pChangedFlag && nLine < m_aLines.size()) + && m_pChangedFlag[ nLine ]; } - size_t GetLineCount() const { return aLines.size(); } + size_t GetLineCount() const { return m_aLines.size(); } const SwCompareLine* GetLine( size_t nLine ) const - { return aLines[ nLine ]; } + { return m_aLines[ nLine ]; } void InsertLine( SwCompareLine* pLine ) - { aLines.push_back( pLine ); } + { m_aLines.push_back( pLine ); } void SetRedlinesToDoc( bool bUseDocInfo ); }; @@ -157,7 +157,7 @@ public: virtual const SwNode& GetEndOfContent() override { - return rDoc.GetNodes().GetEndOfContent(); + return m_rDoc.GetNodes().GetEndOfContent(); } }; @@ -188,16 +188,16 @@ class Hash : nNext( 0 ), nHash( 0 ), pLine(nullptr) {} }; - std::unique_ptr<sal_uLong[]> pHashArr; - std::unique_ptr<HashData[]> pDataArr; - sal_uLong nCount, nPrime; + std::unique_ptr<sal_uLong[]> m_pHashArr; + std::unique_ptr<HashData[]> m_pDataArr; + sal_uLong m_nCount, m_nPrime; public: explicit Hash( sal_uLong nSize ); void CalcHashValue( CompareData& rData ); - sal_uLong GetCount() const { return nCount; } + sal_uLong GetCount() const { return m_nCount; } }; class Compare @@ -205,16 +205,16 @@ class Compare public: class MovedData { - std::unique_ptr<sal_uLong[]> pIndex; - std::unique_ptr<sal_uLong[]> pLineNum; - sal_uLong nCount; + std::unique_ptr<sal_uLong[]> m_pIndex; + std::unique_ptr<sal_uLong[]> m_pLineNum; + sal_uLong m_nCount; public: MovedData( CompareData& rData, const char* pDiscard ); - sal_uLong GetIndex( sal_uLong n ) const { return pIndex[ n ]; } - sal_uLong GetLineNum( sal_uLong n ) const { return pLineNum[ n ]; } - sal_uLong GetCount() const { return nCount; } + sal_uLong GetIndex( sal_uLong n ) const { return m_pIndex[ n ]; } + sal_uLong GetLineNum( sal_uLong n ) const { return m_pLineNum[ n ]; } + sal_uLong GetCount() const { return m_nCount; } }; private: @@ -348,8 +348,8 @@ class LgstCommonSubseq: public CommonSubseq private: static const int CUTOFF = 1<<20; // Stop recursion at this value - std::unique_ptr<int[]> pL1, pL2; - std::unique_ptr<int[]> pBuff1, pBuff2; + std::unique_ptr<int[]> m_pL1, m_pL2; + std::unique_ptr<int[]> m_pBuff1, m_pBuff2; void FindL( int *pL, int nStt1, int nEnd1, int nStt2, int nEnd2 ); int HirschbergLCS( int *pLcs1, int *pLcs2, int nStt1, int nEnd1, @@ -387,40 +387,40 @@ public: CompareData::~CompareData() { - if( pDelRing ) + if( m_pDelRing ) { - while( pDelRing->GetNext() != pDelRing.get() ) - delete pDelRing->GetNext(); - pDelRing.reset(); + while( m_pDelRing->GetNext() != m_pDelRing.get() ) + delete m_pDelRing->GetNext(); + m_pDelRing.reset(); } - if( pInsRing ) + if( m_pInsertRing ) { - while( pInsRing->GetNext() != pInsRing.get() ) - delete pInsRing->GetNext(); - pInsRing.reset(); + while( m_pInsertRing->GetNext() != m_pInsertRing.get() ) + delete m_pInsertRing->GetNext(); + m_pInsertRing.reset(); } } void CompareData::SetIndex( size_t nLine, size_t nIndex ) { - if( !pIndex ) + if( !m_pIndex ) { - pIndex.reset( new size_t[ aLines.size() ] ); - memset( pIndex.get(), 0, aLines.size() * sizeof( size_t ) ); + m_pIndex.reset( new size_t[ m_aLines.size() ] ); + memset( m_pIndex.get(), 0, m_aLines.size() * sizeof( size_t ) ); } - if( nLine < aLines.size() ) - pIndex[ nLine ] = nIndex; + if( nLine < m_aLines.size() ) + m_pIndex[ nLine ] = nIndex; } void CompareData::SetChanged( size_t nLine, bool bFlag ) { - if( !pChangedFlag ) + if( !m_pChangedFlag ) { - pChangedFlag.reset( new bool[ aLines.size() +1 ] ); - memset( pChangedFlag.get(), 0, (aLines.size() +1) * sizeof( bool ) ); + m_pChangedFlag.reset( new bool[ m_aLines.size() +1 ] ); + memset( m_pChangedFlag.get(), 0, (m_aLines.size() +1) * sizeof( bool ) ); } - if( nLine < aLines.size() ) - pChangedFlag[ nLine ] = bFlag; + if( nLine < m_aLines.size() ) + m_pChangedFlag[ nLine ] = bFlag; } void CompareData::CompareLines( CompareData& rData ) @@ -490,7 +490,7 @@ bool CompareData::HasDiffs( const CompareData& rData ) const } Hash::Hash( sal_uLong nSize ) - : nCount(1) + : m_nCount(1) { static const sal_uLong primes[] = @@ -522,26 +522,26 @@ Hash::Hash( sal_uLong nSize ) }; int i; - pDataArr.reset( new HashData[ nSize ] ); - pDataArr[0].nNext = 0; - pDataArr[0].nHash = 0; - pDataArr[0].pLine = nullptr; - nPrime = primes[0]; + m_pDataArr.reset( new HashData[ nSize ] ); + m_pDataArr[0].nNext = 0; + m_pDataArr[0].nHash = 0; + m_pDataArr[0].pLine = nullptr; + m_nPrime = primes[0]; for( i = 0; primes[i] < nSize / 3; i++) if( !primes[i] ) { - pHashArr = nullptr; + m_pHashArr = nullptr; return; } - nPrime = primes[ i ]; - pHashArr.reset( new sal_uLong[ nPrime ] ); - memset( pHashArr.get(), 0, nPrime * sizeof( sal_uLong ) ); + m_nPrime = primes[ i ]; + m_pHashArr.reset( new sal_uLong[ m_nPrime ] ); + memset( m_pHashArr.get(), 0, m_nPrime * sizeof( sal_uLong ) ); } void Hash::CalcHashValue( CompareData& rData ) { - if( pHashArr ) + if( m_pHashArr ) { for( size_t n = 0; n < rData.GetLineCount(); ++n ) { @@ -549,20 +549,20 @@ void Hash::CalcHashValue( CompareData& rData ) OSL_ENSURE( pLine, "where is the line?" ); sal_uLong nH = pLine->GetHashValue(); - sal_uLong* pFound = &pHashArr[ nH % nPrime ]; + sal_uLong* pFound = &m_pHashArr[ nH % m_nPrime ]; size_t i; - for( i = *pFound; ; i = pDataArr[i].nNext ) + for( i = *pFound; ; i = m_pDataArr[i].nNext ) if( !i ) { - i = nCount++; - pDataArr[i].nNext = *pFound; - pDataArr[i].nHash = nH; - pDataArr[i].pLine = pLine; + i = m_nCount++; + m_pDataArr[i].nNext = *pFound; + m_pDataArr[i].nHash = nH; + m_pDataArr[i].pLine = pLine; *pFound = i; break; } - else if( pDataArr[i].nHash == nH && - pDataArr[i].pLine->Compare( *pLine )) + else if( m_pDataArr[i].nHash == nH && + m_pDataArr[i].pLine->Compare( *pLine )) break; rData.SetIndex( n, i ); @@ -753,7 +753,7 @@ void Compare::CheckDiscard( sal_uLong nLen, char* pDiscard ) } Compare::MovedData::MovedData( CompareData& rData, const char* pDiscard ) - : nCount( 0 ) + : m_nCount( 0 ) { sal_uLong nLen = rData.GetLineCount(); sal_uLong n; @@ -762,18 +762,18 @@ Compare::MovedData::MovedData( CompareData& rData, const char* pDiscard ) if( pDiscard[ n ] ) rData.SetChanged( n ); else - ++nCount; + ++m_nCount; - if( nCount ) + if( m_nCount ) { - pIndex.reset( new sal_uLong[ nCount ] ); - pLineNum.reset( new sal_uLong[ nCount ] ); + m_pIndex.reset( new sal_uLong[ m_nCount ] ); + m_pLineNum.reset( new sal_uLong[ m_nCount ] ); - for( n = 0, nCount = 0; n < nLen; ++n ) + for( n = 0, m_nCount = 0; n < nLen; ++n ) if( !pDiscard[ n ] ) { - pIndex[ nCount ] = rData.GetIndex( n ); - pLineNum[ nCount++ ] = n; + m_pIndex[ m_nCount ] = rData.GetIndex( n ); + m_pLineNum[ m_nCount++ ] = n; } } } @@ -1436,8 +1436,8 @@ sal_uLong CompareData::PrevIdx( const SwNode* pNd ) void CompareData::CheckRanges( CompareData& rData ) { - const SwNodes& rSrcNds = rData.rDoc.GetNodes(); - const SwNodes& rDstNds = rDoc.GetNodes(); + const SwNodes& rSrcNds = rData.m_rDoc.GetNodes(); + const SwNodes& rDstNds = m_rDoc.GetNodes(); const SwNode& rSrcEndNd = rData.GetEndOfContent(); const SwNode& rDstEndNd = GetEndOfContent(); @@ -1491,9 +1491,9 @@ void CompareData::ShowInsert( sal_uLong nStt, sal_uLong nEnd ) { SwPaM* pTmp = new SwPaM( GetLine( nStt )->GetNode(), 0, GetLine( nEnd-1 )->GetEndNode(), 0, - pInsRing.get() ); - if( !pInsRing ) - pInsRing.reset( pTmp ); + m_pInsertRing.get() ); + if( !m_pInsertRing ) + m_pInsertRing.reset( pTmp ); // #i65201#: These SwPaMs are calculated smaller than needed, see comment below } @@ -1538,8 +1538,8 @@ void CompareData::ShowDelete( SwNodeIndex aInsPos( *pLineNd, nOffset ); SwNodeIndex aSavePos( aInsPos, -1 ); - rData.rDoc.GetDocumentContentOperationsManager().CopyWithFlyInFly(aRg, aInsPos); - rDoc.getIDocumentState().SetModified(); + rData.m_rDoc.GetDocumentContentOperationsManager().CopyWithFlyInFly(aRg, aInsPos); + m_rDoc.getIDocumentState().SetModified(); ++aSavePos; // #i65201#: These SwPaMs are calculated when the (old) delete-redlines are hidden, @@ -1547,13 +1547,13 @@ void CompareData::ShowDelete( // To avoid unwanted insertions of delete-redlines into these new redlines, what happens // especially at the end of the document, I reduce the SwPaM by one node. // Before the new redlines are inserted, they have to expand again. - SwPaM* pTmp = new SwPaM( aSavePos.GetNode(), aInsPos.GetNode(), 0, -1, pDelRing.get() ); - if( !pDelRing ) - pDelRing.reset(pTmp); + SwPaM* pTmp = new SwPaM( aSavePos.GetNode(), aInsPos.GetNode(), 0, -1, m_pDelRing.get() ); + if( !m_pDelRing ) + m_pDelRing.reset(pTmp); - if( pInsRing ) + if( m_pInsertRing ) { - SwPaM* pCorr = pInsRing->GetPrev(); + SwPaM* pCorr = m_pInsertRing->GetPrev(); if( *pCorr->GetPoint() == *pTmp->GetPoint() ) { SwNodeIndex aTmpPos( pTmp->GetMark()->nNode, -1 ); @@ -1593,7 +1593,7 @@ void CompareData::CheckForChangesInLine( const CompareData& rData, // Show differences in detail for lines that // were matched as only slightly different - if( !pDstLn->ChangesInLine( *pSrcLn, pInsRing, pDelRing ) ) + if( !pDstLn->ChangesInLine( *pSrcLn, m_pInsertRing, m_pDelRing ) ) { ShowInsert( nThisStt + nDstFrom - 1, nThisStt + nDstFrom ); ShowDelete( rData, nStt + nSrcFrom - 1, nStt + nSrcFrom, @@ -1617,12 +1617,12 @@ void CompareData::CheckForChangesInLine( const CompareData& rData, void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) { - SwPaM* pTmp = pDelRing.get(); + SwPaM* pTmp = m_pDelRing.get(); // get the Author / TimeStamp from the "other" document info - std::size_t nAuthor = rDoc.getIDocumentRedlineAccess().GetRedlineAuthor(); + std::size_t nAuthor = m_rDoc.getIDocumentRedlineAccess().GetRedlineAuthor(); DateTime aTimeStamp( DateTime::SYSTEM ); - SwDocShell *pDocShell(rDoc.GetDocShell()); + SwDocShell *pDocShell(m_rDoc.GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); if (pDocShell) { uno::Reference<document::XDocumentPropertiesSupplier> xDPS( @@ -1641,7 +1641,7 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) if( !aTmp.isEmpty() ) { - nAuthor = rDoc.getIDocumentRedlineAccess().InsertRedlineAuthor( aTmp ); + nAuthor = m_rDoc.getIDocumentRedlineAccess().InsertRedlineAuthor( aTmp ); aTimeStamp = DateTime(uDT); } } @@ -1680,19 +1680,19 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) } } - rDoc.getIDocumentRedlineAccess().DeleteRedline( *pTmp, false, RedlineType::Any ); + m_rDoc.getIDocumentRedlineAccess().DeleteRedline( *pTmp, false, RedlineType::Any ); - if (rDoc.GetIDocumentUndoRedo().DoesUndo()) + if (m_rDoc.GetIDocumentUndoRedo().DoesUndo()) { - rDoc.GetIDocumentUndoRedo().AppendUndo( + m_rDoc.GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoCompDoc>( *pTmp, false )); } - rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( aRedlnData, *pTmp ), true ); + m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( aRedlnData, *pTmp ), true ); - } while( pDelRing.get() != ( pTmp = pTmp->GetNext()) ); + } while( m_pDelRing.get() != ( pTmp = pTmp->GetNext()) ); } - pTmp = pInsRing.get(); + pTmp = m_pInsertRing.get(); if( pTmp ) { do { @@ -1722,12 +1722,12 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) } } } - } while( pInsRing.get() != ( pTmp = pTmp->GetNext()) ); + } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) ); SwRedlineData aRedlnData( RedlineType::Insert, nAuthor, aTimeStamp, OUString(), nullptr ); // combine consecutive - if( pTmp->GetNext() != pInsRing.get() ) + if( pTmp->GetNext() != m_pInsertRing.get() ) { do { SwPosition& rSttEnd = *pTmp->End(), @@ -1739,12 +1739,12 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) nullptr != ( pCNd = rSttEnd.nNode.GetNode().GetContentNode() ) && rSttEnd.nContent.GetIndex() == pCNd->Len())) { - if( pTmp->GetNext() == pInsRing.get() ) + if( pTmp->GetNext() == m_pInsertRing.get() ) { // are consecutive, so combine rEndStt = *pTmp->Start(); delete pTmp; - pTmp = pInsRing.get(); + pTmp = m_pInsertRing.get(); } else { @@ -1755,19 +1755,19 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) } else pTmp = pTmp->GetNext(); - } while( pInsRing.get() != pTmp ); + } while( m_pInsertRing.get() != pTmp ); } do { if (IDocumentRedlineAccess::AppendResult::APPENDED == - rDoc.getIDocumentRedlineAccess().AppendRedline( + m_rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(aRedlnData, *pTmp), true) && - rDoc.GetIDocumentUndoRedo().DoesUndo()) + m_rDoc.GetIDocumentUndoRedo().DoesUndo()) { - rDoc.GetIDocumentUndoRedo().AppendUndo( + m_rDoc.GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoCompDoc>( *pTmp, true )); } - } while( pInsRing.get() != ( pTmp = pTmp->GetNext()) ); + } while( m_pInsertRing.get() != ( pTmp = pTmp->GetNext()) ); } } @@ -2434,11 +2434,11 @@ int CommonSubseq::IgnoreIsolatedPieces( int *pLcs1, int *pLcs2, int nLen1, LgstCommonSubseq::LgstCommonSubseq( ArrayComparator &rComparator ) : CommonSubseq( rComparator, CUTOFF ) { - pBuff1.reset( new int[ rComparator.GetLen2() + 1 ] ); - pBuff2.reset( new int[ rComparator.GetLen2() + 1 ] ); + m_pBuff1.reset( new int[ rComparator.GetLen2() + 1 ] ); + m_pBuff2.reset( new int[ rComparator.GetLen2() + 1 ] ); - pL1.reset( new int[ rComparator.GetLen2() + 1 ] ); - pL2.reset( new int[ rComparator.GetLen2() + 1 ] ); + m_pL1.reset( new int[ rComparator.GetLen2() + 1 ] ); + m_pL2.reset( new int[ rComparator.GetLen2() + 1 ] ); } void LgstCommonSubseq::FindL( int *pL, int nStt1, int nEnd1, @@ -2447,8 +2447,8 @@ void LgstCommonSubseq::FindL( int *pL, int nStt1, int nEnd1, int nLen1 = nEnd1 ? nEnd1 - nStt1 : m_rComparator.GetLen1(); int nLen2 = nEnd2 ? nEnd2 - nStt2 : m_rComparator.GetLen2(); - int *currL = pBuff1.get(); - int *prevL = pBuff2.get(); + int *currL = m_pBuff1.get(); + int *prevL = m_pBuff2.get(); // Avoid memory corruption if( nLen2 > m_rComparator.GetLen2() ) @@ -2457,8 +2457,8 @@ void LgstCommonSubseq::FindL( int *pL, int nStt1, int nEnd1, return; } - memset( pBuff1.get(), 0, sizeof( pBuff1[0] ) * ( nLen2 + 1 ) ); - memset( pBuff2.get(), 0, sizeof( pBuff2[0] ) * ( nLen2 + 1 ) ); + memset( m_pBuff1.get(), 0, sizeof( m_pBuff1[0] ) * ( nLen2 + 1 ) ); + memset( m_pBuff2.get(), 0, sizeof( m_pBuff2[0] ) * ( nLen2 + 1 ) ); // Find lcs for( int i = 1; i <= nLen1; i++ ) @@ -2496,8 +2496,8 @@ int LgstCommonSubseq::HirschbergLCS( int *pLcs1, int *pLcs2, int nStt1, int nMid = nLen1/2; - FindL( pL1.get(), nStt1, nStt1 + nMid, nStt2, nEnd2 ); - FindL( pL2.get(), nStt1 + nMid, nEnd1, nStt2, nEnd2 ); + FindL( m_pL1.get(), nStt1, nStt1 + nMid, nStt2, nEnd2 ); + FindL( m_pL2.get(), nStt1 + nMid, nEnd1, nStt2, nEnd2 ); int nMaxPos = 0; static int nMaxVal; @@ -2506,10 +2506,10 @@ int LgstCommonSubseq::HirschbergLCS( int *pLcs1, int *pLcs2, int nStt1, static int i; for( i = 0; i <= nLen2; i++ ) { - if( pL1[i] + ( pL2[nLen2] - pL2[i] ) > nMaxVal ) + if( m_pL1[i] + ( m_pL2[nLen2] - m_pL2[i] ) > nMaxVal ) { nMaxPos = i; - nMaxVal = pL1[i]+( pL2[nLen2] - pL2[i] ); + nMaxVal = m_pL1[i]+( m_pL2[nLen2] - m_pL2[i] ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits