[Libreoffice-commits] core.git: include/svx svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 13 17:15:25 UTC 2020


 include/svx/dialcontrol.hxx                         |    6 +++-
 svx/source/dialog/dialcontrol.cxx                   |   26 ++++++++++++--------
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx |    9 ++----
 svx/source/sidebar/possize/PosSizePropertyPanel.hxx |    2 -
 4 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit 1caaf3cb0691a1659379ae3ce9964f600da5aa66
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jan 13 10:30:20 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jan 13 18:14:53 2020 +0100

    update rotation immediately in sidebar
    
    Change-Id: I7e44c3010bf44dca9c97548e040edf3af3573c43
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86674
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx
index a67d522dff61..1b768e2c9ec5 100644
--- a/include/svx/dialcontrol.hxx
+++ b/include/svx/dialcontrol.hxx
@@ -115,6 +115,8 @@ public:
     const OUString&     GetText() const { return mpImpl->maText; }
     void                SetText(const OUString& rText) { mpImpl->maText = rText; }
 
+    void                SetModifyHdl( const Link<DialControl&,void>& rLink );
+
     void                Init( const Size& rWinSize );
 private:
     struct DialControl_Impl
@@ -122,6 +124,7 @@ private:
         ScopedVclPtr<DialControlBmp> mxBmpEnabled;
         ScopedVclPtr<DialControlBmp> mxBmpDisabled;
         ScopedVclPtr<DialControlBmp> mxBmpBuffered;
+        Link<DialControl&,void>      maModifyHdl;
         OUString            maText;
         weld::SpinButton*   mpLinkField;
         sal_Int32           mnLinkedFieldValueMultiplyer;
@@ -143,12 +146,13 @@ private:
     void                HandleMouseEvent( const Point& rPos, bool bInitial );
     void                HandleEscapeEvent();
 
+    void                SetRotation( sal_Int32 nAngle, bool bBroadcast );
+
     void                Init( const Size& rWinSize, const vcl::Font& rWinFont );
 
     void                InvalidateControl();
 
     DECL_LINK(LinkedFieldModifyHdl, weld::SpinButton&, void);
-    void LinkedFieldModifyHdl();
 };
 
 }
diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx
index 3ca96e2926af..6ebe5e397db2 100644
--- a/svx/source/dialog/dialcontrol.cxx
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -354,6 +354,11 @@ sal_Int32 DialControl::GetRotation() const
     return mpImpl->mnAngle;
 }
 
+void DialControl::SetRotation(sal_Int32 nAngle)
+{
+    SetRotation(nAngle, false);
+}
+
 void DialControl::SetLinkedField(weld::SpinButton* pField, sal_Int32 nDecimalPlaces)
 {
     mpImpl->mnLinkedFieldValueMultiplyer = 100 / std::pow(10.0, double(nDecimalPlaces));
@@ -376,13 +381,7 @@ void DialControl::SetLinkedField(weld::SpinButton* pField, sal_Int32 nDecimalPla
 
 IMPL_LINK_NOARG(DialControl, LinkedFieldModifyHdl, weld::SpinButton&, void)
 {
-    LinkedFieldModifyHdl();
-}
-
-void DialControl::LinkedFieldModifyHdl()
-{
-    if( mpImpl->mpLinkField )
-        SetRotation(mpImpl->mpLinkField->get_value() * mpImpl->mnLinkedFieldValueMultiplyer);
+    SetRotation(mpImpl->mpLinkField->get_value() * mpImpl->mnLinkedFieldValueMultiplyer, true);
 }
 
 void DialControl::SaveValue()
@@ -422,7 +421,7 @@ void DialControl::InvalidateControl()
     Invalidate();
 }
 
-void DialControl::SetRotation(sal_Int32 nAngle)
+void DialControl::SetRotation(sal_Int32 nAngle, bool bBroadcast)
 {
     bool bOldSel = mpImpl->mbNoRot;
     mpImpl->mbNoRot = false;
@@ -436,9 +435,16 @@ void DialControl::SetRotation(sal_Int32 nAngle)
         InvalidateControl();
         if( mpImpl->mpLinkField )
             mpImpl->mpLinkField->set_value(GetRotation() / mpImpl->mnLinkedFieldValueMultiplyer);
+        if( bBroadcast )
+            mpImpl->maModifyHdl.Call(*this);
     }
 }
 
+void DialControl::SetModifyHdl( const Link<DialControl&,void>& rLink )
+{
+    mpImpl->maModifyHdl = rLink;
+}
+
 void DialControl::HandleMouseEvent( const Point& rPos, bool bInitial )
 {
     long nX = rPos.X() - mpImpl->mnCenterX;
@@ -454,7 +460,7 @@ void DialControl::HandleMouseEvent( const Point& rPos, bool bInitial )
             nAngle = ((nAngle + 750) / 1500) * 1500;
         // Round up to 1 degree
         nAngle = (((nAngle + 50) / 100) * 100) % 36000;
-        SetRotation( nAngle );
+        SetRotation(nAngle, true);
     }
 }
 
@@ -463,7 +469,7 @@ void DialControl::HandleEscapeEvent()
     if( IsMouseCaptured() )
     {
         ReleaseMouse();
-        SetRotation( mpImpl->mnOldAngle );
+        SetRotation(mpImpl->mnOldAngle, true);
         if( mpImpl->mpLinkField )
             mpImpl->mpLinkField->grab_focus();
     }
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index a0d030172cef..fb4798920ce4 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -207,11 +207,9 @@ void PosSizePropertyPanel::Initialize()
     //Size : Keep ratio
     mxCbxScale->connect_toggled( LINK( this, PosSizePropertyPanel, ClickAutoHdl ) );
 
-    //rotation:
-    mxMtrAngle->connect_value_changed(LINK( this, PosSizePropertyPanel, AngleModifiedHdl));
-
     //rotation control
     mxCtrlDial->SetLinkedField(mxMtrAngle.get());
+    mxCtrlDial->SetModifyHdl(LINK( this, PosSizePropertyPanel, RotationHdl));
 
     //use same logic as DialControl_Impl::SetSize
     weld::DrawingArea* pDrawingArea = mxCtrlDial->GetDrawingArea();
@@ -438,9 +436,9 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ClickAutoHdl, weld::ToggleButton&, void )
     aPageOpt.SetUserItem( USERITEM_NAME, css::uno::makeAny( OUString::number( int(mxCbxScale->get_active()) ) ) );
 }
 
-IMPL_LINK_NOARG( PosSizePropertyPanel, AngleModifiedHdl, weld::SpinButton&, void )
+IMPL_LINK_NOARG( PosSizePropertyPanel, RotationHdl, DialControl&, void )
 {
-    sal_Int64 nTmp = mxMtrAngle->get_value() * 100;
+    sal_Int32 nTmp = mxCtrlDial->GetRotation();
 
     // #i123993# Need to take UIScale into account when executing rotations
     const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);
@@ -452,7 +450,6 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, AngleModifiedHdl, weld::SpinButton&, void
             SfxCallMode::RECORD, { &aAngleItem, &aRotXItem, &aRotYItem });
 }
 
-
 IMPL_STATIC_LINK_NOARG( PosSizePropertyPanel, ClickChartEditHdl, weld::Button&, void )
 {
     SfxViewShell* pCurSh = SfxViewShell::Current();
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
index 297ddbc9ce81..271b160d88d1 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.hxx
@@ -152,7 +152,7 @@ private:
     DECL_LINK( ChangeWidthHdl, weld::MetricSpinButton&, void );
     DECL_LINK( ChangeHeightHdl, weld::MetricSpinButton&, void );
     DECL_LINK( ClickAutoHdl, weld::ToggleButton&, void );
-    DECL_LINK( AngleModifiedHdl, weld::SpinButton&, void );
+    DECL_LINK( RotationHdl, svx::DialControl&, void );
     DECL_STATIC_LINK( PosSizePropertyPanel, ClickChartEditHdl, weld::Button&, void );
 
     void Initialize();


More information about the Libreoffice-commits mailing list