[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 15 07:07:52 UTC 2020
sw/qa/core/crsr/crsr.cxx | 29 +++++++++++++++++++++
sw/qa/core/crsr/data/sel-all-starts-with-table.odt |binary
sw/source/core/crsr/callnk.cxx | 5 ++-
sw/source/core/doc/docfmt.cxx | 1
4 files changed, 33 insertions(+), 2 deletions(-)
New commits:
commit 6f1e02c96b887750f974c187a82ecd6236e6a435
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Sep 14 21:02:31 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 15 09:07:18 2020 +0200
tdf#135682 sw: fix lost selection-all when doc starts with table
Regression from commit c56bf1479cc71d1a2b0639f6383e90c1f7e3655b
(tdf#105330 sw: fix lost cursor on undoing nested table insert,
2019-09-16), the problem was that the change reverted lcl_notifyRow()
back to its original state, because it seemed the conditional
notification is no longer needed. However, this broke the fix for
tdf#37606 (ability to select-all when the doc starts with a table).
Fix the problem by handling the starts-with-table case similar to a
normal table selection, so there is still no need to restore the nested
table visitor code but select-all works nicely with starts-with-table
documents again.
Change-Id: Icb823a39432d1774a63a0c633c172bba827ac76d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102694
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx
index 6c503e81cb90..f02c3bd3487b 100644
--- a/sw/qa/core/crsr/crsr.cxx
+++ b/sw/qa/core/crsr/crsr.cxx
@@ -18,6 +18,13 @@
#include <comphelper/propertysequence.hxx>
#include <svl/srchitem.hxx>
+#include <vcl/scheduler.hxx>
+
+#include <docsh.hxx>
+#include <unotxdoc.hxx>
+#include <wrtsh.hxx>
+
+char const DATA_DIRECTORY[] = "/sw/qa/core/crsr/data/";
/// Covers sw/source/core/crsr/ fixes.
class SwCoreCrsrTest : public SwModelTestBase
@@ -75,6 +82,28 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testFindReplace)
CPPUNIT_ASSERT_EQUAL(OUString("bar"), aActualStart);
}
+CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testSelAllStartsWithTable)
+{
+ load(DATA_DIRECTORY, "sel-all-starts-with-table.odt");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDocShell* pDocShell = pTextDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
+
+ pWrtShell->SelAll();
+ pWrtShell->SelAll();
+ Scheduler::ProcessEventsToIdle();
+ pWrtShell->DelLeft();
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0
+ // - Actual : 1
+ // i.e. the table selection was lost and the table was not deleted.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/crsr/data/sel-all-starts-with-table.odt b/sw/qa/core/crsr/data/sel-all-starts-with-table.odt
new file mode 100644
index 000000000000..a368095a55cf
Binary files /dev/null and b/sw/qa/core/crsr/data/sel-all-starts-with-table.odt differ
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 3b0ca8fcc21a..a59c9c6aac61 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -59,7 +59,7 @@ SwCallLink::SwCallLink( SwCursorShell & rSh )
}
}
-static void lcl_notifyRow(const SwContentNode* pNode, SwCursorShell const & rShell)
+static void lcl_notifyRow(const SwContentNode* pNode, SwCursorShell & rShell)
{
if ( !pNode )
return;
@@ -76,11 +76,12 @@ static void lcl_notifyRow(const SwContentNode* pNode, SwCursorShell const & rShe
const SwTableLine* pLine = pRow->GetTabLine( );
- if (rShell.IsTableMode())
+ if (rShell.IsTableMode() || (rShell.StartsWithTable() && rShell.ExtendedSelectedAll()))
{
// If we have a table selection, then avoid the notification: it's not necessary (the text
// cursor needs no updating) and the notification may kill the selection overlay, leading to
// flicker.
+ // Same for whole-document selection when it starts with a table.
return;
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index b0d5f00dfd40..90fa2ed9e289 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1955,6 +1955,7 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const
mpFrameFormatTable->dumpAsXml(pWriter, "frmFormatTable");
mpSpzFrameFormatTable->dumpAsXml(pWriter, "spzFrameFormatTable");
mpSectionFormatTable->dumpAsXml(pWriter);
+ mpTableFrameFormatTable->dumpAsXml(pWriter, "tableFrameFormatTable");
mpNumRuleTable->dumpAsXml(pWriter);
getIDocumentRedlineAccess().GetRedlineTable().dumpAsXml(pWriter);
getIDocumentRedlineAccess().GetExtraRedlineTable().dumpAsXml(pWriter);
More information about the Libreoffice-commits
mailing list