tdf#125916 DOCX import: fix outline numbering at tracked deletion

Now there is no extra header after import (fixed regression from the
commit 8acc15b5113c798ecdbeed91456a92e7b0c1334e "tdf#118699 DOCX import:
don't add numbering") and the actual outline numbering is stable during
the next export/import cycles (losing correct numbering is the original
bug of DOCX import with change tracking).

Change-Id: I49a78549c10c4ce0b97bb2d593059bf25c4d7aab
Reviewed-on: https://gerrit.libreoffice.org/74054
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf125916.docx b/sw/qa/extras/uiwriter/data2/tdf125916.docx
new file mode 100644
index 0000000..6e1350d
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf125916.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 1be95f8..b283af2 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -1268,6 +1268,23 @@
    CPPUNIT_ASSERT_EQUAL(sal_Int16(1), getProperty<sal_Int16>(getParagraph(8), "NumberingLevel"));
}

CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125916_redline_restart_numbering)
{
    load(DATA_DIRECTORY, "tdf125916.docx");

    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
    CPPUNIT_ASSERT(pTextDoc);

    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
    IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
    rIDRA.AcceptAllRedline(true);

    // check unnecessary numbering
    uno::Reference<beans::XPropertySet> xProps(getParagraph(3), uno::UNO_QUERY_THROW);
    CPPUNIT_ASSERT_MESSAGE("first paragraph after the first deletion: erroneous numbering",
                           !xProps->getPropertyValue("NumberingRules").hasValue());
}

CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf125310)
{
    load(DATA_DIRECTORY, "tdf125310.fodt");
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 8548768..5142be7 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -3046,6 +3046,8 @@
                // tdf#118699 remove numbering of the first deleted list item
                const SwPaM aPam( *pStt, *pStt );
                m_rDoc.DelNumRules( aPam );
                // tdf#125916 copy style
                pDelNode->ChgFormatColl( pTextNode->GetTextColl() );
            }
            else if ( pDelNode->GetNumRule() != pTextNode->GetNumRule() )
            {