summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/main/PositionAndSizeHelper.cxx
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2020-01-15 16:31:35 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-30 10:43:02 +0100
commit4223ff2be69f03e571464b0b09ad0d278918631b (patch)
tree7205f05cf9773f53f0ad4433703055794eb3f997 /chart2/source/controller/main/PositionAndSizeHelper.cxx
parenttdf#42949 Fix IWYU warnings in avmedia/ (diff)
downloadcore-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/PositionAndSizeHelper.cxx')
-rw-r--r--chart2/source/controller/main/PositionAndSizeHelper.cxx30
1 files changed, 29 insertions, 1 deletions
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