diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-01-15 16:31:35 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-01-30 10:43:02 +0100 |
commit | 4223ff2be69f03e571464b0b09ad0d278918631b (patch) | |
tree | 7205f05cf9773f53f0ad4433703055794eb3f997 /chart2/source/controller/main | |
parent | tdf#42949 Fix IWYU warnings in avmedia/ (diff) | |
download | core-4223ff2be69f03e571464b0b09ad0d278918631b.tar.gz core-4223ff2be69f03e571464b0b09ad0d278918631b.zip |
tdf#48436 Chart: add CustomLabelPosition UNO API property
and CUSTOM DataLabelPlacement to support custom data label positions,
and its initial implementation: only UI support with OOXML import
(tdf#130030), yet.
Change-Id: I01d986071d78ae3e2a5f43d5711e9f60b8410c21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86859
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2/source/controller/main')
3 files changed, 32 insertions, 2 deletions
diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 184c37e108ed..32c4bd78522e 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -194,7 +194,7 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence } bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() - , aObjectRect, aPageRect ); + , aObjectRect, awt::Rectangle(), aPageRect ); if( bMoved || bChanged ) aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 9266e61005c7..c7b753dda1dc 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -836,6 +836,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( pObj ) { tools::Rectangle aObjectRect = pObj->GetSnapRect(); + tools::Rectangle aOldObjectRect = pObj->GetLastBoundRect(); awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); tools::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); @@ -868,6 +869,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) + , awt::Rectangle(aOldObjectRect.getX(), aOldObjectRect.getY(), 0, 0) , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); if( bMoved || bChanged ) diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx index d9100c839a14..c1e0e14441bd 100644 --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -36,6 +36,7 @@ using namespace ::com::sun::star::chart2; bool PositionAndSizeHelper::moveObject( ObjectType eObjectType , const uno::Reference< beans::XPropertySet >& xObjectProp , const awt::Rectangle& rNewPositionAndSize + , const awt::Rectangle& rOldPositionAndSize , const awt::Rectangle& rPageRectangle ) { @@ -59,6 +60,32 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType aRelativePosition.Secondary = (double(aPos.Y())+double(aObjectRect.getHeight())/2.0)/double(aPageRect.getHeight()); xObjectProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); } + else if( eObjectType == OBJECTTYPE_DATA_LABEL ) + { + RelativePosition aAbsolutePosition; + RelativePosition aCustomLabelPosition; + aAbsolutePosition.Primary = double(rOldPositionAndSize.X) / double(aPageRect.getWidth()); + aAbsolutePosition.Secondary = double(rOldPositionAndSize.Y) / double(aPageRect.getHeight()); + + if( xObjectProp->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition ) + { + aAbsolutePosition.Primary -= aCustomLabelPosition.Primary; + aAbsolutePosition.Secondary -= aCustomLabelPosition.Secondary; + } + + //the anchor point at the data label object is top/left + Point aPos = aObjectRect.TopLeft(); + double fRotation = 0.0; + xObjectProp->getPropertyValue("TextRotation") >>= fRotation; + if( fRotation == 90.0 ) + aPos = aObjectRect.BottomLeft(); + else if( fRotation == 270.0 ) + aPos = aObjectRect.TopRight(); + + aCustomLabelPosition.Primary = double(aPos.X()) / double(aPageRect.getWidth()) - aAbsolutePosition.Primary; + aCustomLabelPosition.Secondary = double(aPos.Y()) / double(aPageRect.getHeight()) - aAbsolutePosition.Secondary; + xObjectProp->setPropertyValue("CustomLabelPosition", uno::Any(aCustomLabelPosition)); + } else if( eObjectType==OBJECTTYPE_DATA_CURVE_EQUATION ) { //@todo decide whether x is primary or secondary @@ -128,6 +155,7 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType bool PositionAndSizeHelper::moveObject( const OUString& rObjectCID , const uno::Reference< frame::XModel >& xChartModel , const awt::Rectangle& rNewPositionAndSize + , const awt::Rectangle& rOldPositionAndSize , const awt::Rectangle& rPageRectangle ) { @@ -143,7 +171,7 @@ bool PositionAndSizeHelper::moveObject( const OUString& rObjectCID if(!xObjectProp.is()) return false; } - return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rPageRectangle ); + return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rOldPositionAndSize, rPageRectangle ); } } //namespace chart |