Kaydet (Commit) f6727831 authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Marco Cecchetti

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: 's avatarMarco Cecchetti <mrcekets@gmail.com>
üst c2e30949
......@@ -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();
......
......@@ -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" )
......
......@@ -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)
......
......@@ -991,7 +991,14 @@ void CallbackFlushHandler::queue(const int type, const char* data)
}
#endif
if (m_bPartTilePainting)
bool bIsChartActive = false;
if (type == LOK_CALLBACK_GRAPHIC_SELECTION)
{
LokChartHelper aChartHelper(SfxViewShell::Current());
bIsChartActive = aChartHelper.GetWindow() != nullptr;
}
if (m_bPartTilePainting && !bIsChartActive)
{
// We drop notifications when this is set, except for important ones.
// When we issue a complex command (such as .uno:InsertAnnotation)
......@@ -3038,13 +3045,20 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
{
bool bNeedConversion = false;
SfxViewShell* pViewShell = SfxViewShell::Current();
if (const SdrView* pView = pViewShell->GetDrawView())
LokChartHelper aChartHelper(pViewShell);
if (aChartHelper.GetWindow() )
{
bNeedConversion = true;
}
else if (const SdrView* pView = pViewShell->GetDrawView())
{
if (OutputDevice* pOutputDevice = pView->GetFirstOutputDevice())
{
bNeedConversion = (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM);
}
}
if (bNeedConversion)
{
sal_Int32 value;
......@@ -3061,8 +3075,35 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
value = OutputDevice::LogicToLogic(value, MapUnit::MapTwip, MapUnit::Map100thMM);
rPropValue.Value <<= value;
}
}
}
if (aChartHelper.GetWindow())
{
tools::Rectangle aChartBB = aChartHelper.GetChartBoundingBox();
int nLeft = OutputDevice::LogicToLogic(aChartBB.Left(), MapUnit::MapTwip, MapUnit::Map100thMM);
int nTop = OutputDevice::LogicToLogic(aChartBB.Top(), MapUnit::MapTwip, MapUnit::Map100thMM);
sal_Int32 value;
for (beans::PropertyValue& rPropValue: aPropertyValuesVector)
{
if (rPropValue.Name == "TransformPosX" || rPropValue.Name == "TransformRotationX")
{
rPropValue.Value >>= value;
rPropValue.Value <<= value - nLeft;
}
else if (rPropValue.Name == "TransformPosY" || rPropValue.Name == "TransformRotationY")
{
rPropValue.Value >>= value;
rPropValue.Value <<= value - nTop;
}
}
util::URL aCommandURL;
aCommandURL.Path = "LOKTransform";
css::uno::Reference<css::frame::XDispatch>& aChartDispatcher = aChartHelper.GetXDispatcher();
aChartDispatcher->dispatch(aCommandURL, comphelper::containerToSequence(aPropertyValuesVector));
return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment