sd/qa/unit/uiimpress.cxx | 32 ++++++++++++++++++++++++++++++++ sd/source/ui/view/drviews7.cxx | 24 +++++++++++++++++------- svx/sdi/svx.sdi | 2 +- 3 files changed, 50 insertions(+), 8 deletions(-)
New commits: commit 7c6adcec995d84285971988f2e05f8f89c50dccc Author: Pranam Lashkari <lpra...@collabora.com> AuthorDate: Tue Apr 21 18:19:44 2020 +0530 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed May 27 08:50:55 2020 +0200 Added parameter to FillPageGradient command Change-Id: Ife435fc25e8e3114e66461af22ac9e0ef8c9d011 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92235 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94852 Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 10908a296710..ce7a310bc289 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -25,6 +25,7 @@ #include <svx/svdotable.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> +#include <svx/xflgrit.hxx> #include <svl/stritem.hxx> #include <undo/undomanager.hxx> @@ -243,6 +244,37 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillColor) Color aColor = rPageAttr.GetItem(XATTR_FILLCOLOR)->GetColorValue(); CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), aColor.AsRGBHexString()); } + +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient) +{ + // Load the document and create two new windows. + mxComponent = loadFromDesktop(m_directories.getURLFromSrc("sd/qa/unit/data/tdf126197.odp")); + auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell(); + + // Set FillPageColor + + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence({ + { "FillPageGradientJSON", + uno::makeAny( + OUString("{\"style\":\"LINEAR\",\"startcolor\":\"ff0000\",\"endcolor\":\"0000ff\"," + "\"angle\":\"300\",\"border\":\"0\",\"x\":\"0\",\"y\":\"0\",\"intensstart\":" + "\"100\",\"intensend\":\"100\",\"stepcount\":\"0\"}")) }, + })); + + dispatchCommand(mxComponent, ".uno:FillPageGradient", aPropertyValues); + + SdPage* pPage = pViewShell->getCurrentPage(); + const SfxItemSet& rPageAttr = pPage->getSdrPageProperties().GetItemSet(); + + const XFillStyleItem* pFillStyle = rPageAttr.GetItem(XATTR_FILLSTYLE); + drawing::FillStyle eXFS = pFillStyle->GetValue(); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, eXFS); + + XGradient aGradient = rPageAttr.GetItem(XATTR_FILLGRADIENT)->GetGradientValue(); + CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), aGradient.GetStartColor().AsRGBHexString()); + CPPUNIT_ASSERT_EQUAL(OUString("0000ff"), aGradient.GetEndColor().AsRGBHexString()); +} CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 8d45e891bf16..a1da9aa4226b 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1804,15 +1804,25 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq) case SID_ATTR_PAGE_GRADIENT: { - XFillGradientItem aGradientItem( pArgs->Get( XATTR_FILLGRADIENT ) ); + if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem)) + { + const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem); + XFillGradientItem aGradient( XGradient::fromJSON(pJSON->GetValue()) ); + rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); + rPageProperties.PutItem( aGradient ); + } + else + { + XFillGradientItem aGradientItem( pArgs->Get( XATTR_FILLGRADIENT ) ); - // MigrateItemSet guarantees unique gradient names - SfxItemSet aMigrateSet( mpDrawView->GetModel()->GetItemPool(), svl::Items<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT>{} ); - aMigrateSet.Put( aGradientItem ); - SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDrawView->GetModel() ); + // MigrateItemSet guarantees unique gradient names + SfxItemSet aMigrateSet( mpDrawView->GetModel()->GetItemPool(), svl::Items<XATTR_FILLGRADIENT, XATTR_FILLGRADIENT>{} ); + aMigrateSet.Put( aGradientItem ); + SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDrawView->GetModel() ); - rPageProperties.PutItemSet( *pTempSet ); - rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); + rPageProperties.PutItemSet( *pTempSet ); + rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); + } } break; diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index a8097ab2df28..fef2049eb638 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -2667,7 +2667,7 @@ XFillGradientItem FillGradient SID_ATTR_FILL_GRADIENT ] XFillGradientItem FillPageGradient SID_ATTR_PAGE_GRADIENT - +(SfxStringItem FillPageGradientJSON SID_FILL_GRADIENT_JSON) [ /* flags: */ AutoUpdate = TRUE, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits