[Libreoffice-commits] core.git: sd/qa sd/source svx/sdi
Pranam Lashkari (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 23 11:22:56 UTC 2020
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 23a3727dc6bdb1a3266f71a58cca0bea8f70ac04
Author: Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue Apr 21 18:19:44 2020 +0530
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Apr 23 13:22:16 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.klos at collabora.com>
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index ee9012bc465a..93a76ac2597d 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -27,6 +27,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>
#include <vcl/scheduler.hxx>
@@ -313,6 +314,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 3b65b9a62108..a0841616946f 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 cb02b6c7816c..f7925c5c376d 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,
More information about the Libreoffice-commits
mailing list