diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-02-20 14:36:12 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-02-23 15:59:34 +0100 |
commit | 10edac7eccc74aca057a086fed6a58f4387920b6 (patch) | |
tree | bed86e5db929af1fc2597f9754da2aab9fb59b15 /sfx2 | |
parent | e99a7a8dfa6f85a8b8bc53298f9300cf2fc77ec2 (diff) |
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>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/sdi/sfx.sdi | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 60 |
3 files changed, 55 insertions, 8 deletions
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)); |