summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-22 01:00:39 +0300
committerAndras Timar <andras.timar@collabora.com>2019-03-27 21:41:25 +0100
commit6f3359112ed46ca74e3217fb3f8d9fb224aa228b (patch)
tree5f3e2010fb38b2d38dd658de3ded6403d30a56e2 /sd
parentad32e6a65bfbcf439470e16c3442a499a9f6b40a (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> Reviewed-on: https://gerrit.libreoffice.org/69816 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-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
4 files changed, 124 insertions, 5 deletions
diff --git a/sd/UIConfig_sdraw.mk b/sd/UIConfig_sdraw.mk
index 1d2d6e9f2a1e..93056ddec9b6 100644
--- a/sd/UIConfig_sdraw.mk
+++ b/sd/UIConfig_sdraw.mk
@@ -86,6 +86,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 e46293693ae6..6631a8705294 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>
@@ -72,15 +75,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;
}
@@ -105,6 +129,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,
@@ -118,10 +145,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 (),
@@ -405,6 +451,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
*/
@@ -494,6 +558,29 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
else if (nSlotId == OBJ_CUSTOMSHAPE )
{
}
+ 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 02a3478c55dd..d792fa822fb9 100644
--- a/sd/source/ui/inc/fuconrec.hxx
+++ b/sd/source/ui/inc/fuconrec.hxx
@@ -35,6 +35,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>