icon-themes/breeze/links.txt | 9 icon-themes/colibre/links.txt | 9 include/sfx2/sfxsids.hrc | 7 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 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu | 4 sd/UIConfig_sdraw.mk | 1 sd/sdi/_drvwsh.sdi | 5 sd/sdi/sdraw.sdi | 18 sd/source/ui/func/fuconbez.cxx | 56 +- sd/source/ui/func/fuconrec.cxx | 7 sd/source/ui/inc/fuconbez.hxx | 3 sd/source/ui/inc/fuconrec.hxx | 1 sd/uiconfig/sdraw/toolbar/redactedexportbar.xml | 23 + sd/uiconfig/sdraw/toolbar/redactionbar.xml | 6 sfx2/Library_sfx.mk | 1 sfx2/inc/SfxRedactionHelper.hxx | 69 +++ sfx2/sdi/sfx.sdi | 2 sfx2/source/appl/appuno.cxx | 1 sfx2/source/doc/SfxRedactionHelper.cxx | 180 ++++++++ sfx2/source/doc/objserv.cxx | 203 ++-------- svx/sdi/svx.sdi | 6 24 files changed, 487 insertions(+), 186 deletions(-)
New commits: commit 2ca3361a28a95bf564af50fc6e3e342f2ecddb7e Author: Muhammet Kara <[email protected]> AuthorDate: Mon Feb 25 14:43:28 2019 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Mon Jun 17 22:16:47 2019 +0200 Create the SfxRedactionHelper class And move some code pieces, related to the redaction functionality, from objserv.cxx to the new SfxRedactionHelper.cxx file. Change-Id: I6491c9b581ea6d3a05a72117c5b72e1dc19025dc Reviewed-on: https://gerrit.libreoffice.org/68338 Tested-by: Jenkins Reviewed-by: Muhammet Kara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/74212 Tested-by: Muhammet Kara <[email protected]> diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 8557d763a31a..a9ba3a144582 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -227,6 +227,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/doc/docundomanager \ sfx2/source/doc/sfxbasemodel \ sfx2/source/doc/sfxmodelfactory \ + sfx2/source/doc/SfxRedactionHelper \ sfx2/source/doc/syspath \ sfx2/source/doc/zoomitem \ sfx2/source/doc/templatedlg \ diff --git a/sfx2/inc/SfxRedactionHelper.hxx b/sfx2/inc/SfxRedactionHelper.hxx new file mode 100644 index 000000000000..d338143c608e --- /dev/null +++ b/sfx2/inc/SfxRedactionHelper.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#ifndef INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX +#define INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/lang/XComponent.hpp> + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#include <vector> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; + +class SfxRequest; +class SfxStringItem; +class GDIMetaFile; +class DocumentToGraphicRenderer; +class SfxViewFrame; + +/* + * Mostly a bunch of static methods to handle the redaction functionality at + * different points of the process. + **/ +class SfxRedactionHelper +{ +public: + /// Checks to see if the request has a parameter of IsRedactMode:bool=true + static bool isRedactMode(const SfxRequest& rReq); + /* + * Returns the value of the given string param as an OUString + * Returns empty OUString if no param + * */ + static OUString getStringParam(const SfxRequest& rReq, const sal_uInt16& nParamId); + /* + * Creates metafiles from the pages of the given document, + * and pushes into the given vector. + * */ + static void getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles, + const sal_Int32& nPages, + DocumentToGraphicRenderer& aRenderer, bool bIsWriter, + bool bIsCalc); + /* + * Creates one shape and one draw page for each gdimetafile, + * and inserts the shapes into the newly created draw pages. + * */ + static void addPagesToDraw(uno::Reference<XComponent>& xComponent, const sal_Int32& nPages, + const std::vector<GDIMetaFile>& aMetaFiles, bool bIsCalc); + /* + * Makes the Redaction toolbar visible to the user. + * Meant to be called after converting a document to a Draw doc + * for redaction purposes. + * */ + static void showRedactionToolbar(SfxViewFrame* pViewFrame); +}; + +#endif // INCLUDED_CUI_SOURCE_INC_SFXREDACTIONHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sfx2/source/doc/SfxRedactionHelper.cxx b/sfx2/source/doc/SfxRedactionHelper.cxx new file mode 100644 index 000000000000..b23ed271eb87 --- /dev/null +++ b/sfx2/source/doc/SfxRedactionHelper.cxx @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <SfxRedactionHelper.hxx> + +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> + +#include <sfx2/request.hxx> +#include <sfx2/sfxsids.hrc> +#include <sfx2/viewfrm.hxx> + +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> + +#include <svtools/DocumentToGraphicRenderer.hxx> + +#include <vcl/gdimtf.hxx> +#include <vcl/graph.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; + +bool SfxRedactionHelper::isRedactMode(const SfxRequest& rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + if (pArgs) + { + const SfxBoolItem* pIsRedactMode = rReq.GetArg<SfxBoolItem>(SID_IS_REDACT_MODE); + if (pIsRedactMode && pIsRedactMode->GetValue()) + return true; + } + + return false; +} + +OUString SfxRedactionHelper::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 SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles, + const sal_Int32& nPages, + DocumentToGraphicRenderer& aRenderer, + bool bIsWriter, bool bIsCalc) +{ + for (sal_Int32 nPage = 1; nPage <= nPages; ++nPage) + { + ::Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(nPage); + ::Point aLogicPos; + ::Point aCalcPageLogicPos; + ::Size aCalcPageContentSize; + ::Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage, &aLogicPos, &aCalcPageLogicPos, + &aCalcPageContentSize); + // FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor. + ::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23); + + Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aTargetSize, + COL_TRANSPARENT, true); + auto& rGDIMetaFile = const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()); + + // Set preferred map unit and size on the metafile, so the Shape size + // will be correct in MM. + MapMode aMapMode; + aMapMode.SetMapUnit(MapUnit::Map100thMM); + // FIXME: This is a temporary hack. Need to figure out a proper way to derive these magic numbers. + if (bIsWriter) + aMapMode.SetOrigin(::Point(-(aLogicPos.getX() - 512) * 1.53, + -((aLogicPos.getY() - 501) * 1.53 + (nPage - 1) * 740))); + else if (bIsCalc) + rGDIMetaFile.Scale(0.566, 0.566); + + rGDIMetaFile.SetPrefMapMode(aMapMode); + + if (bIsCalc) + { + double aWidthRatio = static_cast<double>(aCalcPageContentSize.Width()) / aLogic.Width(); + // FIXME: Get rid of these magic numbers. Also watch for floating point rounding errors + rGDIMetaFile.Move(-2400 + aCalcPageLogicPos.X() * (aWidthRatio - 0.0887), + -3300 + aCalcPageLogicPos.Y() * 0.64175); + } + + rGDIMetaFile.SetPrefSize(bIsCalc ? aCalcPageContentSize : aLogic); + + aMetaFiles.push_back(rGDIMetaFile); + } +} + +void SfxRedactionHelper::addPagesToDraw(uno::Reference<XComponent>& xComponent, + const sal_Int32& nPages, + const std::vector<GDIMetaFile>& aMetaFiles, bool bIsCalc) +{ + // Access the draw pages + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); + + uno::Reference<css::lang::XMultiServiceFactory> xFactory(xComponent, uno::UNO_QUERY); + + for (sal_Int32 nPage = 0; nPage < nPages; ++nPage) + { + GDIMetaFile rGDIMetaFile = aMetaFiles[nPage]; + Graphic aGraphic(rGDIMetaFile); + + uno::Reference<graphic::XGraphic> xGraph = aGraphic.GetXGraphic(); + uno::Reference<drawing::XDrawPage> xPage = xDrawPages->insertNewByIndex(nPage); + + // Create and insert the shape + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xShapeProperySet(xShape, uno::UNO_QUERY); + xShapeProperySet->setPropertyValue("Graphic", uno::Any(xGraph)); + + // Set size and position + xShape->setSize( + awt::Size(rGDIMetaFile.GetPrefSize().Width(), rGDIMetaFile.GetPrefSize().Height())); + + xPage->add(xShape); + + // Shapes from Calc have the size of the content instead of the whole standard page (like A4) + // so it needs positioning on the draw page + if (bIsCalc) + xShape->setPosition(awt::Point(1000, 1000)); + } + + // Remove the extra page at the beginning + uno::Reference<drawing::XDrawPage> xPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW); + xDrawPages->remove(xPage); +} + +void SfxRedactionHelper::showRedactionToolbar(SfxViewFrame* pViewFrame) +{ + if (!pViewFrame) + return; + + 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!"); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 25204e56b8e4..ffd7643658af 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -97,6 +97,7 @@ #include <sfx2/objface.hxx> #include <sfx2/checkin.hxx> #include <sfx2/infobar.hxx> +#include <SfxRedactionHelper.hxx> #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> @@ -403,42 +404,6 @@ uno::Sequence< document::CmisVersion > SfxObjectShell::GetCmisVersions( ) return uno::Sequence< document::CmisVersion > ( ); } -namespace{ - -/// Checks to see if the request has a parameter of IsRedactMode:bool=true -bool isRedactMode(SfxRequest& rReq) -{ - const SfxItemSet *pArgs = rReq.GetArgs(); - if (pArgs) - { - const SfxBoolItem* pIsRedactMode = rReq.GetArg<SfxBoolItem>(SID_IS_REDACT_MODE); - if (pIsRedactMode && pIsRedactMode->GetValue()) - return true; - } - - 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) { weld::Window* pDialogParent = rReq.GetFrameWeld(); @@ -598,114 +563,24 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) } sal_Int32 nPages = aRenderer.getPageCount(); - std::vector< GDIMetaFile > aMetaFiles; - for (sal_Int32 nPage = 1; nPage <= nPages; ++nPage) - { - ::Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(nPage); - ::Point aLogicPos; - ::Point aCalcPageLogicPos; - ::Size aCalcPageContentSize; - ::Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage, &aLogicPos, &aCalcPageLogicPos, &aCalcPageContentSize); - // FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor. - ::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23); - - Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aTargetSize, COL_TRANSPARENT, - true); - auto& rGDIMetaFile = const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()); - - // Set preferred map unit and size on the metafile, so the Shape size - // will be correct in MM. - MapMode aMapMode; - aMapMode.SetMapUnit(MapUnit::Map100thMM); - // FIXME: This is a temporary hack. Need to figure out a proper way to derive these magic numbers. - if (bIsWriter) - aMapMode.SetOrigin(::Point(-(aLogicPos.getX() - 512) * 1.53, -((aLogicPos.getY() - 501)* 1.53 + (nPage-1)*740 ))); - else if (bIsCalc) - rGDIMetaFile.Scale(0.566, 0.566); - - rGDIMetaFile.SetPrefMapMode(aMapMode); - - if (bIsCalc) - { - double aWidthRatio = static_cast<double>(aCalcPageContentSize.Width()) / aLogic.Width(); - // FIXME: Get rid of these magic numbers. Also watch for floating point rounding errors - rGDIMetaFile.Move(-2400 + aCalcPageLogicPos.X() * (aWidthRatio - 0.0887), -3300 + aCalcPageLogicPos.Y() * 0.64175); - } - - rGDIMetaFile.SetPrefSize( bIsCalc ? aCalcPageContentSize : aLogic ); - - aMetaFiles.push_back(rGDIMetaFile); - } + // Convert the pages of the document to gdimetafiles + SfxRedactionHelper::getPageMetaFilesFromDoc(aMetaFiles, nPages, aRenderer, bIsWriter, bIsCalc); // Create an empty Draw component. uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext()); uno::Reference<frame::XComponentLoader> xComponentLoader(xDesktop, uno::UNO_QUERY); uno::Reference<lang::XComponent> xComponent = xComponentLoader->loadComponentFromURL("private:factory/sdraw", "_default", 0, {}); - // Access the draw pages - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); - - uno::Reference<css::lang::XMultiServiceFactory> xFactory(xComponent, uno::UNO_QUERY); - - for (sal_Int32 nPage = 0; nPage < nPages; ++nPage) - { - GDIMetaFile rGDIMetaFile = aMetaFiles[nPage]; - Graphic aGraphic(rGDIMetaFile); - - uno::Reference<graphic::XGraphic> xGraph = aGraphic.GetXGraphic(); - uno::Reference< drawing::XDrawPage > xPage = xDrawPages->insertNewByIndex(nPage); - - // Create and insert the shape - uno::Reference<drawing::XShape> xShape( - xFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xShapeProperySet(xShape, uno::UNO_QUERY); - xShapeProperySet->setPropertyValue("Graphic", uno::Any( xGraph )); - - // Set size and position - xShape->setSize(awt::Size(rGDIMetaFile.GetPrefSize().Width(),rGDIMetaFile.GetPrefSize().Height()) ); - - xPage->add(xShape); - - // Shapes from Calc have the size of the content instead of the whole standard page (like A4) - // so it needs positioning on the draw page - if (bIsCalc) - xShape->setPosition(awt::Point(1000,1000)); - } - - // Remove the extra page at the beginning - uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW ); - xDrawPages->remove( xPage ); + // Add the doc pages to the new draw document + SfxRedactionHelper::addPagesToDraw(xComponent, nPages, aMetaFiles, bIsCalc); // 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!"); - } - } - } + if (!pViewFrame) + return; + SfxRedactionHelper::showRedactionToolbar(pViewFrame); return; } @@ -721,9 +596,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) // Redaction finalization takes place in Draw if ( xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") - && isRedactMode(rReq) ) + && SfxRedactionHelper::isRedactMode(rReq) ) { - OUString sRedactionStyle(getStringParam(rReq, SID_REDACTION_STYLE)); + OUString sRedactionStyle(SfxRedactionHelper::getStringParam(rReq, SID_REDACTION_STYLE)); // Access the draw pages uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY); @@ -995,7 +870,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) } if (nId == SID_DIRECTEXPORTDOCASPDF && - isRedactMode(rReq)) + SfxRedactionHelper::isRedactMode(rReq)) { // Return the finalized redaction shapes back to normal (gray & transparent) uno::Reference< lang::XComponent > xComponent( GetCurrentComponent(), uno::UNO_QUERY ); commit daa2eff9f843ce83de6dc050052eaa3039900579 Author: Muhammet Kara <[email protected]> AuthorDate: Sun Feb 24 11:55:29 2019 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Mon Jun 17 22:16:26 2019 +0200 Temp icons for the redactedexport commands Just put some links for now for the icons, and replace the two buttons on the redaction toolbar with the new redactedexporttoolbox Change-Id: Ic1df62d56c965869135ceca97bbeb87efd3aaa0d Reviewed-on: https://gerrit.libreoffice.org/68281 Tested-by: Jenkins Reviewed-by: Muhammet Kara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/74211 Tested-by: Muhammet Kara <[email protected]> diff --git a/icon-themes/breeze/links.txt b/icon-themes/breeze/links.txt index 89b9dc01835c..4889dd11127a 100644 --- a/icon-themes/breeze/links.txt +++ b/icon-themes/breeze/links.txt @@ -1802,3 +1802,12 @@ cmd/lc_macrodialog.png cmd/lc_scriptorganizer.png cmd/lc_donation.png cmd/lc_currencyfield.png cmd/sc_donation.png cmd/sc_currencyfield.png + +# Redaction toolbar +cmd/lc_redactedexportblack.png cmd/lc_exportdirecttopdf.png +cmd/sc_redactedexportblack.png cmd/sc_exportdirecttopdf.png +cmd/32/redactedexportblack.png cmd/32/exportdirecttopdf.png + +cmd/lc_redactedexportwhite.png cmd/lc_exportdirecttopdf.png +cmd/sc_redactedexportwhite.png cmd/sc_exportdirecttopdf.png +cmd/32/redactedexportwhite.png cmd/32/exportdirecttopdf.png diff --git a/icon-themes/colibre/links.txt b/icon-themes/colibre/links.txt index 97f55e3d0c63..f20fea8b44f8 100644 --- a/icon-themes/colibre/links.txt +++ b/icon-themes/colibre/links.txt @@ -1811,3 +1811,12 @@ cmd/sc_basicideappear.png cmd/sc_toolsmacroedit.png cmd/lc_donation.png cmd/lc_currencyfield.png cmd/sc_donation.png cmd/sc_currencyfield.png + +# Redaction toolbar +cmd/lc_redactedexportblack.png cmd/lc_exportdirecttopdf.png +cmd/sc_redactedexportblack.png cmd/sc_exportdirecttopdf.png +cmd/32/redactedexportblack.png cmd/32/exportdirecttopdf.png + +cmd/lc_redactedexportwhite.png cmd/lc_exportdirecttopdf.png +cmd/sc_redactedexportwhite.png cmd/sc_exportdirecttopdf.png +cmd/32/redactedexportwhite.png cmd/32/exportdirecttopdf.png diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu index aced9b2e8e83..cef3aced3fe9 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu @@ -625,7 +625,7 @@ <value>com.sun.star.comp.framework.SubToolBarController</value> </prop> <prop oor:name="Value"> - <value>redactedexportbar;.uno:ExportDirectToPDF?IsRedactMode:bool=true</value> + <value>redactedexportbar;.uno:RedactedExportBlack</value> </prop> </node> <node oor:name="LineToolBox" oor:op="replace"> diff --git a/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml b/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml index 06468d459409..727a34ba72d5 100644 --- a/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml +++ b/sd/uiconfig/sdraw/toolbar/redactedexportbar.xml @@ -18,6 +18,6 @@ * 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:toolbaritem xlink:href=".uno:RedactedExportBlack"/> + <toolbar:toolbaritem xlink:href=".uno:RedactedExportWhite"/> </toolbar:toolbar> diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml index bb27cd01acb4..e25e53d4414b 100644 --- a/sd/uiconfig/sdraw/toolbar/redactionbar.xml +++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml @@ -21,6 +21,5 @@ <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:RedactedExportBlack"/> - <toolbar:toolbaritem xlink:href=".uno:RedactedExportWhite"/> + <toolbar:toolbaritem xlink:href=".uno:RedactedExportToolbox"/> </toolbar:toolbar> commit aa9b7673e823384755284faada126ecff70de17c Author: Muhammet Kara <[email protected]> AuthorDate: Wed Mar 27 18:08:40 2019 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Mon Jun 17 22:16:02 2019 +0200 Sync fuconbez.cxx with master Change-Id: I2e898f5bfbbaa55c5e403185cd445af605300d1e Reviewed-on: https://gerrit.libreoffice.org/69837 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/74210 Reviewed-by: Muhammet Kara <[email protected]> Tested-by: Muhammet Kara <[email protected]> diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index f36d89ba5e01..12c680cbaf57 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -105,39 +105,35 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq ) const SfxItemSet* pArgs = rReq.GetArgs(); - if( pArgs ) + if( !pArgs ) + return; + + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) + maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); + + if (nSlotId == SID_DRAW_FREELINE_NOFILL) { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) - maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); + const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); + const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2); + const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3); + const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME); - if (nSlotId == SID_DRAW_FREELINE_NOFILL) + if (pTransparence && pTransparence->GetValue() > 0) { - // This piece is only relevant for SID_DRAW_FREELINE_NOFILL - // Adding this note for the future because the if-block gets auto-flattened - // by loplugins - const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); - const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2); - const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3); - const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME); - - if (pTransparence && pTransparence->GetValue() > 0) - { - mnTransparence = pTransparence->GetValue(); - } - if (pColor && !pColor->GetValue().isEmpty()) - { - msColor = pColor->GetValue(); - } - if (pWidth && pWidth->GetValue() > 0) - { - mnWidth = pWidth->GetValue(); - } - if (pShapeName && !pShapeName->GetValue().isEmpty()) - { - msShapeName = pShapeName->GetValue(); - } - // End of the SID_DRAW_FREELINE_NOFILL block + mnTransparence = pTransparence->GetValue(); + } + if (pColor && !pColor->GetValue().isEmpty()) + { + msColor = pColor->GetValue(); + } + if (pWidth && pWidth->GetValue() > 0) + { + mnWidth = pWidth->GetValue(); + } + if (pShapeName && !pShapeName->GetValue().isEmpty()) + { + msShapeName = pShapeName->GetValue(); } } } commit d4f3360626ef41b769122a022c3791f22e4489c2 Author: Muhammet Kara <[email protected]> AuthorDate: Wed Feb 20 14:36:12 2019 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Mon Jun 17 22:15:44 2019 +0200 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 <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/74209 Tested-by: Muhammet Kara <[email protected]> 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 5ccb79dcf527..2df9fe15843f 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -456,6 +456,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 ) @@ -538,7 +540,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 3a9f1527cab4..aced9b2e8e83 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 653675259aeb..cd81624dc785 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 5e24ed525be8..9e30bfc2aaf1 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -1265,6 +1265,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 dec5c15a9896..55ec01a7995d 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 c6a432498165..25204e56b8e4 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)); + } } } } @@ -1002,18 +1040,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)); commit 133237ec76a07060c4a57a4288a0140376c26c74 Author: Muhammet Kara <[email protected]> AuthorDate: Tue Feb 19 23:41:57 2019 +0300 Commit: Muhammet Kara <[email protected]> CommitDate: Mon Jun 17 22:15:18 2019 +0200 Use named shapes for redaction Change-Id: Ibb55bd503d264b618c3fbebfdbcf3fe9958c6783 Reviewed-on: https://gerrit.libreoffice.org/68031 Tested-by: Jenkins Reviewed-by: Muhammet Kara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/74208 Tested-by: Muhammet Kara <[email protected]> diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 811bfe59ce57..491874ecdaa0 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -416,7 +416,9 @@ class SfxDocumentInfoItem; #define SID_PASTE_ONLY_TEXT (SID_SFX_START + 802) #define SID_PASTE_ONLY_FORMULA (SID_SFX_START + 803) #define SID_PASTE_ONLY_VALUE (SID_SFX_START + 804) - // FREE: SID_SFX_START + 808 + +// Used for redaction +#define SID_SHAPE_NAME (SID_SFX_START + 808) // FREE: SID_SFX_START + 809 // FREE: SID_SFX_START + 810 #define SID_ASYNCHRON (SID_SFX_START + 811) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 1c829f842879..bcbeadb3ebdc 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -2082,7 +2082,7 @@ <value>1</value> </prop> </node> - <node oor:name=".uno:Rect?FillTransparence:short=50&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true" oor:op="replace"> + <node oor:name=".uno:Rect?FillTransparence:short=50&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true&ShapeName:string=RectangleRedactionShape" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Rectangle</value> </prop> @@ -4746,7 +4746,7 @@ <value>1</value> </prop> </node> - <node oor:name=".uno:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true" oor:op="replace"> + <node oor:name=".uno:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true&ShapeName:string=FreeformRedactionShape" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Freeform</value> </prop> diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index 1acc46a41f9c..f36d89ba5e01 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -56,7 +56,8 @@ namespace sd { /*//Extra attributes coming from parameters sal_uInt16 mnTransparence; // Default: 0 OUString msColor; // Default: "" - sal_uInt16 mnWidth; // Default: 0*/ + sal_uInt16 mnWidth; // Default: 0 + OUString msShapeName; // Default: ""*/ FuConstructBezierPolygon::FuConstructBezierPolygon ( ViewShell* pViewSh, ::sd::Window* pWin, @@ -112,9 +113,13 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq ) if (nSlotId == SID_DRAW_FREELINE_NOFILL) { + // This piece is only relevant for SID_DRAW_FREELINE_NOFILL + // Adding this note for the future because the if-block gets auto-flattened + // by loplugins const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2); const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3); + const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME); if (pTransparence && pTransparence->GetValue() > 0) { @@ -128,6 +133,11 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq ) { mnWidth = pWidth->GetValue(); } + if (pShapeName && !pShapeName->GetValue().isEmpty()) + { + msShapeName = pShapeName->GetValue(); + } + // End of the SID_DRAW_FREELINE_NOFILL block } } } @@ -174,7 +184,7 @@ bool FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt) { SfxItemSet aAttr(mpDoc->GetPool()); SetStyleSheet(aAttr, pObj); - SetAttributes(aAttr); + SetAttributes(aAttr, pObj); pObj->SetMergedItemSet(aAttr); } } @@ -352,7 +362,7 @@ Color strToColor(const OUString& sColor) } } -void FuConstructBezierPolygon::SetAttributes(SfxItemSet& rAttr) +void FuConstructBezierPolygon::SetAttributes(SfxItemSet& rAttr, SdrObject *pObj) { if (nSlotId == SID_DRAW_FREELINE_NOFILL) { @@ -362,6 +372,8 @@ void FuConstructBezierPolygon::SetAttributes(SfxItemSet& rAttr) rAttr.Put(XLineColorItem(OUString(), strToColor(msColor))); if (mnWidth > 0) rAttr.Put(XLineWidthItem(mnWidth)); + if (!msShapeName.isEmpty()) + pObj->SetName(msShapeName); } } diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index c0007ab55ccc..64765ad3a548 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -156,6 +156,7 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq ) 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); + const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME); if (pFillTransparence && pFillTransparence->GetValue() > 0) { @@ -169,6 +170,10 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq ) { mnLineStyle = pLineStyle->GetValue(); } + if (pShapeName && !pShapeName->GetValue().isEmpty()) + { + msShapeName = pShapeName->GetValue(); + } if (!pMouseStartX || !pMouseStartY || !pMouseEndX || !pMouseEndY) break; @@ -565,6 +570,8 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) rAttr.Put(XFillTransparenceItem(mnFillTransparence)); if (!msFillColor.isEmpty()) rAttr.Put(XFillColorItem(OUString(), strToColor(msFillColor))); + if (!msShapeName.isEmpty()) + pObj->SetName(msShapeName); switch(mnLineStyle) { diff --git a/sd/source/ui/inc/fuconbez.hxx b/sd/source/ui/inc/fuconbez.hxx index 21b4a5ba6aa6..907ebebfa930 100644 --- a/sd/source/ui/inc/fuconbez.hxx +++ b/sd/source/ui/inc/fuconbez.hxx @@ -50,7 +50,7 @@ public: /** * set attribute for the object to be created */ - void SetAttributes(SfxItemSet& rAttr); + void SetAttributes(SfxItemSet& rAttr, SdrObject* pObj); virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override; @@ -69,6 +69,7 @@ private: sal_uInt16 mnTransparence; // Default: 0 OUString msColor; // Default: "" sal_uInt16 mnWidth; // Default: 0 + OUString msShapeName; // Default: "" }; } // end of namespace sd diff --git a/sd/source/ui/inc/fuconrec.hxx b/sd/source/ui/inc/fuconrec.hxx index 978dc133bab2..1c8ce15a0dff 100644 --- a/sd/source/ui/inc/fuconrec.hxx +++ b/sd/source/ui/inc/fuconrec.hxx @@ -38,6 +38,7 @@ private: sal_uInt16 mnFillTransparence; // Default: 0 OUString msFillColor; // Default: "" sal_uInt16 mnLineStyle; // Default: SAL_MAX_UINT16 + OUString msShapeName; // Default: "" public: diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml index a0fb06709377..43ce5e856f7a 100644 --- a/sd/uiconfig/sdraw/toolbar/redactionbar.xml +++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml @@ -18,8 +18,8 @@ * 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:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true"/> + <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:toolbar> diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 9488603e277c..c6a432498165 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -734,46 +734,28 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if (!xInfo.is()) continue; - // Rectangle redaction - if (xInfo->hasPropertyByName("FillTransparence") && xInfo->hasPropertyByName("FillColor")) + OUString sShapeName; + if (xInfo->hasPropertyByName("Name")) { - uno::Any aAnyTransp = xPropSet->getPropertyValue("FillTransparence"); - uno::Any aAnyColor = xPropSet->getPropertyValue("FillColor"); - - sal_Int16 nTransp = 0; - Color aColor; - const OUString sRectangleName("RectangleRedactionShape"); - - aAnyTransp >>= nTransp; - aAnyColor >>= aColor; + uno::Any aAnyShapeName = xPropSet->getPropertyValue("Name"); + aAnyShapeName >>= sShapeName; + } + else + continue; - if (nTransp == 50 && aColor == COL_GRAY7) - { - xPropSet->setPropertyValue("FillTransparence", css::uno::makeAny(static_cast<sal_Int16>(0))); - xPropSet->setPropertyValue("FillColor", css::uno::makeAny(COL_BLACK)); - xPropSet->setPropertyValue("Name", css::uno::makeAny(sRectangleName)); - } + // Rectangle redaction + if (sShapeName == "RectangleRedactionShape" + && 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)); } - //FIXME: Turn this into an else-if when we have the name-check // Freeform redaction - if (xInfo->hasPropertyByName("LineTransparence") && xInfo->hasPropertyByName("LineColor")) + else if (sShapeName == "FreeformRedactionShape" + && xInfo->hasPropertyByName("LineTransparence") && xInfo->hasPropertyByName("LineColor")) { - uno::Any aAnyTransp = xPropSet->getPropertyValue("LineTransparence"); - uno::Any aAnyColor = xPropSet->getPropertyValue("LineColor"); - - sal_Int16 nTransp = 0; - Color aColor; - const OUString sFreeformName("FreeformRedactionShape"); - - aAnyTransp >>= nTransp; - aAnyColor >>= aColor; - - if (nTransp == 50 && aColor == COL_GRAY7) - { xPropSet->setPropertyValue("LineTransparence", css::uno::makeAny(static_cast<sal_Int16>(0))); xPropSet->setPropertyValue("LineColor", css::uno::makeAny(COL_BLACK)); - xPropSet->setPropertyValue("Name", css::uno::makeAny(sFreeformName)); - } } } } diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 55d869ca9868..ca9784bcaaec 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -3456,7 +3456,8 @@ SfxBoolItem Freeline SID_DRAW_FREELINE SfxBoolItem Freeline_Unfilled SID_DRAW_FREELINE_NOFILL (SfxUInt16Item Transparence FN_PARAM_1, SfxStringItem Color FN_PARAM_2, - SfxUInt16Item Width FN_PARAM_3, SfxBoolItem IsSticky FN_PARAM_4) + SfxUInt16Item Width FN_PARAM_3, SfxBoolItem IsSticky FN_PARAM_4, + SfxStringItem ShapeName SID_SHAPE_NAME) [ AutoUpdate = TRUE, FastCall = FALSE, @@ -6813,7 +6814,8 @@ 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, SfxUInt16Item FillTransparence FN_PARAM_1, SfxStringItem FillColor FN_PARAM_2, - SfxUInt16Item LineStyle FN_PARAM_3, SfxBoolItem IsSticky FN_PARAM_4) + SfxUInt16Item LineStyle FN_PARAM_3, SfxBoolItem IsSticky FN_PARAM_4, + SfxStringItem ShapeName SID_SHAPE_NAME) [ AutoUpdate = TRUE, FastCall = FALSE, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
