[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/CppunitTest_sc_macros_test.mk sc/qa sc/sdi sc/source

Henry Castro hcastro at collabora.com
Fri Dec 1 09:46:50 UTC 2017


 sc/CppunitTest_sc_macros_test.mk             |    1 
 sc/qa/extras/macros-test.cxx                 |   40 +++++++++++++++++++++++++++
 sc/qa/extras/testdocuments/StarBasic.ods     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   29 ++++++++-----------
 sc/sdi/scalc.sdi                             |    4 +-
 sc/source/ui/view/cellsh3.cxx                |   30 ++++++++++----------
 6 files changed, 72 insertions(+), 32 deletions(-)

New commits:
commit 6fea94f8c2b31ac9ab7c92ae81b6dc07ffe6dd28
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Aug 25 08:11:16 2017 -0400

    tdf#107806: Semantic and syntax for .uno:RowHeight have been changed
    
    Change-Id: If9ce7ff36ef3ba8e55103765f3260e74ab2eebd4
    Reviewed-on: https://gerrit.libreoffice.org/41567
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/45632
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk
index 8e241681ce57..7861290cd40a 100644
--- a/sc/CppunitTest_sc_macros_test.mk
+++ b/sc/CppunitTest_sc_macros_test.mk
@@ -79,6 +79,7 @@ $(eval $(call gb_CppunitTest_use_components,sc_macros_test,\
     filter/source/storagefilterdetect/storagefd \
     forms/util/frm \
     framework/util/fwk \
+    framework/util/fwl \
     i18npool/source/search/i18nsearch \
     i18npool/util/i18npool \
     linguistic/source/lng \
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 064dccd09c55..9a1c600d8ccd 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -41,6 +41,7 @@ public:
     void testVba();
     void testMSP();
     void testPasswordProtectedStarBasic();
+    void testRowColumn();
 #endif
     CPPUNIT_TEST_SUITE(ScMacrosTest);
 #if !defined(MACOSX)
@@ -50,6 +51,7 @@ public:
     CPPUNIT_TEST(testMSP);
     CPPUNIT_TEST(testVba);
     CPPUNIT_TEST(testPasswordProtectedStarBasic);
+    CPPUNIT_TEST(testRowColumn);
 #endif
 
     CPPUNIT_TEST_SUITE_END();
@@ -344,6 +346,44 @@ void ScMacrosTest::testVba()
     }
 }
 
+void ScMacrosTest::testRowColumn()
+{
+    const OUString aFileNameBase("StarBasic.ods");
+    OUString aFileName;
+    createFileURL(aFileNameBase, aFileName);
+    uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument");
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is());
+
+    Any aRet;
+    Sequence< sal_Int16 > aOutParamIndex;
+    Sequence< Any > aOutParam;
+    Sequence< uno::Any > aParams;
+
+    SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+    ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell);
+    ScDocument& rDoc = pDocSh->GetDocument();
+
+    SfxObjectShell::CallXScript(
+        xComponent,
+        "vnd.sun.Star.script:Standard.Module1.Macro_RowHeight?language=Basic&location=document",
+        aParams, aRet, aOutParamIndex, aOutParam);
+
+    sal_uInt16 nHeight = rDoc.GetRowHeight(0, 0) * HMM_PER_TWIPS;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(2000), nHeight);
+
+    SfxObjectShell::CallXScript(
+        xComponent,
+        "vnd.sun.Star.script:Standard.Module1.Macro_ColumnWidth?language=Basic&location=document",
+        aParams, aRet, aOutParamIndex, aOutParam);
+    sal_uInt16 nWidth  = rDoc.GetColWidth(0, 0) * HMM_PER_TWIPS;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(4000), nWidth);
+
+    pDocSh->DoClose();
+}
+
 #endif
 
 ScMacrosTest::ScMacrosTest()
diff --git a/sc/qa/extras/testdocuments/StarBasic.ods b/sc/qa/extras/testdocuments/StarBasic.ods
index a4b74b350364..6b94f0684e25 100644
Binary files a/sc/qa/extras/testdocuments/StarBasic.ods and b/sc/qa/extras/testdocuments/StarBasic.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 32ccf698e872..6e5fdbe646a9 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -639,29 +639,26 @@ void ScTiledRenderingTest::testColRowResize()
 
     uno::Sequence<beans::PropertyValue> aArgs(2);
     ScDocument& rDoc = pDocSh->GetDocument();
-    // Col 3, Tab 0
-    int nOldWidth = rDoc.GetColWidth(static_cast<SCCOL>(2), static_cast<SCTAB>(0), false);
 
-    aArgs[0].Name = OUString::fromUtf8("Column");
-    aArgs[0].Value <<= static_cast<sal_Int16>(3);
-    aArgs[1].Name = OUString::fromUtf8("Width");
-    aArgs[1].Value <<= static_cast<sal_uInt16>(nOldWidth + 100);
+    // Col 3, Tab 0
+    aArgs[0].Name = OUString::fromUtf8("ColumnWidth");
+    aArgs[0].Value <<= static_cast<sal_uInt16>(4000); // 4cm
+    aArgs[1].Name = OUString::fromUtf8("Column");
+    aArgs[1].Value <<= static_cast<sal_Int16>(3);
     comphelper::dispatchCommand(".uno:ColumnWidth", aArgs);
 
-    int nNewWidth = rDoc.GetColWidth(static_cast<SCCOL>(2), static_cast<SCTAB>(0), false);
-    CPPUNIT_ASSERT(nNewWidth > nOldWidth);
+    sal_uInt16 nWidth = rDoc.GetColWidth(static_cast<SCCOL>(2), static_cast<SCTAB>(0), false) * HMM_PER_TWIPS;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(4000), nWidth);
 
     // Row 5, Tab 0
-    int nOldHeight = rDoc.GetRowHeight(static_cast<SCROW>(4), static_cast<SCTAB>(0), false);
-
-    aArgs[0].Name = OUString::fromUtf8("Row");
-    aArgs[0].Value <<= static_cast<sal_Int16>(5);
-    aArgs[1].Name = OUString::fromUtf8("Height");
-    aArgs[1].Value <<= static_cast<sal_uInt16>(nOldHeight + 100);
+    aArgs[0].Name = OUString::fromUtf8("RowHeight");
+    aArgs[0].Value <<= static_cast<sal_uInt16>(2000); // 2cm
+    aArgs[1].Name = OUString::fromUtf8("Row");
+    aArgs[1].Value <<= static_cast<sal_Int16>(5);
     comphelper::dispatchCommand(".uno:RowHeight", aArgs);
 
-    int nNewHeight = rDoc.GetRowHeight(static_cast<SCROW>(4), static_cast<SCTAB>(0), false);
-    CPPUNIT_ASSERT(nNewHeight > nOldHeight);
+    sal_uInt16 nHeight = rDoc.GetRowHeight(static_cast<SCROW>(4), static_cast<SCTAB>(0), false) * HMM_PER_TWIPS;
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(2000), nHeight);
 
     comphelper::LibreOfficeKit::setActive(false);
 }
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 735e18086e36..2f855e4a7d38 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -721,7 +721,7 @@ SfxInt16Item Column SID_RANGE_COL
 
 
 SfxUInt16Item ColumnWidth FID_COL_WIDTH
-(SfxUInt16Item Column FN_PARAM_1,SfxUInt16Item Width FN_PARAM_2)
+(SfxUInt16Item ColumnWidth FID_COL_WIDTH,SfxUInt16Item Column FN_PARAM_1)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
@@ -4461,7 +4461,7 @@ SfxInt32Item Row SID_RANGE_ROW
 
 
 SfxUInt16Item RowHeight FID_ROW_HEIGHT
-(SfxInt32Item Row FN_PARAM_1,SfxUInt16Item Height FN_PARAM_2)
+(SfxUInt16Item RowHeight FID_ROW_HEIGHT,SfxInt32Item Row FN_PARAM_1)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 1674b121996f..78e47be0f182 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -541,13 +541,14 @@ void ScCellShell::Execute( SfxRequest& rReq )
             {
                 const SfxPoolItem* pRow;
                 const SfxPoolItem* pHeight;
+                sal_uInt16 nHeight;
 
-                if ( pReqArgs && pReqArgs->HasItem( FN_PARAM_1, &pRow ) &&
-                                 pReqArgs->HasItem( FN_PARAM_2, &pHeight ) )
+                if ( pReqArgs && pReqArgs->HasItem( FID_ROW_HEIGHT, &pHeight ) &&
+                                 pReqArgs->HasItem( FN_PARAM_1, &pRow ) )
                 {
                     std::vector<sc::ColRowSpan> aRanges;
                     SCCOLROW nRow = static_cast<const SfxInt32Item*>(pRow)->GetValue() - 1;
-                    sal_uInt16 nHeight = static_cast<const SfxUInt16Item*>(pHeight)->GetValue();
+                    nHeight = static_cast<const SfxUInt16Item*>(pHeight)->GetValue();
                     ScMarkData& rMark = GetViewData()->GetMarkData();
 
                     if ( rMark.IsRowMarked( static_cast<SCROW>(nRow) ) )
@@ -559,15 +560,15 @@ void ScCellShell::Execute( SfxRequest& rReq )
                         aRanges.push_back(sc::ColRowSpan(nRow, nRow));
                     }
 
-                    pTabViewShell->SetWidthOrHeight(false, aRanges, SC_SIZE_DIRECT, nHeight);
+                    pTabViewShell->SetWidthOrHeight(false, aRanges, SC_SIZE_DIRECT, HMMToTwips(nHeight));
                 }
-                else if ( pReqArgs )
+                else if ( pReqArgs && pReqArgs->HasItem( FID_ROW_HEIGHT, &pHeight ) )
                 {
-                    const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_ROW_HEIGHT ));
+                    nHeight = static_cast<const SfxUInt16Item*>(pHeight)->GetValue();
 
                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
                     pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT,
-                                    sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+                                    sal::static_int_cast<sal_uInt16>( HMMToTwips(nHeight) ) );
                     if( ! rReq.IsAPI() )
                         rReq.Done();
                 }
@@ -646,13 +647,14 @@ void ScCellShell::Execute( SfxRequest& rReq )
             {
                 const SfxPoolItem* pColumn;
                 const SfxPoolItem* pWidth;
+                sal_uInt16 nWidth;
 
-                if ( pReqArgs && pReqArgs->HasItem( FN_PARAM_1, &pColumn ) &&
-                                 pReqArgs->HasItem( FN_PARAM_2, &pWidth ) )
+                if ( pReqArgs && pReqArgs->HasItem( FID_COL_WIDTH, &pWidth ) &&
+                                 pReqArgs->HasItem( FN_PARAM_1, &pColumn ) )
                 {
                     std::vector<sc::ColRowSpan> aRanges;
                     SCCOLROW nColumn = static_cast<const SfxUInt16Item*>(pColumn)->GetValue() - 1;
-                    sal_uInt16 nWidth = static_cast<const SfxUInt16Item*>(pWidth)->GetValue();
+                    nWidth = static_cast<const SfxUInt16Item*>(pWidth)->GetValue();
                     ScMarkData& rMark = GetViewData()->GetMarkData();
 
                     if ( rMark.IsColumnMarked( static_cast<SCCOL>(nColumn) ) )
@@ -664,15 +666,15 @@ void ScCellShell::Execute( SfxRequest& rReq )
                         aRanges.push_back(sc::ColRowSpan(nColumn, nColumn));
                     }
 
-                    pTabViewShell->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, nWidth);
+                    pTabViewShell->SetWidthOrHeight(true, aRanges, SC_SIZE_DIRECT, HMMToTwips(nWidth));
                 }
-                else if ( pReqArgs )
+                else if ( pReqArgs && pReqArgs->HasItem( FID_COL_WIDTH, &pWidth ) )
                 {
-                    const SfxUInt16Item&  rUInt16Item = static_cast<const SfxUInt16Item&>(pReqArgs->Get( FID_COL_WIDTH ));
+                    nWidth = static_cast<const SfxUInt16Item*>(pWidth)->GetValue();
 
                     // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
                     pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT,
-                                    sal::static_int_cast<sal_uInt16>( HMMToTwips(rUInt16Item.GetValue()) ) );
+                                    sal::static_int_cast<sal_uInt16>( HMMToTwips(nWidth) ) );
                     if( ! rReq.IsAPI() )
                         rReq.Done();
                 }


More information about the Libreoffice-commits mailing list