diff options
Diffstat (limited to 'chart2')
46 files changed, 918 insertions, 762 deletions
diff --git a/chart2/prj/build.lst b/chart2/prj/build.lst index ec6658d212c6..5b534700a4f0 100644 --- a/chart2/prj/build.lst +++ b/chart2/prj/build.lst @@ -1,4 +1,4 @@ -ch chart2 : offapi offuh l10n comphelper cppu cppuhelper sal svtools svx tools vcl toolkit unotools sfx2 LIBXSLT:libxslt NULL +ch chart2 : offapi offuh L10N:l10n comphelper cppu cppuhelper sal svtools svx tools vcl toolkit unotools sfx2 LIBXSLT:libxslt NULL ch chart2 usr1 - all ch_mkout NULL ch chart2\inc nmake - all ch_inc NULL ch chart2\source\inc get - all ch_source_inc NULL 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/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx index 5e8bd7336b86..4f52f7f23220 100644 --- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -1173,6 +1173,8 @@ void CombiColumnLineChartDialogController::showExtraControls( Window* pParent, c m_pFT_NumberOfLines->Show(); m_pMF_NumberOfLines->Show(); + m_pMF_NumberOfLines->SetAccessibleName(m_pFT_NumberOfLines->GetText()); + m_pMF_NumberOfLines->SetAccessibleRelationLabeledBy(m_pFT_NumberOfLines); } void CombiColumnLineChartDialogController::hideExtraControls() const { diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 1c0a066df046..bb2538a97cad 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -101,6 +101,15 @@ String STR_PAGE_POSITION Text [ en-US ] = "Position" ; }; +String STR_BUTTON_UP +{ + Text [ en-US ] = "Up"; +}; +String STR_BUTTON_DOWN +{ + Text [ en-US ] = "Down"; +}; + String STR_PAGE_LAYOUT { Text [ en-US ] = "Layout"; 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_BarGeometry.cxx b/chart2/source/controller/dialogs/res_BarGeometry.cxx index ee2278589b89..59beaf35a152 100644 --- a/chart2/source/controller/dialogs/res_BarGeometry.cxx +++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx @@ -48,6 +48,8 @@ BarGeometryResources::BarGeometryResources( Window* pWindow ) { m_aFT_Geometry.SetText( String( SchResId( STR_BAR_GEOMETRY )) ); m_aFT_Geometry.SetSizePixel( m_aFT_Geometry.CalcMinimumSize() ); + m_aLB_Geometry.SetAccessibleName(m_aFT_Geometry.GetText()); + m_aLB_Geometry.SetAccessibleRelationLabeledBy(&m_aFT_Geometry); } void BarGeometryResources::SetPosPixel( const Point& rPosition ) { diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx index 0bbfcb7eee68..4093cf34894f 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 @@ -61,8 +60,8 @@ LegendPositionResources::LegendPositionResources( Window* pWindow ) : m_xCC() //unused in this scenario , m_aCbxShow( pWindow ) //unused in this scenario , m_aRbtLeft( pWindow, SchResId(RBT_LEFT) ) - , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) , m_aRbtRight( pWindow, SchResId(RBT_RIGHT) ) + , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) , m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) ) { m_aCbxShow.Check();//legend is assumed to be visible in this scenario @@ -73,12 +72,17 @@ LegendPositionResources::LegendPositionResources( Window* pWindow, const uno::Re : m_xCC( xCC ) , m_aCbxShow( pWindow, SchResId(CBX_SHOWLEGEND) ) , m_aRbtLeft( pWindow, SchResId(RBT_LEFT) ) - , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) , m_aRbtRight( pWindow, SchResId(RBT_RIGHT) ) + , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) , m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) ) { m_aCbxShow.SetToggleHdl( LINK( this, LegendPositionResources, PositionEnableHdl ) ); impl_setRadioButtonToggleHdl(); + m_aCbxShow.SetAccessibleRelationMemberOf(&m_aCbxShow); + m_aRbtLeft.SetAccessibleRelationMemberOf(&m_aCbxShow); + m_aRbtRight.SetAccessibleRelationMemberOf(&m_aCbxShow); + m_aRbtTop.SetAccessibleRelationMemberOf(&m_aCbxShow); + m_aRbtBottom.SetAccessibleRelationMemberOf(&m_aCbxShow); } void LegendPositionResources::impl_setRadioButtonToggleHdl() @@ -151,7 +155,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 +166,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 +201,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 ) @@ -259,6 +262,14 @@ void LegendPositionResources::SetChangeHdl( const Link& rLink ) m_aChangeLink = rLink; } +void LegendPositionResources::SetAccessibleRelationMemberOf(Window* pMemberOf) +{ + m_aRbtLeft.SetAccessibleRelationMemberOf(pMemberOf); + m_aRbtRight.SetAccessibleRelationMemberOf(pMemberOf); + m_aRbtTop.SetAccessibleRelationMemberOf(pMemberOf); + m_aRbtBottom.SetAccessibleRelationMemberOf(pMemberOf); +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/controller/dialogs/res_LegendPosition.hxx b/chart2/source/controller/dialogs/res_LegendPosition.hxx index ee0ac5a7601c..a4809df97239 100644 --- a/chart2/source/controller/dialogs/res_LegendPosition.hxx +++ b/chart2/source/controller/dialogs/res_LegendPosition.hxx @@ -44,6 +44,7 @@ namespace chart class LegendPositionResources { + public: //constructor without Display checkbox LegendPositionResources( Window* pParent ); @@ -66,6 +67,8 @@ public: DECL_LINK( PositionEnableHdl, void* ); DECL_LINK( PositionChangeHdl, RadioButton* ); + void SetAccessibleRelationMemberOf(Window* pMemberOf); //IAccessibility2 Implementation 2009----- + private: void impl_setRadioButtonToggleHdl(); @@ -76,8 +79,8 @@ private: CheckBox m_aCbxShow; RadioButton m_aRbtLeft; - RadioButton m_aRbtTop; RadioButton m_aRbtRight; + RadioButton m_aRbtTop; RadioButton m_aRbtBottom; Link m_aChangeLink; diff --git a/chart2/source/controller/dialogs/res_TextSeparator.cxx b/chart2/source/controller/dialogs/res_TextSeparator.cxx index 8878f5f77ffc..9cca483b711d 100644 --- a/chart2/source/controller/dialogs/res_TextSeparator.cxx +++ b/chart2/source/controller/dialogs/res_TextSeparator.cxx @@ -59,6 +59,9 @@ TextSeparatorResources::TextSeparatorResources( Window* pWindow ) m_aEntryMap[ C2U( ", " ) ] = 1; m_aEntryMap[ C2U( "; " ) ] = 2; m_aEntryMap[ C2U( "\n" ) ] = 3; + + m_aLB_Separator.SetAccessibleName(m_aFT_Separator.GetText()); + m_aLB_Separator.SetAccessibleRelationLabeledBy(&m_aFT_Separator); } TextSeparatorResources::~TextSeparatorResources() { diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx index 8e32a4f6a262..be6500b54e93 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -110,9 +110,9 @@ ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( , m_aFT_Scheme ( this, SchResId( FT_SCHEME ) ) , m_aLB_Scheme ( this, SchResId( LB_SCHEME ) ) , m_aFL_Seperator ( this, SchResId( FL_SEPERATOR ) ) - , m_aCB_RoundedEdge ( this, SchResId( CB_ROUNDEDEDGE ) ) , m_aCB_Shading ( this, SchResId( CB_SHADING ) ) , m_aCB_ObjectLines ( this, SchResId( CB_OBJECTLINES ) ) + , m_aCB_RoundedEdge ( this, SchResId( CB_ROUNDEDEDGE ) ) , m_bUpdateOtherControls( true ) , m_bCommitToModel( true ) , m_rControllerLockHelper( rControllerLockHelper ) diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx index 252c5c21669b..0e119d959c66 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx @@ -82,9 +82,9 @@ private: FixedLine m_aFL_Seperator; - CheckBox m_aCB_RoundedEdge; CheckBox m_aCB_Shading; CheckBox m_aCB_ObjectLines; + CheckBox m_aCB_RoundedEdge; bool m_bUpdateOtherControls; bool m_bCommitToModel; diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index ff1e784b5ff9..0d3914460e78 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -162,6 +162,8 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( Window* pWindow { m_aCbxRightAngledAxes.Enable(false); } + m_aMFPerspective.SetAccessibleName(m_aCbxPerspective.GetText()); + m_aMFPerspective.SetAccessibleRelationLabeledBy(&m_aCbxPerspective); } ThreeD_SceneGeometry_TabPage::~ThreeD_SceneGeometry_TabPage() diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index 2310e193e5ba..1c75fcab7a0f 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -357,6 +357,15 @@ ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( Window* pWin //m_aDelyedModelChangeTimer.SetTimeout( 4*EDIT_UPDATEDATA_TIMEOUT ); m_aModelChangeListener.startListening( uno::Reference< util::XModifyBroadcaster >(m_xSceneProperties, uno::UNO_QUERY) ); + m_aBtn_Light1.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light2.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light3.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light4.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light5.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light6.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light7.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aBtn_Light8.SetAccessibleRelationLabeledBy(&m_aFT_LightSource); + m_aCtl_Preview.SetAccessibleName(String(SchResId( STR_LIGHT_PREVIEW ))); } ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage() diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc index e2d031955867..f5ae0dcda267 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc @@ -42,5 +42,7 @@ #define BTN_LIGHT_6 8 #define BTN_LIGHT_7 9 #define BTN_LIGHT_8 10 - +//IAccessibility2 Implementation 2009----- +#define STR_LIGHT_PREVIEW 6000 +//-----IAccessibility2 Implementation 2009 #define CTL_LIGHT_PREVIEW 1 diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src index 0b052f4d00c6..cf5898af8c85 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src @@ -173,3 +173,8 @@ TabPage TP_3D_SCENEILLUMINATION }; }; +String STR_LIGHT_PREVIEW +{ + Text [ en-US ] = "Light Preview" ; +}; + diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx index 3538277c2004..508bec302bf2 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -222,6 +222,10 @@ AxisPositionsTabPage::AxisPositionsTabPage(Window* pWindow,const SfxItemSet& rIn m_aLB_PlaceLabels.SetSelectHdl( LINK( this, AxisPositionsTabPage, PlaceLabelsSelectHdl ) ); m_aLB_PlaceLabels.SetDropDownLineCount( m_aLB_PlaceLabels.GetEntryCount() ); m_aLB_PlaceTicks.SetDropDownLineCount( m_aLB_PlaceTicks.GetEntryCount() ); + m_aCB_TicksInner.SetAccessibleRelationLabeledBy(&m_aFT_Major); + m_aCB_TicksOuter.SetAccessibleRelationLabeledBy(&m_aFT_Major); + m_aCB_MinorInner.SetAccessibleRelationLabeledBy(&m_aFT_Minor); + m_aCB_MinorOuter.SetAccessibleRelationLabeledBy(&m_aFT_Minor); } SfxTabPage* AxisPositionsTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 0504ecee4161..7919820b2100 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -189,6 +189,8 @@ Dim3DLookResourceGroup::Dim3DLookResourceGroup( Window* pWindow ) m_aLB_Scheme.SetDropDownLineCount(2); m_aLB_Scheme.SetSelectHdl( LINK( this, Dim3DLookResourceGroup, SelectSchemeHdl ) ); + m_aLB_Scheme.SetAccessibleName(m_aCB_3DLook.GetText()); + m_aLB_Scheme.SetAccessibleRelationLabeledBy(&m_aCB_3DLook); } Dim3DLookResourceGroup::~Dim3DLookResourceGroup() { @@ -344,6 +346,9 @@ StackingResourceGroup::StackingResourceGroup( Window* pWindow ) m_aRB_Stack_Y.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); m_aRB_Stack_Y_Percent.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); m_aRB_Stack_Z.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); + m_aRB_Stack_Y.SetAccessibleRelationMemberOf(&m_aCB_Stacked); + m_aRB_Stack_Y_Percent.SetAccessibleRelationMemberOf(&m_aCB_Stacked); + m_aRB_Stack_Z.SetAccessibleRelationMemberOf(&m_aCB_Stacked); } StackingResourceGroup::~StackingResourceGroup() { @@ -472,9 +477,9 @@ private: MetricField m_aMF_SplineOrder; FixedLine m_aFL_DialogButtons; + HelpButton m_aBP_Help; OKButton m_aBP_OK; CancelButton m_aBP_Cancel; - HelpButton m_aBP_Help; }; SplinePropertiesDialog::SplinePropertiesDialog( Window* pParent ) @@ -487,9 +492,9 @@ SplinePropertiesDialog::SplinePropertiesDialog( Window* pParent ) , m_aFT_SplineOrder( this, SchResId( FT_SPLINE_ORDER ) ) , m_aMF_SplineOrder( this, SchResId( MF_SPLINE_ORDER ) ) , m_aFL_DialogButtons( this, SchResId( FL_SPLINE_DIALOGBUTTONS ) ) + , m_aBP_Help( this, SchResId(BTN_HELP) ) , m_aBP_OK( this, SchResId(BTN_OK) ) - , m_aBP_Cancel( this, SchResId(BTN_CANCEL) ) - , m_aBP_Help( this, SchResId(BTN_HELP) ) + , m_aBP_Cancel( this, SchResId(BTN_CANCEL) ) { FreeResource(); diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index ed48747e5502..2eaf97767fa5 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -359,6 +359,8 @@ DataSourceTabPage::DataSourceTabPage( if( m_apLB_SERIES->First()) m_apLB_SERIES->Select( m_apLB_SERIES->First()); m_apLB_SERIES->GrabFocus(); + m_aBTN_UP.SetAccessibleName(String(SchResId(STR_BUTTON_UP))); + m_aBTN_DOWN.SetAccessibleName(String(SchResId(STR_BUTTON_DOWN))); } DataSourceTabPage::~DataSourceTabPage() diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx index e08bd83f869d..049b78d9b6f5 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -51,6 +51,7 @@ SchLegendPosTabPage::SchLegendPosTabPage(Window* pWindow, , m_aFtTextDirection( this, SchResId( FT_LEGEND_TEXTDIR ) ) , m_aLbTextDirection( this, SchResId( LB_LEGEND_TEXTDIR ), &m_aFlTextOrient, &m_aFtTextDirection ) { + m_apLegendPositionResources->SetAccessibleRelationMemberOf(&aGrpLegend); FreeResource(); } diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index ae812d72d723..6fdf16bb73af 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, sal_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, sal_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; diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc index d7c490c1ca87..c5b03392cd8d 100644 --- a/chart2/source/inc/Strings.hrc +++ b/chart2/source/inc/Strings.hrc @@ -156,6 +156,7 @@ #define STR_REGRESSION_LOG (RID_APP_START + 136) #define STR_REGRESSION_EXP (RID_APP_START + 137) #define STR_REGRESSION_POWER (RID_APP_START + 138) +#define STR_REGRESSION_MEAN (RID_APP_START + 180) //----------------------------------------------------------------------------- //for scale tab page @@ -264,8 +265,6 @@ #define STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS (RID_APP_START + 265) #define STR_OBJECT_CURVE_EQUATION (RID_APP_START + 268) -#define STR_STATISTICS_IN_LEGEND (RID_APP_START + 180) - #define STR_OBJECT_SHAPE (RID_APP_START + 290) //----------------------------------------------------------------------------- @@ -343,6 +342,10 @@ #define STR_TEXT_DIRECTION_RTL (RID_APP_START + 279) #define STR_TEXT_DIRECTION_SUPER (RID_APP_START + 280) +//IAccessibility2 Implementation 2009----- +#define STR_BUTTON_UP (RID_APP_START + 500) +#define STR_BUTTON_DOWN (RID_APP_START + 501) +//-----IAccessibility2 Implementation 2009 //----------------------------------------------------------------------------- /* ////#define STR_DIAGRAM_X_AXIS (RID_APP_START + 34) diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index b6390ab12b22..e3846a1d0462 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -49,7 +49,8 @@ //legend #define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1) #define SCHATTR_LEGEND_POS SCHATTR_LEGEND_START -#define SCHATTR_LEGEND_END SCHATTR_LEGEND_POS +#define SCHATTR_LEGEND_SHOW (SCHATTR_LEGEND_START + 1) +#define SCHATTR_LEGEND_END SCHATTR_LEGEND_SHOW //text #define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index e9f5f5324365..a7c2ab86f5c1 100755 --- a/chart2/source/model/main/Legend.cxx +++ b/chart2/source/model/main/Legend.cxx @@ -40,8 +40,9 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/awt/Size.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/chart2/RelativeSize.hpp> #include <algorithm> @@ -63,10 +64,11 @@ static const OUString lcl_aServiceName( enum { PROP_LEGEND_ANCHOR_POSITION, - PROP_LEGEND_PREFERRED_EXPANSION, + PROP_LEGEND_EXPANSION, PROP_LEGEND_SHOW, PROP_LEGEND_REF_PAGE_SIZE, - PROP_LEGEND_REL_POS + PROP_LEGEND_REL_POS, + PROP_LEGEND_REL_SIZE }; void lcl_AddPropertiesToVector( @@ -81,8 +83,8 @@ void lcl_AddPropertiesToVector( rOutProperties.push_back( Property( C2U( "Expansion" ), - PROP_LEGEND_PREFERRED_EXPANSION, - ::getCppuType( reinterpret_cast< const chart2::LegendExpansion * >(0)), + PROP_LEGEND_EXPANSION, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendExpansion * >(0)), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT )); @@ -105,6 +107,14 @@ void lcl_AddPropertiesToVector( ::getCppuType( reinterpret_cast< const chart2::RelativePosition * >(0)), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "RelativeSize" ), + PROP_LEGEND_REL_SIZE, + ::getCppuType( reinterpret_cast< const chart2::RelativeSize * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + } struct StaticLegendDefaults_Initializer @@ -123,7 +133,7 @@ private: ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_PREFERRED_EXPANSION, chart2::LegendExpansion_HIGH ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_EXPANSION, ::com::sun::star::chart::ChartLegendExpansion_HIGH ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true ); float fDefaultCharHeight = 10.0; @@ -197,58 +207,10 @@ Legend::Legend( const Legend & rOther ) : ::property::OPropertySet( rOther, m_aMutex ), m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()) { - CloneHelper::CloneRefVector< Reference< chart2::XLegendEntry > >( rOther.m_aLegendEntries, m_aLegendEntries ); - ModifyListenerHelper::addListenerToAllElements( m_aLegendEntries, m_xModifyEventForwarder ); } Legend::~Legend() { - try - { - ModifyListenerHelper::removeListenerFromAllElements( m_aLegendEntries, m_xModifyEventForwarder ); - } - catch( const uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } -} - -// ____ XLegend ____ -void SAL_CALL Legend::registerEntry( const Reference< chart2::XLegendEntry >& xEntry ) - throw (lang::IllegalArgumentException, - uno::RuntimeException) -{ - if( ::std::find( m_aLegendEntries.begin(), - m_aLegendEntries.end(), - xEntry ) != m_aLegendEntries.end()) - throw lang::IllegalArgumentException(); - - m_aLegendEntries.push_back( xEntry ); - ModifyListenerHelper::addListener( xEntry, m_xModifyEventForwarder ); - fireModifyEvent(); -} - -void SAL_CALL Legend::revokeEntry( const Reference< chart2::XLegendEntry >& xEntry ) - throw (container::NoSuchElementException, - uno::RuntimeException) -{ - tLegendEntries::iterator aIt( - ::std::find( m_aLegendEntries.begin(), - m_aLegendEntries.end(), - xEntry )); - - if( aIt == m_aLegendEntries.end()) - throw container::NoSuchElementException(); - - m_aLegendEntries.erase( aIt ); - ModifyListenerHelper::removeListener( xEntry, m_xModifyEventForwarder ); - fireModifyEvent(); -} - -Sequence< Reference< chart2::XLegendEntry > > SAL_CALL Legend::getEntries() - throw (uno::RuntimeException) -{ - return ContainerHelper::ContainerToSequence( m_aLegendEntries ); } // ____ XCloneable ____ diff --git a/chart2/source/model/main/Legend.hxx b/chart2/source/model/main/Legend.hxx index 6b645828f4c1..56c41db2e38a 100644..100755 --- a/chart2/source/model/main/Legend.hxx +++ b/chart2/source/model/main/Legend.hxx @@ -97,20 +97,6 @@ protected: // const ::com::sun::star::uno::Any& rValue ) // throw (::com::sun::star::lang::IllegalArgumentException); - // ____ XLegend ____ - virtual void SAL_CALL registerEntry( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XLegendEntry >& xEntry ) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL revokeEntry( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XLegendEntry >& xEntry ) - throw (::com::sun::star::container::NoSuchElementException, - ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XLegendEntry > > SAL_CALL getEntries() - throw (::com::sun::star::uno::RuntimeException); - // ____ XCloneable ____ virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() throw (::com::sun::star::uno::RuntimeException); @@ -140,11 +126,6 @@ protected: void fireModifyEvent(); private: - typedef ::std::vector< - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XLegendEntry > > tLegendEntries; - - tLegendEntries m_aLegendEntries; ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder; }; diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index e0e37e2c825a..bb7e4ab68d98 100755 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -36,8 +36,6 @@ #include "servicenames_charttypes.hxx" #include "ContainerHelper.hxx" #include "DataSeriesHelper.hxx" -#include <com/sun/star/chart2/SymbolStyle.hpp> -#include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include "PropertyHelper.hxx" #include <com/sun/star/beans/PropertyAttribute.hpp> diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx index b265561eca90..3f82f5b7bf68 100755 --- a/chart2/source/model/template/StockChartTypeTemplate.cxx +++ b/chart2/source/model/template/StockChartTypeTemplate.cxx @@ -39,7 +39,6 @@ #include "ContainerHelper.hxx" #include "AxisIndexDefines.hxx" #include <com/sun/star/chart2/AxisType.hpp> -#include <com/sun/star/chart2/SymbolStyle.hpp> #include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> diff --git a/chart2/source/tools/LegendHelper.cxx b/chart2/source/tools/LegendHelper.cxx index af170e971a5b..aceb033b7919 100755 --- a/chart2/source/tools/LegendHelper.cxx +++ b/chart2/source/tools/LegendHelper.cxx @@ -29,7 +29,7 @@ #include "precompiled_chart2.hxx" #include "LegendHelper.hxx" #include "macros.hxx" -#include <com/sun/star/chart2/LegendExpansion.hpp> +#include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -62,11 +62,11 @@ Reference< chart2::XLegend > LegendHelper::showLegend( const Reference< frame::X if( !(xProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos ) ) xProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( ePos )); - chart2::LegendExpansion eExpansion = + ::com::sun::star::chart::ChartLegendExpansion eExpansion = ( ePos == chart2::LegendPosition_LINE_END || ePos == chart2::LegendPosition_LINE_START ) - ? chart2::LegendExpansion_HIGH - : chart2::LegendExpansion_WIDE; + ? ::com::sun::star::chart::ChartLegendExpansion_HIGH + : ::com::sun::star::chart::ChartLegendExpansion_WIDE; if( !(xProp->getPropertyValue( C2U( "Expansion" )) >>= eExpansion ) ) xProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion )); diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index df9c4bdadd65..0d5ceb36199a 100755 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -608,9 +608,7 @@ OUString RegressionCurveHelper::getUINameForRegressionCurve( const Reference< XR if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.MeanValueRegressionCurve" ))) { - OSL_ENSURE( false, "Meanvalue lines in legend not supported" ); - aResult = OUString(); - // aResult = ::chart::SchResId::getResString( STR_OBJECT_AVERAGE_LINE ); + aResult = ::chart::SchResId::getResString( STR_REGRESSION_MEAN ); } else if( aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.LinearRegressionCurve" ))) diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx index 06e09d60fcf1..41bec1f9c331 100644 --- a/chart2/source/view/charttypes/AreaChart.cxx +++ b/chart2/source/view/charttypes/AreaChart.cxx @@ -48,9 +48,11 @@ #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> + #include <tools/debug.hxx> #include <editeng/unoprnms.hxx> #include <rtl/math.hxx> + #include <com/sun/star/drawing/DoubleSequence.hpp> #include <com/sun/star/drawing/NormalsKind.hpp> #include <com/sun/star/lang/XServiceName.hpp> @@ -152,8 +154,8 @@ bool AreaChart::isSeperateStackingForDifferentSigns( sal_Int32 /*nDimensionIndex LegendSymbolStyle AreaChart::getLegendSymbolStyle() { if( m_bArea || m_nDimension == 3 ) - return chart2::LegendSymbolStyle_BOX; - return chart2::LegendSymbolStyle_LINE_WITH_SYMBOL; + return LegendSymbolStyle_BOX; + return LegendSymbolStyle_LINE; } uno::Any AreaChart::getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex ) diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx index 4b6ff3f45251..972d97fa75ac 100644 --- a/chart2/source/view/charttypes/AreaChart.hxx +++ b/chart2/source/view/charttypes/AreaChart.hxx @@ -71,7 +71,7 @@ public: //------------------------------------------------------------------------- - virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle(); + virtual LegendSymbolStyle getLegendSymbolStyle(); virtual ::com::sun::star::uno::Any getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex=-1/*-1 for series symbol*/ ); //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/BubbleChart.cxx b/chart2/source/view/charttypes/BubbleChart.cxx index 0cbcff33bfcd..3dbbc0eaf3e2 100644 --- a/chart2/source/view/charttypes/BubbleChart.cxx +++ b/chart2/source/view/charttypes/BubbleChart.cxx @@ -175,7 +175,7 @@ bool BubbleChart::isSeperateStackingForDifferentSigns( sal_Int32 /*nDimensionInd LegendSymbolStyle BubbleChart::getLegendSymbolStyle() { - return chart2::LegendSymbolStyle_CIRCLE; + return LegendSymbolStyle_CIRCLE; } drawing::Direction3D BubbleChart::getPreferredDiagramAspectRatio() const diff --git a/chart2/source/view/charttypes/BubbleChart.hxx b/chart2/source/view/charttypes/BubbleChart.hxx index ed3d9e051cc4..f94fe9e367e7 100644 --- a/chart2/source/view/charttypes/BubbleChart.hxx +++ b/chart2/source/view/charttypes/BubbleChart.hxx @@ -61,7 +61,7 @@ public: //------------------------------------------------------------------------- - virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle(); + virtual LegendSymbolStyle getLegendSymbolStyle(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/CandleStickChart.cxx b/chart2/source/view/charttypes/CandleStickChart.cxx index 61c49c61d4a0..57d5a70e4080 100644 --- a/chart2/source/view/charttypes/CandleStickChart.cxx +++ b/chart2/source/view/charttypes/CandleStickChart.cxx @@ -86,7 +86,7 @@ bool CandleStickChart::isSeperateStackingForDifferentSigns( sal_Int32 /* nDimens LegendSymbolStyle CandleStickChart::getLegendSymbolStyle() { - return chart2::LegendSymbolStyle_VERTICAL_LINE; + return LegendSymbolStyle_LINE; } //----------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/CandleStickChart.hxx b/chart2/source/view/charttypes/CandleStickChart.hxx index 6fbf980058e7..df9531ec71bf 100644 --- a/chart2/source/view/charttypes/CandleStickChart.hxx +++ b/chart2/source/view/charttypes/CandleStickChart.hxx @@ -59,7 +59,7 @@ public: //------------------------------------------------------------------------- - virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle(); + virtual LegendSymbolStyle getLegendSymbolStyle(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index c37842e19888..1077591dfce8 100644..100755 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -75,6 +75,7 @@ #include <rtl/math.hxx> #include <tools/debug.hxx> #include <basegfx/vector/b2dvector.hxx> +#include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/util/XCloneable.hpp> #include <svx/unoshape.hxx> @@ -107,7 +108,6 @@ VDataSeriesGroup::VDataSeriesGroup() , m_bMaxPointCountDirty(true) , m_nMaxPointCount(0) , m_aListOfCachedYValues() - { } @@ -461,13 +461,30 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re //------------------------------------------------ //prepare legend symbol + float fViewFontSize( 10.0 ); + { + uno::Reference< beans::XPropertySet > xProps( rDataSeries.getPropertiesOfPoint( nPointIndex ) ); + if( xProps.is() ) + xProps->getPropertyValue( C2U( "CharHeight" )) >>= fViewFontSize; + // pt -> 1/100th mm + fViewFontSize *= (2540.0 / 72.0); + } Reference< drawing::XShape > xSymbol; if(pLabel->ShowLegendSymbol) { + sal_Int32 nSymbolHeigth = static_cast< sal_Int32 >( fViewFontSize * 0.6 ); + awt::Size aCurrentRatio = this->getPreferredLegendKeyAspectRatio(); + sal_Int32 nSymbolWidth = aCurrentRatio.Width; + if( aCurrentRatio.Height > 0 ) + { + nSymbolWidth = nSymbolHeigth* aCurrentRatio.Width/aCurrentRatio.Height; + } + awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeigth ); + if( rDataSeries.isVaryColorsByPoint() ) - xSymbol.set( VSeriesPlotter::createLegendSymbolForPoint( rDataSeries, nPointIndex, xTarget_, m_xShapeFactory ) ); + xSymbol.set( VSeriesPlotter::createLegendSymbolForPoint( aMaxSymbolExtent, rDataSeries, nPointIndex, xTarget_, m_xShapeFactory ) ); else - xSymbol.set( VSeriesPlotter::createLegendSymbolForSeries( rDataSeries, xTarget_, m_xShapeFactory ) ); + xSymbol.set( VSeriesPlotter::createLegendSymbolForSeries( aMaxSymbolExtent, rDataSeries, xTarget_, m_xShapeFactory ) ); } //prepare text @@ -567,25 +584,14 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re const awt::Point aOldTextPos( xTextShape->getPosition() ); awt::Point aNewTextPos( aOldTextPos ); + awt::Point aSymbolPosition( aUnrotatedTextPos ); awt::Size aSymbolSize( xSymbol->getSize() ); awt::Size aTextSize( xTextShape->getSize() ); + sal_Int32 nXDiff = aSymbolSize.Width + static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.22 ) );//minimum 1mm if( !bMultiLineLabel || nLineCountForSymbolsize <= 0 ) nLineCountForSymbolsize = 1; - sal_Int32 nYDiff = aTextSize.Height/nLineCountForSymbolsize; - sal_Int32 nXDiff = aSymbolSize.Width * nYDiff/aSymbolSize.Height; - - // #i109336# Improve auto positioning in chart - nXDiff = nXDiff * 80 / 100; - nYDiff = nYDiff * 80 / 100; - - aSymbolSize.Width = nXDiff * 75/100; - aSymbolSize.Height = nYDiff * 75/100; - - awt::Point aSymbolPosition( aUnrotatedTextPos ); - - // #i109336# Improve auto positioning in chart - aSymbolPosition.Y += ( nYDiff / 4 ); + aSymbolPosition.Y += ((aTextSize.Height/nLineCountForSymbolsize)/4); if(LABEL_ALIGN_LEFT==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment @@ -607,10 +613,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re aNewTextPos.X += nXDiff/2; } - xSymbol->setSize( aSymbolSize ); xSymbol->setPosition( aSymbolPosition ); - - //set position xTextShape->setPosition( aNewTextPos ); } } @@ -1818,13 +1821,14 @@ bool VSeriesPlotter::shouldSnapRectToUsedArea() return true; } -Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries( - LegendExpansion eLegendExpansion +std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( + const awt::Size& rEntryKeyAspectRatio + , ::com::sun::star::chart::ChartLegendExpansion eLegendExpansion , const Reference< beans::XPropertySet >& xTextProperties , const Reference< drawing::XShapes >& xTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory , const Reference< uno::XComponentContext >& xContext - ) throw (uno::RuntimeException) + ) { std::vector< ViewLegendEntry > aResult; @@ -1851,7 +1855,7 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries( if(!pSeries) continue; - std::vector< ViewLegendEntry > aSeriesEntries( this->createLegendEntriesForSeries( + std::vector< ViewLegendEntry > aSeriesEntries( this->createLegendEntriesForSeries( rEntryKeyAspectRatio, *pSeries, xTextProperties, xTarget, xShapeFactory, xContext ) ); //add series entries to the result now @@ -1865,7 +1869,7 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries( // If the legend is wide and we have a stacked bar-chart the normal order // is the correct one bool bReverse = false; - if( eLegendExpansion != LegendExpansion_WIDE ) + if( eLegendExpansion != ::com::sun::star::chart::ChartLegendExpansion_WIDE ) { StackingDirection eStackingDirection( pSeries->getStackingDirection() ); bReverse = ( eStackingDirection == StackingDirection_Y_STACKING ); @@ -1880,24 +1884,119 @@ Sequence< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntries( } } } + } - //add charttype specific entries if any + return aResult; +} + +::std::vector< VDataSeries* > VSeriesPlotter::getAllSeries() +{ + ::std::vector< VDataSeries* > aAllSeries; + ::std::vector< ::std::vector< VDataSeriesGroup > >::iterator aZSlotIter = m_aZSlots.begin(); + const ::std::vector< ::std::vector< VDataSeriesGroup > >::const_iterator aZSlotEnd = m_aZSlots.end(); + for( ; aZSlotIter != aZSlotEnd; aZSlotIter++ ) + { + ::std::vector< VDataSeriesGroup >::iterator aXSlotIter = aZSlotIter->begin(); + const ::std::vector< VDataSeriesGroup >::const_iterator aXSlotEnd = aZSlotIter->end(); + for( ; aXSlotIter != aXSlotEnd; aXSlotIter++ ) { - std::vector< ViewLegendEntry > aChartTypeEntries( this->createLegendEntriesForChartType( - xTextProperties, xTarget, xShapeFactory, xContext ) ); - aResult.insert( aResult.end(), aChartTypeEntries.begin(), aChartTypeEntries.end() ); + ::std::vector< VDataSeries* > aSeriesList = aXSlotIter->m_aSeriesVector; + aAllSeries.insert( aAllSeries.end(), aSeriesList.begin(), aSeriesList.end() ); } } - - return ::chart::ContainerHelper::ContainerToSequence( aResult ); + return aAllSeries; } +namespace +{ +bool lcl_HasVisibleLine( const uno::Reference< beans::XPropertySet >& xProps, bool& rbHasDashedLine ) +{ + bool bHasVisibleLine = false; + rbHasDashedLine = false; + drawing::LineStyle aLineStyle = drawing::LineStyle_NONE; + if( xProps.is() && ( xProps->getPropertyValue( C2U("LineStyle")) >>= aLineStyle ) ) + { + if( aLineStyle != drawing::LineStyle_NONE ) + bHasVisibleLine = true; + if( aLineStyle == drawing::LineStyle_DASH ) + rbHasDashedLine = true; + } + return bHasVisibleLine; +} +bool lcl_HasRegressionCurves( const VDataSeries& rSeries, bool& rbHasDashedLine ) +{ + bool bHasRegressionCurves = false; + Reference< XRegressionCurveContainer > xRegrCont( rSeries.getModel(), uno::UNO_QUERY ); + if( xRegrCont.is()) + { + Sequence< Reference< XRegressionCurve > > aCurves( xRegrCont->getRegressionCurves() ); + sal_Int32 i = 0, nCount = aCurves.getLength(); + for( i=0; i<nCount; ++i ) + { + if( aCurves[i].is() ) + { + bHasRegressionCurves = true; + lcl_HasVisibleLine( uno::Reference< beans::XPropertySet >( aCurves[i], uno::UNO_QUERY ), rbHasDashedLine ); + } + } + } + return bHasRegressionCurves; +} +} LegendSymbolStyle VSeriesPlotter::getLegendSymbolStyle() { - return chart2::LegendSymbolStyle_BOX; + return LegendSymbolStyle_BOX; } +awt::Size VSeriesPlotter::getPreferredLegendKeyAspectRatio() +{ + awt::Size aRet(1000,1000); + if( m_nDimension==3 ) + return aRet; + + bool bSeriesAllowsLines = (getLegendSymbolStyle() == LegendSymbolStyle_LINE); + bool bHasLines = false; + bool bHasDashedLines = false; + ::std::vector< VDataSeries* > aAllSeries( getAllSeries() ); + ::std::vector< VDataSeries* >::const_iterator aSeriesIter = aAllSeries.begin(); + const ::std::vector< VDataSeries* >::const_iterator aSeriesEnd = aAllSeries.end(); + //iterate through all series + for( ; aSeriesIter != aSeriesEnd; aSeriesIter++ ) + { + if( bSeriesAllowsLines ) + { + bool bCurrentDashed = false; + if( lcl_HasVisibleLine( (*aSeriesIter)->getPropertiesOfSeries(), bCurrentDashed ) ) + { + bHasLines = true; + if( bCurrentDashed ) + { + bHasDashedLines = true; + break; + } + } + } + bool bRegressionHasDashedLines=false; + if( lcl_HasRegressionCurves( **aSeriesIter, bRegressionHasDashedLines ) ) + { + bHasLines = true; + if( bRegressionHasDashedLines ) + { + bHasDashedLines = true; + break; + } + } + } + if( bHasLines ) + { + if( bHasDashedLines ) + aRet = awt::Size(1600,-1); + else + aRet = awt::Size(800,-1); + } + return aRet; +} uno::Any VSeriesPlotter::getExplicitSymbol( const VDataSeries& /*rSeries*/, sal_Int32 /*nPointIndex*/ ) { @@ -1905,7 +2004,8 @@ uno::Any VSeriesPlotter::getExplicitSymbol( const VDataSeries& /*rSeries*/, sal_ } Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries( - const VDataSeries& rSeries + const awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries , const Reference< drawing::XShapes >& xTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory ) { @@ -1920,17 +2020,13 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries( // legend-symbol type switch( eLegendSymbolStyle ) { - case LegendSymbolStyle_HORIZONTAL_LINE: - case LegendSymbolStyle_VERTICAL_LINE: - case LegendSymbolStyle_DIAGONAL_LINE: - case LegendSymbolStyle_LINE_WITH_BOX: - case LegendSymbolStyle_LINE_WITH_SYMBOL: + case LegendSymbolStyle_LINE: ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES; break; default: break; }; - Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( + Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio, xTarget, eLegendSymbolStyle, xShapeFactory , rSeries.getPropertiesOfSeries(), ePropType, aExplicitSymbol )); @@ -1938,7 +2034,8 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForSeries( } Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint( - const VDataSeries& rSeries + const awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries , sal_Int32 nPointIndex , const Reference< drawing::XShapes >& xTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory ) @@ -1954,11 +2051,7 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint( // legend-symbol type switch( eLegendSymbolStyle ) { - case LegendSymbolStyle_HORIZONTAL_LINE: - case LegendSymbolStyle_VERTICAL_LINE: - case LegendSymbolStyle_DIAGONAL_LINE: - case LegendSymbolStyle_LINE_WITH_BOX: - case LegendSymbolStyle_LINE_WITH_SYMBOL: + case LegendSymbolStyle_LINE: ePropType = VLegendSymbolFactory::PROP_TYPE_LINE_SERIES; break; default: @@ -1989,14 +2082,15 @@ Reference< drawing::XShape > VSeriesPlotter::createLegendSymbolForPoint( } } - Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( + Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio, xTarget, eLegendSymbolStyle, xShapeFactory, xPointSet, ePropType, aExplicitSymbol )); return xShape; } -std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSeries( - const VDataSeries& rSeries +std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( + const awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries , const Reference< beans::XPropertySet >& xTextProperties , const Reference< drawing::XShapes >& xTarget , const Reference< lang::XMultiServiceFactory >& xShapeFactory @@ -2025,7 +2119,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory(xShapeFactory).createGroup2D( xTarget )); // create the symbol - Reference< drawing::XShape > xShape( this->createLegendSymbolForPoint( + Reference< drawing::XShape > xShape( this->createLegendSymbolForPoint( rEntryKeyAspectRatio, rSeries, nIdx, xSymbolGroup, xShapeFactory ) ); // set CID to symbol for selection @@ -2055,7 +2149,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe // create the symbol Reference< drawing::XShape > xShape( this->createLegendSymbolForSeries( - rSeries, xSymbolGroup, xShapeFactory ) ); + rEntryKeyAspectRatio, rSeries, xSymbolGroup, xShapeFactory ) ); // set CID to symbol for selection if( xShape.is()) @@ -2085,11 +2179,10 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe sal_Int32 i = 0, nCount = aCurves.getLength(); for( i=0; i<nCount; ++i ) { - if( aCurves[i].is() && !RegressionCurveHelper::isMeanValueLine( aCurves[i] ) ) + if( aCurves[i].is() ) { //label - OUString aResStr( SchResId::getResString( STR_STATISTICS_IN_LEGEND )); - replaceParamterInString( aResStr, C2U("%REGRESSIONCURVE"), RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] )); + OUString aResStr( RegressionCurveHelper::getUINameForRegressionCurve( aCurves[i] ) ); replaceParamterInString( aResStr, C2U("%SERIESNAME"), aLabelText ); aEntry.aLabel = FormattedStringHelper::createFormattedStringSequence( xContext, aResStr, xTextProperties ); @@ -2097,8 +2190,8 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe uno::Reference< drawing::XShapes > xSymbolGroup( ShapeFactory(xShapeFactory).createGroup2D( xTarget )); // create the symbol - Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( - xSymbolGroup, chart2::LegendSymbolStyle_DIAGONAL_LINE, xShapeFactory, + Reference< drawing::XShape > xShape( VLegendSymbolFactory::createSymbol( rEntryKeyAspectRatio, + xSymbolGroup, LegendSymbolStyle_LINE, xShapeFactory, Reference< beans::XPropertySet >( aCurves[i], uno::UNO_QUERY ), VLegendSymbolFactory::PROP_TYPE_LINE, uno::Any() )); @@ -2107,7 +2200,7 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe { aEntry.aSymbol = uno::Reference< drawing::XShape >( xSymbolGroup, uno::UNO_QUERY ); - bool bAverageLine = false;//@todo find out wether this is an average line or a regression curve + bool bAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[i] ); ObjectType eObjectType = bAverageLine ? OBJECTTYPE_DATA_AVERAGE_LINE : OBJECTTYPE_DATA_CURVE; OUString aChildParticle( ObjectIdentifier::createChildParticleWithIndex( eObjectType, i ) ); aChildParticle = ObjectIdentifier::addChildParticle( aChildParticle, ObjectIdentifier::createChildParticleWithIndex( OBJECTTYPE_LEGEND_ENTRY, 0 ) ); @@ -2127,16 +2220,6 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe return aResult; } -std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForChartType( - const Reference< beans::XPropertySet >& /* xTextProperties */, - const Reference< drawing::XShapes >& /* xTarget */, - const Reference< lang::XMultiServiceFactory >& /* xShapeFactory */, - const Reference< uno::XComponentContext >& /* xContext */ - ) -{ - return std::vector< ViewLegendEntry >(); -} - VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( const uno::Reference<XChartType>& xChartTypeModel , sal_Int32 nDimensionCount diff --git a/chart2/source/view/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx index 14b6cda47870..1ecc78107d2b 100644 --- a/chart2/source/view/inc/LegendEntryProvider.hxx +++ b/chart2/source/view/inc/LegendEntryProvider.hxx @@ -27,22 +27,58 @@ #ifndef CHART2_VIEW_LEGENDENTRYPROVIDER_HXX #define CHART2_VIEW_LEGENDENTRYPROVIDER_HXX -#include <com/sun/star/chart2/LegendExpansion.hpp> - -#ifndef _COM_SUN_STAR_CHART2_VIEWLEGENDENTRYP_HPP_ -#include <com/sun/star/chart2/ViewLegendEntry.hpp> -#endif +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/chart/ChartLegendExpansion.hpp> +#include <com/sun/star/chart2/XFormattedString.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <vector> + namespace chart { +enum LegendSymbolStyle +{ + /** A square box with border. + */ + LegendSymbolStyle_BOX, + + /** A line like with a symbol. + */ + LegendSymbolStyle_LINE, + + /** A bordered circle which has the same bounding-box as the + <member>BOX</member>. + */ + LegendSymbolStyle_CIRCLE +}; + +struct ViewLegendEntry +{ + /** The legend symbol that represents a data series or other + information contained in the legend + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > aSymbol; + + /** The descriptive text for a legend entry. + */ + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XFormattedString > > aLabel; +}; + class LegendEntryProvider { public: - virtual ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ViewLegendEntry > SAL_CALL createLegendEntries( - ::com::sun::star::chart2::LegendExpansion eLegendExpansion, + virtual ::com::sun::star::awt::Size getPreferredLegendKeyAspectRatio()=0; + + virtual std::vector< ViewLegendEntry > createLegendEntries( + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio, + ::com::sun::star::chart::ChartLegendExpansion eLegendExpansion, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTextProperties, const ::com::sun::star::uno::Reference< @@ -51,10 +87,7 @@ public: ::com::sun::star::lang::XMultiServiceFactory >& xShapeFactory, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext - ) - throw (::com::sun::star::uno::RuntimeException) = 0; - -private: + ) = 0; }; } // namespace chart diff --git a/chart2/source/view/inc/VLegendSymbolFactory.hxx b/chart2/source/view/inc/VLegendSymbolFactory.hxx index a568a9ef4a85..4ea3c67d5ece 100644 --- a/chart2/source/view/inc/VLegendSymbolFactory.hxx +++ b/chart2/source/view/inc/VLegendSymbolFactory.hxx @@ -27,7 +27,7 @@ #ifndef CHART2_VLEGENDSYMBOLFACTORY_HXX #define CHART2_VLEGENDSYMBOLFACTORY_HXX -#include <com/sun/star/chart2/LegendSymbolStyle.hpp> +#include "LegendEntryProvider.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/drawing/XShapes.hpp> @@ -50,9 +50,10 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createSymbol( + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > xSymbolContainer, - ::com::sun::star::chart2::LegendSymbolStyle eStyle, + LegendSymbolStyle eStyle, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xShapeFactory, const ::com::sun::star::uno::Reference< @@ -60,13 +61,6 @@ public: tPropertyType ePropertyType, const ::com::sun::star::uno::Any& rExplicitSymbol /*should contain a ::com::sun::star::chart2::Symbol without automatic symbol if the charttype does support symbols else empty*/); - enum tStockLineType - { - STOCK_LINE_TYPE_VERT, - STOCK_LINE_TYPE_OPEN, - STOCK_LINE_TYPE_CLOSE - }; - private: VLegendSymbolFactory(); }; diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 8147c3443ec6..9e427a5e2a81 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -33,7 +33,6 @@ #include "MinimumAndMaximumSupplier.hxx" #include "LegendEntryProvider.hxx" #include "ExplicitCategoriesProvider.hxx" -#include <com/sun/star/chart2/LegendSymbolStyle.hpp> #include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/drawing/Direction3D.hpp> @@ -207,9 +206,9 @@ public: //------------------------------------------------------------------------- //------------------------------------------------------------------------- - virtual ::com::sun::star::uno::Sequence< - ::com::sun::star::chart2::ViewLegendEntry > SAL_CALL createLegendEntries( - ::com::sun::star::chart2::LegendExpansion eLegendExpansion, + virtual std::vector< ViewLegendEntry > createLegendEntries( + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio, + ::com::sun::star::chart::ChartLegendExpansion eLegendExpansion, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTextProperties, const ::com::sun::star::uno::Reference< @@ -218,26 +217,29 @@ public: ::com::sun::star::lang::XMultiServiceFactory >& xShapeFactory, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext - ) - throw (::com::sun::star::uno::RuntimeException); + ); + + virtual LegendSymbolStyle getLegendSymbolStyle(); + virtual com::sun::star::awt::Size getPreferredLegendKeyAspectRatio(); - virtual ::com::sun::star::chart2::LegendSymbolStyle getLegendSymbolStyle(); virtual ::com::sun::star::uno::Any getExplicitSymbol( const VDataSeries& rSeries, sal_Int32 nPointIndex=-1/*-1 for series symbol*/ ); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createLegendSymbolForSeries( - const VDataSeries& rSeries + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xShapeFactory ); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > createLegendSymbolForPoint( - const VDataSeries& rSeries + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries , sal_Int32 nPointIndex , const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xShapeFactory ); - virtual std::vector< - ::com::sun::star::chart2::ViewLegendEntry > SAL_CALL createLegendEntriesForSeries( + virtual std::vector< ViewLegendEntry > createLegendEntriesForSeries( + const ::com::sun::star::awt::Size& rEntryKeyAspectRatio, const VDataSeries& rSeries, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTextProperties, @@ -249,17 +251,7 @@ public: ::com::sun::star::uno::XComponentContext >& xContext ); - virtual std::vector< - ::com::sun::star::chart2::ViewLegendEntry > SAL_CALL createLegendEntriesForChartType( - const ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet >& xTextProperties, - const ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShapes >& xTarget, - const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory >& xShapeFactory, - const ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext >& xContext - ); + ::std::vector< VDataSeries* > getAllSeries(); //------------------------------------------------------------------------- //------------------------------------------------------------------------- diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 60e880ab311e..c66044b9aa0d 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -44,6 +44,8 @@ #include <editeng/editids.hrc> #include <svx/svxids.hrc> +#include <com/sun/star/chart2/LegendPosition.hpp> + namespace chart { @@ -69,7 +71,8 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE); //legend - ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SvxChartLegendPosItem( CHLEGEND_RIGHT, SCHATTR_LEGEND_POS ); + ppPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SfxInt32Item(SCHATTR_LEGEND_POS, ::com::sun::star::chart2::LegendPosition_LINE_END ); + ppPoolDefaults[SCHATTR_LEGEND_SHOW - SCHATTR_START] = new SfxBoolItem(SCHATTR_LEGEND_SHOW, sal_True); //text ppPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index fbc74bad05a5..33e1d1f26aa4 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -36,13 +36,14 @@ #include "ShapeFactory.hxx" #include "RelativeSizeHelper.hxx" #include "LegendEntryProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/LineJoint.hpp> -#include <com/sun/star/chart2/LegendExpansion.hpp> +#include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <rtl/ustrbuf.hxx> @@ -123,7 +124,6 @@ void lcl_getProperties( const Reference< beans::XPropertySet > & xLegendProp, tPropertyValues & rOutLineFillProperties, tPropertyValues & rOutTextProperties, - sal_Int32 nMaxLabelWidth, const awt::Size & rReferenceSize ) { // Get Line- and FillProperties from model legend @@ -146,7 +146,7 @@ void lcl_getProperties( aTextValueMap[ C2U("TextAutoGrowHeight") ] = uno::makeAny( sal_True ); aTextValueMap[ C2U("TextAutoGrowWidth") ] = uno::makeAny( sal_True ); aTextValueMap[ C2U("TextHorizontalAdjust") ] = uno::makeAny( eHorizAdjust ); - aTextValueMap[ C2U("TextMaximumFrameWidth") ] = uno::makeAny( nMaxLabelWidth ); + aTextValueMap[ C2U("TextMaximumFrameWidth") ] = uno::makeAny( rReferenceSize.Width ); //needs to be overwritten by actual available space in the legend // recalculate font size awt::Size aPropRefSize; @@ -193,16 +193,10 @@ awt::Size lcl_createTextShapes( try { // create label shape - Reference< drawing::XShape > xGroupShapeForSingleEntry( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.GroupShape" )), uno::UNO_QUERY_THROW ); - Reference< drawing::XShape >xEntry( + Reference< drawing::XShape > xEntry( xShapeFactory->createInstance( C2U( "com.sun.star.drawing.TextShape" )), uno::UNO_QUERY_THROW ); - xTarget->add( xGroupShapeForSingleEntry ); - - Reference< drawing::XShapes > xGroup( xGroupShapeForSingleEntry, uno::UNO_QUERY_THROW ); - xGroup->add( xEntry ); + xTarget->add( xEntry ); // set label text Sequence< Reference< XFormattedString > > aLabelSeq = (*aIt).aLabel; @@ -230,7 +224,7 @@ awt::Size lcl_createTextShapes( aResult.Height = ::std::max( aResult.Height, aCurrSize.Height ); } - rOutTextShapes.push_back( xGroupShapeForSingleEntry ); + rOutTextShapes.push_back( xEntry ); } catch( uno::Exception & ex ) { @@ -241,57 +235,272 @@ awt::Size lcl_createTextShapes( return aResult; } +void lcl_collectColumnWidths( std::vector< sal_Int32 >& rColumnWidths, const sal_Int32 nNumberOfRows, const sal_Int32 nNumberOfColumns + , const ::std::vector< Reference< drawing::XShape > > aTextShapes, sal_Int32 nSymbolPlusDistanceWidth ) +{ + rColumnWidths.clear(); + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; + sal_Int32 nNumberOfEntries = aTextShapes.size(); + for( ; nRow < nNumberOfRows; ++nRow ) + { + for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + { + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); + if( nEntry < nNumberOfEntries ) + { + awt::Size aTextSize( aTextShapes[ nEntry ]->getSize() ); + sal_Int32 nWidth = nSymbolPlusDistanceWidth + aTextSize.Width; + if( nRow==0 ) + rColumnWidths.push_back( nWidth ); + else + rColumnWidths[nColumn] = ::std::max( nWidth, rColumnWidths[nColumn] ); + } + } + } +} -void lcl_placeLegendEntries( - const tViewLegendEntryContainer & rEntries, - LegendExpansion eExpansion, +void lcl_collectRowHeighs( std::vector< sal_Int32 >& rRowHeights, const sal_Int32 nNumberOfRows, const sal_Int32 nNumberOfColumns + , const ::std::vector< Reference< drawing::XShape > > aTextShapes ) +{ + // calculate maximum height for each row + // and collect column widths + rRowHeights.clear(); + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; + sal_Int32 nNumberOfEntries = aTextShapes.size(); + for( ; nRow < nNumberOfRows; ++nRow ) + { + sal_Int32 nCurrentRowHeight = 0; + for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) + { + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); + if( nEntry < nNumberOfEntries ) + { + awt::Size aTextSize( aTextShapes[ nEntry ]->getSize() ); + nCurrentRowHeight = ::std::max( nCurrentRowHeight, aTextSize.Height ); + } + } + rRowHeights.push_back( nCurrentRowHeight ); + } +} + +sal_Int32 lcl_getTextLineHeight( const std::vector< sal_Int32 >& aRowHeights, const sal_Int32 nNumberOfRows, double fViewFontSize ) +{ + const sal_Int32 nFontHeight = static_cast< sal_Int32 >( fViewFontSize ); + sal_Int32 nTextLineHeight = nFontHeight; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + { + sal_Int32 nFullTextHeight = aRowHeights[ nR ]; + if( ( nFullTextHeight / nFontHeight ) <= 1 ) + { + nTextLineHeight = nFullTextHeight;//found an entry with one line-> have real text height + break; + } + } + return nTextLineHeight; +} + +//returns resulting legend size +awt::Size lcl_placeLegendEntries( + tViewLegendEntryContainer & rEntries, + ::com::sun::star::chart::ChartLegendExpansion eExpansion, bool bSymbolsLeftSide, - const Reference< beans::XPropertySet > & xProperties, + double fViewFontSize, + const awt::Size& rMaxSymbolExtent, tPropertyValues & rTextProperties, const Reference< drawing::XShapes > & xTarget, const Reference< lang::XMultiServiceFactory > & xShapeFactory, - const Reference< uno::XComponentContext > & /* xContext */, - const awt::Size & rAvailableSpace, - const awt::Size & rPageSize, - awt::Size & rOutLegendSize ) + const awt::Size & rAvailableSpace ) { - double fViewFontSize = lcl_CalcViewFontSize( xProperties, rPageSize ); + bool bIsCustomSize = (eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM); + awt::Size aResultingLegendSize(0,0); + if( bIsCustomSize ) + aResultingLegendSize = rAvailableSpace; - // padding as percentage of the font height // #i109336# Improve auto positioning in chart - double fXPadding = 0.1; - double fYPadding = 0.2; - double fXOffset = 0.15; - double fYOffset = 0.15; - - const sal_Int32 nXPadding = static_cast< sal_Int32 >( fViewFontSize * fXPadding ); - const sal_Int32 nYPadding = static_cast< sal_Int32 >( fViewFontSize * fYPadding ); - const sal_Int32 nXOffset = static_cast< sal_Int32 >( fViewFontSize * fXOffset ); - const sal_Int32 nYOffset = static_cast< sal_Int32 >( fViewFontSize * fYOffset ); + sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.33 ) ); + //sal_Int32 nXPadding = static_cast< sal_Int32 >( std::max( 200.0, fViewFontSize * 0.33 ) ); + sal_Int32 nXOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.66 ) ); + sal_Int32 nYPadding = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); + sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.2 ) ); + //sal_Int32 nYOffset = static_cast< sal_Int32 >( std::max( 230.0, fViewFontSize * 0.45 ) ); + + const sal_Int32 nSymbolToTextDistance = static_cast< sal_Int32 >( std::max( 100.0, fViewFontSize * 0.22 ) );//minimum 1mm + const sal_Int32 nSymbolPlusDistanceWidth = rMaxSymbolExtent.Width + nSymbolToTextDistance; + sal_Int32 nMaxTextWidth = rAvailableSpace.Width - (2 * nXPadding) - nSymbolPlusDistanceWidth; + rtl::OUString aPropNameTextMaximumFrameWidth( C2U("TextMaximumFrameWidth") ); + uno::Any* pFrameWidthAny = PropertyMapper::getValuePointer( rTextProperties.second, rTextProperties.first, aPropNameTextMaximumFrameWidth); + if(pFrameWidthAny) + { + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_HIGH ) + { + // limit the width of texts to 30% of the total available width + // #i109336# Improve auto positioning in chart + nMaxTextWidth = rAvailableSpace.Width * 3 / 10; + } + *pFrameWidthAny = uno::makeAny(nMaxTextWidth); + } ::std::vector< Reference< drawing::XShape > > aTextShapes; - awt::Size aMaxEntryExtent = lcl_createTextShapes( - rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); + awt::Size aMaxEntryExtent = lcl_createTextShapes( rEntries, xShapeFactory, xTarget, aTextShapes, rTextProperties ); OSL_ASSERT( aTextShapes.size() == rEntries.size()); - // #i109336# Improve auto positioning in chart - double fSymbolSizeFraction = 0.8; - awt::Size aMaxSymbolExtent( static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction * 3.0 / 2.0 ), - static_cast< sal_Int32 >( fViewFontSize * fSymbolSizeFraction ) ); - - sal_Int32 nCurrentXPos = nXPadding; - sal_Int32 nCurrentYPos = nYPadding; - sal_Int32 nMaxEntryWidth = 2 * nXOffset + aMaxSymbolExtent.Width + aMaxEntryExtent.Width; + sal_Int32 nMaxEntryWidth = nXOffset + nSymbolPlusDistanceWidth + aMaxEntryExtent.Width; sal_Int32 nMaxEntryHeight = nYOffset + aMaxEntryExtent.Height; sal_Int32 nNumberOfEntries = rEntries.size(); - if( !bSymbolsLeftSide ) - nCurrentXPos = -nXPadding; - sal_Int32 nNumberOfColumns = 0, nNumberOfRows = 0; + std::vector< sal_Int32 > aColumnWidths; + std::vector< sal_Int32 > aRowHeights; + + sal_Int32 nTextLineHeight = static_cast< sal_Int32 >( fViewFontSize ); // determine layout depending on LegendExpansion - if( eExpansion == LegendExpansion_HIGH ) + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) + { + sal_Int32 nCurrentRow=0; + sal_Int32 nCurrentColumn=-1; + sal_Int32 nColumnCount=0; + sal_Int32 nMaxColumnCount=-1; + for( sal_Int32 nN=0; nN<static_cast<sal_Int32>(aTextShapes.size()); nN++ ) + { + Reference< drawing::XShape > xShape( aTextShapes[nN] ); + if( !xShape.is() ) + continue; + awt::Size aSize( xShape->getSize() ); + sal_Int32 nNewWidth = aSize.Width + nSymbolPlusDistanceWidth; + sal_Int32 nCurrentColumnCount = aColumnWidths.size(); + + //are we allowed to add a new column? + if( nMaxColumnCount==-1 || (nCurrentColumn+1) < nMaxColumnCount ) + { + //try add a new column + nCurrentColumn++; + if( nCurrentColumn < nCurrentColumnCount ) + { + //check wether the current column width is sufficient for the new entry + if( aColumnWidths[nCurrentColumn]>=nNewWidth ) + { + //all good proceed with next entry + continue; + } + } + if( nCurrentColumn < nCurrentColumnCount ) + aColumnWidths[nCurrentColumn] = std::max( nNewWidth, aColumnWidths[nCurrentColumn] ); + else + aColumnWidths.push_back(nNewWidth); + + //do the columns still fit into the given size? + nCurrentColumnCount = aColumnWidths.size();//update count + sal_Int32 nSumWidth = 0; + for( sal_Int32 nC=0; nC<nCurrentColumnCount; nC++ ) + nSumWidth += aColumnWidths[nC]; + + if( nSumWidth <= rAvailableSpace.Width || nCurrentColumnCount==1 ) + { + //all good proceed with next entry + continue; + } + else + { + //not enough space for the current amount of columns + //try again with less columns + nMaxColumnCount = nCurrentColumnCount-1; + nN=-1; + nCurrentRow=0; + nCurrentColumn=-1; + nColumnCount=0; + aColumnWidths.clear(); + } + } + else + { + //add a new row and try the same entry again + nCurrentRow++; + nCurrentColumn=-1; + nN--; + } + } + nNumberOfColumns = aColumnWidths.size(); + nNumberOfRows = nCurrentRow+1; + + //check if there is not enough space so that some entries must be removed + lcl_collectRowHeighs( aRowHeights, nNumberOfRows, nNumberOfColumns, aTextShapes ); + nTextLineHeight = lcl_getTextLineHeight( aRowHeights, nNumberOfRows, fViewFontSize ); + sal_Int32 nSumHeight = 0; + for( sal_Int32 nR=0; nR<nNumberOfRows; nR++ ) + nSumHeight += aRowHeights[nR]; + sal_Int32 nRemainingSpace = rAvailableSpace.Height - nSumHeight; + + if( nRemainingSpace<0 ) + { + //remove entries that are too big + for( sal_Int32 nR=nNumberOfRows; nR--; ) + { + for( sal_Int32 nC=nNumberOfColumns; nC--; ) + { + sal_Int32 nEntry = (nC + nR * nNumberOfColumns); + if( nEntry < static_cast<sal_Int32>(aTextShapes.size()) ) + { + DrawModelWrapper::removeShape( aTextShapes[nEntry] ); + aTextShapes.pop_back(); + } + if( nEntry < nNumberOfEntries ) + { + DrawModelWrapper::removeShape( rEntries[ nEntry ].aSymbol ); + rEntries.pop_back(); + nNumberOfEntries--; + } + } + nSumHeight -= aRowHeights[nR]; + aRowHeights.pop_back(); + nRemainingSpace = rAvailableSpace.Height - nSumHeight; + if( nRemainingSpace>=0 ) + break; + } + nNumberOfRows = static_cast<sal_Int32>(aRowHeights.size()); + } + if( nRemainingSpace > 0 ) + { + sal_Int32 nNormalSpacingHeight = 2*nYPadding+(nNumberOfRows-1)*nYOffset; + if( nRemainingSpace < nNormalSpacingHeight ) + { + //reduce spacing between the entries + nYPadding = nYOffset = nRemainingSpace/(nNumberOfRows+1); + } + else + { + //we have some space left that should be spread equally between all rows + sal_Int32 nRemainingSingleSpace = (nRemainingSpace-nNormalSpacingHeight)/(nNumberOfRows+1); + nYPadding += nRemainingSingleSpace; + nYOffset += nRemainingSingleSpace; + } + } + + //check spacing between columns + sal_Int32 nSumWidth = 0; + for( sal_Int32 nC=0; nC<nNumberOfColumns; nC++ ) + nSumWidth += aColumnWidths[nC]; + nRemainingSpace = rAvailableSpace.Width - nSumWidth; + if( nRemainingSpace>=0 ) + { + sal_Int32 nNormalSpacingWidth = 2*nXPadding+(nNumberOfColumns-1)*nXOffset; + if( nRemainingSpace < nNormalSpacingWidth ) + { + //reduce spacing between the entries + nXPadding = nXOffset = nRemainingSpace/(nNumberOfColumns+1); + } + else + { + //we have some space left that should be spread equally between all columns + sal_Int32 nRemainingSingleSpace = (nRemainingSpace-nNormalSpacingWidth)/(nNumberOfColumns+1); + nXPadding += nRemainingSingleSpace; + nXOffset += nRemainingSingleSpace; + } + } + } + else if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_HIGH ) { sal_Int32 nMaxNumberOfRows = nMaxEntryHeight ? (rAvailableSpace.Height - 2*nYPadding ) / nMaxEntryHeight @@ -308,7 +517,7 @@ void lcl_placeLegendEntries( static_cast< double >( nNumberOfColumns ) )) : 0; } - else if( eExpansion == LegendExpansion_WIDE ) + else if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_WIDE ) { sal_Int32 nMaxNumberOfColumns = nMaxEntryWidth ? (rAvailableSpace.Width - 2*nXPadding ) / nMaxEntryWidth @@ -325,7 +534,7 @@ void lcl_placeLegendEntries( static_cast< double >( nNumberOfRows ) )) : 0; } - else // LegendExpansion_BALANCED + else // ::com::sun::star::chart::ChartLegendExpansion_BALANCED { double fAspect = nMaxEntryHeight ? static_cast< double >( nMaxEntryWidth ) / static_cast< double >( nMaxEntryHeight ) @@ -341,93 +550,90 @@ void lcl_placeLegendEntries( } if(nNumberOfRows<=0) - return; + return aResultingLegendSize; - // calculate maximum height for current row - std::vector< sal_Int32 > nMaxHeights( nNumberOfRows ); - sal_Int32 nRow = 0; - sal_Int32 nColumn = 0; - for( ; nRow < nNumberOfRows; ++nRow ) + if( eExpansion != ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) { - sal_Int32 nMaxHeight = 0; - for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) - { - sal_Int32 nEntry = ( eExpansion == LegendExpansion_WIDE ) - ? (nColumn + nRow * nNumberOfColumns) - // HIGH or BALANCED - : (nRow + nColumn * nNumberOfRows); - if( nEntry < nNumberOfEntries ) - nMaxHeight = ::std::max( - nMaxHeight, nYOffset + aTextShapes[ nEntry ]->getSize().Height ); - } - nMaxHeights[ nRow ] = nMaxHeight; + lcl_collectColumnWidths( aColumnWidths, nNumberOfRows, nNumberOfColumns, aTextShapes, nSymbolPlusDistanceWidth ); + lcl_collectRowHeighs( aRowHeights, nNumberOfRows, nNumberOfColumns, aTextShapes ); + nTextLineHeight = lcl_getTextLineHeight( aRowHeights, nNumberOfRows, fViewFontSize ); } - // place entries ordered in optimal-width columns + sal_Int32 nCurrentXPos = nXPadding; + sal_Int32 nCurrentYPos = nYPadding; + if( !bSymbolsLeftSide ) + nCurrentXPos = -nXPadding; + + // place entries into column and rows sal_Int32 nMaxYPos = 0; + sal_Int32 nRow = 0; + sal_Int32 nColumn = 0; for( nColumn = 0; nColumn < nNumberOfColumns; ++nColumn ) { - sal_Int32 nMaxWidth = 0; nCurrentYPos = nYPadding; - for( nRow = 0; nRow < nNumberOfRows; ++nRow ) { - sal_Int32 nEntry = ( eExpansion == LegendExpansion_WIDE ) - ? (nColumn + nRow * nNumberOfColumns) - // HIGH or BALANCED - : (nRow + nColumn * nNumberOfRows); - + sal_Int32 nEntry = (nColumn + nRow * nNumberOfColumns); if( nEntry >= nNumberOfEntries ) break; + // text shape + Reference< drawing::XShape > xTextShape( aTextShapes[nEntry] ); + if( xTextShape.is() ) + { + awt::Size aTextSize( xTextShape->getSize() ); + sal_Int32 nTextXPos = nCurrentXPos + nSymbolPlusDistanceWidth; + if( !bSymbolsLeftSide ) + nTextXPos = nCurrentXPos - nSymbolPlusDistanceWidth - aTextSize.Width; + xTextShape->setPosition( awt::Point( nTextXPos, nCurrentYPos )); + } + // symbol Reference< drawing::XShape > xSymbol( rEntries[ nEntry ].aSymbol ); - if( xSymbol.is() ) { - // Note: aspect ratio should always be 3:2 - - // set symbol size to 75% of maximum space - awt::Size aSymbolSize( - aMaxSymbolExtent.Width * 75 / 100, - aMaxSymbolExtent.Height * 75 / 100 ); - xSymbol->setSize( aSymbolSize ); - sal_Int32 nSymbolXPos = nCurrentXPos + ((aMaxSymbolExtent.Width - aSymbolSize.Width) / 2); + awt::Size aSymbolSize( rMaxSymbolExtent ); + sal_Int32 nSymbolXPos = nCurrentXPos; if( !bSymbolsLeftSide ) - nSymbolXPos = nSymbolXPos - aMaxSymbolExtent.Width; - - // #i109336# Improve auto positioning in chart - sal_Int32 nTextHeight = nMaxHeights[ nRow ] - nYOffset; - sal_Int32 nFontSize = static_cast< sal_Int32 >( fViewFontSize ); - sal_Int32 nMaxRowHeight = ( ( ( nTextHeight / nFontSize ) <= 1 ) ? nTextHeight : nFontSize ); - sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nMaxRowHeight - aSymbolSize.Height ) / 2 ); + nSymbolXPos = nCurrentXPos - rMaxSymbolExtent.Width; + sal_Int32 nSymbolYPos = nCurrentYPos + ( ( nTextLineHeight - aSymbolSize.Height ) / 2 ); xSymbol->setPosition( awt::Point( nSymbolXPos, nSymbolYPos ) ); } - // position text shape - awt::Size aTextSize( aTextShapes[ nEntry ]->getSize()); - nMaxWidth = ::std::max( nMaxWidth, 2 * nXOffset + aMaxSymbolExtent.Width + aTextSize.Width ); - sal_Int32 nTextXPos = nCurrentXPos + aMaxSymbolExtent.Width; - if( !bSymbolsLeftSide ) - nTextXPos = nCurrentXPos - aMaxSymbolExtent.Width - aTextSize.Width; - aTextShapes[ nEntry ]->setPosition( awt::Point( nTextXPos, nCurrentYPos )); - - nCurrentYPos += nMaxHeights[ nRow ]; + nCurrentYPos += aRowHeights[ nRow ]; + if( nRow+1 < nNumberOfRows ) + nCurrentYPos += nYOffset; nMaxYPos = ::std::max( nMaxYPos, nCurrentYPos ); } if( bSymbolsLeftSide ) - nCurrentXPos += nMaxWidth; + { + nCurrentXPos += aColumnWidths[nColumn]; + if( nColumn+1 < nNumberOfColumns ) + nCurrentXPos += nXOffset; + } else - nCurrentXPos -= nMaxWidth; + { + nCurrentXPos -= aColumnWidths[nColumn]; + if( nColumn+1 < nNumberOfColumns ) + nCurrentXPos -= nXOffset; + } } - if( bSymbolsLeftSide ) - rOutLegendSize.Width = nCurrentXPos + nXPadding; - else + if( !bIsCustomSize ) { - sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); - rOutLegendSize.Width = nLegendWidth; + if( bSymbolsLeftSide ) + aResultingLegendSize.Width = nCurrentXPos + nXPadding; + else + { + sal_Int32 nLegendWidth = -(nCurrentXPos-nXPadding); + aResultingLegendSize.Width = nLegendWidth; + } + aResultingLegendSize.Height = nMaxYPos + nYPadding; + } + if( !bSymbolsLeftSide ) + { + sal_Int32 nLegendWidth = aResultingLegendSize.Width; awt::Point aPos(0,0); for( sal_Int32 nEntry=0; nEntry<nNumberOfEntries; nEntry++ ) { @@ -441,7 +647,8 @@ void lcl_placeLegendEntries( xText->setPosition( aPos ); } } - rOutLegendSize.Height = nMaxYPos + nYPadding; + + return aResultingLegendSize; } // #i109336# Improve auto positioning in chart @@ -583,14 +790,6 @@ awt::Point lcl_calculatePositionAndRemainingSpace( return aResult; } -template< class T > -void lcl_appendSeqToVector( const Sequence< T > & rSource, ::std::vector< T > & rDest ) -{ - const sal_Int32 nCount = rSource.getLength(); - for( sal_Int32 i = 0; i < nCount; ++i ) - rDest.push_back( rSource[ i ] ); -} - bool lcl_shouldSymbolsBePlacedOnTheLeftSide( const Reference< beans::XPropertySet >& xLegendProp, sal_Int16 nDefaultWritingMode ) { bool bSymbolsLeftSide = true; @@ -706,23 +905,26 @@ void VLegend::createShapes( tPropertyValues aLineFillProperties; tPropertyValues aTextProperties; - // limit the width of texts to 30% of the total available width - // #i109336# Improve auto positioning in chart - sal_Int32 nMaxLabelWidth = rAvailableSpace.Width * 3 / 10; Reference< beans::XPropertySet > xLegendProp( m_xLegend, uno::UNO_QUERY ); - LegendExpansion eExpansion = LegendExpansion_HIGH; + ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; + awt::Size aLegendSize( rAvailableSpace ); + if( xLegendProp.is()) { // get Expansion property xLegendProp->getPropertyValue( C2U( "Expansion" )) >>= eExpansion; - if( eExpansion == LegendExpansion_WIDE ) + if( eExpansion == ::com::sun::star::chart::ChartLegendExpansion_CUSTOM ) { - //#i80377# - nMaxLabelWidth = (rAvailableSpace.Width * 5) / 6;//completely correct would be available width minus symbol size minus distances to page ... + RelativeSize aRelativeSize; + if ((xLegendProp->getPropertyValue( C2U( "RelativeSize" )) >>= aRelativeSize)) + { + aLegendSize.Width = aRelativeSize.Primary * rPageSize.Width; + aLegendSize.Height = aRelativeSize.Secondary * rPageSize.Height; + } + else + eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH; } - - lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, nMaxLabelWidth, - rPageSize ); + lcl_getProperties( xLegendProp, aLineFillProperties, aTextProperties, rPageSize ); } if( xBorder.is()) @@ -739,32 +941,47 @@ void VLegend::createShapes( } // create entries - tViewLegendEntryContainer aViewEntries; + double fViewFontSize = lcl_CalcViewFontSize( xLegendProp, rPageSize );//todo + // #i109336# Improve auto positioning in chart + sal_Int32 nSymbolHeigth = static_cast< sal_Int32 >( fViewFontSize * 0.6 ); + sal_Int32 nSymbolWidth = static_cast< sal_Int32 >( nSymbolHeigth ); + + ::std::vector< LegendEntryProvider* >::const_iterator aIter = m_aLegendEntryProviderList.begin(); + const ::std::vector< LegendEntryProvider* >::const_iterator aEnd = m_aLegendEntryProviderList.end(); + for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; aIter++ ) { - ::std::vector< LegendEntryProvider* >::const_iterator aIter = m_aLegendEntryProviderList.begin(); - const ::std::vector< LegendEntryProvider* >::const_iterator aEnd = m_aLegendEntryProviderList.end(); - for( ; aIter != aEnd; aIter++ ) + LegendEntryProvider* pLegendEntryProvider( *aIter ); + if( pLegendEntryProvider ) { - LegendEntryProvider* pLegendEntryProvider( *aIter ); - if( pLegendEntryProvider ) + awt::Size aCurrentRatio = pLegendEntryProvider->getPreferredLegendKeyAspectRatio(); + sal_Int32 nCurrentWidth = aCurrentRatio.Width; + if( aCurrentRatio.Height > 0 ) { - lcl_appendSeqToVector< ViewLegendEntry >( - pLegendEntryProvider->createLegendEntries( eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ) - , aViewEntries ); + nCurrentWidth = nSymbolHeigth* aCurrentRatio.Width/aCurrentRatio.Height; } + nSymbolWidth = std::max( nSymbolWidth, nCurrentWidth ); + } + } + awt::Size aMaxSymbolExtent( nSymbolWidth, nSymbolHeigth ); + + tViewLegendEntryContainer aViewEntries; + for( aIter = m_aLegendEntryProviderList.begin(); aIter != aEnd; aIter++ ) + { + LegendEntryProvider* pLegendEntryProvider( *aIter ); + if( pLegendEntryProvider ) + { + std::vector< ViewLegendEntry > aNewEntries = pLegendEntryProvider->createLegendEntries( aMaxSymbolExtent, eExpansion, xLegendProp, xLegendContainer, m_xShapeFactory, m_xContext ); + aViewEntries.insert( aViewEntries.end(), aNewEntries.begin(), aNewEntries.end() ); } } bool bSymbolsLeftSide = lcl_shouldSymbolsBePlacedOnTheLeftSide( xLegendProp, m_nDefaultWritingMode ); // place entries - awt::Size aLegendSize; - lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide - , xLegendProp, aTextProperties - , xLegendContainer, m_xShapeFactory, m_xContext - , rAvailableSpace, rPageSize, aLegendSize ); + aLegendSize = lcl_placeLegendEntries( aViewEntries, eExpansion, bSymbolsLeftSide, fViewFontSize, aMaxSymbolExtent + , aTextProperties, xLegendContainer, m_xShapeFactory, aLegendSize ); - if( xBorder.is()) + if( xBorder.is() ) xBorder->setSize( aLegendSize ); } } diff --git a/chart2/source/view/main/VLegendSymbolFactory.cxx b/chart2/source/view/main/VLegendSymbolFactory.cxx index d29b28e8dbe9..b7168bd7ee9f 100644 --- a/chart2/source/view/main/VLegendSymbolFactory.cxx +++ b/chart2/source/view/main/VLegendSymbolFactory.cxx @@ -38,9 +38,6 @@ // header for define DBG_ASSERT #include <tools/debug.hxx> -// uncomment to disable line dashes at the border of boxes -// #define DISABLE_DASHES_AT_BORDER - using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -105,16 +102,16 @@ namespace chart { Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( + const awt::Size& rEntryKeyAspectRatio, const Reference< drawing::XShapes > xSymbolContainer, - chart2::LegendSymbolStyle eStyle, + LegendSymbolStyle eStyle, const Reference< lang::XMultiServiceFactory > & xShapeFactory, const Reference< beans::XPropertySet > & xLegendEntryProperties, tPropertyType ePropertyType, const uno::Any& rExplicitSymbol ) { Reference< drawing::XShape > xResult; - if( ! (xSymbolContainer.is() && - xShapeFactory.is())) + if( ! (xSymbolContainer.is() && xShapeFactory.is())) return xResult; xResult.set( xShapeFactory->createInstance( @@ -124,247 +121,92 @@ Reference< drawing::XShape > VLegendSymbolFactory::createSymbol( if( ! xResultGroup.is()) return xResult; - // aspect ratio of symbols is always 3:2 - awt::Size aBoundSize( 3000, 2000 ); - bool bUseBox = false; - // add an invisible square box to maintain aspect ratio - switch( eStyle ) - { - case chart2::LegendSymbolStyle_BOX: - case chart2::LegendSymbolStyle_HORIZONTAL_LINE: - case chart2::LegendSymbolStyle_VERTICAL_LINE: - case chart2::LegendSymbolStyle_DIAGONAL_LINE: - case chart2::LegendSymbolStyle_LINE_WITH_BOX: - case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL: - case chart2::LegendSymbolStyle_CIRCLE: - { - Reference< drawing::XShape > xBound( ShapeFactory(xShapeFactory).createInvisibleRectangle( - xResultGroup, aBoundSize )); - break; - } - - case chart2::LegendSymbolStyle_BAR: - case chart2::LegendSymbolStyle_RECTANGLE: - case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE: - case chart2::LegendSymbolStyle_USER_DEFINED: - default: - break; - } + Reference< drawing::XShape > xBound( ShapeFactory(xShapeFactory).createInvisibleRectangle( + xResultGroup, rEntryKeyAspectRatio )); // create symbol - switch( eStyle ) + try { - case chart2::LegendSymbolStyle_BOX: - case chart2::LegendSymbolStyle_BAR: - case chart2::LegendSymbolStyle_RECTANGLE: - case chart2::LegendSymbolStyle_STRETCHED_RECTANGLE: - case chart2::LegendSymbolStyle_CIRCLE: + if( eStyle == LegendSymbolStyle_LINE ) { - try + Reference< drawing::XShape > xLine( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); + if( xLine.is()) { - Reference< drawing::XShape > xShape; + xResultGroup->add( xLine ); + xLine->setSize( awt::Size( rEntryKeyAspectRatio.Width, 0 )); + xLine->setPosition( awt::Point( 0, rEntryKeyAspectRatio.Height/2 )); - if( eStyle == chart2::LegendSymbolStyle_CIRCLE ) - xShape.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.EllipseShape" )), uno::UNO_QUERY ); - else - xShape.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); + lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); + } - if( xShape.is()) + Reference< drawing::XShape > xSymbol; + const sal_Int32 nSize = std::min(rEntryKeyAspectRatio.Width,rEntryKeyAspectRatio.Height); + chart2::Symbol aSymbol; + if( rExplicitSymbol >>= aSymbol ) + { + drawing::Direction3D aSymbolSize( nSize, nSize, 0 ); + drawing::Position3D aPos( rEntryKeyAspectRatio.Width/2, rEntryKeyAspectRatio.Height/2, 0 ); + ShapeFactory aFactory( xShapeFactory ); + if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) { - xResultGroup->add( xShape ); - if( eStyle == chart2::LegendSymbolStyle_BOX || - eStyle == chart2::LegendSymbolStyle_CIRCLE ) - { - xShape->setSize( awt::Size( 2000, 2000 )); - xShape->setPosition( awt::Point( 500, 0 )); - } - else - { - xShape->setSize( aBoundSize ); - } + // take series color as fill color + xLegendEntryProperties->getPropertyValue( C2U("Color")) >>= aSymbol.FillColor; + // border of symbols always same as fill color + aSymbol.BorderColor = aSymbol.FillColor; + + xSymbol.set( aFactory.createSymbol2D( + xResultGroup, + aPos, + aSymbolSize, + aSymbol.StandardSymbol, + aSymbol.BorderColor, + aSymbol.FillColor )); } - - lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); - -#ifdef DISABLE_DASHES_AT_BORDER - // don't allow dashed border style - Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); - if( xShapeProp.is()) + else if( aSymbol.Style == chart2::SymbolStyle_GRAPHIC ) { - drawing::LineStyle aLineStyle; - if( ( xShapeProp->getPropertyValue( C2U("LineStyle")) >>= aLineStyle ) && - aLineStyle == drawing::LineStyle_DASH ) - { - aLineStyle = drawing::LineStyle_SOLID; - xShapeProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( aLineStyle )); - } + xSymbol.set( aFactory.createGraphic2D( + xResultGroup, + aPos, + aSymbolSize, + aSymbol.Graphic )); } -#endif - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; - } - - case chart2::LegendSymbolStyle_HORIZONTAL_LINE: - { - try - { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) + else if( aSymbol.Style == chart2::SymbolStyle_AUTO ) { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 3000, 0 )); - xLine->setPosition( awt::Point( 0, 1000 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); + DBG_ERROR("the given parameter is not allowed to contain an automatic symbol style"); } } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; } - - case chart2::LegendSymbolStyle_VERTICAL_LINE: + else if( eStyle == LegendSymbolStyle_CIRCLE ) { - try + Reference< drawing::XShape > xShape( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.EllipseShape" )), uno::UNO_QUERY ); + if( xShape.is() ) { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 0, 2000 )); - xLine->setPosition( awt::Point( 1500, 0 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); + xResultGroup->add( xShape ); + sal_Int32 nSize = std::min( rEntryKeyAspectRatio.Width, rEntryKeyAspectRatio.Height ); + xShape->setSize( awt::Size( nSize, nSize ) ); + xShape->setPosition( awt::Point( rEntryKeyAspectRatio.Width/2-nSize/2, rEntryKeyAspectRatio.Height/2-nSize/2 ) ); + lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); } - break; } - - case chart2::LegendSymbolStyle_DIAGONAL_LINE: + else // eStyle == LegendSymbolStyle_BOX { - try + Reference< drawing::XShape > xShape( xShapeFactory->createInstance( + C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); + if( xShape.is() ) { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 2000, 2000 )); - xLine->setPosition( awt::Point( 500, 0 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); // PROP_TYPE_LINE_SERIES ); - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); + xResultGroup->add( xShape ); + xShape->setSize( rEntryKeyAspectRatio ); + xShape->setPosition( awt::Point( 0, 0 ) ); + lcl_setPropetiesToShape( xLegendEntryProperties, xShape, ePropertyType ); // PROP_TYPE_FILLED_SERIES ); } - break; } - - case chart2::LegendSymbolStyle_LINE_WITH_BOX: - bUseBox = true; - // fall-through intended - case chart2::LegendSymbolStyle_LINE_WITH_SYMBOL: - try - { - Reference< drawing::XShape > xLine( - xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.LineShape" )), uno::UNO_QUERY ); - if( xLine.is()) - { - xResultGroup->add( xLine ); - xLine->setSize( awt::Size( 3000, 0 )); - xLine->setPosition( awt::Point( 0, 1000 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xLine, ePropertyType ); - } - - Reference< drawing::XShape > xSymbol; - const sal_Int32 nSize = 1500; - if( bUseBox ) - { - xSymbol.set( xShapeFactory->createInstance( - C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY ); - xResultGroup->add( xSymbol ); - - if( xSymbol.is()) - { - xSymbol->setSize( awt::Size( nSize, nSize )); - xSymbol->setPosition( awt::Point( 1500 - nSize/2, 1000 - nSize/2 )); - - lcl_setPropetiesToShape( xLegendEntryProperties, xSymbol, ePropertyType ); - } - } - else - { - chart2::Symbol aSymbol; - - if( rExplicitSymbol >>= aSymbol ) - { - drawing::Direction3D aSymbolSize( nSize, nSize, 0 ); - drawing::Position3D aPos( 1500, 1000, 0 ); - ShapeFactory aFactory( xShapeFactory ); - if( aSymbol.Style == chart2::SymbolStyle_STANDARD ) - { - // take series color as fill color - xLegendEntryProperties->getPropertyValue( C2U("Color")) >>= aSymbol.FillColor; - // border of symbols always same as fill color - aSymbol.BorderColor = aSymbol.FillColor; - - xSymbol.set( aFactory.createSymbol2D( - xResultGroup, - aPos, - aSymbolSize, - aSymbol.StandardSymbol, - aSymbol.BorderColor, - aSymbol.FillColor )); - } - else if( aSymbol.Style == chart2::SymbolStyle_GRAPHIC ) - { - xSymbol.set( aFactory.createGraphic2D( - xResultGroup, - aPos, - aSymbolSize, - aSymbol.Graphic )); - } - else if( aSymbol.Style == chart2::SymbolStyle_AUTO ) - { - DBG_ERROR("the given parameter is not allowed to contain an automatic symbol style"); - } - } - } - } - catch( uno::Exception & ex ) - { - ASSERT_EXCEPTION( ex ); - } - break; - - case chart2::LegendSymbolStyle_USER_DEFINED: - break; - - default: - // just to remove warning (there is an auto-generated extra label) - break; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); } return xResult; |