summaryrefslogtreecommitdiff
path: root/chart2/source/controller/main/ChartController_Position.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/main/ChartController_Position.cxx')
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx53
1 files changed, 21 insertions, 32 deletions
diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx
index 4b9479c78dab..df047d747afd 100644
--- a/chart2/source/controller/main/ChartController_Position.cxx
+++ b/chart2/source/controller/main/ChartController_Position.cxx
@@ -19,31 +19,28 @@
#include <ChartController.hxx>
-#include <ChartWindow.hxx>
#include <DrawViewWrapper.hxx>
#include <PositionAndSizeHelper.hxx>
#include <ChartModel.hxx>
#include <ChartModelHelper.hxx>
+#include <ChartView.hxx>
#include "UndoGuard.hxx"
#include <ObjectNameProvider.hxx>
#include <DiagramHelper.hxx>
-#include <chartview/ExplicitValueProvider.hxx>
#include <CommonConverters.hxx>
#include <svx/ActionDescriptionProvider.hxx>
-#include <comphelper/servicehelper.hxx>
#include <svx/svxids.hrc>
#include <svx/rectenum.hxx>
#include <svl/intitem.hxx>
#include <svx/svxdlg.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <vcl/svapp.hxx>
#include <memory>
namespace chart
{
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
static void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt::Rectangle& rPosAndSize, const awt::Size& rOriginalSize )
{
@@ -54,19 +51,18 @@ static void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt::
RectPoint eRP = RectPoint::LT;
- const SfxPoolItem* pPoolItem=nullptr;
//read position
- if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,true,&pPoolItem)==SfxItemState::SET)
- nPosX= static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
- if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,true,&pPoolItem)==SfxItemState::SET)
- nPosY=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue();
+ if (const SfxInt32Item* pPosXItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_X))
+ nPosX = pPosXItem->GetValue();
+ if (const SfxInt32Item* pPosYItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_Y))
+ nPosY = pPosYItem->GetValue();
//read size
- if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,true,&pPoolItem)==SfxItemState::SET)
- nSizX=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
- if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,true,&pPoolItem)==SfxItemState::SET)
- nSizY=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue();
- if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,true,&pPoolItem)==SfxItemState::SET)
- eRP=static_cast<RectPoint>(static_cast<const SfxUInt16Item*>(pPoolItem)->GetValue());
+ if (const SfxUInt32Item* pWidthItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_WIDTH))
+ nSizX = pWidthItem->GetValue();
+ if (const SfxUInt32Item* pHeightItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_HEIGHT))
+ nSizY = pHeightItem->GetValue();
+ if (const SfxUInt16Item* pSizeItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_SIZE_POINT))
+ eRP=static_cast<RectPoint>(pSizeItem->GetValue());
switch( eRP )
{
@@ -150,26 +146,21 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence
if (!pPool)
return;
- sal_uInt16 nWhich;
for (const auto& aProp: *pArgs)
{
sal_Int32 nValue = 0;
aProp.Value >>= nValue;
if (aProp.Name == "TransformPosX") {
- nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_X);
- aItemSet.Put(SfxInt32Item(nWhich, nValue));
+ aItemSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X, nValue));
}
else if (aProp.Name == "TransformPosY") {
- nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_Y);
- aItemSet.Put(SfxInt32Item(nWhich, nValue));
+ aItemSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y, nValue));
}
else if (aProp.Name == "TransformWidth") {
- nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_WIDTH);
- aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue)));
+ aItemSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_WIDTH, static_cast<sal_uInt32>(nValue)));
}
else if (aProp.Name == "TransformHeight") {
- nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_HEIGHT);
- aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue)));
+ aItemSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_HEIGHT, static_cast<sal_uInt32>(nValue)));
}
}
}
@@ -177,23 +168,21 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence
if(pOutItemSet || pArgs)
{
awt::Rectangle aOldObjectRect;
- ExplicitValueProvider* pProvider(comphelper::getFromUnoTunnel<ExplicitValueProvider>( m_xChartView ));
- if( pProvider )
- aOldObjectRect = pProvider->getRectangleOfObject(aCID);
+ if( m_xChartView )
+ aOldObjectRect = m_xChartView->getRectangleOfObject(aCID);
awt::Rectangle aNewObjectRect;
lcl_getPositionAndSizeFromItemSet( aItemSet, aNewObjectRect, ToSize(aOldObjectRect) );
- awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
+ awt::Size aPageSize( ChartModelHelper::getPageSize( getChartModel() ) );
awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height );
bool bChanged = false;
if ( eObjectType == OBJECTTYPE_LEGEND )
{
- ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel());
- bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, false , true);
+ bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(*getChartModel(), false , true);
}
- bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel()
+ bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getChartModel()
, aNewObjectRect, aOldObjectRect, aPageRect );
if( bMoved || bChanged )
aUndoGuard.commit();