[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - officecfg/registry sd/source sd/uiconfig sd/UIConfig_sdraw.mk sfx2/source svx/sdi

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 27 20:41:55 UTC 2019


 officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu |   11 +
 sd/UIConfig_sdraw.mk                                                 |    1 
 sd/source/ui/func/fuconrec.cxx                                       |   97 +++++++++-
 sd/source/ui/inc/fuconrec.hxx                                        |    6 
 sd/uiconfig/sdraw/toolbar/redactionbar.xml                           |   25 ++
 sfx2/source/doc/objserv.cxx                                          |   32 +++
 svx/sdi/svx.sdi                                                      |    5 
 7 files changed, 171 insertions(+), 6 deletions(-)

New commits:
commit 6f3359112ed46ca74e3217fb3f8d9fb224aa228b
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Tue Jan 22 01:00:39 2019 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Mar 27 21:41:25 2019 +0100

    Add Redaction Toolbar
    
    * Consists of .uno:Rect, .uno:LineToolbox, and .uno:ExportDirectToPDF
    * Automatically shown when we are in the redaction process
    * Customizes the rectangle tool for our needs
    
    Also:
        * Adds new parameters to the SID_DRAW_RECT (.uno:Rect)
          to be able to set transparancy, fill color, and line/border style,
          and to make our button sticky/permanent
    
    Known problem: Button's icon is not shown after adding the parameters
    
    Change-Id: I7928264415769f7e0a4ded171b864adb99aed442
    Reviewed-on: https://gerrit.libreoffice.org/66706
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/69816
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
index ab64a1eb10f6..53f3d1adb244 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
@@ -900,6 +900,17 @@
           <value>true</value>
         </prop>
       </node>
+      <node oor:name="private:resource/toolbar/redactionbar" oor:op="replace">
+        <prop oor:name="Docked" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+        <prop oor:name="Visible" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+        <prop oor:name="UIName" oor:type="xs:string">
+          <value xml:lang="en-US">Redaction</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sd/UIConfig_sdraw.mk b/sd/UIConfig_sdraw.mk
index 1d2d6e9f2a1e..93056ddec9b6 100644
--- a/sd/UIConfig_sdraw.mk
+++ b/sd/UIConfig_sdraw.mk
@@ -86,6 +86,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/sdraw,\
 	sd/uiconfig/sdraw/toolbar/optionsbar \
 	sd/uiconfig/sdraw/toolbar/positionbar \
 	sd/uiconfig/sdraw/toolbar/rectanglesbar \
+	sd/uiconfig/sdraw/toolbar/redactionbar \
 	sd/uiconfig/sdraw/toolbar/standardbar \
 	sd/uiconfig/sdraw/toolbar/starshapes \
 	sd/uiconfig/sdraw/toolbar/symbolshapes \
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index e46293693ae6..6631a8705294 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -26,6 +26,7 @@
 
 #include <app.hrc>
 #include <svl/aeitem.hxx>
+#include <svl/itemset.hxx>
 #include <svx/xlnstwit.hxx>
 #include <svx/xlnedwit.hxx>
 #include <svx/xlnedit.hxx>
@@ -42,6 +43,8 @@
 #include <sfx2/request.hxx>
 #include <editeng/adjustitem.hxx>
 #include <svx/xtable.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xfillit.hxx>
 
 #include <svx/svdocapt.hxx>
 
@@ -72,15 +75,36 @@ FuConstructRectangle::FuConstructRectangle (
     SdDrawDocument* pDoc,
     SfxRequest&     rReq)
     : FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+    , mnFillTransparence(0)
+    , mnLineStyle(SAL_MAX_UINT16)
 {
 }
 
+namespace{
+
+/// Checks to see if the request has a parameter of IsSticky:bool=true
+/// It means that the selected command/button will stay selected after use
+bool isSticky(SfxRequest& rReq)
+{
+    const SfxItemSet *pArgs = rReq.GetArgs ();
+    if (pArgs)
+    {
+        const SfxBoolItem* pIsSticky = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
+        if (pIsSticky && pIsSticky->GetValue())
+            return true;
+    }
+
+    return false;
+}
+
+}
+
 rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
 {
     FuConstructRectangle* pFunc;
     rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( pViewSh, pWin, pView, pDoc, rReq ) );
     xFunc->DoExecute(rReq);
-    pFunc->SetPermanent(bPermanent);
+    pFunc->SetPermanent(bPermanent || isSticky(rReq));
     return xFunc;
 }
 
@@ -105,6 +129,9 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
                 const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X);
                 const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y);
 
+                if (!pCenterX || !pCenterY || !pAxisX || !pAxisY)
+                    break;
+
                 ::tools::Rectangle   aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
                                            pCenterY->GetValue () - pAxisY->GetValue () / 2,
                                            pCenterX->GetValue () + pAxisX->GetValue () / 2,
@@ -118,10 +145,29 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
 
             case SID_DRAW_RECT :
             {
-                const SfxUInt32Item* pMouseStartX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_X);
-                const SfxUInt32Item* pMouseStartY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_Y);
-                const SfxUInt32Item* pMouseEndX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_X);
-                const SfxUInt32Item* pMouseEndY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_Y);
+                const SfxUInt32Item* pMouseStartX       = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_X);
+                const SfxUInt32Item* pMouseStartY       = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_Y);
+                const SfxUInt32Item* pMouseEndX         = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_X);
+                const SfxUInt32Item* pMouseEndY         = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_Y);
+                const SfxUInt16Item* pFillTransparence  = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
+                const SfxStringItem* pFillColor         = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
+                const SfxUInt16Item* pLineStyle         = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3);
+
+                if (pFillTransparence && pFillTransparence->GetValue() > 0)
+                {
+                    mnFillTransparence = pFillTransparence->GetValue();
+                }
+                if (pFillColor && !pFillColor->GetValue().isEmpty())
+                {
+                    msFillColor = pFillColor->GetValue();
+                }
+                if (pLineStyle)
+                {
+                    mnLineStyle = pLineStyle->GetValue();
+                }
+
+                if (!pMouseStartX || !pMouseStartY || !pMouseEndX || !pMouseEndY)
+                    break;
 
                 ::tools::Rectangle   aNewRectangle (pMouseStartX->GetValue (),
                                            pMouseStartY->GetValue (),
@@ -405,6 +451,24 @@ void FuConstructRectangle::Deactivate()
     FuConstruct::Deactivate();
 }
 
+namespace {
+/// Returns the color based on the color names listed in core/include/tools/color.hxx
+/// Feel free to extend with more color names from color.hxx
+Color strToColor(const OUString& sColor)
+{
+    Color aColor = COL_AUTO;
+
+    if (sColor == "COL_GRAY")
+        aColor = COL_GRAY;
+    else if (sColor == "COL_GRAY3")
+        aColor = COL_GRAY3;
+    else if (sColor == "COL_GRAY7")
+        aColor = COL_GRAY7;
+
+    return aColor;
+}
+}
+
 /**
  * set attribute for the object to be created
  */
@@ -494,6 +558,29 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
     else if (nSlotId == OBJ_CUSTOMSHAPE )
     {
     }
+    else if (nSlotId == SID_DRAW_RECT)
+    {
+        if (mnFillTransparence > 0 && mnFillTransparence <= 100)
+            rAttr.Put(XFillTransparenceItem(mnFillTransparence));
+        if (!msFillColor.isEmpty())
+            rAttr.Put(XFillColorItem(OUString(), strToColor(msFillColor)));
+
+        switch(mnLineStyle)
+        {
+        case 0:
+            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_NONE ) );
+            break;
+        case 1:
+            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_SOLID ) );
+            break;
+        case 2:
+            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_DASH ) );
+            break;
+        default:
+            // Leave it to the defaults
+            break;
+        }
+    }
 }
 
 /**
diff --git a/sd/source/ui/inc/fuconrec.hxx b/sd/source/ui/inc/fuconrec.hxx
index 02a3478c55dd..d792fa822fb9 100644
--- a/sd/source/ui/inc/fuconrec.hxx
+++ b/sd/source/ui/inc/fuconrec.hxx
@@ -35,6 +35,12 @@ namespace sd {
 class FuConstructRectangle final
     : public FuConstruct
 {
+private:
+    //Extra attributes coming from parameters
+    sal_uInt16 mnFillTransparence;  // Default: 0
+    OUString msFillColor;           // Default: ""
+    sal_uInt16 mnLineStyle;         // Default: SAL_MAX_UINT16
+
 public:
 
     static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent );
diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
new file mode 100644
index 000000000000..b3b8deb053d0
--- /dev/null
+++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <toolbar:toolbaritem xlink:href=".uno:Rect?FillTransparence:short=50&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true"/>
+ <toolbar:toolbaritem xlink:href=".uno:LineToolbox"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/>
+</toolbar:toolbar>
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index ee8d25987845..776e4c7b997a 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -109,6 +109,10 @@
 
 #include <helpids.h>
 
+#include <com/sun/star/frame/XDesktop2.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
 #include <guisaveas.hxx>
 #include <sfx2/saveastemplatedlg.hxx>
 #include <memory>
@@ -625,6 +629,34 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW );
             xDrawPages->remove( xPage );
 
+            // Show the Redaction toolbar
+            SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+            if (pViewFrame)
+            {
+                Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
+                Reference<css::beans::XPropertySet> xPropSet( xFrame, UNO_QUERY );
+                Reference<css::frame::XLayoutManager> xLayoutManager;
+
+                if ( xPropSet.is() )
+                {
+                    try
+                    {
+                        Any aValue = xPropSet->getPropertyValue( "LayoutManager" );
+                        aValue >>= xLayoutManager;
+                        xLayoutManager->createElement( "private:resource/toolbar/redactionbar" );
+                        xLayoutManager->showElement("private:resource/toolbar/redactionbar");
+                    }
+                    catch ( const css::uno::RuntimeException& )
+                    {
+                        throw;
+                    }
+                    catch ( css::uno::Exception& )
+                    {
+                         SAL_WARN( "sfx.doc", "Exception while trying to show the Redaction Toolbar!");
+                    }
+                }
+            }
+
             return;
         }
 
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 57208ebce7bf..db2a6970d5b2 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -6828,7 +6828,10 @@ SfxVoidItem RecSearch SID_FM_SEARCH
 
 
 SfxBoolItem Rect SID_DRAW_RECT
-(SfxUInt32Item MouseStartX ID_VAL_MOUSESTART_X,SfxUInt32Item MouseStartY ID_VAL_MOUSESTART_Y,SfxUInt32Item MouseEndX ID_VAL_MOUSEEND_X,SfxUInt32Item MouseEndY ID_VAL_MOUSEEND_Y)
+(SfxUInt32Item MouseStartX ID_VAL_MOUSESTART_X, SfxUInt32Item MouseStartY ID_VAL_MOUSESTART_Y,
+ SfxUInt32Item MouseEndX ID_VAL_MOUSEEND_X, SfxUInt32Item MouseEndY ID_VAL_MOUSEEND_Y,
+ SfxUInt16Item FillTransparence FN_PARAM_1, SfxStringItem FillColor FN_PARAM_2,
+ SfxUInt16Item LineStyle FN_PARAM_3, SfxBoolItem IsSticky FN_PARAM_4)
 [
     AutoUpdate = TRUE,
     FastCall = FALSE,


More information about the Libreoffice-commits mailing list