[Libreoffice-commits] core.git: include/svtools svtools/source svx/inc svx/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri May 15 15:27:48 UTC 2020
include/svtools/valueset.hxx | 1
svtools/source/control/valueset.cxx | 12 ++++++++++-
svx/inc/colrctrl.hxx | 6 ++---
svx/source/tbxctrls/colrctrl.cxx | 39 ++++++++++++++++++++++++------------
4 files changed, 41 insertions(+), 17 deletions(-)
New commits:
commit 23a1b7bad5147ee48d7f920085426d8846559af7
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri May 15 14:54:58 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri May 15 17:27:10 2020 +0200
Resolves: tdf#132461 set color on mouse release, not press
and rearrange to allow dnd to drop the currently selected color, not
the one seen by SelectHdl which is now called on mouse release
which allows the dnd from color bar to gradiant tool to work as
expected
Change-Id: Ib54850ff8f73dc3a0d08c76060309a7a74d2cc8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94314
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index 3aefe3d82072..f1bdd154a790 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -272,6 +272,7 @@ public:
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
+ virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
virtual bool MouseMove( const MouseEvent& rMEvt ) override;
virtual bool KeyInput( const KeyEvent& rKEvt ) override;
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index e195f195f48d..4bc20997393f 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -477,7 +477,6 @@ bool ValueSet::MouseButtonDown( const MouseEvent& rMouseEvent )
SelectItem( pItem->mnId );
if (!(GetStyle() & WB_NOPOINTERFOCUS))
GrabFocus();
- Select();
}
else if ( rMouseEvent.GetClicks() == 2 )
maDoubleClickHdl.Call( this );
@@ -489,6 +488,17 @@ bool ValueSet::MouseButtonDown( const MouseEvent& rMouseEvent )
return CustomWidgetController::MouseButtonDown( rMouseEvent );
}
+bool ValueSet::MouseButtonUp( const MouseEvent& rMouseEvent )
+{
+ if (rMouseEvent.IsLeft() && !rMouseEvent.IsMod2())
+ {
+ Select();
+ return true;
+ }
+
+ return CustomWidgetController::MouseButtonUp( rMouseEvent );
+}
+
bool ValueSet::MouseMove(const MouseEvent& rMouseEvent)
{
// because of SelectionMode
diff --git a/svx/inc/colrctrl.hxx b/svx/inc/colrctrl.hxx
index 019be34863e6..012f0085598d 100644
--- a/svx/inc/colrctrl.hxx
+++ b/svx/inc/colrctrl.hxx
@@ -44,6 +44,7 @@ class SvxColorValueSetData;
class SAL_WARN_UNUSED SvxColorValueSet_docking final : public SvxColorValueSet
{
+ rtl::Reference<SvxColorValueSetData> m_xHelper;
bool mbLeftButton;
// ValueSet
@@ -51,6 +52,8 @@ class SAL_WARN_UNUSED SvxColorValueSet_docking final : public SvxColorValueSet
virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ virtual bool StartDrag() override;
+
public:
SvxColorValueSet_docking(std::unique_ptr<weld::ScrolledWindow> pWindow);
@@ -69,7 +72,6 @@ friend class SvxColorChildWindow;
private:
XColorListRef pColorList;
- rtl::Reference<SvxColorValueSetData> m_xHelper;
std::unique_ptr<SvxColorValueSet_docking> xColorSet;
std::unique_ptr<weld::CustomWeld> xColorSetWin;
@@ -85,8 +87,6 @@ private:
virtual bool Close() override;
- void SetupDrag(const OUString& rItemText, const Color& rItemColor, css::drawing::FillStyle eStyle);
-
public:
SvxColorDockingWindow(SfxBindings* pBindings,
SfxChildWindow *pCW,
diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
index 318598516f3f..7091a67388b9 100644
--- a/svx/source/tbxctrls/colrctrl.cxx
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -52,16 +52,21 @@ using namespace com::sun::star;
class SvxColorValueSetData final : public TransferDataContainer
{
private:
-
uno::Sequence<beans::NamedValue> m_Data;
virtual void AddSupportedFormats() override;
virtual bool GetData(const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc) override;
public:
- explicit SvxColorValueSetData(const uno::Sequence<beans::NamedValue>& rProps)
- : m_Data(rProps)
- {}
+ SvxColorValueSetData()
+ {
+ }
+
+ void SetData(const uno::Sequence<beans::NamedValue>& rData)
+ {
+ m_Data = rData;
+ ClearFormats(); // invalidate m_aAny so new data will take effect
+ }
};
void SvxColorValueSetData::AddSupportedFormats()
@@ -87,6 +92,10 @@ void SvxColorValueSet_docking::SetDrawingArea(weld::DrawingArea* pDrawingArea)
SvxColorValueSet::SetDrawingArea(pDrawingArea);
SetAccessibleName(SvxResId(STR_COLORTABLE));
SetStyle(GetStyle() | WB_ITEMBORDER);
+
+ m_xHelper.set(new SvxColorValueSetData);
+ rtl::Reference<TransferDataContainer> xHelper(m_xHelper.get());
+ SetDragDataTransferrable(xHelper, DND_ACTION_COPY);
}
SvxColorValueSet_docking::SvxColorValueSet_docking(std::unique_ptr<weld::ScrolledWindow> xWindow)
@@ -144,19 +153,27 @@ bool SvxColorValueSet_docking::MouseButtonUp( const MouseEvent& rMEvt )
return bRet;
}
-void SvxColorDockingWindow::SetupDrag(const OUString& rItemText, const Color& rItemColor, drawing::FillStyle eStyle)
+bool SvxColorValueSet_docking::StartDrag()
{
+ sal_uInt16 nPos = GetSelectedItemId();
+ Color aItemColor( GetItemColor( nPos ) );
+ OUString sItemText( GetItemText( nPos ) );
+
+ drawing::FillStyle eStyle = ((1 == nPos)
+ ? drawing::FillStyle_NONE
+ : drawing::FillStyle_SOLID);
+
uno::Sequence<beans::NamedValue> props(2);
- XFillColorItem const color(rItemText, rItemColor);
+ XFillColorItem const color(sItemText, aItemColor);
props[0].Name = "FillColor";
color.QueryValue(props[0].Value, 0);
XFillStyleItem const style(eStyle);
props[1].Name = "FillStyle";
style.QueryValue(props[1].Value, 0);
- m_xHelper.set(new SvxColorValueSetData(props));
- rtl::Reference<TransferDataContainer> xHelper(m_xHelper.get());
- xColorSet->SetDragDataTransferrable(xHelper, DND_ACTION_COPY);
+ m_xHelper->SetData(props);
+
+ return false;
}
static constexpr sal_uInt16 gnLeftSlot = SID_ATTR_FILL_COLOR;
@@ -284,10 +301,6 @@ IMPL_LINK_NOARG(SvxColorDockingWindow, SelectHdl, ValueSet*, void)
Color aColor( xColorSet->GetItemColor( nPos ) );
OUString aStr( xColorSet->GetItemText( nPos ) );
- SetupDrag(aStr, aColor, ((1 == nPos)
- ? drawing::FillStyle_NONE
- : drawing::FillStyle_SOLID));
-
if (xColorSet->IsLeftButton())
{
if ( gnLeftSlot == SID_ATTR_FILL_COLOR )
More information about the Libreoffice-commits
mailing list