diff options
author | Muhammet Kara <muhammet.kara@collabora.com> | 2019-01-22 01:00:39 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2019-01-25 12:47:58 +0100 |
commit | d051eef1119832ea35cf76a3d4472cb653b73e86 (patch) | |
tree | 7f3c72d9d0ba1f1276319d666423d19aeef0a2cd /sd | |
parent | 5cdb0821d2b59145cf83ea3652a5df72a6a3c8c8 (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>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/UIConfig_sdraw.mk | 1 | ||||
-rw-r--r-- | sd/source/ui/func/fuconrec.cxx | 97 | ||||
-rw-r--r-- | sd/source/ui/inc/fuconrec.hxx | 6 | ||||
-rw-r--r-- | sd/uiconfig/sdraw/toolbar/redactionbar.xml | 25 |
4 files changed, 124 insertions, 5 deletions
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&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true"/> + <toolbar:toolbaritem xlink:href=".uno:LineToolbox"/> + <toolbar:toolbarseparator/> + <toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/> +</toolbar:toolbar> |