summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2020-04-07 18:29:35 +0530
committerSzymon Kłos <szymon.klos@collabora.com>2020-04-23 13:21:49 +0200
commit24a90870991d2629014b60435e3ca98a64dd3043 (patch)
tree2fc3c863ba4f480f111f826b0278481934038235 /sd
parent9ed61699760544b780bd3eb5820d92233cd5fb4d (diff)
Added parameter to FillPageColor command
Change-Id: I22943815b69eeb7628eb243e0dbc6c8e0ea3487e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92213 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/uiimpress.cxx48
-rw-r--r--sd/source/ui/view/drviews7.cxx26
2 files changed, 71 insertions, 3 deletions
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 31c76fdbd0a9..ee9012bc465a 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -13,6 +13,8 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
@@ -23,6 +25,8 @@
#include <svx/svxids.hrc>
#include <svx/svdoashp.hxx>
#include <svx/svdotable.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
#include <svl/stritem.hxx>
#include <undo/undomanager.hxx>
#include <vcl/scheduler.hxx>
@@ -265,6 +269,50 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127481)
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pActualPage->GetObjCount());
}
+namespace
+{
+void dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand,
+ const uno::Sequence<beans::PropertyValue>& rPropertyValues)
+{
+ uno::Reference<frame::XController> xController
+ = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController();
+ CPPUNIT_ASSERT(xController.is());
+ uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xFrame.is());
+
+ uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext));
+ CPPUNIT_ASSERT(xDispatchHelper.is());
+
+ xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues);
+}
+}
+
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillColor)
+{
+ // 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({
+ { "Color", uno::makeAny(OUString("ff0000")) },
+ }));
+
+ ::dispatchCommand(mxComponent, ".uno:FillPageColor", 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_SOLID, eXFS);
+
+ Color aColor = rPageAttr.GetItem(XATTR_FILLCOLOR)->GetColorValue();
+ CPPUNIT_ASSERT_EQUAL(OUString("ff0000"), aColor.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 693d0bd1a8dc..3b65b9a62108 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1756,6 +1756,7 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq)
SdrPageProperties& rPageProperties = pPage->getSdrPageProperties();
const SfxItemSet &aPageItemSet = rPageProperties.GetItemSet();
std::unique_ptr<SfxItemSet> pTempSet = aPageItemSet.Clone(false, &mpDrawView->GetModel()->GetItemPool());
+ const SfxPoolItem* pItem = nullptr;
rPageProperties.ClearItem(XATTR_FILLSTYLE);
rPageProperties.ClearItem(XATTR_FILLGRADIENT);
@@ -1776,9 +1777,28 @@ void DrawViewShell::SetPageProperties (SfxRequest& rReq)
case SID_ATTR_PAGE_COLOR:
{
- XFillColorItem aColorItem( pArgs->Get( XATTR_FILLCOLOR ) );
- rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
- rPageProperties.PutItem( aColorItem );
+ if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem))
+ {
+ Color aColor;
+ OUString sColor;
+
+ sColor = static_cast<const SfxStringItem*>(pItem)->GetValue();
+
+ if (sColor == "transparent")
+ aColor = COL_TRANSPARENT;
+ else
+ aColor = Color(sColor.toInt32(16));
+
+ XFillColorItem aColorItem(OUString(), aColor);
+ rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
+ rPageProperties.PutItem( aColorItem );
+ }
+ else
+ {
+ XFillColorItem aColorItem( pArgs->Get( XATTR_FILLCOLOR ) );
+ rPageProperties.PutItem( XFillStyleItem( drawing::FillStyle_SOLID ) );
+ rPageProperties.PutItem( aColorItem );
+ }
}
break;