diff options
author | Henry Castro <hcastro@collabora.com> | 2017-08-25 08:11:16 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2017-08-25 16:28:16 +0200 |
commit | 2356d9e4997fe9613c0f3e399ec6a03a2bdf861e (patch) | |
tree | 8203aefd7ef1d24a4800bce5c819104703cfc72d | |
parent | 3a1d6a2bccd05e5859ab44593609d11c39fc518a (diff) |
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@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
-rw-r--r-- | sc/CppunitTest_sc_macros_test.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 40 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/StarBasic.ods | bin | 9780 -> 9802 bytes | |||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 19 | ||||
-rw-r--r-- | sc/sdi/scalc.sdi | 8 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 30 |
6 files changed, 69 insertions, 29 deletions
diff --git a/sc/CppunitTest_sc_macros_test.mk b/sc/CppunitTest_sc_macros_test.mk index 2232fa3296e1..9fa520e19a7d 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 84cfa9c396b8..da4e30bfc20d 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 Binary files differindex a4b74b350364..6b94f0684e25 100644 --- a/sc/qa/extras/testdocuments/StarBasic.ods +++ b/sc/qa/extras/testdocuments/StarBasic.ods diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index b05817af6c5c..3d7aba5d1b26 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -642,29 +642,26 @@ void ScTiledRenderingTest::testColRowResize() pViewShell->registerLibreOfficeKitViewCallback(&ScTiledRenderingTest::callback, this); ScDocument& rDoc = pDocSh->GetDocument(); - // Col 3, Tab 0 - int nOldWidth = rDoc.GetColWidth(static_cast<SCCOL>(2), static_cast<SCTAB>(0), false); + // Col 3, Tab 0 uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({ - { "Column", uno::Any(sal_Int16(3)) }, - { "Width", uno::Any(sal_uInt16(nOldWidth + 100)) } + { "ColumnWidth", uno::Any(sal_uInt16(4000)) }, // 4cm + { "Column", uno::Any(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); - uno::Sequence<beans::PropertyValue> aArgs2( comphelper::InitPropertySequence({ + { "RowHeight", uno::Any(sal_uInt16(2000)) }, { "Row", uno::Any(sal_Int16(5)) }, - { "Height", uno::Any(sal_uInt16(nOldHeight + 100)) } })); comphelper::dispatchCommand(".uno:RowHeight", aArgs2); - 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 ffb9f3c59e2b..db1a738fe8c8 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -630,8 +630,8 @@ SfxInt16Item Column SID_RANGE_COL ] -SfxVoidItem ColumnWidth FID_COL_WIDTH -(SfxUInt16Item Column FN_PARAM_1,SfxUInt16Item Width FN_PARAM_2) +SfxUInt16Item ColumnWidth FID_COL_WIDTH +(SfxUInt16Item ColumnWidth FID_COL_WIDTH,SfxUInt16Item Column FN_PARAM_1) [ AutoUpdate = FALSE, FastCall = FALSE, @@ -4202,8 +4202,8 @@ SfxInt32Item Row SID_RANGE_ROW ] -SfxVoidItem RowHeight FID_ROW_HEIGHT -(SfxInt32Item Row FN_PARAM_1,SfxUInt16Item Height FN_PARAM_2) +SfxUInt16Item RowHeight FID_ROW_HEIGHT +(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 35cd7e44d25c..7d6b9fcb7858 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -526,13 +526,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) ) ) @@ -544,15 +545,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(); } @@ -631,13 +632,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) ) ) @@ -649,15 +651,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(); } |