From 10edac7eccc74aca057a086fed6a58f4387920b6 Mon Sep 17 00:00:00 2001 From: Muhammet Kara Date: Wed, 20 Feb 2019 14:36:12 +0300 Subject: [PATCH] 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 --- include/sfx2/sfxsids.hrc | 3 +- include/svx/svxids.hrc | 4 +- .../org/openoffice/Office/UI/Controller.xcu | 14 +++++ .../Office/UI/DrawImpressCommands.xcu | 30 ++++++++++ .../openoffice/Office/UI/DrawWindowState.xcu | 14 +++++ sd/UIConfig_sdraw.mk | 1 + sd/sdi/_drvwsh.sdi | 5 ++ sd/sdi/sdraw.sdi | 18 ++++++ .../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(-) create mode 100644 sd/uiconfig/sdraw/toolbar/redactedexportbar.xml 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(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 @@ ellipsesbar;.uno:Ellipse + + + .uno:RedactedExportToolbox + + + + + + com.sun.star.comp.framework.SubToolBarController + + + redactedexportbar;.uno:ExportDirectToPDF?IsRedactMode:bool=true + + .uno:LineToolbox 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 @@ 1 + + + Redacted Export + + + 1 + + Straight Connector ends with Arrow @@ -2414,6 +2422,28 @@ 1 + + + Redacted Export (Black) + + + .uno:ExportDirectToPDF?IsRedactMode:bool=true&RedactionStyle:string=Black + + + 1 + + + + + Redacted Export (White) + + + .uno:ExportDirectToPDF?IsRedactMode:bool=true&RedactionStyle:string=White + + + 1 + + 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 @@ true + + + false + + + Redacted Export + + + false + + + true + + false 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 @@ + + + + + + + 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 @@ - + + 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(&aSfxBoolItem_Impl), "NoThumbnail", SID_NO_THUMBNAIL }, { reinterpret_cast(&aSfxBoolItem_Impl), "NoEmbDataSet", SID_NO_EMBEDDED_DS }, { reinterpret_cast(&aSfxBoolItem_Impl), "IsRedactMode", SID_IS_REDACT_MODE }, + { reinterpret_cast(&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(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 xDrawPagesSupplier(xComponent, uno::UNO_QUERY); uno::Reference 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(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(0))); + xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast(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(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(50))); xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_GRAY7));