[Libreoffice-commits] core.git: chart2/source

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 11 06:41:49 UTC 2020


 chart2/source/controller/main/ChartController_Window.cxx |   32 +++++++++++----
 1 file changed, 24 insertions(+), 8 deletions(-)

New commits:
commit db7a5861b2c42a56aa56af0bee1e9c5b06faee99
Author:     Tünde Tóth <toth.tunde at nisz.hu>
AuthorDate: Tue Sep 8 16:47:20 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Sep 11 08:41:08 2020 +0200

    tdf#136573 chart2: enable arrow keys in data label
    
    moving to custom positions.
    
    Follow-up of commit c10d5854b5427ad1bfffc00e77a9306c99c78c63
    (tdf#136430 Fix chart crash trying to move data labels
    with arrow keys.)
    
    Change-Id: I8833e14a7c9c8f7bdb758fc0eb97be38aee35b34
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102262
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index a7b6ee840b55..aedeab062113 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1512,8 +1512,29 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
                     if( !m_aSelection.getSelectedCID().isEmpty() )
                     {
                         //move chart objects
-                        bReturn = impl_moveOrResizeObject(
-                            m_aSelection.getSelectedCID(), MOVE_OBJECT, fShiftAmountX, fShiftAmountY );
+                        if (eObjectType == OBJECTTYPE_DATA_LABEL)
+                        {
+                            SdrObject* pObj = pDrawViewWrapper->getSelectedObject();
+                            if (pObj)
+                            {
+                                tools::Rectangle aRect = pObj->GetSnapRect();
+                                awt::Size aPageSize(ChartModelHelper::getPageSize(getModel()));
+                                if ((fShiftAmountX > 0.0 && (aRect.getX() + fShiftAmountX + aRect.getWidth() > aPageSize.Width)) ||
+                                    (fShiftAmountX < 0.0 && (aRect.getX() + fShiftAmountX < 0)) ||
+                                    (fShiftAmountY > 0.0 && (aRect.getY() + fShiftAmountY + aRect.getHeight() > aPageSize.Height)) ||
+                                    (fShiftAmountY < 0.0 && (aRect.getY() + fShiftAmountY < 0)))
+                                    bReturn = false;
+                                else
+                                    bReturn = PositionAndSizeHelper::moveObject(
+                                        m_aSelection.getSelectedCID(), getModel(),
+                                        awt::Rectangle(aRect.getX() + fShiftAmountX, aRect.getY() + fShiftAmountY, aRect.getWidth(), aRect.getHeight()),
+                                        awt::Rectangle(aRect.getX(), aRect.getY(), 0, 0),
+                                        awt::Rectangle(0, 0, aPageSize.Width, aPageSize.Height));
+                            }
+                        }
+                        else
+                            bReturn = impl_moveOrResizeObject(
+                                m_aSelection.getSelectedCID(), MOVE_OBJECT, fShiftAmountX, fShiftAmountY );
                     }
                     else
                     {
@@ -1765,12 +1786,6 @@ bool ChartController::impl_moveOrResizeObject(
 {
     bool bResult = false;
     bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT );
-    ObjectType eObjectType = ObjectIdentifier::getObjectType(rCID);
-
-    /*TODO: Move data label objects with arrow-keys,
-    in that case we have to use CustomLabelPosition instead of RelativePosition!*/
-    if( eObjectType == OBJECTTYPE_DATA_LABEL )
-        return bResult;
 
     uno::Reference< frame::XModel > xChartModel( getModel() );
     uno::Reference< beans::XPropertySet > xObjProp(
@@ -1830,6 +1845,7 @@ bool ChartController::impl_moveOrResizeObject(
             if( bNeedResize )
                 eActionType = ActionDescriptionProvider::ActionType::Resize;
 
+            ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
             UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
                     eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager );
             {


More information about the Libreoffice-commits mailing list