sw/qa/extras/uiwriter/data2/tdf118699.docx |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 21 +++++++++++++++++ sw/source/core/doc/DocumentRedlineManager.cxx | 32 ++++++++++++++++++++++++++ sw/source/core/inc/DocumentRedlineManager.hxx | 3 ++ 4 files changed, 56 insertions(+)
New commits: commit 8acc15b5113c798ecdbeed91456a92e7b0c1334e Author: László Németh <nem...@numbertext.org> AuthorDate: Wed May 8 19:00:18 2019 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed May 15 08:18:17 2019 +0200 tdf#118699 DOCX import: don't add numbering after a tracked deletion of a numbered list to the next not numbered paragraph. Note: we remove the numbering of the first item of the deleted numbered list to import the actual text content correctly, giving correct numbering after accepting the changes or in the Hide Changes mode. Change-Id: I98767937bc783cb5e8ecb05558a5ad05a57ff281 Reviewed-on: https://gerrit.libreoffice.org/72001 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/data2/tdf118699.docx b/sw/qa/extras/uiwriter/data2/tdf118699.docx new file mode 100644 index 000000000000..6aea0911aef1 Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf118699.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 2a106ed74581..b7199d5f1b17 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1231,4 +1231,25 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testDocxAttributeTableExport) CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xShape, "HoriOrientRelation")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf118699_redline_numbering) +{ + load(DATA_DIRECTORY, "tdf118699.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); + rIDRA.AcceptAllRedline(true); + + uno::Reference<beans::XPropertySet> xProps(getParagraph(2), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering", + !xProps->getPropertyValue("NumberingRules").hasValue()); + + CPPUNIT_ASSERT_MESSAGE( + "first paragraph after the second deletion: missing numbering", + getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(5), "NumberingRules") + .is()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 3056f8f27d12..9735e50390e4 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -820,6 +820,12 @@ RedlineFlags DocumentRedlineManager::GetRedlineFlags() const void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode ) { + if ( m_bFinalizeImport ) + { + FinalizeImport(); + m_bFinalizeImport = false; + } + if( meRedlineFlags != eMode ) { if( (RedlineFlags::ShowMask & meRedlineFlags) != (RedlineFlags::ShowMask & eMode) @@ -1418,6 +1424,8 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall // better fix it. n = 0; bDec = true; + // or simply this is an OOXML import + m_bFinalizeImport = true; } mpRedlineTable->DeleteAndDestroy( nToBeDeleted ); @@ -3011,6 +3019,30 @@ void DocumentRedlineManager::SetAutoFormatRedlineComment( const OUString* pText, mnAutoFormatRedlnCommentNo = nSeqNo; } +void DocumentRedlineManager::FinalizeImport() +{ + // tdf#118699 fix numbering after deletion of numbered list items + for( SwRedlineTable::size_type n = 0; n < mpRedlineTable->size(); ++n ) + { + SwRangeRedline* pRedl = (*mpRedlineTable)[ n ]; + if ( nsRedlineType_t::REDLINE_DELETE == pRedl->GetType() ) + { + const SwPosition* pStt = pRedl->Start(), + * pEnd = pStt == pRedl->GetPoint() + ? pRedl->GetMark() : pRedl->GetPoint(); + SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode(); + SwTextNode* pTextNode = pEnd->nNode.GetNode().GetTextNode(); + // remove numbering of the first deleted list item + // to avoid of incorrect numbering after the deletion + if ( pDelNode->GetNumRule() && !pTextNode->GetNumRule() ) + { + const SwPaM aPam( *pStt, *pStt ); + m_rDoc.DelNumRules( aPam ); + } + } + } +} + DocumentRedlineManager::~DocumentRedlineManager() { } diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx index f962d4fb6a70..56ff92942de9 100644 --- a/sw/source/core/inc/DocumentRedlineManager.hxx +++ b/sw/source/core/inc/DocumentRedlineManager.hxx @@ -127,6 +127,7 @@ public: bool IsHideRedlines() const { return m_bHideRedlines; } void SetHideRedlines(bool const bHideRedlines) { m_bHideRedlines = bHideRedlines; } + void FinalizeImport(); virtual ~DocumentRedlineManager() override; private: @@ -148,6 +149,8 @@ private: /// this flag is necessary for file import because the ViewShell/layout is /// created "too late" and the ShowRedlineChanges item is not below "Views" bool m_bHideRedlines = false; + /// need post-processing, eg. for OOXML import + bool m_bFinalizeImport = false; }; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits