summaryrefslogtreecommitdiff
path: root/chart2/source/controller/main
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/main')
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx14
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx9
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx16
-rw-r--r--chart2/source/controller/main/PositionAndSizeHelper.cxx59
-rw-r--r--chart2/source/controller/main/SelectionHelper.cxx20
5 files changed, 65 insertions, 53 deletions
diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx
index 0f2a722c2872..37cbdbb30f6b 100644
--- a/chart2/source/controller/main/ChartController_Position.cxx
+++ b/chart2/source/controller/main/ChartController_Position.cxx
@@ -37,6 +37,7 @@
#include "UndoGuard.hxx"
#include "Strings.hrc"
#include "ObjectNameProvider.hxx"
+#include "DiagramHelper.hxx"
#include "chartview/ExplicitValueProvider.hxx"
#include "CommonConverters.hxx"
#include <svx/ActionDescriptionProvider.hxx>
@@ -135,10 +136,12 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize()
if( pProvider )
aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) );
+ ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID );
+
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::POS_SIZE,
- ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))),
+ ObjectNameProvider::getName( eObjectType)),
m_xUndoManager );
SfxAbstractTabDialog * pDlg = NULL;
@@ -169,11 +172,14 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize()
awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height );
- bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
- , getModel()
+ bool bChanged = false;
+ if ( eObjectType == OBJECTTYPE_LEGEND )
+ bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( getModel(), false , true );
+
+ bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel()
, awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
, awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
- if( bChanged )
+ if( bMoved || bChanged )
aUndoGuard.commit();
}
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 945ccf4b4b34..0282abcefdf7 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -251,7 +251,11 @@ void ChartController::executeDispatch_NewArrangement()
// legend
Reference< beans::XPropertyState > xLegendState( xDiagram->getLegend(), uno::UNO_QUERY );
if( xLegendState.is())
+ {
xLegendState->setPropertyToDefault( C2U("RelativePosition"));
+ xLegendState->setPropertyToDefault( C2U("RelativeSize"));
+ xLegendState->setPropertyToDefault( C2U("AnchorPosition"));
+ }
// titles
for( sal_Int32 eType = TitleHelper::TITLE_BEGIN;
@@ -696,6 +700,11 @@ bool ChartController::executeDispatch_Delete()
bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
else if( eParentObjectType == OBJECTTYPE_DATA_CURVE )
bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
+ else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE )
+ {
+ executeDispatch_DeleteMeanValue();
+ bReturn = true;
+ }
break;
}
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index bc06886f14a3..1692c5761ae9 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -871,16 +871,22 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if( !bIsMoveOnly && m_aSelection.isResizeableObjectSelected() )
eActionType = ActionDescriptionProvider::RESIZE;
+ ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() );
+
UndoGuard aUndoGuard(
- ActionDescriptionProvider::createDescription(
- eActionType,
- ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))),
+ ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( eObjectType)),
m_xUndoManager );
- bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
+
+ bool bChanged = false;
+ if ( eObjectType == OBJECTTYPE_LEGEND )
+ bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( getModel(), false , true );
+
+ bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
, getModel()
, awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
, awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
- if( bChanged )
+
+ if( bMoved || bChanged )
{
bDraggingDone = true;
aUndoGuard.commit();
diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx
index f0ce3eaaa04e..bdee4a14f66b 100644
--- a/chart2/source/controller/main/PositionAndSizeHelper.cxx
+++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx
@@ -33,6 +33,7 @@
#include "ChartModelHelper.hxx"
#include "ControllerLockGuard.hxx"
#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
#include "chartview/ExplicitValueProvider.hxx"
@@ -83,51 +84,12 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType
}
else if(OBJECTTYPE_LEGEND==eObjectType)
{
- LegendPosition ePos = LegendPosition_LINE_END;
- xObjectProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos;
+ xObjectProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny(LegendPosition(LegendPosition_CUSTOM)));
+ xObjectProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny(::com::sun::star::chart::ChartLegendExpansion_CUSTOM));
chart2::RelativePosition aRelativePosition;
+ chart2::RelativeSize aRelativeSize;
Point aAnchor = aObjectRect.TopLeft();
- switch( ePos )
- {
- case LegendPosition_LINE_START:
- {
- //@todo language dependent positions ...
- aRelativePosition.Anchor = drawing::Alignment_LEFT;
- aAnchor = aObjectRect.LeftCenter();
- }
- break;
- case LegendPosition_LINE_END:
- {
- //@todo language dependent positions ...
- aRelativePosition.Anchor = drawing::Alignment_RIGHT;
- aAnchor = aObjectRect.RightCenter();
- }
- break;
- case LegendPosition_PAGE_START:
- {
- //@todo language dependent positions ...
- aRelativePosition.Anchor = drawing::Alignment_TOP;
- aAnchor = aObjectRect.TopCenter();
- }
- break;
- case LegendPosition_PAGE_END:
- //@todo language dependent positions ...
- {
- aRelativePosition.Anchor = drawing::Alignment_BOTTOM;
- aAnchor = aObjectRect.BottomCenter();
- }
- break;
- case LegendPosition_CUSTOM:
- {
- //@todo language dependent positions ...
- aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT;
- }
- break;
- case LegendPosition_MAKE_FIXED_SIZE:
- OSL_ASSERT( false );
- break;
- }
aRelativePosition.Primary =
static_cast< double >( aAnchor.X()) /
static_cast< double >( aPageRect.getWidth() );
@@ -136,6 +98,19 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType
static_cast< double >( aPageRect.getHeight());
xObjectProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) );
+
+ aRelativeSize.Primary =
+ static_cast< double >( aObjectRect.getWidth()) /
+ static_cast< double >( aPageRect.getWidth() );
+ if (aRelativeSize.Primary > 1.0)
+ aRelativeSize.Primary = 1.0;
+ aRelativeSize.Secondary =
+ static_cast< double >( aObjectRect.getHeight()) /
+ static_cast< double >( aPageRect.getHeight());
+ if (aRelativeSize.Secondary > 1.0)
+ aRelativeSize.Secondary = 1.0;
+
+ xObjectProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) );
}
else if(OBJECTTYPE_DIAGRAM==eObjectType || OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType)
{
diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index cd51adc7842e..d5dadcf1d800 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -276,10 +276,11 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
}
//check wether the diagram was hit but not selected (e.g. because it has no filling):
+ rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) );
rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model
- if ( m_aSelectedOID.getObjectCID().equals( aPageCID ) || m_aSelectedOID.getObjectCID().equals( aWallCID ) || !m_aSelectedOID.isAutoGeneratedObject() )
+ bool bBackGroundHit = m_aSelectedOID.getObjectCID().equals( aPageCID ) || m_aSelectedOID.getObjectCID().equals( aWallCID ) || !m_aSelectedOID.isAutoGeneratedObject();
+ if( bBackGroundHit )
{
- rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) );
//todo: if more than one diagram is available in future do chack the list of all diagrams here
SdrObject* pDiagram = pDrawViewWrapper->getNamedSdrObject( aDiagramCID );
if( pDiagram )
@@ -291,6 +292,20 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper*
}
}
}
+ //check wether the legend was hit but not selected (e.g. because it has no filling):
+ if( bBackGroundHit || m_aSelectedOID.getObjectCID().equals( aDiagramCID ) )
+ {
+ rtl::OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::createParticleForLegend(0,0) ) );//@todo read CID from model
+ SdrObject* pLegend = pDrawViewWrapper->getNamedSdrObject( aLegendCID );
+ if( pLegend )
+ {
+ if( pDrawViewWrapper->IsObjectHit( pLegend, rMousePos ) )
+ {
+ m_aSelectedOID = ObjectIdentifier( aLegendCID );
+ pNewObj = pLegend;
+ }
+ }
+ }
}
}
@@ -309,6 +324,7 @@ bool Selection::isResizeableObjectSelected()
case OBJECTTYPE_DIAGRAM:
case OBJECTTYPE_DIAGRAM_WALL:
case OBJECTTYPE_SHAPE:
+ case OBJECTTYPE_LEGEND:
return true;
default:
return false;