summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-14 21:02:31 +0200
committerCaolán McNamara <caolanm@redhat.com>2020-09-15 10:58:41 +0200
commitd3a874cedc6129bace47fbee4b781e7a5e30b65f (patch)
tree422013eda5c7fcbdd9b24c156d8737202407a107
parenttdf#135623: modified generation of unique fly name (diff)
downloadcore-d3a874cedc6129bace47fbee4b781e7a5e30b65f.tar.gz
core-d3a874cedc6129bace47fbee4b781e7a5e30b65f.zip
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. (cherry picked from commit 6f1e02c96b887750f974c187a82ecd6236e6a435) Conflicts: sw/qa/core/crsr/crsr.cxx Change-Id: Icb823a39432d1774a63a0c633c172bba827ac76d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102706 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/CppunitTest_sw_core_crsr.mk73
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/core/crsr/crsr.cxx58
-rw-r--r--sw/qa/core/crsr/data/sel-all-starts-with-table.odtbin0 -> 8720 bytes
-rw-r--r--sw/source/core/crsr/callnk.cxx5
-rw-r--r--sw/source/core/doc/docfmt.cxx1
6 files changed, 136 insertions, 2 deletions
diff --git a/sw/CppunitTest_sw_core_crsr.mk b/sw/CppunitTest_sw_core_crsr.mk
new file mode 100644
index 000000000000..895b3ff63e57
--- /dev/null
+++ b/sw/CppunitTest_sw_core_crsr.mk
@@ -0,0 +1,73 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_core_crsr))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_crsr))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_crsr, \
+ sw/qa/core/crsr/crsr \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_crsr, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ svxcore \
+ sw \
+ test \
+ unotest \
+ utl \
+ vcl \
+ svt \
+ tl \
+ svl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_crsr,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_crsr,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_crsr,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_crsr))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_crsr))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_crsr,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_crsr,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_crsr))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_crsr, \
+ modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_crsr))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index f8d59d1e7848..aa737173f861 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -113,6 +113,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_core_objectpositioning \
CppunitTest_sw_core_layout \
CppunitTest_sw_core_unocore \
+ CppunitTest_sw_core_crsr \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx
new file mode 100644
index 000000000000..c22e072091a5
--- /dev/null
+++ b/sw/qa/core/crsr/crsr.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include <com/sun/star/view/XLineCursor.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+
+#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
+{
+};
+
+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
--- /dev/null
+++ b/sw/qa/core/crsr/data/sel-all-starts-with-table.odt
Binary files differ
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index f02e6336631a..4d956e90e2c5 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 a738ea1596a0..f7a11676594e 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1942,6 +1942,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);