summaryrefslogtreecommitdiff
path: root/chart2/source/controller
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller')
-rwxr-xr-xchart2/source/controller/chartapiwrapper/LegendWrapper.cxx21
-rw-r--r--chart2/source/controller/dialogs/Strings_Statistic.src12
-rw-r--r--chart2/source/controller/dialogs/res_LegendPosition.cxx76
-rw-r--r--chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx133
-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
9 files changed, 173 insertions, 187 deletions
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
index 5b71c7d3e768..05848422f885 100755
--- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
@@ -37,7 +37,7 @@
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart/ChartLegendPosition.hpp>
#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/LegendExpansion.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
@@ -139,13 +139,13 @@ void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, c
chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END);
if( aInnerValue >>= eNewInnerPos )
{
- chart2::LegendExpansion eNewExpansion =
+ ::com::sun::star::chart::ChartLegendExpansion eNewExpansion =
( eNewInnerPos == chart2::LegendPosition_LINE_END ||
eNewInnerPos == chart2::LegendPosition_LINE_START )
- ? chart2::LegendExpansion_HIGH
- : chart2::LegendExpansion_WIDE;
+ ? ::com::sun::star::chart::ChartLegendExpansion_HIGH
+ : ::com::sun::star::chart::ChartLegendExpansion_WIDE;
- chart2::LegendExpansion eOldExpansion( chart2::LegendExpansion_HIGH );
+ ::com::sun::star::chart::ChartLegendExpansion eOldExpansion( ::com::sun::star::chart::ChartLegendExpansion_HIGH );
bool bExpansionWasSet(
xInnerPropertySet->getPropertyValue( C2U( "Expansion" ) ) >>= eOldExpansion );
@@ -232,7 +232,8 @@ static const ::rtl::OUString lcl_aServiceName(
enum
{
- PROP_LEGEND_ALIGNMENT
+ PROP_LEGEND_ALIGNMENT,
+ PROP_LEGEND_EXPANSION
};
void lcl_AddPropertiesToVector(
@@ -244,6 +245,13 @@ void lcl_AddPropertiesToVector(
::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendPosition * >(0)),
//#i111967# no PropertyChangeEvent is fired on change so far
beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Expansion" ),
+ PROP_LEGEND_EXPANSION,
+ ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendExpansion * >(0)),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT ));
}
struct StaticLegendWrapperPropertyArray_Initializer
@@ -429,6 +437,7 @@ const std::vector< WrappedProperty* > LegendWrapper::createWrappedProperties()
::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
aWrappedProperties.push_back( new WrappedLegendAlignmentProperty() );
+ aWrappedProperties.push_back( new WrappedProperty( C2U("Expansion"), C2U("Expansion") ));
WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
//same problem as for wall: thje defaults ion the old chart are different for different charttypes, so we need to export explicitly
aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") ) );
diff --git a/chart2/source/controller/dialogs/Strings_Statistic.src b/chart2/source/controller/dialogs/Strings_Statistic.src
index f2dc4235f783..10c59a4c9b1d 100644
--- a/chart2/source/controller/dialogs/Strings_Statistic.src
+++ b/chart2/source/controller/dialogs/Strings_Statistic.src
@@ -51,22 +51,22 @@ String STR_CONTROLTEXT_ERROR_BARS_FROM_DATA
String STR_REGRESSION_LINEAR
{
- Text [ en-US ] = "Linear Regression" ;
+ Text [ en-US ] = "Linear (%SERIESNAME)" ;
};
String STR_REGRESSION_LOG
{
- Text [ en-US ] = "Logarithmic Regression" ;
+ Text [ en-US ] = "Logarithmic (%SERIESNAME)" ;
};
String STR_REGRESSION_EXP
{
- Text [ en-US ] = "Exponential Regression" ;
+ Text [ en-US ] = "Exponential (%SERIESNAME)" ;
};
String STR_REGRESSION_POWER
{
- Text [ en-US ] = "Power Regression" ;
+ Text [ en-US ] = "Power (%SERIESNAME)" ;
};
-String STR_STATISTICS_IN_LEGEND
+String STR_REGRESSION_MEAN
{
- Text [ en-US ] = "%REGRESSIONCURVE for %SERIESNAME" ;
+ Text [ en-US ] = "Mean (%SERIESNAME)" ;
};
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 0bbfcb7eee68..3a7294cd3ed2 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -41,13 +41,12 @@
#include <svtools/controldims.hrc>
#endif
#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/LegendExpansion.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
//itemset stuff
#include "chartview/ChartSfxItemIds.hxx"
-#include <svx/chrtitem.hxx>
-// header for class SfxItemPool
-#include <svl/itempool.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
//.............................................................................
namespace chart
@@ -151,7 +150,7 @@ void LegendPositionResources::writeToModel( const ::com::sun::star::uno::Referen
//position
chart2::LegendPosition eNewPos;
- chart2::LegendExpansion eExp = chart2::LegendExpansion_HIGH;
+ ::com::sun::star::chart::ChartLegendExpansion eExp = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
if( m_aRbtLeft.IsChecked() )
eNewPos = chart2::LegendPosition_LINE_START;
@@ -162,12 +161,12 @@ void LegendPositionResources::writeToModel( const ::com::sun::star::uno::Referen
else if( m_aRbtTop.IsChecked() )
{
eNewPos = chart2::LegendPosition_PAGE_START;
- eExp = chart2::LegendExpansion_WIDE;
+ eExp = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
}
else if( m_aRbtBottom.IsChecked() )
{
eNewPos = chart2::LegendPosition_PAGE_END;
- eExp = chart2::LegendExpansion_WIDE;
+ eExp = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
}
xProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos ));
@@ -197,51 +196,50 @@ IMPL_LINK( LegendPositionResources, PositionEnableHdl, void*, EMPTYARG )
void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
{
- SvxChartLegendPos ePos = CHLEGEND_NONE;
-
const SfxPoolItem* pPoolItem = NULL;
- if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS,
- sal_True, &pPoolItem ) != SFX_ITEM_SET )
- pPoolItem = &(rInAttrs.GetPool()->GetDefaultItem( SCHATTR_LEGEND_POS ));
-
- if( pPoolItem )
- ePos = ((const SvxChartLegendPosItem*)pPoolItem)->GetValue();
+ if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, sal_True, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ sal_Int32 nLegendPosition = ((const SfxInt32Item*)pPoolItem)->GetValue();
+ switch( nLegendPosition )
+ {
+ case chart2::LegendPosition_LINE_START:
+ m_aRbtLeft.Check(sal_True);
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ m_aRbtTop.Check(sal_True);
+ break;
+ case chart2::LegendPosition_LINE_END:
+ m_aRbtRight.Check(sal_True);
+ break;
+ case chart2::LegendPosition_PAGE_END:
+ m_aRbtBottom.Check(sal_True);
+ break;
+ default:
+ break;
+ }
+ }
- switch( ePos )
+ if( rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, sal_True, &pPoolItem ) == SFX_ITEM_SET )
{
- case CHLEGEND_LEFT:
- m_aRbtLeft.Check(sal_True);
- break;
- case CHLEGEND_TOP:
- m_aRbtTop.Check(sal_True);
- break;
- case CHLEGEND_RIGHT:
- m_aRbtRight.Check(sal_True);
- break;
- case CHLEGEND_BOTTOM:
- m_aRbtBottom.Check(sal_True);
- break;
- default:
- break;
+ bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
+ m_aCbxShow.Check(bShow);
}
}
void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
{
- SvxChartLegendPos ePos;
-
+ sal_Int32 nLegendPosition = chart2::LegendPosition_CUSTOM;
if( m_aRbtLeft.IsChecked() )
- ePos = CHLEGEND_LEFT;
+ nLegendPosition = chart2::LegendPosition_LINE_START;
else if( m_aRbtTop.IsChecked() )
- ePos = CHLEGEND_TOP;
+ nLegendPosition = chart2::LegendPosition_PAGE_START;
else if( m_aRbtRight.IsChecked() )
- ePos = CHLEGEND_RIGHT;
+ nLegendPosition = chart2::LegendPosition_LINE_END;
else if( m_aRbtBottom.IsChecked() )
- ePos = CHLEGEND_BOTTOM;
- else
- ePos = CHLEGEND_NONE;
+ nLegendPosition = chart2::LegendPosition_PAGE_END;
+ rOutAttrs.Put(SfxInt32Item(SCHATTR_LEGEND_POS, nLegendPosition ));
- rOutAttrs.Put(SvxChartLegendPosItem( ePos, SCHATTR_LEGEND_POS ));
+ rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, m_aCbxShow.IsChecked()) );
}
IMPL_LINK( LegendPositionResources, PositionChangeHdl, RadioButton*, pRadio )
diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
index ae812d72d723..c9ce4dc7bff1 100644
--- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
@@ -33,10 +33,12 @@
#include "ItemPropertyMap.hxx"
#include "GraphicPropertyItemConverter.hxx"
#include "CharacterPropertyItemConverter.hxx"
-#include <svx/chrtitem.hxx>
#include <com/sun/star/chart2/XLegend.hpp>
#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/LegendExpansion.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
#include <functional>
#include <algorithm>
@@ -104,52 +106,19 @@ bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyN
}
-bool LegendItemConverter::ApplySpecialItem(
- sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
+bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet& rInItemSet )
throw( uno::Exception )
{
bool bChanged = false;
switch( nWhichId )
{
- case SCHATTR_LEGEND_POS:
+ case SCHATTR_LEGEND_SHOW:
{
- chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END;
- chart2::LegendPosition eOldPos;
- bool bIsWide = false;
- sal_Bool bShow = sal_True;
-
- SvxChartLegendPos eItemPos =
- static_cast< const SvxChartLegendPosItem & >(
- rItemSet.Get( nWhichId )).GetValue();
- switch( eItemPos )
- {
- case CHLEGEND_LEFT:
- eNewPos = chart2::LegendPosition_LINE_START;
- break;
- case CHLEGEND_RIGHT:
- eNewPos = chart2::LegendPosition_LINE_END;
- break;
- case CHLEGEND_TOP:
- eNewPos = chart2::LegendPosition_PAGE_START;
- bIsWide = true;
- break;
- case CHLEGEND_BOTTOM:
- eNewPos = chart2::LegendPosition_PAGE_END;
- bIsWide = true;
- break;
-
- case CHLEGEND_NONE:
- case CHLEGEND_NONE_LEFT:
- case CHLEGEND_NONE_RIGHT:
- case CHLEGEND_NONE_TOP:
- case CHLEGEND_NONE_BOTTOM:
- bShow = sal_False;
- break;
- }
-
- try
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, TRUE, &pPoolItem ) == SFX_ITEM_SET )
{
+ sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
sal_Bool bWasShown = sal_True;
if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) ||
( bWasShown != bShow ))
@@ -157,25 +126,48 @@ bool LegendItemConverter::ApplySpecialItem(
GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow ));
bChanged = true;
}
+ }
+
+ }
+ break;
+ case SCHATTR_LEGEND_POS:
+ {
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, TRUE, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(((const SfxInt32Item*)pPoolItem)->GetValue());
- if( bShow )
+ ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ switch( eNewPos )
{
+ case chart2::LegendPosition_LINE_START:
+ case chart2::LegendPosition_LINE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ case chart2::LegendPosition_PAGE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
+ break;
+ default:
+ break;
+ }
+
+ try
+ {
+ chart2::LegendPosition eOldPos;
if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) ||
( eOldPos != eNewPos ))
{
GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos ));
- chart2::LegendExpansion eExp = bIsWide
- ? chart2::LegendExpansion_WIDE
- : chart2::LegendExpansion_HIGH;
- GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExp ));
+ GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion ));
GetPropertySet()->setPropertyValue( C2U( "RelativePosition" ), uno::Any());
bChanged = true;
}
}
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
}
}
break;
@@ -190,43 +182,18 @@ void LegendItemConverter::FillSpecialItem(
{
switch( nWhichId )
{
- case SCHATTR_LEGEND_POS:
+ case SCHATTR_LEGEND_SHOW:
{
- SvxChartLegendPos eItemPos( CHLEGEND_RIGHT );
- chart2::LegendPosition ePos;
-
sal_Bool bShow = sal_True;
GetPropertySet()->getPropertyValue( C2U( "Show" )) >>= bShow;
-
- if( ! bShow )
- {
- eItemPos = CHLEGEND_NONE;
- }
- else if( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos )
- {
- switch( ePos )
- {
- case chart2::LegendPosition_LINE_START:
- eItemPos = CHLEGEND_LEFT;
- break;
- case chart2::LegendPosition_LINE_END:
- eItemPos = CHLEGEND_RIGHT;
- break;
- case chart2::LegendPosition_PAGE_START:
- eItemPos = CHLEGEND_TOP;
- break;
- case chart2::LegendPosition_PAGE_END:
- eItemPos = CHLEGEND_BOTTOM;
- break;
-
- case chart2::LegendPosition_CUSTOM:
- default:
- eItemPos = CHLEGEND_RIGHT;
- break;
- }
- }
-
- rOutItemSet.Put( SvxChartLegendPosItem( eItemPos, SCHATTR_LEGEND_POS ) );
+ rOutItemSet.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, bShow) );
+ }
+ break;
+ case SCHATTR_LEGEND_POS:
+ {
+ chart2::LegendPosition eLegendPos( chart2::LegendPosition_LINE_END );
+ GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eLegendPos;
+ rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, eLegendPos ) );
}
break;
}
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;