[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sd/qa sd/source svx/sdi
Pranam Lashkari (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 21 10:17:08 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 b130b6ba1ef81bec7cdf4556cd0b72c071b8f637
Author: Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Mon Apr 13 01:37:39 2020 +0530
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Apr 21 12:16:35 2020 +0200
Added parameter to FillPageGradient command
Change-Id: Ife435fc25e8e3114e66461af22ac9e0ef8c9d011
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92093
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
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 16cfe7b64cad..ad8ba2cd6987 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -29,6 +29,7 @@
#include <comphelper/propertysequence.hxx>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <svx/xflclit.hxx>
+#include <svx/xflgrit.hxx>
using namespace ::com::sun::star;
@@ -198,6 +199,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 488a2ca3882d..cdf81cdfe364 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1802,15 +1802,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 23a98354b09f..7c4a5e8cadc0 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -2652,7 +2652,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