summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-01-25 14:24:42 +0300
committerAndras Timar <andras.timar@collabora.com>2019-03-27 21:41:54 +0100
commit38ce298746bc26d6894432d8baed7aac45c379ca (patch)
tree4d5f2de430eac03c9df9f5203241d477440adb56 /sd
parent6f3359112ed46ca74e3217fb3f8d9fb224aa228b (diff)
Forge the freeform redaction tool
out of the Freeform Line tool in Draw. * Replace .uno:LineToolbox with .uno:Freeline_Unfilled in Redaction toolbar * Add new parameters to .uno:Freeline_Unfilled - SfxUInt16Item Transparence, SfxStringItem Color, SfxUInt16Item Width, SfxBoolItem IsSticky * Handle the params in FuConstructBezierPolygon * Now the freeform line draw tool on the Redaction toolbar works with a default width of 5mm, color of COL_GRAY7, and a transparency of 50%; and it sticks when it is clicked/selected once until user deliberately deselects it by clicking on another tool or by clicking outside of the page. * Known problem: icon is not displayed on the toolbar after adding the params Change-Id: I6b09276ca82782dbf214aab8d2ba3b407fb0d81c Reviewed-on: https://gerrit.libreoffice.org/66916 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/69817 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/func/fuconbez.cxx86
-rw-r--r--sd/source/ui/inc/fuconbez.hxx10
-rw-r--r--sd/uiconfig/sdraw/toolbar/redactionbar.xml2
3 files changed, 94 insertions, 4 deletions
diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx
index d49f009506dc..bb7352328d10 100644
--- a/sd/source/ui/func/fuconbez.cxx
+++ b/sd/source/ui/func/fuconbez.cxx
@@ -31,6 +31,9 @@
#include <svx/svxids.hrc>
#include <svx/svdpagv.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xlnwtit.hxx>
#include <app.hrc>
#include <ViewShell.hxx>
@@ -49,7 +52,10 @@ using namespace ::com::sun::star::uno;
namespace sd {
-
+/*//Extra attributes coming from parameters
+ sal_uInt16 mnTransparence; // Default: 0
+ OUString msColor; // Default: ""
+ sal_uInt16 mnWidth; // Default: 0*/
FuConstructBezierPolygon::FuConstructBezierPolygon (
ViewShell* pViewSh,
::sd::Window* pWin,
@@ -57,8 +63,29 @@ FuConstructBezierPolygon::FuConstructBezierPolygon (
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuConstruct(pViewSh, pWin, pView, pDoc, rReq),
- nEditMode(SID_BEZIER_MOVE)
+ nEditMode(SID_BEZIER_MOVE),
+ mnTransparence(0),
+ mnWidth(0)
+{
+}
+
+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> FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
@@ -66,7 +93,7 @@ rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::s
FuConstructBezierPolygon* pFunc;
rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructBezierPolygon( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
- pFunc->SetPermanent(bPermanent);
+ pFunc->SetPermanent(bPermanent || isSticky(rReq));
return xFunc;
}
@@ -75,11 +102,32 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq )
FuConstruct::DoExecute( rReq );
const SfxItemSet* pArgs = rReq.GetArgs();
+
if( pArgs )
{
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 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);
+
+ if (pTransparence && pTransparence->GetValue() > 0)
+ {
+ mnTransparence = pTransparence->GetValue();
+ }
+ if (pColor && !pColor->GetValue().isEmpty())
+ {
+ msColor = pColor->GetValue();
+ }
+ if (pWidth && pWidth->GetValue() > 0)
+ {
+ mnWidth = pWidth->GetValue();
+ }
+ }
}
}
@@ -125,6 +173,7 @@ bool FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt)
{
SfxItemSet aAttr(mpDoc->GetPool());
SetStyleSheet(aAttr, pObj);
+ SetAttributes(aAttr);
pObj->SetMergedItemSet(aAttr);
}
}
@@ -284,6 +333,37 @@ void FuConstructBezierPolygon::SelectionHasChanged()
*mpView);
}
+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;
+}
+}
+
+void FuConstructBezierPolygon::SetAttributes(SfxItemSet& rAttr)
+{
+ if (nSlotId == SID_DRAW_FREELINE_NOFILL)
+ {
+ if (mnTransparence > 0 && mnTransparence <= 100)
+ rAttr.Put(XLineTransparenceItem(mnTransparence));
+ if (!msColor.isEmpty())
+ rAttr.Put(XLineColorItem(OUString(), strToColor(msColor)));
+ if (mnWidth > 0)
+ rAttr.Put(XLineWidthItem(mnWidth));
+ }
+}
+
/**
* Set current bezier edit mode
*/
diff --git a/sd/source/ui/inc/fuconbez.hxx b/sd/source/ui/inc/fuconbez.hxx
index 8bb42e88da86..2ec20f0a0488 100644
--- a/sd/source/ui/inc/fuconbez.hxx
+++ b/sd/source/ui/inc/fuconbez.hxx
@@ -47,6 +47,11 @@ public:
void SetEditMode(sal_uInt16 nMode);
sal_uInt16 GetEditMode() { return nEditMode; }
+ /**
+ * set attribute for the object to be created
+ */
+ void SetAttributes(SfxItemSet& rAttr);
+
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
private:
@@ -59,6 +64,11 @@ private:
sal_uInt16 nEditMode;
css::uno::Any maTargets; // used for creating a path for custom animations
+
+ //Extra attributes coming from parameters
+ sal_uInt16 mnTransparence; // Default: 0
+ OUString msColor; // Default: ""
+ sal_uInt16 mnWidth; // Default: 0
};
} // end of namespace sd
diff --git a/sd/uiconfig/sdraw/toolbar/redactionbar.xml b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
index b3b8deb053d0..1a5b45b31634 100644
--- a/sd/uiconfig/sdraw/toolbar/redactionbar.xml
+++ b/sd/uiconfig/sdraw/toolbar/redactionbar.xml
@@ -19,7 +19,7 @@
-->
<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:toolbaritem xlink:href=".uno:Freeline_Unfilled?Transparence:short=50&amp;Color:string=COL_GRAY7&amp;Width:short=500&amp;IsSticky:bool=true"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/>
</toolbar:toolbar>