summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-22 01:00:39 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-01-25 12:47:58 +0100
commitd051eef1119832ea35cf76a3d4472cb653b73e86 (patch)
tree7f3c72d9d0ba1f1276319d666423d19aeef0a2cd
parent5cdb0821d2b59145cf83ea3652a5df72a6a3c8c8 (diff)
Add Redaction Toolbar
* Consists of .uno:Rect, .uno:LineToolbox, and .uno:ExportDirectToPDF * Automatically shown when we are in the redaction process * Customizes the rectangle tool for our needs Also: * Adds new parameters to the SID_DRAW_RECT (.uno:Rect) to be able to set transparancy, fill color, and line/border style, and to make our button sticky/permanent Known problem: Button's icon is not shown after adding the parameters Change-Id: I7928264415769f7e0a4ded171b864adb99aed442 Reviewed-on: https://gerrit.libreoffice.org/66706 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu11
-rw-r--r--sd/UIConfig_sdraw.mk1
-rw-r--r--sd/source/ui/func/fuconrec.cxx97
-rw-r--r--sd/source/ui/inc/fuconrec.hxx6
-rw-r--r--sd/uiconfig/sdraw/toolbar/redactionbar.xml25
-rw-r--r--sfx2/source/doc/objserv.cxx29
-rw-r--r--svx/sdi/svx.sdi5
7 files changed, 168 insertions, 6 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
index ab64a1eb10f6..53f3d1adb244 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawWindowState.xcu
@@ -900,6 +900,17 @@
<value>true</value>
</prop>
</node>
+ <node oor:name="private:resource/toolbar/redactionbar" oor:op="replace">
+ <prop oor:name="Docked" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">Redaction</value>
+ </prop>
+ </node>
</node>
</node>
</oor:component-data>
diff --git a/sd/UIConfig_sdraw.mk b/sd/UIConfig_sdraw.mk
index 8fd16e5cc8e4..ca9e2753b660 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/redactionbar \
sd/uiconfig/sdraw/toolbar/standardbar \
sd/uiconfig/sdraw/toolbar/starshapes \
sd/uiconfig/sdraw/toolbar/symbolshapes \
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index 01cbb669ca11..fff0fac7ce5c 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -26,6 +26,7 @@
#include <app.hrc>
#include <svl/aeitem.hxx>
+#include <svl/itemset.hxx>
#include <svx/xlnstwit.hxx>
#include <svx/xlnedwit.hxx>
#include <svx/xlnedit.hxx>
@@ -42,6 +43,8 @@
#include <sfx2/request.hxx>
#include <editeng/adjustitem.hxx>
#include <svx/xtable.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xfillit.hxx>
#include <svx/svdocapt.hxx>
@@ -73,15 +76,36 @@ FuConstructRectangle::FuConstructRectangle (
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
+ , mnFillTransparence(0)
+ , mnLineStyle(SAL_MAX_UINT16)
{
}
+namespace{
+
+/// Checks to see if the request has a parameter of IsSticky:bool=true
+/// It means that the selected command/button will stay selected after use
+bool isSticky(SfxRequest& rReq)
+{
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+ if (pArgs)
+ {
+ const SfxBoolItem* pIsSticky = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
+ if (pIsSticky && pIsSticky->GetValue())
+ return true;
+ }
+
+ return false;
+}
+
+}
+
rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
{
FuConstructRectangle* pFunc;
rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
- pFunc->SetPermanent(bPermanent);
+ pFunc->SetPermanent(bPermanent || isSticky(rReq));
return xFunc;
}
@@ -106,6 +130,9 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X);
const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y);
+ if (!pCenterX || !pCenterY || !pAxisX || !pAxisY)
+ break;
+
::tools::Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
pCenterY->GetValue () - pAxisY->GetValue () / 2,
pCenterX->GetValue () + pAxisX->GetValue () / 2,
@@ -122,10 +149,29 @@ void FuConstructRectangle::DoExecute( SfxRequest& rReq )
case SID_DRAW_RECT :
{
- const SfxUInt32Item* pMouseStartX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_X);
- const SfxUInt32Item* pMouseStartY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_Y);
- const SfxUInt32Item* pMouseEndX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_X);
- const SfxUInt32Item* pMouseEndY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_Y);
+ const SfxUInt32Item* pMouseStartX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_X);
+ const SfxUInt32Item* pMouseStartY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_Y);
+ const SfxUInt32Item* pMouseEndX = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_X);
+ const SfxUInt32Item* pMouseEndY = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_Y);
+ 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);
+
+ if (pFillTransparence && pFillTransparence->GetValue() > 0)
+ {
+ mnFillTransparence = pFillTransparence->GetValue();
+ }
+ if (pFillColor && !pFillColor->GetValue().isEmpty())
+ {
+ msFillColor = pFillColor->GetValue();
+ }
+ if (pLineStyle)
+ {
+ mnLineStyle = pLineStyle->GetValue();
+ }
+
+ if (!pMouseStartX || !pMouseStartY || !pMouseEndX || !pMouseEndY)
+ break;
::tools::Rectangle aNewRectangle (pMouseStartX->GetValue (),
pMouseStartY->GetValue (),
@@ -410,6 +456,24 @@ void FuConstructRectangle::Deactivate()
FuConstruct::Deactivate();
}
+namespace {
+/// Returns the color based on the color names listed in core/include/tools/color.hxx
+/// Feel free to extend with more color names from color.hxx
+Color strToColor(const OUString& sColor)
+{
+ Color aColor = COL_AUTO;
+
+ if (sColor == "COL_GRAY")
+ aColor = COL_GRAY;
+ else if (sColor == "COL_GRAY3")
+ aColor = COL_GRAY3;
+ else if (sColor == "COL_GRAY7")
+ aColor = COL_GRAY7;
+
+ return aColor;
+}
+}
+
/**
* set attribute for the object to be created
*/
@@ -495,6 +559,29 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
SdrLayerAdmin& rAdmin = mpDoc->GetLayerAdmin();
pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
}
+ else if (nSlotId == SID_DRAW_RECT)
+ {
+ if (mnFillTransparence > 0 && mnFillTransparence <= 100)
+ rAttr.Put(XFillTransparenceItem(mnFillTransparence));
+ if (!msFillColor.isEmpty())
+ rAttr.Put(XFillColorItem(OUString(), strToColor(msFillColor)));
+
+ switch(mnLineStyle)
+ {
+ case 0:
+ rAttr.Put( XLineStyleItem(css::drawing::LineStyle_NONE ) );
+ break;
+ case 1:
+ rAttr.Put( XLineStyleItem(css::drawing::LineStyle_SOLID ) );
+ break;
+ case 2:
+ rAttr.Put( XLineStyleItem(css::drawing::LineStyle_DASH ) );
+ break;
+ default:
+ // Leave it to the defaults
+ break;
+ }
+ }
}
/**
diff --git a/sd/source/ui/inc/fuconrec.hxx b/sd/source/ui/inc/fuconrec.hxx
index 0a0d23fedd50..978dc133bab2 100644
--- a/sd/source/ui/inc/fuconrec.hxx
+++ b/sd/source/ui/inc/fuconrec.hxx
@@ -33,6 +33,12 @@ namespace sd {
class FuConstructRectangle final
: public FuConstruct
{
+private:
+ //Extra attributes coming from parameters
+ sal_uInt16 mnFillTransparence; // Default: 0
+ OUString msFillColor; // Default: ""
+ sal_uInt16 mnLineStyle; // Default: SAL_MAX_UINT16
+
public:
static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent );
diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
new file mode 100644
index 000000000000..b3b8deb053d0
--- /dev/null
+++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
@@ -0,0 +1,25 @@
+<?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:Rect?FillTransparence:short=50&amp;FillColor:string=COL_GRAY7&amp;LineStyle:short=0&amp;IsSticky:bool=true"/>
+ <toolbar:toolbaritem xlink:href=".uno:LineToolbox"/>
+ <toolbar:toolbarseparator/>
+ <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/>
+</toolbar:toolbar>
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index defa5ea0e483..2d202cc79376 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -109,6 +109,7 @@
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/frame/XDesktop2.hpp>
#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
#include <guisaveas.hxx>
#include <saveastemplatedlg.hxx>
@@ -642,6 +643,34 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW );
xDrawPages->remove( xPage );
+ // 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!");
+ }
+ }
+ }
+
return;
}
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 1c956b191dee..362e183e91d6 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -6826,7 +6826,10 @@ SfxVoidItem RecSearch SID_FM_SEARCH
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)
+(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)
[
AutoUpdate = TRUE,
FastCall = FALSE,