diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2020-04-21 18:19:44 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-05-27 08:50:55 +0200 |
commit | 7c6adcec995d84285971988f2e05f8f89c50dccc (patch) | |
tree | 6a73e7f7e87036472f22ddc4ae3f9894663421fa /sd | |
parent | 7bbb7a06a965169a5edf897194c4eefd7a22f665 (diff) |
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.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94852
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 32 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 24 |
2 files changed, 49 insertions, 7 deletions
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; |