[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sc/qa sc/source

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Sat May 4 11:59:33 UTC 2019


 sc/qa/unit/copy_paste_test.cxx |   65 +++++++++++++++++++++++++++++++++++++++++
 sc/source/core/data/table7.cxx |   10 ++++++
 2 files changed, 75 insertions(+)

New commits:
commit 5b32ac3e953d4ed92d4bec1a6ffbbee5b8af4f94
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri May 3 00:09:37 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Sat May 4 13:59:01 2019 +0200

    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 at redhat.com>
    Reviewed-on: https://gerrit.libreoffice.org/71788
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index f222f8fd3e34..c8f75f15b975 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:
@@ -225,6 +227,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" )
 {
diff --git a/sc/source/core/data/table7.cxx b/sc/source/core/data/table7.cxx
index aab7c47cf522..633d03474d0c 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -19,6 +19,7 @@
 #include <tabprotection.hxx>
 #include <columniterator.hxx>
 #include <drwlayer.hxx>
+#include <compressedarray.hxx>
 
 bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
 {
@@ -140,8 +141,17 @@ void ScTable::CopyOneCellFromClip(
     }
 
     if (nCol1 == 0 && nCol2 == MAXCOL && mpRowHeights)
+    {
         mpRowHeights->setValue(nRow1, nRow2, pSrcTab->GetOriginalHeight(nSrcRow));
 
+        if (pRowFlags && pSrcTab->pRowFlags) {
+           if (pSrcTab->pRowFlags->GetValue(nSrcRow) & CRFlags::ManualSize)
+               pRowFlags->OrValue(nRow1, CRFlags::ManualSize);
+           else
+               pRowFlags->AndValue(nRow1, ~CRFlags::ManualSize);
+        }
+    }
+
     // Copy graphics over too
     bool bCopyGraphics
         = (rCxt.getInsertFlag() & InsertDeleteFlags::OBJECTS) != InsertDeleteFlags::NONE;


More information about the Libreoffice-commits mailing list