From 6f1e02c96b887750f974c187a82ecd6236e6a435 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 14 Sep 2020 21:02:31 +0200 Subject: [PATCH] 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 --- sw/qa/core/crsr/crsr.cxx | 29 ++++++++++++++++++ .../crsr/data/sel-all-starts-with-table.odt | Bin 0 -> 8720 bytes sw/source/core/crsr/callnk.cxx | 5 +-- sw/source/core/doc/docfmt.cxx | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 sw/qa/core/crsr/data/sel-all-starts-with-table.odt 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 #include +#include + +#include +#include +#include + +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(mxComponent.get()); + SwDocShell* pDocShell = pTextDoc->GetDocShell(); + SwDoc* pDoc = pDocShell->GetDoc(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + + CPPUNIT_ASSERT_EQUAL(static_cast(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(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 0000000000000000000000000000000000000000..a368095a55cf8bc6eb2d327974bb6322211161ca GIT binary patch literal 8720 zcmd5>bySqw*B+2=1f-Ep=`LxIZV&`z=%Hp{h7RfO5Cu``mhSG5PNk%g?vnc8{+3to z{dw>DzW=^GYu0<-d1pW8tbNY=Jp1gUrg#ql9{@lB0MP6i)Sq{9VK4vyfV=PQPXJqx ztr^S}Vg`gjY(OSJ7zk{~?qp}m1_nYwP&P2c%+3^S;%IAT2V;Yoxxm!^07F4R`2+0M z|4&1^Z9!qKHfB&Z7h9Wc{TJXFzWXnmR7=!`-A5IsDoor-v#Ze|lkh6LLm7jJx@k_X zsnR|f^>ZHI2h=j8L75dc42Ypn41}ix5c9KSvE^vDizTTR!c#3~`rc_uz0MZjSGnC! zYw9q)E{=-!gwFP7zs`kX))WLv?-DOSiQ=x9hCRX3RjAR!TwMQZMHZ)HEQ=OVn>58vT1K&IDq^sKlZcn5Cc0zhOZVm=Yw(xxzyGc>Z^yZeV0O1v3!h-vMtH~)zwbqU&%5W#eJK|oTwaHv za&yUJ9s2o_QRZK*CwY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jrFp2xp;T*ny{A<@2yT5{x({%h<1&m%_M~D7d`6I$enJi`w&`fcV~y#}6No zXHl(})jWuG5jukOogfGB#bmn5i=H@3mlKE|FaIbr#zN+g*l#0Fcbi|RDZ;_y1OE9~_BQOl*pEZn zA6`FZ>es^Moyz<)<=f`Z)7ZcJ{kosKdqI908|q(+oPYQHH9xxB@BK7YoWJb;{_gmz zn%<>PKTYs|B+1n@cKdGe^=U{UebjBth;|l`RN4!+%d^dTfe2Fztinsh2gK$ z^wSdnxMRSdMnnAHNWTij{}$)jZ*YDUj(^6vW7eM*_Zys_Lh`>w>G=)HPht6Ilsjqp zX*a(?`7fdQXRyBpTIBZj?^E`x@cc8*UjqdD4bD#?`e&5CE}*>Mp!`*s{)6=6js2B% z|N7=F-y;1V-f%G{FOcKSox>X+z#ot9Id8^cw4jq0B~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);