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

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Wed May 22 13:11:46 UTC 2019


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

New commits:
commit 5814680a18ad64235535b865bf19c59e435ad2d7
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: Wed May 22 15:11:05 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.
    
    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>
    (cherry picked from commit 5b32ac3e953d4ed92d4bec1a6ffbbee5b8af4f94)
    
    Change-Id: I3c892fbe3ea5a54e7468fb23b993fa19370f85af
    Reviewed-on: https://gerrit.libreoffice.org/72755
    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 cf1ea0e36843..a2daf06340dd 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -32,9 +32,12 @@ public:
     virtual void tearDown() override;
 
     void testCopyPasteXLS();
+    void testTdf124565();
 
     CPPUNIT_TEST_SUITE(ScCopyPasteTest);
     CPPUNIT_TEST(testCopyPasteXLS);
+    CPPUNIT_TEST(testTdf124565);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -121,6 +124,69 @@ void ScCopyPasteTest::testCopyPasteXLS()
     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 81aa6dde3a4a..aa1be3e06a92 100644
--- a/sc/source/core/data/table7.cxx
+++ b/sc/source/core/data/table7.cxx
@@ -17,6 +17,7 @@
 #include <cellvalues.hxx>
 #include "olinetab.hxx"
 #include <drwlayer.hxx>
+#include <compressedarray.hxx>
 
 bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
 {
@@ -68,8 +69,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) & CR_MANUALSIZE)
+               pRowFlags->OrValue(nRow1, CR_MANUALSIZE);
+           else
+               pRowFlags->AndValue(nRow1, ~CR_MANUALSIZE);
+        }
+    }
+
     // Copy graphics over too
     bool bCopyGraphics
         = (rCxt.getInsertFlag() & InsertDeleteFlags::OBJECTS) != InsertDeleteFlags::NONE;


More information about the Libreoffice-commits mailing list