summaryrefslogtreecommitdiff
path: root/chart2/source/controller/itemsetwrapper
diff options
context:
space:
mode:
authorIngrid Halama [iha] <Ingrid.Halama@oracle.com>2011-01-27 20:57:37 +0100
committerIngrid Halama [iha] <Ingrid.Halama@oracle.com>2011-01-27 20:57:37 +0100
commitd6f9cfd061e34b2354b2f2fa09f833a0dcf1cefe (patch)
treec2dda935b703456af4784f8348176d78458c834c /chart2/source/controller/itemsetwrapper
parentc634a9b59904c79872ba2376fa032e4f68986280 (diff)
chart52: #28670# make the legend within charts resizeable - part 3
Diffstat (limited to 'chart2/source/controller/itemsetwrapper')
-rw-r--r--chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx131
1 files changed, 49 insertions, 82 deletions
diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
index c02df4aa4bfc..c93505181c0d 100644
--- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx
@@ -33,11 +33,13 @@
#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/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(
- USHORT nWhichId, const SfxItemSet & rItemSet )
+bool LegendItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet& rInItemSet )
throw( uno::Exception )
{
bool bChanged = false;
switch( nWhichId )
{
- case SCHATTR_LEGEND_POS:
+ case SCHATTR_LEGEND_SHOW:
{
- chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END;
- chart2::LegendPosition eOldPos;
- bool bIsWide = false;
- sal_Bool bShow = sal_True;
-
- SvxChartLegendPos eItemPos =
- static_cast< const SvxChartLegendPosItem & >(
- rItemSet.Get( nWhichId )).GetValue();
- switch( eItemPos )
- {
- case CHLEGEND_LEFT:
- eNewPos = chart2::LegendPosition_LINE_START;
- break;
- case CHLEGEND_RIGHT:
- eNewPos = chart2::LegendPosition_LINE_END;
- break;
- case CHLEGEND_TOP:
- eNewPos = chart2::LegendPosition_PAGE_START;
- bIsWide = true;
- break;
- case CHLEGEND_BOTTOM:
- eNewPos = chart2::LegendPosition_PAGE_END;
- bIsWide = true;
- break;
-
- case CHLEGEND_NONE:
- case CHLEGEND_NONE_LEFT:
- case CHLEGEND_NONE_RIGHT:
- case CHLEGEND_NONE_TOP:
- case CHLEGEND_NONE_BOTTOM:
- bShow = sal_False;
- break;
- }
-
- try
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, TRUE, &pPoolItem ) == SFX_ITEM_SET )
{
+ sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
sal_Bool bWasShown = sal_True;
if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) ||
( bWasShown != bShow ))
@@ -157,25 +126,48 @@ bool LegendItemConverter::ApplySpecialItem(
GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow ));
bChanged = true;
}
+ }
+
+ }
+ break;
+ case SCHATTR_LEGEND_POS:
+ {
+ const SfxPoolItem* pPoolItem = NULL;
+ if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, TRUE, &pPoolItem ) == SFX_ITEM_SET )
+ {
+ chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(((const SfxInt32Item*)pPoolItem)->GetValue());
- if( bShow )
+ ::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ switch( eNewPos )
{
+ case chart2::LegendPosition_LINE_START:
+ case chart2::LegendPosition_LINE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ case chart2::LegendPosition_PAGE_END:
+ eExpansion = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
+ break;
+ default:
+ break;
+ }
+
+ try
+ {
+ chart2::LegendPosition eOldPos;
if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) ||
( eOldPos != eNewPos ))
{
GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos ));
- ::com::sun::star::chart::ChartLegendExpansion eExp = bIsWide
- ? ::com::sun::star::chart::ChartLegendExpansion_WIDE
- : ::com::sun::star::chart::ChartLegendExpansion_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;
}