2003-10-09 15:46:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
2008-04-10 19:44:44 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-10-09 15:46:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 12:02:33 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_chart2.hxx"
|
2003-10-09 15:46:46 +00:00
|
|
|
#include "LegendItemConverter.hxx"
|
|
|
|
#include "SchWhichPairs.hxx"
|
|
|
|
#include "macros.hxx"
|
|
|
|
#include "ItemPropertyMap.hxx"
|
|
|
|
#include "GraphicPropertyItemConverter.hxx"
|
|
|
|
#include "CharacterPropertyItemConverter.hxx"
|
2004-01-26 08:13:31 +00:00
|
|
|
#include <com/sun/star/chart2/XLegend.hpp>
|
|
|
|
#include <com/sun/star/chart2/LegendPosition.hpp>
|
2011-01-24 17:44:18 +01:00
|
|
|
#include <com/sun/star/chart/ChartLegendExpansion.hpp>
|
2003-10-09 15:46:46 +00:00
|
|
|
|
2011-01-27 20:57:37 +01:00
|
|
|
#include <svl/intitem.hxx>
|
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
|
2003-10-09 15:46:46 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
namespace wrapper
|
|
|
|
{
|
|
|
|
|
|
|
|
LegendItemConverter::LegendItemConverter(
|
|
|
|
const ::com::sun::star::uno::Reference<
|
|
|
|
::com::sun::star::beans::XPropertySet > & rPropertySet,
|
|
|
|
SfxItemPool& rItemPool,
|
2003-11-25 12:08:01 +00:00
|
|
|
SdrModel& rDrawModel,
|
2007-05-22 17:01:06 +00:00
|
|
|
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
|
2003-11-25 12:08:01 +00:00
|
|
|
::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) :
|
2003-10-09 15:46:46 +00:00
|
|
|
ItemConverter( rPropertySet, rItemPool )
|
|
|
|
{
|
|
|
|
m_aConverters.push_back( new GraphicPropertyItemConverter(
|
2007-05-22 17:01:06 +00:00
|
|
|
rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
|
2003-10-09 15:46:46 +00:00
|
|
|
GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ));
|
|
|
|
m_aConverters.push_back( new CharacterPropertyItemConverter(
|
2003-11-25 12:08:01 +00:00
|
|
|
rPropertySet, rItemPool, pRefSize,
|
|
|
|
C2U( "ReferencePageSize" ) ));
|
2003-10-09 15:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LegendItemConverter::~LegendItemConverter()
|
|
|
|
{
|
|
|
|
::std::for_each( m_aConverters.begin(), m_aConverters.end(),
|
|
|
|
::comphelper::DeleteItemConverterPtr() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void LegendItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
|
|
|
|
{
|
|
|
|
::std::for_each( m_aConverters.begin(), m_aConverters.end(),
|
|
|
|
::comphelper::FillItemSetFunc( rOutItemSet ));
|
|
|
|
|
|
|
|
// own items
|
|
|
|
ItemConverter::FillItemSet( rOutItemSet );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet )
|
|
|
|
{
|
|
|
|
bool bResult = false;
|
|
|
|
|
|
|
|
::std::for_each( m_aConverters.begin(), m_aConverters.end(),
|
|
|
|
::comphelper::ApplyItemSetFunc( rItemSet, bResult ));
|
|
|
|
|
|
|
|
// own items
|
|
|
|
return ItemConverter::ApplyItemSet( rItemSet ) || bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
const USHORT * LegendItemConverter::GetWhichPairs() const
|
|
|
|
{
|
|
|
|
// must span all used items!
|
|
|
|
return nLegendWhichPairs;
|
|
|
|
}
|
|
|
|
|
2007-07-25 07:41:14 +00:00
|
|
|
bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const
|
2003-10-09 15:46:46 +00:00
|
|
|
{
|
|
|
|
// No own (non-special) properties
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-27 20:57:37 +01:00
|
|
|
bool LegendItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet& rInItemSet )
|
2003-10-17 13:30:15 +00:00
|
|
|
throw( uno::Exception )
|
2003-10-09 15:46:46 +00:00
|
|
|
{
|
|
|
|
bool bChanged = false;
|
|
|
|
|
|
|
|
switch( nWhichId )
|
|
|
|
{
|
2011-01-27 20:57:37 +01:00
|
|
|
case SCHATTR_LEGEND_SHOW:
|
2003-10-09 15:46:46 +00:00
|
|
|
{
|
2011-01-27 20:57:37 +01:00
|
|
|
const SfxPoolItem* pPoolItem = NULL;
|
|
|
|
if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, TRUE, &pPoolItem ) == SFX_ITEM_SET )
|
2003-10-14 13:45:06 +00:00
|
|
|
{
|
2011-01-27 20:57:37 +01:00
|
|
|
sal_Bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
|
2003-12-11 13:07:23 +00:00
|
|
|
sal_Bool bWasShown = sal_True;
|
|
|
|
if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) ||
|
|
|
|
( bWasShown != bShow ))
|
2003-10-16 13:41:55 +00:00
|
|
|
{
|
2007-05-22 17:01:06 +00:00
|
|
|
GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow ));
|
2003-10-16 13:41:55 +00:00
|
|
|
bChanged = true;
|
|
|
|
}
|
2011-01-27 20:57:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
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());
|
2003-12-11 13:07:23 +00:00
|
|
|
|
2011-01-27 20:57:37 +01:00
|
|
|
::com::sun::star::chart::ChartLegendExpansion eExpansion = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
|
|
|
|
switch( eNewPos )
|
2003-12-11 13:07:23 +00:00
|
|
|
{
|
2011-01-27 20:57:37 +01:00
|
|
|
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;
|
2003-12-11 13:07:23 +00:00
|
|
|
if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) ||
|
|
|
|
( eOldPos != eNewPos ))
|
|
|
|
{
|
|
|
|
GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos ));
|
2011-01-27 20:57:37 +01:00
|
|
|
GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExpansion ));
|
2003-12-11 13:07:23 +00:00
|
|
|
GetPropertySet()->setPropertyValue( C2U( "RelativePosition" ), uno::Any());
|
|
|
|
bChanged = true;
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 20:57:37 +01:00
|
|
|
catch( uno::Exception & ex )
|
|
|
|
{
|
|
|
|
ASSERT_EXCEPTION( ex );
|
|
|
|
}
|
2003-10-16 13:41:55 +00:00
|
|
|
}
|
2003-10-09 15:46:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LegendItemConverter::FillSpecialItem(
|
|
|
|
USHORT nWhichId, SfxItemSet & rOutItemSet ) const
|
2003-10-17 13:30:15 +00:00
|
|
|
throw( uno::Exception )
|
2003-10-09 15:46:46 +00:00
|
|
|
{
|
|
|
|
switch( nWhichId )
|
|
|
|
{
|
2011-01-27 20:57:37 +01:00
|
|
|
case SCHATTR_LEGEND_SHOW:
|
2003-10-09 15:46:46 +00:00
|
|
|
{
|
2003-10-16 13:41:55 +00:00
|
|
|
sal_Bool bShow = sal_True;
|
|
|
|
GetPropertySet()->getPropertyValue( C2U( "Show" )) >>= bShow;
|
2011-01-27 20:57:37 +01:00
|
|
|
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 ) );
|
2003-10-09 15:46:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace wrapper
|
|
|
|
} // namespace chart
|