diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2019-05-03 00:09:37 +0300 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-05-03 22:43:49 +0200 |
commit | 7ca7d61dc25f409e209b3a432c7f07469b17e316 (patch) | |
tree | a09f2f270aa145fc05fa3c896e23e10d4456dbc8 /sc/qa | |
parent | 9ff8bdcd33cb93998eb7d6b151e310634b88bdfc (diff) |
tdf#124565: calc: copy/paste manual row height
Row height being pasted is not sufficient without knowing
if it is auto height or was set manually.
Change-Id: I3c892fbe3ea5a54e7468fb23b993fa19370f85af
Reviewed-on: https://gerrit.libreoffice.org/71706
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/copy_paste_test.cxx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index ac14129d0e74..967faaadf13a 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -32,10 +32,12 @@ public: void testCopyPasteXLS(); void testTdf84411(); + void testTdf124565(); CPPUNIT_TEST_SUITE(ScCopyPasteTest); CPPUNIT_TEST(testCopyPasteXLS); CPPUNIT_TEST(testTdf84411); + CPPUNIT_TEST(testTdf124565); CPPUNIT_TEST_SUITE_END(); private: @@ -224,6 +226,69 @@ void ScCopyPasteTest::testTdf84411() xComponent->dispose(); } +void ScCopyPasteTest::testTdf124565() +{ + // Create new document + ScDocShell* xDocSh = new ScDocShell( + SfxModelFlags::EMBEDDED_OBJECT | + SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | + SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + xDocSh->DoInitNew(); + + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext()); + CPPUNIT_ASSERT( xDesktop.is() ); + + Reference< frame::XFrame > xTargetFrame = xDesktop->findFrame( "_blank", 0 ); + CPPUNIT_ASSERT( xTargetFrame.is() ); + + uno::Reference< frame::XModel2 > xModel2 ( xDocSh->GetModel(), UNO_QUERY ); + CPPUNIT_ASSERT( xModel2.is() ); + + Reference< frame::XController2 > xController ( xModel2->createDefaultViewController( xTargetFrame ), UNO_QUERY ); + CPPUNIT_ASSERT( xController.is() ); + + // introduce model/view/controller to each other + xController->attachModel( xModel2.get() ); + xModel2->connectController( xController.get() ); + xTargetFrame->setComponent( xController->getComponentWindow(), xController.get() ); + xController->attachFrame( xTargetFrame ); + xModel2->setCurrentController( xController.get() ); + + ScDocument& rDoc = xDocSh->GetDocument(); + ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); + CPPUNIT_ASSERT(pViewShell != nullptr); + + // Set content and height of first row + rDoc.SetString(ScAddress(0, 0, 0), "Test"); + rDoc.SetRowHeight(0, 0, 500); + rDoc.SetManualHeight(0, 0, 0, true); + + // Copy first row + ScDocument aClipDoc(SCDOCMODE_CLIP); + ScRange aCopyRange(0, 0, 0, MAXCOL, 0, 0); + pViewShell->GetViewData().GetMarkData().SetMarkArea(aCopyRange); + pViewShell->GetViewData().GetView()->CopyToClip(&aClipDoc, false, false, false, false); + + // Paste to second row + SCTAB nTab = 0; + SCCOL nCol = 0; + SCROW nRow = 1; + + ScRange aPasteRange(nCol, nRow, nTab, MAXCOL, nRow, nTab); + pViewShell->GetViewData().GetMarkData().SetMarkArea(aPasteRange); + pViewShell->GetViewData().GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); + + // Copy-pasted? + CPPUNIT_ASSERT_EQUAL_MESSAGE("String was not pasted!", OUString("Test"), rDoc.GetString(nCol, nRow, nTab)); + + // And height same as in source? + CPPUNIT_ASSERT_EQUAL_MESSAGE("Row#2 height is invalid!", sal_uInt16(500), rDoc.GetRowHeight(nRow, nTab)); + + CPPUNIT_ASSERT_MESSAGE("Row#2 must be manual height!", rDoc.IsManualRowHeight(nRow, nTab)); + + xDocSh->DoClose(); +} + ScCopyPasteTest::ScCopyPasteTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { |