[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 13 14:52:34 UTC 2021


 sw/qa/extras/uiwriter/data/TC-table-converttotable.docx |binary
 sw/qa/extras/uiwriter/uiwriter2.cxx                     |   23 +++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx           |    3 ++
 sw/source/core/unocore/unocrsrhelper.cxx                |   24 ++++++++--------
 4 files changed, 38 insertions(+), 12 deletions(-)

New commits:
commit 21c56b7412fda90350732737f2f11cbaa7abad46
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Jul 12 13:27:05 2021 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Tue Jul 13 16:51:58 2021 +0200

    tdf#143278 DOCX: support tracked table (row) insertion
    
    Rejection of tracked table insertion didn't remove
    the table from the text, leaving an empty table at the
    place of the insertion.
    
    Regression from commit c4cf85766453982f1aa94a7f2cb22af19ed100be
    "sw: fix crash due to redlines on tables on ooo121112-2.docx".
    
    Follow-up to commit 05366b8e6683363688de8708a3d88cf144c7a2bf
    "tdf#60382 sw offapi: add change tracking of table/row deletion"
    and commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06
    "tdf#79069 DOCX: support tracked table (row) deletion".
    
    Change-Id: I4c7242c432d1ad329a56a9a5423aa68fd7f94420
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118773
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 03b29d4ddb99337c4d54b241020c95e8b2a66991)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118801

diff --git a/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx b/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx
new file mode 100644
index 000000000000..9af615ba8268
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/TC-table-converttotable.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 32e891fe53d7..97e14b77cabd 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -4228,6 +4228,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineTableRowDeletionWithDOCXExport)
     assertXPath(pXmlDoc, "//page[1]//body/tab", 0);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineDOCXTableInsertion)
+{
+    // load a 3-row table inserted with change tracking by text to table conversion
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-converttotable.docx");
+
+    // check table count (1)
+    uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+                                                    uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+    // reject the text insertions of the table cells (also reject deletion of the tabulated
+    // text source of the table, which was used by the tracked text to table conversion)
+    SwEditShell* const pEditShell(pDoc->GetEditShell());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(10), pEditShell->GetRedlineCount());
+    while (pEditShell->GetRedlineCount())
+        pEditShell->RejectRedline(0);
+
+    // rejecting all text insertions must undo the table insertion
+    // This was 1 (remaining empty table after rejecting all table text insertions)
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf128335)
 {
     // Load the bugdoc, which has 3 textboxes.
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 9476e962eee0..5e88331edac5 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -733,7 +733,10 @@ namespace
                     rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore));
 
                     if( pCSttNd && pCEndNd )
+                    {
                         rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
+                        lcl_DeleteTrackedTableRow( aPam.End() );
+                    }
                     else if (pCSttNd && !pCEndNd)
                         {
                             aPam.GetBound().nContent.Assign( nullptr, 0 );
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 1c9f9d4b28db..aaa223d02894 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1398,24 +1398,24 @@ void makeTableRowRedline( SwTableLine& rTableLine,
     else if ( rRedlineType == u"TableRowDelete" )
     {
         eType = RedlineType::TableRowDelete;
-
-        // set table row property "HasTextChangesOnly" to false
-        // to handle tracked deletion of the table row on the UI
-        const SvxPrintItem *pHasTextChangesOnlyProp =
-             rTableLine.GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
-        if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() )
-        {
-            SvxPrintItem aSetTracking(RES_PRINT, false);
-            SwPosition aPos( *rTableLine.GetTabBoxes()[0]->GetSttNd() );
-            SwCursor aCursor( aPos, nullptr );
-            pDoc->SetRowNotTracked( aCursor, aSetTracking );
-        }
     }
     else
     {
         throw lang::IllegalArgumentException();
     }
 
+    // set table row property "HasTextChangesOnly" to false
+    // to handle tracked deletion or insertion of the table row on the UI
+    const SvxPrintItem *pHasTextChangesOnlyProp =
+         rTableLine.GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
+    if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() )
+    {
+        SvxPrintItem aSetTracking(RES_PRINT, false);
+        SwPosition aPos( *rTableLine.GetTabBoxes()[0]->GetSttNd() );
+        SwCursor aCursor( aPos, nullptr );
+        pDoc->SetRowNotTracked( aCursor, aSetTracking );
+    }
+
     comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
     std::size_t nAuthor = 0;
     OUString sAuthor;


More information about the Libreoffice-commits mailing list