summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-09-16 21:15:28 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-09-17 08:57:15 +0200
commitc56bf1479cc71d1a2b0639f6383e90c1f7e3655b (patch)
tree3db679971be5be40d2f737202de6b8106dc1d53c
parent813cca94cd3a08d98c09fc7c34afddd02dc912ce (diff)
tdf#105330 sw: fix lost cursor on undoing nested table insert
This is a regression from commit e4509eea8fc7c07ddff48edf0d4c015c2663d896 (n#751313 SwCallLink: avoid redrawing complete rows without nested tables, 2012-04-20), though manual testing shows that the underlying problem has been addressed in the meantime, so this can be reverted. Over time, some poor tests started to depend on the new behavior so adapt them as necessary: 1) Change back test added in commit 075fc0c0a34875adf2833e5933b4982b9443a373 (testcase for fdo#38414, 2014-03-18) to its original form, that was changed to an export test in commit 086550313260d9fa45b91dc705b21bb9b51ce0b8 (move round-tripables to ooxmlexport, 2016-10-07), as the export of that document still results in data loss of cell content, just happened to pass so far. 2) Explicitly calculate content of text frames in two more tests, which just hoped that by the time they assert, the layout is ready already (but now that the missing notification is restored, it happens that the first pass of the layout doesn't create them; only a later pass, invoked by Idle, which doesn't run during cppunit tests). Change-Id: Ie13d17266cd552f3850848ae980bcfe8776997ac Reviewed-on: https://gerrit.libreoffice.org/79026 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/inc/crsrsh.hxx1
-rw-r--r--sw/inc/viscrs.hxx4
-rw-r--r--sw/qa/extras/layout/layout.cxx8
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx2
-rw-r--r--sw/qa/extras/uiwriter/data2/tdf105330.odtbin0 -> 8970 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx25
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx8
-rw-r--r--sw/source/core/crsr/callnk.cxx15
-rw-r--r--sw/source/core/crsr/crsrsh.cxx5
-rw-r--r--sw/source/core/crsr/viscrs.cxx5
10 files changed, 58 insertions, 15 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 7ccb97c5b954..5ad7a6ac2dd2 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -691,6 +691,7 @@ public:
// (This is needed for displaying the Drag&Drop/Copy-Cursor.)
bool SetVisibleCursor( const Point &rPt );
inline void UnSetVisibleCursor();
+ SwVisibleCursor* GetVisibleCursor() const;
// jump to the next or previous field of the corresponding type
bool MoveFieldType(
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index 49a9cc9035bb..2361bed32ecc 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -25,6 +25,7 @@
#include "swcrsr.hxx"
#include "swrect.hxx"
#include "swregion.hxx"
+#include "swdllapi.h"
namespace sdr { namespace overlay { class OverlayObject; } }
@@ -33,7 +34,7 @@ class SfxViewShell;
// From here classes/methods for non-text cursor.
-class SwVisibleCursor
+class SW_DLLPUBLIC SwVisibleCursor
{
friend void InitCore();
friend void FinitCore();
@@ -57,6 +58,7 @@ public:
bool IsVisible() const { return m_bIsVisible; }
void SetDragCursor( bool bFlag = true ) { m_bIsDragCursor = bFlag; }
void SetPosAndShow(SfxViewShell const * pViewShell);
+ const vcl::Cursor& GetTextCursor() const;
};
// From here classes/methods for selections.
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 66421ec4998b..e6958348d0d6 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -2525,6 +2525,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118672)
CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf117923)
{
createDoc("tdf117923.doc");
+ // Ensure that all text portions are calculated before testing.
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwViewShell* pViewShell
+ = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ pViewShell->Reformat();
+
xmlDocPtr pXmlDoc = parseLayoutDump();
// Check that we actually test the line we need
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index babff3bbec07..911c343922eb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -525,7 +525,7 @@ DECLARE_OOXMLEXPORT_TEST(testNegativeCellMarginTwips, "negative-cell-margin-twip
CPPUNIT_ASSERT( width.toInt32() > 0 );
}
-DECLARE_OOXMLEXPORT_TEST(testFdo38414, "fdo38414.docx" )
+DECLARE_OOXMLIMPORT_TEST(testFdo38414, "fdo38414.docx" )
{
// The cells in the last (4th) column were merged properly and so the result didn't have the same height.
// (Since w:gridBefore is worked around by faking another cell in the row, so column count is thus 5
diff --git a/sw/qa/extras/uiwriter/data2/tdf105330.odt b/sw/qa/extras/uiwriter/data2/tdf105330.odt
new file mode 100644
index 000000000000..bb1a088c38cc
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf105330.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 6ae3c023439c..dce955f9981e 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -39,6 +39,7 @@
#include <svl/stritem.hxx>
#include <svx/svxids.hrc>
#include <comphelper/lok.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <txtfrm.hxx>
#include <redline.hxx>
#include <view.hxx>
@@ -2228,4 +2229,28 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testOleSaveWhileEdit)
comphelper::LibreOfficeKit::setActive(false);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf105330)
+{
+ load(DATA_DIRECTORY, "tdf105330.odt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Down(/*bSelect=*/false);
+ uno::Sequence<beans::PropertyValue> aTableArgs = {
+ comphelper::makePropertyValue("Rows", static_cast<sal_uInt16>(1)),
+ comphelper::makePropertyValue("Columns", static_cast<sal_uInt16>(1)),
+ };
+ lcl_dispatchCommand(mxComponent, ".uno:InsertTable", aTableArgs);
+
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ rUndoManager.Undo();
+
+ // Without the accompanying fix in place, height was only 1 twips (practically invisible).
+ CPPUNIT_ASSERT_EQUAL(static_cast<long>(276),
+ pWrtShell->GetVisibleCursor()->GetTextCursor().GetSize().getHeight());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index bd29b496fea4..41b97b098951 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -164,6 +164,14 @@ DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.doc")
DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
{
+ // Ensure that all text portions are calculated before testing.
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwViewShell* pViewShell
+ = pTextDoc->GetDocShell()->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ pViewShell->Reformat();
+
sal_Int32 const nCellWidths[3][4] = { { 9530, 0, 0, 0 },{ 2382, 2382, 2382, 2384 },{ 2382, 2382, 2382, 2384 } };
sal_Int32 const nCellTxtLns[3][4] = { { 1, 0, 0, 0 },{ 1, 0, 0, 0},{ 1, 1, 1, 1 } };
// Table was distorted because of missing sprmPFInnerTableCell at paragraph marks (0x0D) with sprmPFInnerTtp
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index f59aa81989fb..0504e3656331 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -75,19 +75,8 @@ static void lcl_notifyRow(const SwContentNode* pNode, SwCursorShell const & rShe
return;
const SwTableLine* pLine = pRow->GetTabLine( );
- // Avoid redrawing the complete row if there are no nested tables
- for (SwFrame *pCell = pRow->GetLower(); pCell; pCell = pCell->GetNext())
- {
- for (SwFrame *pContent = pCell->GetLower(); pContent; pContent = pContent->GetNext())
- {
- if (pContent->GetType() == SwFrameType::Tab)
- {
- SwFormatFrameSize aSize = pLine->GetFrameFormat()->GetFrameSize();
- pRow->ModifyNotification(nullptr, &aSize);
- return;
- }
- }
- }
+ SwFormatFrameSize aSize = pLine->GetFrameFormat()->GetFrameSize();
+ pRow->ModifyNotification(nullptr, &aSize);
}
SwCallLink::~SwCallLink() COVERITY_NOEXCEPT_FALSE
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 538009793741..994a2d4af3bc 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2679,6 +2679,11 @@ bool SwCursorShell::SetVisibleCursor( const Point &rPt )
return bRet;
}
+SwVisibleCursor* SwCursorShell::GetVisibleCursor() const
+{
+ return m_pVisibleCursor;
+}
+
bool SwCursorShell::IsOverReadOnlyPos( const Point& rPt ) const
{
Point aPt( rPt );
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 15176de29952..5aa804d364b0 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -238,6 +238,11 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * pViewShell)
}
}
+const vcl::Cursor& SwVisibleCursor::GetTextCursor() const
+{
+ return m_aTextCursor;
+}
+
SwSelPaintRects::SwSelPaintRects( const SwCursorShell& rCSh )
: SwRects()
, m_pCursorShell( &rCSh )