summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2019-04-10 15:49:12 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2019-05-20 10:34:29 +0200
commitf6727831d56afe6360a2489a1bc251990fe26c19 (patch)
treede5430a13601264817a26aac7013a1f482832e82 /chart2
parentc2e30949e0fb7c6a73742450f646e0d8d59d5e4f (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.hxx2
-rw-r--r--chart2/source/controller/main/ChartController.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx90
3 files changed, 67 insertions, 29 deletions
diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx
index eb4cad46b540..a14224e24c73 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -481,7 +481,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 d26d2be9da39..5540d67a0e90 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1085,6 +1085,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 6fc9eeb948a6..164b2197ec91 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)