[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sd/source sd/uiconfig svx/sdi
Muhammet Kara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 17 19:22:02 UTC 2019
sd/source/ui/func/fuconbez.cxx | 86 +++++++++++++++++++++++++++--
sd/source/ui/inc/fuconbez.hxx | 10 +++
sd/uiconfig/sdraw/toolbar/redactionbar.xml | 2
svx/sdi/svx.sdi | 3 -
4 files changed, 96 insertions(+), 5 deletions(-)
New commits:
commit 39c94811a6a3630deae81812f05cde7717e8dfef
Author: Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Fri Jan 25 14:24:42 2019 +0300
Commit: Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Mon Jun 17 21:21:18 2019 +0200
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 at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/74199
Tested-by: Muhammet Kara <muhammet.kara at collabora.com>
diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx
index ebc57cb87ebc..1acc46a41f9c 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>
@@ -50,7 +53,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,
@@ -58,8 +64,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 )
@@ -67,7 +94,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;
}
@@ -76,11 +103,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();
+ }
+ }
}
}
@@ -126,6 +174,7 @@ bool FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt)
{
SfxItemSet aAttr(mpDoc->GetPool());
SetStyleSheet(aAttr, pObj);
+ SetAttributes(aAttr);
pObj->SetMergedItemSet(aAttr);
}
}
@@ -285,6 +334,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 15754c4b3c94..21b4a5ba6aa6 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 SdrObjectUniquePtr 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&FillColor:string=COL_GRAY7&LineStyle:short=0&IsSticky:bool=true"/>
- <toolbar:toolbaritem xlink:href=".uno:LineToolbox"/>
+ <toolbar:toolbaritem xlink:href=".uno:Freeline_Unfilled?Transparence:short=50&Color:string=COL_GRAY7&Width:short=500&IsSticky:bool=true"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:ExportDirectToPDF"/>
</toolbar:toolbar>
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index d762205a262a..55d869ca9868 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -3455,7 +3455,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)
[
AutoUpdate = TRUE,
FastCall = FALSE,
More information about the Libreoffice-commits
mailing list