|
|
ebc4bd |
From b2b455b4258993a9982efb829b333df9905fe95c Mon Sep 17 00:00:00 2001
|
|
|
ebc4bd |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
|
ebc4bd |
Date: Tue, 13 Jan 2015 13:55:58 +0000
|
|
|
ebc4bd |
Subject: [PATCH] allow comparing documents which only differ by frame contents
|
|
|
ebc4bd |
|
|
|
ebc4bd |
if two documents have the same number of frames then have an additional stab at
|
|
|
ebc4bd |
comparing the contents of those frames
|
|
|
ebc4bd |
|
|
|
ebc4bd |
(cherry picked from commit 16916a14a2ce382aa4ff2a25f8e477108aba5a67)
|
|
|
ebc4bd |
|
|
|
ebc4bd |
Change-Id: Ib8ad2ba938da48a46c012961b00d81b2c386a368
|
|
|
ebc4bd |
---
|
|
|
ebc4bd |
sw/source/core/doc/doccomp.cxx | 238 +++++++++++++++++++++++++----------------
|
|
|
ebc4bd |
1 file changed, 146 insertions(+), 92 deletions(-)
|
|
|
ebc4bd |
|
|
|
ebc4bd |
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
|
|
|
ebc4bd |
index 3a6e4f3..210224f 100644
|
|
|
ebc4bd |
--- a/sw/source/core/doc/doccomp.cxx
|
|
|
ebc4bd |
+++ b/sw/source/core/doc/doccomp.cxx
|
|
|
ebc4bd |
@@ -35,6 +35,8 @@
|
|
|
ebc4bd |
#include <section.hxx>
|
|
|
ebc4bd |
#include <tox.hxx>
|
|
|
ebc4bd |
#include <docsh.hxx>
|
|
|
ebc4bd |
+#include <fmtcntnt.hxx>
|
|
|
ebc4bd |
+#include <boost/shared_ptr.hpp>
|
|
|
ebc4bd |
|
|
|
ebc4bd |
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
|
|
ebc4bd |
#include <com/sun/star/document/XDocumentProperties.hpp>
|
|
|
ebc4bd |
@@ -62,18 +63,32 @@ public:
|
|
|
ebc4bd |
|
|
|
ebc4bd |
class CompareData
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
+protected:
|
|
|
ebc4bd |
+ SwDoc& rDoc;
|
|
|
ebc4bd |
+private:
|
|
|
ebc4bd |
size_t* pIndex;
|
|
|
ebc4bd |
bool* pChangedFlag;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-protected:
|
|
|
ebc4bd |
+ SwPaM *pInsRing, *pDelRing;
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ sal_uLong PrevIdx( const SwNode* pNd );
|
|
|
ebc4bd |
+ sal_uLong NextIdx( const SwNode* pNd );
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
vector< CompareLine* > aLines;
|
|
|
ebc4bd |
sal_uLong nSttLineNum;
|
|
|
ebc4bd |
+ bool m_bRecordDiff;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
// Truncate beginning and end and add all others to the LinesArray
|
|
|
ebc4bd |
- virtual void CheckRanges( CompareData& ) = 0;
|
|
|
ebc4bd |
+ void CheckRanges( CompareData& );
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ virtual const SwNode& GetEndOfContent() = 0;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
public:
|
|
|
ebc4bd |
- CompareData();
|
|
|
ebc4bd |
+ CompareData(SwDoc& rD, bool bRecordDiff)
|
|
|
ebc4bd |
+ : rDoc( rD ), pIndex( 0 ), pChangedFlag( 0 ), pInsRing(0), pDelRing(0)
|
|
|
ebc4bd |
+ , nSttLineNum( 0 ), m_bRecordDiff(bRecordDiff)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
virtual ~CompareData();
|
|
|
ebc4bd |
|
|
|
ebc4bd |
// Are there differences?
|
|
|
ebc4bd |
@@ -86,10 +101,10 @@ public:
|
|
|
ebc4bd |
// Displaying the actually content is to be handled by the subclass!
|
|
|
ebc4bd |
sal_uLong ShowDiffs( const CompareData& rData );
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- virtual void ShowInsert( sal_uLong nStt, sal_uLong nEnd );
|
|
|
ebc4bd |
- virtual void ShowDelete( const CompareData& rData, sal_uLong nStt,
|
|
|
ebc4bd |
+ void ShowInsert( sal_uLong nStt, sal_uLong nEnd );
|
|
|
ebc4bd |
+ void ShowDelete( const CompareData& rData, sal_uLong nStt,
|
|
|
ebc4bd |
sal_uLong nEnd, sal_uLong nInsPos );
|
|
|
ebc4bd |
- virtual void CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
+ void CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
sal_uLong& nStt, sal_uLong& nEnd,
|
|
|
ebc4bd |
sal_uLong& nThisStt, sal_uLong& nThisEnd );
|
|
|
ebc4bd |
|
|
|
ebc4bd |
@@ -111,6 +126,38 @@ public:
|
|
|
ebc4bd |
{ return aLines[ nLine ]; }
|
|
|
ebc4bd |
void InsertLine( CompareLine* pLine )
|
|
|
ebc4bd |
{ aLines.push_back( pLine ); }
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ void SetRedlinesToDoc( bool bUseDocInfo );
|
|
|
ebc4bd |
+};
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+class CompareMainText : public CompareData
|
|
|
ebc4bd |
+{
|
|
|
ebc4bd |
+public:
|
|
|
ebc4bd |
+ CompareMainText(SwDoc &rD, bool bRecordDiff=true)
|
|
|
ebc4bd |
+ : CompareData(rD, bRecordDiff)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ virtual const SwNode& GetEndOfContent() SAL_OVERRIDE
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ return rDoc.GetNodes().GetEndOfContent();
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+};
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+class CompareFrmFmtText : public CompareData
|
|
|
ebc4bd |
+{
|
|
|
ebc4bd |
+ const SwNodeIndex &m_rIndex;
|
|
|
ebc4bd |
+public:
|
|
|
ebc4bd |
+ CompareFrmFmtText(SwDoc &rD, const SwNodeIndex &rIndex, bool bRecordDiff=true)
|
|
|
ebc4bd |
+ : CompareData(rD, bRecordDiff)
|
|
|
ebc4bd |
+ , m_rIndex(rIndex)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ virtual const SwNode& GetEndOfContent() SAL_OVERRIDE
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ return *m_rIndex.GetNode().EndOfSectionNode();
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
};
|
|
|
ebc4bd |
|
|
|
ebc4bd |
class Hash
|
|
|
ebc4bd |
@@ -325,13 +372,21 @@ public:
|
|
|
ebc4bd |
|
|
|
ebc4bd |
CompareLine::~CompareLine() {}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-CompareData::CompareData()
|
|
|
ebc4bd |
- : pIndex( 0 ), pChangedFlag( 0 ), nSttLineNum( 0 )
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
-}
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
CompareData::~CompareData()
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
+ if( pDelRing )
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ while( pDelRing->GetNext() != pDelRing )
|
|
|
ebc4bd |
+ delete pDelRing->GetNext();
|
|
|
ebc4bd |
+ delete pDelRing;
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+ if( pInsRing )
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ while( pInsRing->GetNext() != pInsRing )
|
|
|
ebc4bd |
+ delete pInsRing->GetNext();
|
|
|
ebc4bd |
+ delete pInsRing;
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
delete[] pIndex;
|
|
|
ebc4bd |
delete[] pChangedFlag;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
@@ -390,9 +445,12 @@ sal_uLong CompareData::ShowDiffs( const CompareData& rData )
|
|
|
ebc4bd |
while( nStt1 < nLen1 && rData.GetChanged( nStt1 )) ++nStt1;
|
|
|
ebc4bd |
while( nStt2 < nLen2 && GetChanged( nStt2 )) ++nStt2;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- // Check if there are changed lines (only slightly different) and
|
|
|
ebc4bd |
- // compare them in detail.
|
|
|
ebc4bd |
- CheckForChangesInLine( rData, nSav1, nStt1, nSav2, nStt2 );
|
|
|
ebc4bd |
+ if (m_bRecordDiff)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ // Check if there are changed lines (only slightly different) and
|
|
|
ebc4bd |
+ // compare them in detail.
|
|
|
ebc4bd |
+ CheckForChangesInLine( rData, nSav1, nStt1, nSav2, nStt2 );
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
|
|
|
ebc4bd |
++nCnt;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
@@ -419,19 +477,6 @@ bool CompareData::HasDiffs( const CompareData& rData ) const
|
|
|
ebc4bd |
return bRet;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void CompareData::ShowInsert( sal_uLong, sal_uLong )
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
-}
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
-void CompareData::ShowDelete( const CompareData&, sal_uLong, sal_uLong, sal_uLong )
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
-}
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
-void CompareData::CheckForChangesInLine( const CompareData& ,
|
|
|
ebc4bd |
- sal_uLong&, sal_uLong&, sal_uLong&, sal_uLong& )
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
-}
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
Hash::Hash( sal_uLong nSize )
|
|
|
ebc4bd |
: nCount(1)
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -969,30 +1014,6 @@ public:
|
|
|
ebc4bd |
OUString GetText() const;
|
|
|
ebc4bd |
};
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-class SwCompareData : public CompareData
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
- SwDoc& rDoc;
|
|
|
ebc4bd |
- SwPaM *pInsRing, *pDelRing;
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
- sal_uLong PrevIdx( const SwNode* pNd );
|
|
|
ebc4bd |
- sal_uLong NextIdx( const SwNode* pNd );
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
- virtual void CheckRanges( CompareData& ) SAL_OVERRIDE;
|
|
|
ebc4bd |
- virtual void ShowInsert( sal_uLong nStt, sal_uLong nEnd ) SAL_OVERRIDE;
|
|
|
ebc4bd |
- virtual void ShowDelete( const CompareData& rData, sal_uLong nStt,
|
|
|
ebc4bd |
- sal_uLong nEnd, sal_uLong nInsPos ) SAL_OVERRIDE;
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
- virtual void CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
- sal_uLong& nStt, sal_uLong& nEnd,
|
|
|
ebc4bd |
- sal_uLong& nThisStt, sal_uLong& nThisEnd ) SAL_OVERRIDE;
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
-public:
|
|
|
ebc4bd |
- SwCompareData( SwDoc& rD ) : rDoc( rD ), pInsRing(0), pDelRing(0) {}
|
|
|
ebc4bd |
- virtual ~SwCompareData();
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
- void SetRedlinesToDoc( bool bUseDocInfo );
|
|
|
ebc4bd |
-};
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
SwCompareLine::SwCompareLine( const SwNode& rNd )
|
|
|
ebc4bd |
: rNode( rNd )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -1397,23 +1418,7 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
|
|
|
ebc4bd |
return bRet;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-SwCompareData::~SwCompareData()
|
|
|
ebc4bd |
-{
|
|
|
ebc4bd |
- if( pDelRing )
|
|
|
ebc4bd |
- {
|
|
|
ebc4bd |
- while( pDelRing->GetNext() != pDelRing )
|
|
|
ebc4bd |
- delete pDelRing->GetNext();
|
|
|
ebc4bd |
- delete pDelRing;
|
|
|
ebc4bd |
- }
|
|
|
ebc4bd |
- if( pInsRing )
|
|
|
ebc4bd |
- {
|
|
|
ebc4bd |
- while( pInsRing->GetNext() != pInsRing )
|
|
|
ebc4bd |
- delete pInsRing->GetNext();
|
|
|
ebc4bd |
- delete pInsRing;
|
|
|
ebc4bd |
- }
|
|
|
ebc4bd |
-}
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
-sal_uLong SwCompareData::NextIdx( const SwNode* pNd )
|
|
|
ebc4bd |
+sal_uLong CompareData::NextIdx( const SwNode* pNd )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
if( pNd->IsStartNode() )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -1427,7 +1432,7 @@ sal_uLong SwCompareData::NextIdx( const SwNode* pNd )
|
|
|
ebc4bd |
return pNd->GetIndex() + 1;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-sal_uLong SwCompareData::PrevIdx( const SwNode* pNd )
|
|
|
ebc4bd |
+sal_uLong CompareData::PrevIdx( const SwNode* pNd )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
if( pNd->IsEndNode() )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -1441,13 +1446,13 @@ sal_uLong SwCompareData::PrevIdx( const SwNode* pNd )
|
|
|
ebc4bd |
return pNd->GetIndex() - 1;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void SwCompareData::CheckRanges( CompareData& rData )
|
|
|
ebc4bd |
+void CompareData::CheckRanges( CompareData& rData )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
- const SwNodes& rSrcNds = ((SwCompareData&)rData).rDoc.GetNodes();
|
|
|
ebc4bd |
+ const SwNodes& rSrcNds = rData.rDoc.GetNodes();
|
|
|
ebc4bd |
const SwNodes& rDstNds = rDoc.GetNodes();
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- const SwNode& rSrcEndNd = rSrcNds.GetEndOfContent();
|
|
|
ebc4bd |
- const SwNode& rDstEndNd = rDstNds.GetEndOfContent();
|
|
|
ebc4bd |
+ const SwNode& rSrcEndNd = rData.GetEndOfContent();
|
|
|
ebc4bd |
+ const SwNode& rDstEndNd = GetEndOfContent();
|
|
|
ebc4bd |
|
|
|
ebc4bd |
sal_uLong nSrcSttIdx = NextIdx( rSrcEndNd.StartOfSectionNode() );
|
|
|
ebc4bd |
sal_uLong nSrcEndIdx = rSrcEndNd.GetIndex();
|
|
|
ebc4bd |
@@ -1494,7 +1499,7 @@ void SwCompareData::CheckRanges( CompareData& rData )
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void SwCompareData::ShowInsert( sal_uLong nStt, sal_uLong nEnd )
|
|
|
ebc4bd |
+void CompareData::ShowInsert( sal_uLong nStt, sal_uLong nEnd )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
SwPaM* pTmp = new SwPaM( ((SwCompareLine*)GetLine( nStt ))->GetNode(), 0,
|
|
|
ebc4bd |
((SwCompareLine*)GetLine( nEnd-1 ))->GetEndNode(), 0,
|
|
|
ebc4bd |
@@ -1505,7 +1510,7 @@ void SwCompareData::ShowInsert( sal_uLong nStt, sal_uLong nEnd )
|
|
|
ebc4bd |
// #i65201#: These SwPaMs are calculated smaller than needed, see comment below
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void SwCompareData::ShowDelete(
|
|
|
ebc4bd |
+void CompareData::ShowDelete(
|
|
|
ebc4bd |
const CompareData& rData,
|
|
|
ebc4bd |
sal_uLong nStt,
|
|
|
ebc4bd |
sal_uLong nEnd,
|
|
|
ebc4bd |
@@ -1538,14 +1543,14 @@ void SwCompareData::ShowDelete(
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
else
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
- pLineNd = &rDoc.GetNodes().GetEndOfContent();
|
|
|
ebc4bd |
+ pLineNd = &GetEndOfContent();
|
|
|
ebc4bd |
nOffset = 0;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
SwNodeIndex aInsPos( *pLineNd, nOffset );
|
|
|
ebc4bd |
SwNodeIndex aSavePos( aInsPos, -1 );
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, 0, aInsPos );
|
|
|
ebc4bd |
+ rData.rDoc.CopyWithFlyInFly( aRg, 0, aInsPos );
|
|
|
ebc4bd |
rDoc.SetModified();
|
|
|
ebc4bd |
++aSavePos;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
@@ -1569,7 +1574,7 @@ void SwCompareData::ShowDelete(
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void SwCompareData::CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
+void CompareData::CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
sal_uLong& rStt, sal_uLong& rEnd,
|
|
|
ebc4bd |
sal_uLong& rThisStt, sal_uLong& rThisEnd )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -1622,7 +1627,7 @@ void SwCompareData::CheckForChangesInLine( const CompareData& rData,
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
-void SwCompareData::SetRedlinesToDoc( bool bUseDocInfo )
|
|
|
ebc4bd |
+void CompareData::SetRedlinesToDoc( bool bUseDocInfo )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
SwPaM* pTmp = pDelRing;
|
|
|
ebc4bd |
|
|
|
ebc4bd |
@@ -1670,7 +1675,7 @@ void SwCompareData::SetRedlinesToDoc( bool bUseDocInfo )
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
// #i101009#
|
|
|
ebc4bd |
// prevent redlines that end on structural end node
|
|
|
ebc4bd |
- if (& rDoc.GetNodes().GetEndOfContent() ==
|
|
|
ebc4bd |
+ if (& GetEndOfContent() ==
|
|
|
ebc4bd |
& pTmp->GetPoint()->nNode.GetNode())
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
pTmp->GetPoint()->nNode--;
|
|
|
ebc4bd |
@@ -1702,7 +1707,7 @@ void SwCompareData::SetRedlinesToDoc( bool bUseDocInfo )
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
// #i101009#
|
|
|
ebc4bd |
// prevent redlines that end on structural end node
|
|
|
ebc4bd |
- if (& rDoc.GetNodes().GetEndOfContent() ==
|
|
|
ebc4bd |
+ if (& GetEndOfContent() ==
|
|
|
ebc4bd |
& pTmp->GetPoint()->nNode.GetNode())
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
pTmp->GetPoint()->nNode--;
|
|
|
ebc4bd |
@@ -1766,6 +1771,48 @@ static bool lcl_MergePortions(SwNode *const& pNode, void *)
|
|
|
ebc4bd |
return true;
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
+typedef boost::shared_ptr<CompareData> CompareDataPtr;
|
|
|
ebc4bd |
+typedef std::pair<CompareDataPtr, CompareDataPtr> CompareDataPtrPair;
|
|
|
ebc4bd |
+typedef std::vector<CompareDataPtrPair> Comparators;
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+namespace
|
|
|
ebc4bd |
+{
|
|
|
ebc4bd |
+ Comparators buildComparators(SwDoc &rSrcDoc, SwDoc &rDestDoc)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ Comparators aComparisons;
|
|
|
ebc4bd |
+ //compare main text
|
|
|
ebc4bd |
+ aComparisons.push_back(CompareDataPtrPair(CompareDataPtr(new CompareMainText(rSrcDoc)),
|
|
|
ebc4bd |
+ CompareDataPtr(new CompareMainText(rDestDoc))));
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
+ //if we have the same number of frames then try to compare within them
|
|
|
ebc4bd |
+ const SwFrmFmts *pSrcFrmFmts = rSrcDoc.GetSpzFrmFmts();
|
|
|
ebc4bd |
+ const SwFrmFmts *pDestFrmFmts = rDestDoc.GetSpzFrmFmts();
|
|
|
ebc4bd |
+ if (pSrcFrmFmts->size() == pDestFrmFmts->size())
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ for (size_t i = 0; i < pSrcFrmFmts->size(); ++i)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ const SwFrmFmt& rSrcFmt = *(*pSrcFrmFmts)[i];
|
|
|
ebc4bd |
+ const SwFrmFmt& rDestFmt = *(*pDestFrmFmts)[i];
|
|
|
ebc4bd |
+ const SwNodeIndex* pSrcIdx = rSrcFmt.GetCntnt().GetCntntIdx();
|
|
|
ebc4bd |
+ const SwNodeIndex* pDestIdx = rDestFmt.GetCntnt().GetCntntIdx();
|
|
|
ebc4bd |
+ if (!pSrcIdx && !pDestIdx)
|
|
|
ebc4bd |
+ continue;
|
|
|
ebc4bd |
+ if (!pSrcIdx || !pDestIdx)
|
|
|
ebc4bd |
+ break;
|
|
|
ebc4bd |
+ const SwNode* pSrcNode = pSrcIdx->GetNode().EndOfSectionNode();
|
|
|
ebc4bd |
+ const SwNode* pDestNode = pDestIdx->GetNode().EndOfSectionNode();
|
|
|
ebc4bd |
+ if (!pSrcNode && !pDestNode)
|
|
|
ebc4bd |
+ continue;
|
|
|
ebc4bd |
+ if (!pSrcNode || !pDestNode)
|
|
|
ebc4bd |
+ break;
|
|
|
ebc4bd |
+ aComparisons.push_back(CompareDataPtrPair(CompareDataPtr(new CompareFrmFmtText(rSrcDoc, *pSrcIdx)),
|
|
|
ebc4bd |
+ CompareDataPtr(new CompareFrmFmtText(rDestDoc, *pDestIdx))));
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+ return aComparisons;
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
+}
|
|
|
ebc4bd |
+
|
|
|
ebc4bd |
// Returns (the difference count?) if something is different
|
|
|
ebc4bd |
long SwDoc::CompareDoc( const SwDoc& rDoc )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
@@ -1808,19 +1855,28 @@ long SwDoc::CompareDoc( const SwDoc& rDoc )
|
|
|
ebc4bd |
rSrcDoc.SetRedlineMode( nsRedlineMode_t::REDLINE_SHOW_INSERT );
|
|
|
ebc4bd |
SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT));
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- SwCompareData aD0( rSrcDoc );
|
|
|
ebc4bd |
- SwCompareData aD1( *this );
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
- aD1.CompareLines( aD0 );
|
|
|
ebc4bd |
+ Comparators aComparisons(buildComparators(rSrcDoc, *this));
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- nRet = aD1.ShowDiffs( aD0 );
|
|
|
ebc4bd |
+ for (Comparators::iterator aIter = aComparisons.begin(); aIter != aComparisons.end(); ++aIter)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ CompareDataPtrPair& a = *aIter;
|
|
|
ebc4bd |
+ CompareData& rD0 = *a.first.get();
|
|
|
ebc4bd |
+ CompareData& rD1 = *a.second.get();
|
|
|
ebc4bd |
+ rD1.CompareLines( rD0 );
|
|
|
ebc4bd |
+ nRet |= rD1.ShowDiffs( rD0 );
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
|
|
|
ebc4bd |
if( nRet )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
- SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_ON |
|
|
|
ebc4bd |
+ SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_ON |
|
|
|
ebc4bd |
nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE));
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- aD1.SetRedlinesToDoc( !bDocWasModified );
|
|
|
ebc4bd |
+ for (Comparators::iterator aIter = aComparisons.begin(); aIter != aComparisons.end(); ++aIter)
|
|
|
ebc4bd |
+ {
|
|
|
ebc4bd |
+ CompareDataPtrPair& a = *aIter;
|
|
|
ebc4bd |
+ CompareData& rD1 = *a.second.get();
|
|
|
ebc4bd |
+ rD1.SetRedlinesToDoc( !bDocWasModified );
|
|
|
ebc4bd |
+ }
|
|
|
ebc4bd |
SetModified();
|
|
|
ebc4bd |
}
|
|
|
ebc4bd |
|
|
|
ebc4bd |
@@ -2026,11 +2082,9 @@ long SwDoc::MergeDoc( const SwDoc& rDoc )
|
|
|
ebc4bd |
rSrcDoc.SetRedlineMode( nsRedlineMode_t::REDLINE_SHOW_DELETE );
|
|
|
ebc4bd |
SetRedlineMode( nsRedlineMode_t::REDLINE_SHOW_DELETE );
|
|
|
ebc4bd |
|
|
|
ebc4bd |
- SwCompareData aD0( rSrcDoc );
|
|
|
ebc4bd |
- SwCompareData aD1( *this );
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
+ CompareMainText aD0(rSrcDoc, false);
|
|
|
ebc4bd |
+ CompareMainText aD1(*this, false);
|
|
|
ebc4bd |
aD1.CompareLines( aD0 );
|
|
|
ebc4bd |
-
|
|
|
ebc4bd |
if( !aD1.HasDiffs( aD0 ) )
|
|
|
ebc4bd |
{
|
|
|
ebc4bd |
// we want to get all redlines from the SourceDoc
|
|
|
ebc4bd |
--
|
|
|
ebc4bd |
1.9.3
|
|
|
ebc4bd |
|