[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/svx sd/qa sd/source svx/sdi svx/source

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 21 08:14:12 UTC 2020


 include/svx/xflclit.hxx        |    1 
 sd/qa/unit/uiimpress.cxx       |   47 +++++++++++++++++++++++++++++++++++++++++
 sd/source/ui/view/drviews7.cxx |   26 ++++++++++++++++++++--
 svx/sdi/svx.sdi                |    2 -
 svx/source/xoutdev/xattr.cxx   |   12 ++++++++++
 5 files changed, 84 insertions(+), 4 deletions(-)

New commits:
commit e389822312144d3c6525820da8a463da1e298a7e
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue Apr 7 18:29:35 2020 +0530
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Apr 21 10:13:37 2020 +0200

    Added parameter to FillPageColor command
    
    Change-Id: I22943815b69eeb7628eb243e0dbc6c8e0ea3487e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91825
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/svx/xflclit.hxx b/include/svx/xflclit.hxx
index 820e574bbaf4..a1459455d5aa 100644
--- a/include/svx/xflclit.hxx
+++ b/include/svx/xflclit.hxx
@@ -49,6 +49,7 @@ public:
                                   OUString &rText, const IntlWrapper& ) const override;
 
     void dumpAsXml(struct _xmlTextWriter* 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 2125820c7c50..16cfe7b64cad 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -26,6 +26,9 @@
 #include <app.hrc>
 #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;
 
@@ -151,6 +154,50 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf126197)
     // in SdrObjEditView::SdrEndTextEdit()
     pViewShell2->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SfxCallMode::SYNCHRON);
 }
+
+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 7fc676643d6d..488a2ca3882d 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1754,6 +1754,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);
@@ -1774,9 +1775,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 5261f616308b..23a98354b09f 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -2614,7 +2614,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 1de52ad51ee5..3651205de848 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -1926,6 +1926,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)
 {


More information about the Libreoffice-commits mailing list