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-25 09:43:16 +0200 |
commit | bf5cbc6adfd7cfcd0d59277a8b1899642038ac88 (patch) | |
tree | bc18582e4667fec486304519f38789e7b0fd13d6 /sw/source/filter | |
parent | 7c13e0337f3a784d6f81296f12ae5d3e6aa5370d (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>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/basflt/fltshell.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/XMLRedlineImportHelper.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/xml/XMLRedlineImportHelper.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltexti.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltexti.hxx | 1 |
6 files changed, 20 insertions, 3 deletions
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index fbfec5eaeccf..b2624c7907f0 100644 --- a/sw/source/filter/basflt/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx @@ -704,6 +704,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwRedlineData aData(rFltRedline.m_eType, rFltRedline.m_nAutorNo, rFltRedline.m_aStamp, + 0, OUString(), nullptr ); diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 5a45a6dbb04b..3c516d00aa70 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -812,7 +812,7 @@ namespace sw (pEntry->m_pAttr.get()); SwRedlineData aData(pFltRedline->m_eType, pFltRedline->m_nAutorNo, - pFltRedline->m_aStamp, OUString(), nullptr); + pFltRedline->m_aStamp, 0, OUString(), nullptr); SwRangeRedline *const pNewRedline(new SwRangeRedline(aData, aRegion)); // the point node may be deleted in AppendRedline, so park diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 6d3bb6007ae6..2d6821edfb84 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -193,6 +193,7 @@ public: OUString sAuthor; // change author string OUString sComment; // change comment string util::DateTime aDateTime; // change DateTime + OUString sMovedID; // change move id string bool bMergeLastParagraph; // the SwRangeRedline::IsDelLastPara flag // each position can may be either empty, an XTextRange, or an SwNodeIndex @@ -374,6 +375,7 @@ void XMLRedlineImportHelper::Add( const OUString& rAuthor, const OUString& rComment, const util::DateTime& rDateTime, + const OUString& rMovedID, bool bMergeLastPara) { // we need to do the following: @@ -411,8 +413,17 @@ void XMLRedlineImportHelper::Add( pInfo->sAuthor = rAuthor; pInfo->sComment = rComment; pInfo->aDateTime = rDateTime; + pInfo->sMovedID = rMovedID; pInfo->bMergeLastParagraph = bMergeLastPara; + //reserve MoveID so it wont be reused by others + if (!rMovedID.isEmpty()) + { + SwDoc* const pDoc(static_cast<SwXMLImport&>(m_rImport).getDoc()); + assert(pDoc); + pDoc->GetDocumentRedlineManager().GetRedlineTable().setMovedIDIfNeeded(rMovedID.toInt32()); + } + // ad 3) auto itPair = m_aRedlineMap.emplace(rId, pInfo); if (itPair.second) @@ -796,6 +807,8 @@ SwRedlineData* XMLRedlineImportHelper::ConvertRedline( aDT.SetSec( pRedlineInfo->aDateTime.Seconds ); aDT.SetNanoSec( pRedlineInfo->aDateTime.NanoSeconds ); + sal_uInt32 nMovedID = pRedlineInfo->sMovedID.toInt32(); + // 3) recursively convert next redline // ( check presence and sanity of hierarchical redline info ) SwRedlineData* pNext = nullptr; @@ -808,7 +821,7 @@ SwRedlineData* XMLRedlineImportHelper::ConvertRedline( // create redline data SwRedlineData* pData = new SwRedlineData(pRedlineInfo->eType, - nAuthorId, aDT, + nAuthorId, aDT, nMovedID, pRedlineInfo->sComment, pNext); // next data (if available) diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.hxx b/sw/source/filter/xml/XMLRedlineImportHelper.hxx index 69e530fbd91e..5bea1badfc90 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.hxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.hxx @@ -81,6 +81,7 @@ public: const OUString& rAuthor, // name of the author const OUString& rComment, // redline comment const css::util::DateTime& rDateTime, // date+time + const OUString& rMovedID, // redline move id bool bMergeLastParagraph); // merge last paragraph? // create a text section for the redline, and return an diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx index 7ec4616f76dd..84fc817c09cd 100644 --- a/sw/source/filter/xml/xmltexti.cxx +++ b/sw/source/filter/xml/xmltexti.cxx @@ -942,12 +942,13 @@ void SwXMLTextImportHelper::RedlineAdd( const OUString& rAuthor, const OUString& rComment, const util::DateTime& rDateTime, + const OUString& rMovedID, bool bMergeLastPara) { // create redline helper on demand OSL_ENSURE(nullptr != m_pRedlineHelper, "helper should have been created in constructor"); if (nullptr != m_pRedlineHelper) - m_pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime, + m_pRedlineHelper->Add(rType, rId, rAuthor, rComment, rDateTime, rMovedID, bMergeLastPara); } diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx index 40d5b169f19d..dbaab53b347d 100644 --- a/sw/source/filter/xml/xmltexti.hxx +++ b/sw/source/filter/xml/xmltexti.hxx @@ -90,6 +90,7 @@ public: const OUString& rAuthor, /// name of the author const OUString& rComment, /// redline comment const css::util::DateTime& rDateTime, /// date+time + const OUString& rMovedID, /// redline move id, to find moveFrom/MoveTo parts bool bMergeLastPara) override; /// merge last paragraph virtual css::uno::Reference<css::text::XTextCursor> RedlineCreateText( css::uno::Reference<css::text::XTextCursor> & rOldCursor, /// needed to get the document |