Files
libreoffice/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx

243 lines
9.8 KiB
C++
Raw Normal View History

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: MultipleChartConverters.cxx,v $
*
* $Revision: 1.13 $
*
* last change: $Author: ihi $ $Date: 2007-11-23 11:51:54 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "MultipleChartConverters.hxx"
#include "chartview/ChartSfxItemIds.hxx"
#include "SchWhichPairs.hxx"
#include "AxisItemConverter.hxx"
2003-12-10 15:51:53 +00:00
#include "StatisticsItemConverter.hxx"
#include "GraphicPropertyItemConverter.hxx"
#include "DataPointItemConverter.hxx"
#include "ChartModelHelper.hxx"
2003-12-18 11:38:44 +00:00
#include "TitleHelper.hxx"
#include "TitleItemConverter.hxx"
#include "AxisHelper.hxx"
#include "chartview/ExplicitValueProvider.hxx"
#include "DiagramHelper.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
namespace chart
{
namespace wrapper
{
//-----------------------------------------------------------------------------
AllAxisItemConverter::AllAxisItemConverter(
const uno::Reference< frame::XModel > & xChartModel,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/,
::std::auto_ptr< awt::Size > pRefSize )
: MultipleItemConverter( rItemPool )
{
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
{
uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY);
if( pRefSize.get())
m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
xObjectProperties, rItemPool, rDrawModel,
uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0,
::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) ));
else
m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter(
xObjectProperties, rItemPool, rDrawModel,
uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) );
}
}
AllAxisItemConverter::~AllAxisItemConverter()
{
}
const USHORT * AllAxisItemConverter::GetWhichPairs() const
{
// must span all used items!
return nAllAxisWhichPairs;
}
//-----------------------------------------------------------------------------
AllGridItemConverter::AllGridItemConverter(
const uno::Reference< frame::XModel > & xChartModel,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory )
: MultipleItemConverter( rItemPool )
{
Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) );
for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ )
{
Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]);
m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter(
xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory,
::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) );
}
}
AllGridItemConverter::~AllGridItemConverter()
{
}
const USHORT * AllGridItemConverter::GetWhichPairs() const
{
// must span all used items!
return nGridWhichPairs;
}
//-----------------------------------------------------------------------------
AllDataLabelItemConverter::AllDataLabelItemConverter(
const uno::Reference< frame::XModel > & xChartModel,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
::std::auto_ptr< awt::Size > pRefSize )
: MultipleItemConverter( rItemPool )
{
::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
::chart::ChartModelHelper::getDataSeries( xChartModel ));
::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
{
uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties
sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForLabel( xObjectProperties, *aIt, -1/*nPointIndex*/,
uno::Reference< beans::XPropertySet >( DiagramHelper::getAttachedAxis( *aIt, ChartModelHelper::findDiagram( xChartModel ) ), uno::UNO_QUERY ) );
sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForLabel(
xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter(
xChartModel, xContext,
xObjectProperties, *aIt, rItemPool, rDrawModel, NULL,
xNamedPropertyContainerFactory,
GraphicPropertyItemConverter::FILLED_DATA_POINT,
::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0),
true, /*bDataSeries*/
false, /*bUseSpecialFillColor*/
0, /*nSpecialFillColor*/
true /*bOverwriteLabelsForAttributedDataPointsAlso*/,
nNumberFormat, nPercentNumberFormat
));
}
}
AllDataLabelItemConverter::~AllDataLabelItemConverter()
{
}
const USHORT * AllDataLabelItemConverter::GetWhichPairs() const
{
// must span all used items!
return nDataLabelWhichPairs;
}
//-----------------------------------------------------------------------------
2003-12-18 11:38:44 +00:00
AllTitleItemConverter::AllTitleItemConverter(
const uno::Reference< frame::XModel > & xChartModel,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
2003-12-18 11:38:44 +00:00
::std::auto_ptr< awt::Size > pRefSize )
: MultipleItemConverter( rItemPool )
{
for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ )
2003-12-18 11:38:44 +00:00
{
uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) );
if(!xTitle.is())
return;
uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY);
::std::auto_ptr< awt::Size > pSingleRefSize(0);
if( pRefSize.get())
pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize ));
m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter(
xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize ));
2003-12-18 11:38:44 +00:00
}
}
AllTitleItemConverter::~AllTitleItemConverter()
{
}
const USHORT * AllTitleItemConverter::GetWhichPairs() const
{
// must span all used items!
return nTitleWhichPairs;
}
//-----------------------------------------------------------------------------
2003-12-10 15:51:53 +00:00
AllSeriesStatisticsConverter::AllSeriesStatisticsConverter(
const uno::Reference< frame::XModel > & xChartModel,
SfxItemPool& rItemPool )
: MultipleItemConverter( rItemPool )
{
::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
::chart::ChartModelHelper::getDataSeries( xChartModel ));
::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt;
for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt )
{
uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY);
m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter(
2003-12-17 15:43:22 +00:00
xChartModel, xObjectProperties, rItemPool ));
2003-12-10 15:51:53 +00:00
}
}
AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter()
{}
const USHORT * AllSeriesStatisticsConverter::GetWhichPairs() const
{
// must span all used items!
return nStatWhichPairs;
}
} // namespace wrapper
} // namespace chart