summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/main/ChartController_Position.cxx
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2003-12-10 17:34:50 +0000
committerIngrid Halama <iha@openoffice.org>2003-12-10 17:34:50 +0000
commit87c434239d7052a87a99429989c610352c067286 (patch)
treeded4b80c58ac84ba37905b65a53545cf9ef59baa /chart2/source/controller/main/ChartController_Position.cxx
parentadded slot SID_ATTR_TRANSFORM with method executeDispatch_PositionAndSize (diff)
downloadcore-87c434239d7052a87a99429989c610352c067286.tar.gz
core-87c434239d7052a87a99429989c610352c067286.zip
added method implementation executeDispatch_PositionAndSize
Diffstat (limited to 'chart2/source/controller/main/ChartController_Position.cxx')
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx
index 9c7f449b3f6d..73c24613c165 100644
--- a/chart2/source/controller/main/ChartController_Position.cxx
+++ b/chart2/source/controller/main/ChartController_Position.cxx
@@ -1,10 +1,13 @@
#include "ChartController.hxx"
+#include "dlg_PositionAndSize.hxx"
#include "dlg_RotateDiagram.hxx"
#include "macros.hxx"
#include "ChartWindow.hxx"
#include "Rotation.hxx"
#include "ChartModelHelper.hxx"
+#include "DrawViewWrapper.hxx"
+#include "PositionAndSizeHelper.hxx"
#ifndef _DRAFTS_COM_SUN_STAR_CHART2_SCENEDESCRIPTOR_HPP_
#include <drafts/com/sun/star/chart2/SceneDescriptor.hpp>
@@ -15,6 +18,10 @@
#include <vcl/msgbox.hxx>
#endif
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
//.............................................................................
namespace chart
{
@@ -25,6 +32,73 @@ using namespace ::drafts::com::sun::star::chart2;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, Rectangle& rPosAndSize )
+{
+ long nPosX(0);
+ long nPosY(0);
+ long nSizX(0);
+ long nSizY(0);
+
+ const SfxPoolItem* pPoolItem=NULL;
+ //read position
+ if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,TRUE,&pPoolItem))
+ nPosX=((const SfxInt32Item*)pPoolItem)->GetValue();
+ if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,TRUE,&pPoolItem))
+ nPosY=((const SfxInt32Item*)pPoolItem)->GetValue();
+ //read size
+ if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,TRUE,&pPoolItem))
+ nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue();
+ if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,TRUE,&pPoolItem))
+ nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue();
+
+ rPosAndSize = Rectangle(Point(nPosX,nPosY),Size(nSizX,nSizY));
+}
+
+void SAL_CALL ChartController::executeDispatch_PositionAndSize( const ::rtl::OUString& rObjectCID )
+{
+ if( !rObjectCID.getLength() )
+ return;
+
+ bool bChanged = false;
+ try
+ {
+ SfxItemSet aItemSet = m_pDrawViewWrapper->getPositionAndSizeItemSetFromMarkedObject();
+
+ //prepare and open dialog
+ Window* pParent( NULL );
+ SdrView* pSdrView = m_pDrawViewWrapper;
+ bool bResizePossible=true;
+ PositionAndSizeDialog aDlg( pParent, &aItemSet, pSdrView, bResizePossible );
+ if( aDlg.Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet();
+ if(pOutItemSet)
+ {
+ Rectangle aObjectRect;
+ aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set)
+ lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect );
+ Rectangle aPageRect( Point(0,0),m_pChartWindow->GetOutputSize() );
+
+ bChanged = PositionAndSizeHelper::moveObject( m_aSelectedObjectCID
+ , m_aModel->getModel()
+ , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
+ , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight())
+ );
+ }
+ }
+ }
+ catch( uno::RuntimeException& e)
+ {
+ ASSERT_EXCEPTION( e );
+ }
+ //make sure that all objects using m_pChartView are already deleted
+ if(bChanged)
+ {
+ m_bViewDirty = true;
+ m_pChartWindow->Invalidate();
+ }
+}
+
void SAL_CALL ChartController::executeDispatch_RotateDiagram()
{
bool bChanged = false;