[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-1' - sw/inc sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 13 09:00:16 UTC 2021
sw/inc/crsrsh.hxx | 1
sw/inc/viewsh.hxx | 2 -
sw/inc/viscrs.hxx | 4 +-
sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 2 -
sw/qa/extras/uiwriter/data2/tdf105330.odt |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 44 +++++++++++++++++++++++++++++
sw/qa/extras/ww8import/ww8import.cxx | 8 +++++
sw/source/core/crsr/callnk.cxx | 15 +--------
sw/source/core/crsr/crsrsh.cxx | 5 +++
sw/source/core/crsr/viscrs.cxx | 5 +++
10 files changed, 70 insertions(+), 16 deletions(-)
New commits:
commit 1c240ab7350b9be6fa26b274d682ee2ce8775250
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Sep 16 21:15:28 2019 +0200
Commit: Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Wed Jan 13 09:59:38 2021 +0100
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).
(cherry picked from commit c56bf1479cc71d1a2b0639f6383e90c1f7e3655b)
Conflicts:
sw/qa/extras/uiwriter/uiwriter2.cxx
Change-Id: Ie13d17266cd552f3850848ae980bcfe8776997ac
Reviewed-on: https://gerrit.libreoffice.org/79043
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
(cherry picked from commit d5b50e74ee822e1c8402e3044e14799e47907ff8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107679
Tested-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 531452561fe9..c2f7d2c99c77 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -668,6 +668,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/viewsh.hxx b/sw/inc/viewsh.hxx
index 832f4f9dd878..0bc777f2dce8 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -152,7 +152,7 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
inline void ResetInvalidRect();
- SAL_DLLPRIVATE void Reformat(); // Invalidates complete Layout (ApplyViewOption).
+ void Reformat(); // Invalidates complete Layout (ApplyViewOption).
SAL_DLLPRIVATE void PaintDesktop(vcl::RenderContext& rRenderContext, const SwRect&); // Collect values for painting of desktop
// and calling.
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index e30fd59283f3..a04a63c67091 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -25,13 +25,14 @@
#include "swcrsr.hxx"
#include "swrect.hxx"
#include "swregion.hxx"
+#include "swdllapi.h"
class SwCursorShell;
class SfxViewShell;
// From here classes/methods for non-text cursor.
-class SwVisibleCursor
+class SW_DLLPUBLIC SwVisibleCursor
{
friend void InitCore();
friend void FinitCore();
@@ -55,6 +56,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/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 2c12311ac0e7..b2bd2f6235fa 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -480,7 +480,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
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf105330.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 239700294b71..e270ee8a8bfa 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -9,8 +9,11 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
#include <swdtflvr.hxx>
#include <wrtsh.hxx>
+#include <UndoManager.hxx>
+#include <comphelper/propertyvalue.hxx>
namespace
{
@@ -22,9 +25,11 @@ class SwUiWriterTest2 : public SwModelTestBase
{
public:
void testTdf101534();
+ void testTdf105330();
CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534);
+ CPPUNIT_TEST(testTdf105330);
CPPUNIT_TEST_SUITE_END();
};
@@ -55,6 +60,45 @@ void SwUiWriterTest2::testTdf101534()
CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE));
}
+static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent,
+ const OUString& rCommand,
+ const uno::Sequence<beans::PropertyValue>& rPropertyValues)
+{
+ uno::Reference<frame::XController> xController
+ = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
+ CPPUNIT_ASSERT(xController.is());
+ uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFrame.is());
+ uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
+ CPPUNIT_ASSERT(xDispatchHelper.is());
+ xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues);
+}
+
+void 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());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index de16cfe253e6..0457d7335ea4 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -126,6 +126,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 f1f7a3f200ef..81240340376f 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -81,19 +81,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 02ecd2e0033f..00cff9684483 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2450,6 +2450,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 b11db04d393f..f06a149c34a0 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -243,6 +243,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 )
More information about the Libreoffice-commits
mailing list