summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorAttila Szűcs <attila.szucs@collabora.com>2023-10-17 09:31:22 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-10-29 19:30:43 +0100
commite4fb4937b3f75ce3544f8de354ed92f7dd314511 (patch)
tree680dc5473643210c9afbd467c446cd2ea59f8477 /sw/inc
parent81f36caea6acd3042d42625940a9396305f5569c (diff)
tdf#157663 SW: Tracked change improve move
Made accept/reject handle move redlines other pair, (moveto-movefrom) and handle the whole move redline, even if it is split into small pieces that separated from each other. Added unique ID to every move redline to help find their other parts. This move ID is generated in case of: move recognition moveing a paragraph. (directly create move redline with unique id without calling the recognition it is faster and more stable) (there are other cases that could be improved to not use recognition, but generate ID directly, like moveing selected partial text with mouse) Implemented the odt export/import of this move ID. it is a tag like this: "<loext:move-id>4</loext:move-id>" next to creator/date Improved the docx import to generate this move ID, so move redlines can find their other parts (Not changed Docx export... it works a bit, but far from perfect) Improved move reckognition: It can find them even if they are split into multiple parts differently. (like "ab"+"cd" == "a"+"bcd") Disabled this because of probably performance issue. made a complex unit test for it. Note: Left the move recognition on every place, to avoid as much regressions as possible.. but in the future, we may can disable it in some cases. Note2: We will have to keep move recognitnion, because there are documents from past, saved without any move informations in the file, and users expect to see move redlines there. (generated by the recognition.) Change-Id: If968d4235b676c5e538cfaf4187a4482a86eae9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157740 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158611 Tested-by: Jenkins
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/IDocumentContentOperations.hxx2
-rw-r--r--sw/inc/crsrsh.hxx2
-rw-r--r--sw/inc/docary.hxx8
-rw-r--r--sw/inc/redline.hxx21
-rw-r--r--sw/inc/unoprnms.hxx1
5 files changed, 23 insertions, 11 deletions
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index 43e2c8492d51..eafc586886c2 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -132,7 +132,7 @@ public:
rPam. If false, then no such check will be performed, and it is assumed
that the caller took care of verifying this constraint already.
*/
- virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, SwCopyFlags flags) const = 0;
+ virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, SwCopyFlags flags, sal_uInt32 nMovedID = 0) const = 0;
/** Delete section containing the node.
*/
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index fd28607c5e32..20636648c794 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -166,7 +166,7 @@ public:
READONLY = (1 << 3) ///< make visible in spite of Readonly
};
- SAL_DLLPRIVATE void UpdateCursor(
+ void UpdateCursor(
sal_uInt16 eFlags = SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE,
bool bIdleEnd = false );
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 64f251957a06..6f2c2c3c3284 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -227,6 +227,7 @@ private:
/// Sometimes we load bad data, and we need to know if we can use
/// fast binary search, or if we have to fall back to a linear search
bool m_bHasOverlappingElements = false;
+ mutable sal_uInt32 m_nMaxMovedID = 1; //every move-redline pair get a unique ID, so they can find each other.
public:
~SwRedlineTable();
bool Contains(const SwRangeRedline* p) const { return maVector.find(const_cast<SwRangeRedline*>(p)) != maVector.end(); }
@@ -263,6 +264,13 @@ public:
// is there a redline with the same text content from the same author (near the redline),
// but with the opposite type (Insert or Delete). It's used to recognize tracked text moving.
bool isMoved(size_type tableIndex) const;
+ bool isMovedImpl(size_type tableIndex, bool bTryCombined) const;
+ sal_uInt32 getNewMovedID() const { return ++m_nMaxMovedID; }
+ void setMovedIDIfNeeded(sal_uInt32 nMax);
+ void getConnectedArea(size_type nPosOrigin, size_type& rPosStart, size_type& rPosEnd,
+ bool bCheckChilds) const;
+ OUString getTextOfArea(size_type rPosStart, size_type rPosEnd) const;
+
bool empty() const { return maVector.empty(); }
size_type size() const { return maVector.size(); }
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index d8eba6480618..a82c785ee58f 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -95,14 +95,14 @@ class SW_DLLPUBLIC SwRedlineData
RedlineType m_eType;
sal_uInt16 m_nSeqNo;
bool m_bAutoFormat;
- bool m_bMoved;
+ sal_uInt32 m_nMovedID; // 0 == not moved, 1 == moved, but dont have its pair, 2+ == unique ID
public:
- SwRedlineData( RedlineType eT, std::size_t nAut );
+ SwRedlineData( RedlineType eT, std::size_t nAut, sal_uInt32 nMoveID = 0 );
SwRedlineData( const SwRedlineData& rCpy, bool bCpyNext = true );
// For sw3io: pNext/pExtraData are taken over.
- SwRedlineData( RedlineType eT, std::size_t nAut, const DateTime& rDT,
+ SwRedlineData( RedlineType eT, std::size_t nAut, const DateTime& rDT, sal_uInt32 nMovedID,
OUString aCmnt, SwRedlineData* pNxt );
~SwRedlineData();
@@ -112,7 +112,7 @@ public:
return m_nAuthor == rCmp.m_nAuthor &&
m_eType == rCmp.m_eType &&
m_bAutoFormat == rCmp.m_bAutoFormat &&
- m_bMoved == rCmp.m_bMoved &&
+ m_nMovedID == rCmp.m_nMovedID &&
m_sComment == rCmp.m_sComment &&
(( !m_pNext && !rCmp.m_pNext ) ||
( m_pNext && rCmp.m_pNext && *m_pNext == *rCmp.m_pNext )) &&
@@ -141,8 +141,9 @@ public:
void SetAutoFormat() { m_bAutoFormat = true; }
bool IsAutoFormat() const { return m_bAutoFormat; }
- void SetMoved() { m_bMoved = true; }
- bool IsMoved() const { return m_bMoved; }
+ void SetMoved( sal_uInt32 nMoveID ) { m_nMovedID = nMoveID; }
+ sal_uInt32 GetMoved() const { return m_nMovedID; }
+ bool IsMoved() const { return m_nMovedID != 0; }
bool CanCombine( const SwRedlineData& rCmp ) const;
bool CanCombineForAcceptReject( const SwRedlineData& rCmp ) const;
@@ -179,7 +180,7 @@ class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
public:
static sal_uInt32 s_nLastId;
- SwRangeRedline( RedlineType eType, const SwPaM& rPam );
+ SwRangeRedline( RedlineType eType, const SwPaM& rPam, sal_uInt32 nMoveID = 0 );
SwRangeRedline( const SwRedlineData& rData, const SwPaM& rPam );
SwRangeRedline( const SwRedlineData& rData, const SwPosition& rPos );
// For sw3io: pData is taken over!
@@ -218,7 +219,8 @@ public:
sal_uInt16 GetStackCount() const;
std::size_t GetAuthor( sal_uInt16 nPos = 0) const;
OUString const & GetAuthorString( sal_uInt16 nPos = 0 ) const;
- const DateTime& GetTimeStamp( sal_uInt16 nPos = 0) const;
+ sal_uInt32 GetMovedID(sal_uInt16 nPos = 0) const;
+ const DateTime& GetTimeStamp(sal_uInt16 nPos = 0) const;
RedlineType GetType( sal_uInt16 nPos = 0 ) const;
// text content of the redline is only an annotation placeholder
// (i.e. a comment, but don't confuse it with comment of the redline)
@@ -282,8 +284,9 @@ public:
void MaybeNotifyRedlinePositionModification(tools::Long nTop);
- void SetMoved() { m_pRedlineData->SetMoved(); }
+ void SetMoved(sal_uInt32 nMoveID = 1) { m_pRedlineData->SetMoved(nMoveID); }
bool IsMoved() const { return m_pRedlineData->IsMoved(); }
+ sal_uInt32 GetMoved(sal_uInt16 nPos = 0) const { return GetRedlineData(nPos).GetMoved(); }
};
void MaybeNotifyRedlineModification(SwRangeRedline& rRedline, SwDoc& rDoc);
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index ca01d55e7803..1ab2395fa67d 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -580,6 +580,7 @@ inline constexpr OUString UNO_NAME_GRAPHIC_IS_INVERTED = u"GraphicIsInverted"_us
inline constexpr OUString UNO_NAME_TRANSPARENCY = u"Transparency"_ustr;
inline constexpr OUString UNO_NAME_REDLINE_AUTHOR = u"RedlineAuthor"_ustr;
inline constexpr OUString UNO_NAME_REDLINE_DATE_TIME = u"RedlineDateTime"_ustr;
+inline constexpr OUString UNO_NAME_REDLINE_MOVED_ID = u"RedlineMovedID"_ustr;
inline constexpr OUString UNO_NAME_REDLINE_COMMENT = u"RedlineComment"_ustr;
inline constexpr OUString UNO_NAME_REDLINE_DESCRIPTION = u"RedlineDescription"_ustr;
inline constexpr OUString UNO_NAME_REDLINE_TYPE = u"RedlineType"_ustr;