diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2019-04-10 15:49:12 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-08-05 21:06:40 -0400 |
commit | 0f21e91722844c18baaf23f4ea8c85956d19303a (patch) | |
tree | ace2e6549f2e5ddd3338677711dfbb9bbbeba9ed /chart2 | |
parent | 35d6c6ffc9b3f66e3802d1770c4e87cf843c3a48 (diff) |
lok: dragging and resizing chart elements
This patch make possible to set the new position or size of a chart
object through setting directly the property value instead of sending
mouse events to the core.
Change-Id: Ifc06dac6bdad78081d63e0ea0db55563a1ae57bc
Reviewed-on: https://gerrit.libreoffice.org/70566
Tested-by: Jenkins
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/inc/ChartController.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController.cxx | 4 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Position.cxx | 90 |
3 files changed, 67 insertions, 29 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 3ad81a5848ca..4165fcf3f38e 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -480,7 +480,7 @@ private: bool EndTextEdit(); void executeDispatch_View3D(); - void executeDispatch_PositionAndSize(); + void executeDispatch_PositionAndSize( const ::css::uno::Sequence< ::css::beans::PropertyValue >* pArgs = nullptr ); void executeDispatch_EditData(); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 717c2b5decd5..e8c177b9d940 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1091,6 +1091,10 @@ void SAL_CALL ChartController::dispatch( executeDispatch_LOKSetTextSelection(nType, nX, nY); } } + else if (aCommand == "LOKTransform") + { + this->executeDispatch_PositionAndSize(&rArgs); + } else if(aCommand == "Paste") this->executeDispatch_Paste(); else if(aCommand == "Copy" ) diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 37e832977dfb..e6010725da67 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -107,7 +107,7 @@ static void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt:: rPosAndSize = awt::Rectangle(nPosX,nPosY,nSizX,nSizY); } -void ChartController::executeDispatch_PositionAndSize() +void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence< ::css::beans::PropertyValue >* pArgs) { const OUString aCID( m_aSelection.getSelectedCID() ); @@ -130,40 +130,74 @@ void ChartController::executeDispatch_PositionAndSize() try { SfxItemSet aItemSet = m_pDrawViewWrapper->getPositionAndSizeItemSetFromMarkedObject(); + const SfxItemSet* pOutItemSet = nullptr; + if (!pArgs) + { + //prepare and open dialog + SdrView* pSdrView = m_pDrawViewWrapper.get(); + bool bResizePossible = m_aSelection.isResizeableObjectSelected(); - //prepare and open dialog - SdrView* pSdrView = m_pDrawViewWrapper.get(); - bool bResizePossible = m_aSelection.isResizeableObjectSelected(); - - SolarMutexGuard aGuard; - SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); - vcl::Window* pWin = GetChartWindow(); - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSchTransformTabDialog( - pWin ? pWin->GetFrameWeld() : nullptr, &aItemSet, pSdrView, bResizePossible)); + SolarMutexGuard aGuard; + SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); + vcl::Window* pWin = GetChartWindow(); + ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSchTransformTabDialog( + pWin ? pWin->GetFrameWeld() : nullptr, &aItemSet, pSdrView, bResizePossible)); - if( pDlg->Execute() == RET_OK ) + if( pDlg->Execute() == RET_OK ) + { + pOutItemSet = pDlg->GetOutputItemSet(); + if (pOutItemSet) + aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set) + } + } + else { - const SfxItemSet* pOutItemSet = pDlg->GetOutputItemSet(); - if(pOutItemSet) + const SfxItemPool* pPool = aItemSet.GetPool(); + if (!pPool) + return; + + sal_uInt16 nWhich; + for (const auto& aProp: *pArgs) { - awt::Rectangle aObjectRect; - aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set) - lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect, aSelectedSize ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); - awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); - - bool bChanged = false; - if ( eObjectType == OBJECTTYPE_LEGEND ) - { - ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel().get()); - bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, false , true); + sal_Int32 nValue = 0; + aProp.Value >>= nValue; + if (aProp.Name == "TransformPosX") { + nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_X); + aItemSet.Put(SfxInt32Item(nWhich, nValue)); + } + else if (aProp.Name == "TransformPosY") { + nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_Y); + aItemSet.Put(SfxInt32Item(nWhich, nValue)); + } + else if (aProp.Name == "TransformWidth") { + nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_WIDTH); + aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue))); } + else if (aProp.Name == "TransformHeight") { + nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_HEIGHT); + aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue))); + } + } + } - bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() - , aObjectRect, aPageRect ); - if( bMoved || bChanged ) - aUndoGuard.commit(); + if(pOutItemSet || pArgs) + { + awt::Rectangle aObjectRect; + lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect, aSelectedSize ); + awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); + + bool bChanged = false; + if ( eObjectType == OBJECTTYPE_LEGEND ) + { + ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel().get()); + bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, false , true); } + + bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() + , aObjectRect, aPageRect ); + if( bMoved || bChanged ) + aUndoGuard.commit(); } } catch(const uno::Exception& e) |