summaryrefslogtreecommitdiff
path: root/chart2/source/controller
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller')
-rw-r--r--chart2/source/controller/chartapiwrapper/LegendWrapper.cxx2
-rw-r--r--chart2/source/controller/inc/PositionAndSizeHelper.hxx2
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx13
-rw-r--r--chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx11
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx2
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx2
-rw-r--r--chart2/source/controller/main/PositionAndSizeHelper.cxx30
7 files changed, 54 insertions, 8 deletions
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
index e4059c6d4b74..4dce225ba570 100644
--- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
@@ -309,7 +309,7 @@ void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize )
awt::Rectangle aNewPositionAndSize(aPos.X,aPos.Y,aSize.Width,aSize.Height);
PositionAndSizeHelper::moveObject( OBJECTTYPE_LEGEND
- , xProp, aNewPositionAndSize, aPageRectangle );
+ , xProp, aNewPositionAndSize, awt::Rectangle(), aPageRectangle );
}
}
diff --git a/chart2/source/controller/inc/PositionAndSizeHelper.hxx b/chart2/source/controller/inc/PositionAndSizeHelper.hxx
index f65b333c3407..964eebfb03cc 100644
--- a/chart2/source/controller/inc/PositionAndSizeHelper.hxx
+++ b/chart2/source/controller/inc/PositionAndSizeHelper.hxx
@@ -34,11 +34,13 @@ public:
static bool moveObject( ObjectType eObjectType
, const css::uno::Reference< css::beans::XPropertySet >& xObjectProp
, const css::awt::Rectangle& rNewPositionAndSize
+ , const css::awt::Rectangle& rOldPositionAndSize
, const css::awt::Rectangle& rPageRectangle );
static bool moveObject( const OUString& rObjectCID
, const css::uno::Reference< css::frame::XModel >& xChartModel
, const css::awt::Rectangle& rNewPositionAndSize
+ , const css::awt::Rectangle& rOldPositionAndSize
, const css::awt::Rectangle& rPageRectangle );
};
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 43721c24502a..aab6be665814 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -31,9 +31,11 @@
#include <ChartTypeHelper.hxx>
#include <unonames.hxx>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <svx/xflclit.hxx>
@@ -409,6 +411,7 @@ bool DataPointItemConverter::ApplySpecialItem(
{
sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();
sal_Int32 nOld =0;
+ RelativePosition aCustomLabelPosition;
if( !(GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nOld) )
{
if( m_aAvailableLabelPlacements.hasElements() )
@@ -424,9 +427,10 @@ bool DataPointItemConverter::ApplySpecialItem(
bChanged = true;
}
}
- else if( nOld!=nNew )
+ else if( nOld!=nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) )
{
- GetPropertySet()->setPropertyValue( "LabelPlacement" , uno::Any( nNew ));
+ GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew));
+ GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any());
bChanged = true;
}
}
@@ -641,7 +645,10 @@ void DataPointItemConverter::FillSpecialItem(
try
{
sal_Int32 nPlacement=0;
- if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
+ RelativePosition aCustomLabelPosition;
+ if( !m_bOverwriteLabelsForAttributedDataPointsAlso && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) )
+ rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
+ else if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement )
rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement ));
else if( m_aAvailableLabelPlacements.hasElements() )
rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] ));
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index 70dc31a46b92..f5c9d8a0ce4d 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -37,9 +37,11 @@
#include <tools/diagnose_ex.h>
#include <vcl/graph.hxx>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
#include <memory>
using namespace com::sun::star;
@@ -370,6 +372,7 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte
{
sal_Int32 nNew = static_cast<const SfxInt32Item&>(rItemSet.Get(nWhichId)).GetValue();
sal_Int32 nOld = 0;
+ RelativePosition aCustomLabelPosition;
if (!(GetPropertySet()->getPropertyValue("LabelPlacement") >>= nOld))
{
if (maAvailableLabelPlacements.hasElements())
@@ -385,9 +388,10 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte
bChanged = true;
}
}
- else if (nOld != nNew)
+ else if (nOld != nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition))
{
GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew));
+ GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any());
bChanged = true;
}
}
@@ -591,7 +595,10 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r
try
{
sal_Int32 nPlacement = 0;
- if (GetPropertySet()->getPropertyValue("LabelPlacement") >>= nPlacement)
+ RelativePosition aCustomLabelPosition;
+ if (!mbDataSeries && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition))
+ rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM));
+ else if (GetPropertySet()->getPropertyValue("LabelPlacement") >>= nPlacement)
rOutItemSet.Put(SfxInt32Item(nWhichId, nPlacement));
else if (maAvailableLabelPlacements.hasElements())
rOutItemSet.Put(SfxInt32Item(nWhichId, maAvailableLabelPlacements[0]));
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