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@collabora.com>
This commit is contained in:
Muhammet Kara 2019-02-20 14:36:12 +03:00
parent e99a7a8dfa
commit 10edac7ecc
13 changed files with 167 additions and 11 deletions

View file

@ -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)

View file

@ -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

View file

@ -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>

View file

@ -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&amp;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&amp;RedactionStyle:string=White</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
</node>
</node>
</oor:component-data>

View file

@ -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>

View file

@ -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 \

View file

@ -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 ;

View file

@ -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
()
[

View file

@ -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>

View file

@ -21,5 +21,6 @@
<toolbar:toolbaritem xlink:href=".uno:Rect?FillTransparence:short=50&amp;FillColor:string=COL_GRAY7&amp;LineStyle:short=0&amp;IsSticky:bool=true&amp;ShapeName:string=RectangleRedactionShape"/>
<toolbar:toolbaritem xlink:href=".uno:Freeline_Unfilled?Transparence:short=50&amp;Color:string=COL_GRAY7&amp;Width:short=500&amp;IsSticky:bool=true&amp;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>

View file

@ -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,

View file

@ -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);

View file

@ -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));