summaryrefslogtreecommitdiff
path: root/chart2/source/controller/main/PositionAndSizeHelper.cxx
diff options
context:
space:
mode:
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