diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2023-10-17 09:31:22 +0200 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-29 19:30:43 +0100 |
commit | e4fb4937b3f75ce3544f8de354ed92f7dd314511 (patch) | |
tree | 680dc5473643210c9afbd467c446cd2ea59f8477 /writerfilter | |
parent | 81f36caea6acd3042d42625940a9396305f5569c (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 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 45 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 4 |
2 files changed, 48 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 24071c73d1ea..ae121ea2b2d3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -344,6 +344,7 @@ DomainMapper_Impl::DomainMapper_Impl( m_nStartGenericField(0), m_bTextInserted(false), m_bTextDeleted(false), + m_nLastRedlineMovedID(1), m_sCurrentPermId(0), m_bFrameDirectionSet(false), m_bInDocDefaultsImport(false), @@ -3676,8 +3677,42 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR pRedlineProperties[1].Value <<= aDateTime; pRedlineProperties[2].Name = getPropertyName( PROP_REDLINE_REVERT_PROPERTIES ); pRedlineProperties[2].Value <<= pRedline->m_aRevertProperties; + + sal_uInt32 nRedlineMovedID = 0; + if (bRedlineMoved) + { + if (!m_sCurrentBkmkId.isEmpty()) + { + nRedlineMovedID = 1; + BookmarkMap_t::iterator aBookmarkIter = m_aBookmarkMap.find(m_sCurrentBkmkId); + if (aBookmarkIter != m_aBookmarkMap.end()) + { + OUString sMoveID = aBookmarkIter->second.m_sBookmarkName; + auto aIter = m_aRedlineMoveIDs.end(); + + if (sMoveID.indexOf("__RefMoveFrom__") >= 0) + { + aIter = std::find(m_aRedlineMoveIDs.begin(), m_aRedlineMoveIDs.end(), + sMoveID.subView(15)); + } + else if (sMoveID.indexOf("__RefMoveTo__") >= 0) + { + aIter = std::find(m_aRedlineMoveIDs.begin(), m_aRedlineMoveIDs.end(), + sMoveID.subView(13)); + }; + + if (aIter != m_aRedlineMoveIDs.end()) + { + nRedlineMovedID = aIter - m_aRedlineMoveIDs.begin() + 2; + m_nLastRedlineMovedID = nRedlineMovedID; + } + } + } + else + nRedlineMovedID = m_nLastRedlineMovedID; + } pRedlineProperties[3].Name = "RedlineMoved"; - pRedlineProperties[3].Value <<= bRedlineMoved; + pRedlineProperties[3].Value <<= nRedlineMovedID; if (!m_bIsActualParagraphFramed) { @@ -8406,6 +8441,14 @@ void DomainMapper_Impl::SetBookmarkName( const OUString& rBookmarkName ) } } + if ((m_sCurrentBkmkPrefix == "__RefMoveFrom__" + || m_sCurrentBkmkPrefix == "__RefMoveTo__") + && std::find(m_aRedlineMoveIDs.begin(), m_aRedlineMoveIDs.end(), rBookmarkName) + == m_aRedlineMoveIDs.end()) + { + m_aRedlineMoveIDs.push_back(rBookmarkName); + } + aBookmarkIter->second.m_sBookmarkName = m_sCurrentBkmkPrefix + rBookmarkName; m_sCurrentBkmkPrefix.clear(); } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 95382009766e..ec34244400dc 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -488,6 +488,10 @@ private: bool m_bTextDeleted; LineNumberSettings m_aLineNumberSettings; + std::vector<OUString> m_aRedlineMoveIDs; + // Remember the last used redline MoveID. To avoid regression, because of wrong docx export + sal_uInt32 m_nLastRedlineMovedID; + BookmarkMap_t m_aBookmarkMap; OUString m_sCurrentBkmkId; OUString m_sCurrentBkmkName; |