Kaydet (Commit) 4a7a37f9 authored tarafından Marco Cecchetti's avatar Marco Cecchetti

lok: chart: constrained dragging of pie segments

The extra information for the graphic selection is now formatted
according to JSON syntax so that is easier to parse.

Information for allowing the client to performa constrained dragging
of a pie segment is appended when needed to the graphic selection
message.

A polygon approximation of the pie segment in svg format is attached
too to the graphic selection message.

Core now is able to handle a specific msg from the client with data
about the new pie segment offset computed by the client on drag end.
This information is dispatched by the chart controller to a specific
method: executeDispatch_LOKPieSegmentDragging.

Change-Id: I42e7742508fa3a453383bf7b95e47df169f24834
Reviewed-on: https://gerrit.libreoffice.org/70568Reviewed-by: 's avatarMarco Cecchetti <mrcekets@gmail.com>
Tested-by: 's avatarMarco Cecchetti <mrcekets@gmail.com>
üst e9e57c61
......@@ -501,6 +501,7 @@ private:
void executeDispatch_ToggleGridVertical();
void executeDispatch_LOKSetTextSelection(int nType, int nX, int nY);
void executeDispatch_LOKPieSegmentDragging(int nOffset);
void sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle);
......
......@@ -1087,7 +1087,25 @@ void SAL_CALL ChartController::dispatch(
}
else if (aCommand == "LOKTransform")
{
this->executeDispatch_PositionAndSize(&rArgs);
if (rArgs[0].Name == "Action")
{
OUString sAction;
if ((rArgs[0].Value >>= sAction) && sAction == "PieSegmentDragging")
{
if (rArgs[1].Name == "Offset")
{
sal_Int32 nOffset;
if (rArgs[1].Value >>= nOffset)
{
this->executeDispatch_LOKPieSegmentDragging(nOffset);
}
}
}
}
else
{
this->executeDispatch_PositionAndSize(&rArgs);
}
}
else if(aCommand == "Paste")
this->executeDispatch_Paste();
......
......@@ -962,6 +962,26 @@ void ChartController::executeDispatch_LOKSetTextSelection(int nType, int nX, int
}
}
void ChartController::executeDispatch_LOKPieSegmentDragging( int nOffset )
{
try
{
OUString aCID( m_aSelection.getSelectedCID() );
const uno::Reference< frame::XModel >& xChartModel = getModel();
if( xChartModel.is() )
{
Reference< beans::XPropertySet > xPointProperties(
ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) );
if( xPointProperties.is() )
xPointProperties->setPropertyValue( "Offset", uno::Any( nOffset / 100.0 ) );
}
}
catch( const uno::Exception & ex )
{
SAL_WARN( "chart2", "Exception caught. " << ex );
}
}
void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const Sequence< beans::PropertyValue >& rArgs )
{
Reference< frame::XDispatch > xDispatch( m_aDispatchContainer.getShapeController() );
......
......@@ -56,7 +56,7 @@ static const char m_aMultiClick[] = "MultiClick";
static const char m_aDragMethodEquals[] = "DragMethod=";
static const char m_aDragParameterEquals[] = "DragParameter=";
static const char m_aProtocol[] = "CID/";
static const OUString m_aPieSegmentDragMethodServiceName("PieSegmentDraging");
static const OUString m_aPieSegmentDragMethodServiceName("PieSegmentDragging");
namespace
{
......
......@@ -3080,25 +3080,27 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
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 (aPropertyValuesVector[0].Name != "Action")
{
if (rPropValue.Name == "TransformPosX" || rPropValue.Name == "TransformRotationX")
{
rPropValue.Value >>= value;
rPropValue.Value <<= value - nLeft;
}
else if (rPropValue.Name == "TransformPosY" || rPropValue.Name == "TransformRotationY")
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)
{
rPropValue.Value >>= value;
rPropValue.Value <<= value - nTop;
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();
......
This diff is collapsed.
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