summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2020-04-07 18:29:35 +0530
committerAndras Timar <andras.timar@collabora.com>2020-05-27 08:50:28 +0200
commit7bbb7a06a965169a5edf897194c4eefd7a22f665 (patch)
treec1b06ceaffdb86c47d0d14c40fdf6d2150811558
parent5bcf8afb26d43d61fd7c89bfc92dfba555af57d2 (diff)
Added parameter to FillPageColor command
Change-Id: I22943815b69eeb7628eb243e0dbc6c8e0ea3487e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94851 Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--include/svx/xflclit.hxx1
-rw-r--r--sd/qa/unit/uiimpress.cxx53
-rw-r--r--sd/source/ui/view/drviews7.cxx26
-rw-r--r--svx/sdi/svx.sdi2
-rw-r--r--svx/source/xoutdev/xattr.cxx12
5 files changed, 90 insertions, 4 deletions
diff --git a/include/svx/xflclit.hxx b/include/svx/xflclit.hxx
index d3998bb17002..3fae41fc6f0c 100644
--- a/include/svx/xflclit.hxx
+++ b/include/svx/xflclit.hxx
@@ -49,6 +49,7 @@ public:
OUString &rText, const IntlWrapper& ) const override;
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
+ virtual boost::property_tree::ptree dumpAsJSON() const override;
};
#endif
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 5923651c9db1..10908a296710 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -12,6 +12,8 @@
#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 <sfx2/dispatch.hxx>
@@ -20,6 +22,9 @@
#include <svl/intitem.hxx>
#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>
@@ -29,6 +34,9 @@
#include <drawdoc.hxx>
#include <sdpage.hxx>
#include <unomodel.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <com/sun/star/frame/DispatchHelper.hpp>
+#include <svx/xflclit.hxx>
using namespace ::com::sun::star;
@@ -190,6 +198,51 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf128651)
const sal_Int32 nRedoWidth(pCustomShape->GetSnapRect().GetWidth());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Redo changes width", nUndoWidth, nRedoWidth);
}
+
+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 21a4d187c014..8d45e891bf16 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;
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 4337583126b3..a8097ab2df28 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -2629,7 +2629,7 @@ XFillColorItem FillColor SID_ATTR_FILL_COLOR
]
XFillColorItem FillPageColor SID_ATTR_PAGE_COLOR
-
+(SfxStringItem Color SID_ATTR_COLOR_STR)
[
/* flags: */
AutoUpdate = TRUE,
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 7ed2da3d66ac..10795e34f54a 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -1925,6 +1925,18 @@ void XFillColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
+boost::property_tree::ptree XFillColorItem::dumpAsJSON() const
+{
+ boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON();
+
+ if (Which() == XATTR_FILLCOLOR)
+ aTree.put("commandName", ".uno:FillPageColor");
+
+ aTree.put("state", GetColorValue().AsRGBHexString());
+
+ return aTree;
+}
+
XSecondaryFillColorItem::XSecondaryFillColorItem(const OUString& rName, const Color& rTheColor) :
XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
{