[Libreoffice-commits] core.git: include/sfx2 include/svx officecfg/registry sd/sdi sd/uiconfig sd/UIConfig_sdraw.mk sfx2/sdi sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Feb 23 14:59:57 UTC 2019


 include/sfx2/sfxsids.hrc                                                 |    3 
 include/svx/svxids.hrc                                                   |    4 
 officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu          |   14 ++
 officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu |   30 +++++
 officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu     |   14 ++
 sd/UIConfig_sdraw.mk                                                     |    1 
 sd/sdi/_drvwsh.sdi                                                       |    5 
 sd/sdi/sdraw.sdi                                                         |   18 +++
 sd/uiconfig/sdraw/toolbar/redactedexportbar.xml                          |   23 +++
 sd/uiconfig/sdraw/toolbar/redactionbar.xml                               |    3 
 sfx2/sdi/sfx.sdi                                                         |    2 
 sfx2/source/appl/appuno.cxx                                              |    1 
 sfx2/source/doc/objserv.cxx                                              |   60 ++++++++--
 13 files changed, 167 insertions(+), 11 deletions(-)

New commits:
commit 10edac7eccc74aca057a086fed6a58f4387920b6
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Wed Feb 20 14:36:12 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Sat Feb 23 15:59:34 2019 +0100

    Add style options to redaction export
    
    * Add 2 new uno command aliases to handle 2 different
      styles of redaction export/sanitization:
        * .uno:RedactedExportBlack & .uno:RedactedExportWhite
    
    * Replace the single export button with the 2 new buttons
    
    * Add a new toolbox names .uno:RedactedExportToolbox which
      consists of the new 2 commands. It will be added to the Redaction
      toolbar after we solve the icon issue.
    
    * Now new redaction shapes are named as RectangleRedactionShape
      or FreeformRedactionShape based on their type.
    
    * While exporting to PDF, a seamless step of "Sanitization"
      takes place, in which, all shapes in the Draw doc are traversed
      and turned into opaq black or white (with black border) shapes,
      then the whole doc is converted into bitmap (page by page).
    
    * After the export operation is completed. All shapes are converted
      back to the usual redaction style (gray and transparent).
    
    * Icon issue:
      * We need 2 new icons for our new commands, one for black redaction
        shapes without border, and one for white redaction shapes with black
        border.
      * I tried adding links to a current icon, but it didn't work, so they
        are iconless for now.
    
    * Next to do: Handle icon issue, and take the redaction implementation
      into a separate helper class because it is growing fast.
    
    Change-Id: I9b2b7716289b800cdbe7bf3ffa4a442fe5afc474
    Reviewed-on: https://gerrit.libreoffice.org/68072
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 491874ecdaa0..24f7d569e5db 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -257,8 +257,9 @@ class SfxDocumentInfoItem;
 // not required for preview, but interferes with not-yet-saved embedded data source for main document.
 #define SID_NO_EMBEDDED_DS                  TypedWhichId<SfxBoolItem>(SID_SFX_START + 1731)
 #define SID_IS_REDACT_MODE                  (SID_SFX_START + 1733)
+#define SID_REDACTION_STYLE                 (SID_SFX_START + 1734)
 
-//      SID_SFX_free_START                  (SID_SFX_START + 1734)
+//      SID_SFX_free_START                  (SID_SFX_START + 1735)
 //      SID_SFX_free_END                    (SID_SFX_START + 3999)
 
 #define SID_OPEN_NEW_VIEW                   (SID_SFX_START + 520)
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 408cb8175455..5e082fa30943 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -458,6 +458,8 @@ class SfxStringItem;
 
 // CAUTION! Range <413 .. 413> used by EditEngine (!)
 
+#define SID_DRAWTBX_REDACTED_EXPORT                     ( SID_SVX_START + 606 )
+
 #define SID_ATTR_3D_START                               ( SID_SVX_START + 415 )
 #define SID_RULER_PROTECT                               SID_ATTR_3D_START
 #define SID_COLOR_CONTROL                               ( SID_SVX_START + 417 )
@@ -540,7 +542,7 @@ class SfxStringItem;
 #define SID_FM_DBGRID                                   ( SID_SVX_START + 603 )
 #define SID_FM_IMAGEBUTTON                              ( SID_SVX_START + 604 )
 #define SID_FM_FILECONTROL                              ( SID_SVX_START + 605 )
-//FREE
+//( SID_SVX_START + 606 ) is used by SID_DRAWTBX_REDACTED_EXPORT
 #define SID_FM_NAVIGATIONBAR                            ( SID_SVX_START + 607 )
 //FREE
 //FREE
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index d135a4571c62..590b28f0b869 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -614,6 +614,20 @@
           <value>ellipsesbar;.uno:Ellipse</value>
         </prop>
       </node>
+      <node oor:name="RedactedExportToolbox" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:RedactedExportToolbox</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>com.sun.star.comp.framework.SubToolBarController</value>
+        </prop>
+        <prop oor:name="Value">
+          <value>redactedexportbar;.uno:ExportDirectToPDF?IsRedactMode:bool=true</value>
+        </prop>
+      </node>
       <node oor:name="LineToolBox" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:LineToolbox</value>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
index ab466b3d66ca..e69ba2b362b7 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
@@ -1310,6 +1310,14 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:RedactedExportToolbox" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Redacted Export</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
       <node oor:name=".uno:ConnectorLineArrowEnd" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Straight Connector ends with Arrow</value>
@@ -2414,6 +2422,28 @@
           <value>1</value>
         </prop>
       </node>
+      <node oor:name=".uno:RedactedExportBlack" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Redacted Export (Black)</value>
+        </prop>
+        <prop oor:name="TargetURL" oor:type="xs:string">
+          <value>.uno:ExportDirectToPDF?IsRedactMode:bool=true&RedactionStyle:string=Black</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:RedactedExportWhite" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Redacted Export (White)</value>
+        </prop>
+        <prop oor:name="TargetURL" oor:type="xs:string">
+          <value>.uno:ExportDirectToPDF?IsRedactMode:bool=true&RedactionStyle:string=White</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
index 53f3d1adb244..9f33993748a6 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
@@ -371,6 +371,20 @@
           <value>true</value>
         </prop>
       </node>
+      <node oor:name="private:resource/toolbar/redactedexportbar" oor:op="replace">
+        <prop oor:name="Docked" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+        <prop oor:name="UIName" oor:type="xs:string">
+          <value xml:lang="en-US">Redacted Export</value>
+        </prop>
+        <prop oor:name="Visible" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+        <prop oor:name="HideFromToolbarMenu" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
+      </node>
       <node oor:name="private:resource/toolbar/ellipsesbar" oor:op="replace">
         <prop oor:name="Docked" oor:type="xs:boolean">
           <value>false</value>
diff --git a/sd/UIConfig_sdraw.mk b/sd/UIConfig_sdraw.mk
index ca9e2753b660..7ddddd22eb08 100644
--- a/sd/UIConfig_sdraw.mk
+++ b/sd/UIConfig_sdraw.mk
@@ -87,6 +87,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/redactedexportbar \
 	sd/uiconfig/sdraw/toolbar/redactionbar \
 	sd/uiconfig/sdraw/toolbar/standardbar \
 	sd/uiconfig/sdraw/toolbar/starshapes \
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index 25332e7f4487..d1164103169f 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -1270,6 +1270,11 @@ interface DrawView
         ExecMethod = FuSupport ;
         StateMethod = GetMenuState ;
     ]
+    SID_DRAWTBX_REDACTED_EXPORT // ole : no, status : ?
+    [
+        ExecMethod = FuSupport ;
+        StateMethod = GetMenuState ;
+    ]
     SID_DRAWTBX_LINES // ole : no, status : ?
     [
         ExecMethod = FuSupport ;
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index 233200c0c22f..c9427f3f94fa 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -1372,6 +1372,24 @@ SfxVoidItem EllipseToolbox SID_DRAWTBX_ELLIPSES
     GroupId = SfxGroupId::Drawing;
 ]
 
+SfxVoidItem RedactedExportToolbox SID_DRAWTBX_REDACTED_EXPORT
+
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Drawing;
+]
+
 SfxVoidItem ExpandPage SID_EXPAND_PAGE
 ()
 [
diff --git a/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml b/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml
new file mode 100644
index 000000000000..06468d459409
--- /dev/null
+++ b/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml
@@ -0,0 +1,23 @@
+<?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:ExportDirectToPDF?IsRedactMode:bool=true"/>
+ <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/>
+</toolbar:toolbar>
diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
index 43ce5e856f7a..bb27cd01acb4 100644
--- a/sd/uiconfig/sdraw/toolbar/redactionbar.xml
+++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
@@ -21,5 +21,6 @@
  <toolbar:toolbaritem xlink:href=".uno:Rect?FillTransparence:short=50&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true&ShapeName:string=RectangleRedactionShape"/>
  <toolbar:toolbaritem xlink:href=".uno:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true&ShapeName:string=FreeformRedactionShape"/>
  <toolbar:toolbarseparator/>
- <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF?IsRedactMode:bool=true"/>
+ <toolbar:toolbaritem xlink:href=".uno:RedactedExportBlack"/>
+ <toolbar:toolbaritem xlink:href=".uno:RedactedExportWhite"/>
 </toolbar:toolbar>
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 0f452114a71e..1794527ef78d 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -4765,7 +4765,7 @@ SfxVoidItem ExportToPDF SID_EXPORTDOCASPDF
 
 SfxVoidItem ExportDirectToPDF SID_DIRECTEXPORTDOCASPDF
 (SfxStringItem URL SID_FILE_NAME, SfxStringItem FilterName SID_FILTER_NAME,
- SfxBoolItem IsRedactMode SID_IS_REDACT_MODE)
+ SfxBoolItem IsRedactMode SID_IS_REDACT_MODE, SfxStringItem RedactionStyle SID_REDACTION_STYLE)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 2fef73c3df21..772807cca9a9 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -110,6 +110,7 @@ SfxFormalArgument const aFormalArgs[] = {
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoThumbnail", SID_NO_THUMBNAIL },
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoEmbDataSet", SID_NO_EMBEDDED_DS },
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "IsRedactMode", SID_IS_REDACT_MODE },
+    { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "RedactionStyle", SID_REDACTION_STYLE },
 };
 
 static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 175f7b22f8ee..e9d477bfd3e7 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -419,6 +419,24 @@ bool isRedactMode(SfxRequest& rReq)
     return false;
 }
 
+/// Returns the value of the given string param as an OUString
+/// Returns empty OUString if no param
+OUString getStringParam(const SfxRequest& rReq, const sal_uInt16& nParamId)
+{
+    OUString sStringParam;
+
+    const SfxItemSet *pArgs = rReq.GetArgs();
+    if (!pArgs)
+        return sStringParam;
+
+    const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(nParamId);
+    if (!pStringArg)
+        return sStringParam;
+
+    sStringParam = pStringArg->GetValue();
+    return sStringParam;
+}
+
 }
 
 void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
@@ -705,6 +723,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             if ( xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")
                  && isRedactMode(rReq) )
             {
+                OUString sRedactionStyle(getStringParam(rReq, SID_REDACTION_STYLE));
+
                 // Access the draw pages
                 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
                 uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
@@ -748,14 +768,32 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                                 && xInfo->hasPropertyByName("FillTransparence") && xInfo->hasPropertyByName("FillColor"))
                         {
                             xPropSet->setPropertyValue("FillTransparence", css::uno::makeAny(static_cast<sal_Int16>(0)));
-                            xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_BLACK));
+                            if (sRedactionStyle == "White")
+                            {
+                                xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_WHITE));
+                                xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_SOLID));
+                                xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_BLACK));
+                            }
+                            else
+                            {
+                                xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_BLACK));
+                                xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_NONE));
+                            }
                         }
                         // Freeform redaction
                         else if (sShapeName == "FreeformRedactionShape"
                                  && xInfo->hasPropertyByName("LineTransparence") && xInfo->hasPropertyByName("LineColor"))
                         {
-                                xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(0)));
+                            xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(0)));
+
+                            if (sRedactionStyle == "White")
+                            {
+                                xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_WHITE));
+                            }
+                            else
+                            {
                                 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_BLACK));
+                            }
                         }
                     }
                 }
@@ -1003,18 +1041,26 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                             if (!xInfo->hasPropertyByName("Name"))
                                 continue;
 
-                            OUString sName;
-                            uno::Any aAnyName = xPropSet->getPropertyValue("Name");
-                            aAnyName >>= sName;
+                            OUString sShapeName;
+                            if (xInfo->hasPropertyByName("Name"))
+                            {
+                                uno::Any aAnyShapeName = xPropSet->getPropertyValue("Name");
+                                aAnyShapeName >>= sShapeName;
+                            }
+                            else
+                                continue;
 
                             // Rectangle redaction
-                            if (!sName.isEmpty() && sName == "RectangleRedactionShape")
+                            if (sShapeName == "RectangleRedactionShape"
+                                    && xInfo->hasPropertyByName("FillTransparence") && xInfo->hasPropertyByName("FillColor"))
                             {
                                 xPropSet->setPropertyValue("FillTransparence", css::uno::makeAny(static_cast<sal_Int16>(50)));
                                 xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_GRAY7));
+                                xPropSet->setPropertyValue("LineStyle", css::uno::makeAny(css::drawing::LineStyle::LineStyle_NONE));
+
                             }
                             // Freeform redaction
-                            else if (!sName.isEmpty() && sName == "FreeformRedactionShape")
+                            else if (sShapeName == "FreeformRedactionShape")
                             {
                                 xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(50)));
                                 xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_GRAY7));


More information about the Libreoffice-commits mailing list