Files
libreoffice/chart2/source/tools/ChartModelHelper.cxx

155 lines
5.4 KiB
C++
Raw Normal View History

2003-10-06 08:58:36 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2003-10-06 08:58:36 +00:00
*
* $RCSfile: ChartModelHelper.cxx,v $
2003-10-06 08:58:36 +00:00
*
* $Revision: 1.9 $
2003-10-06 08:58:36 +00:00
*
* last change: $Author: vg $ $Date: 2007-05-22 18:56:01 $
2003-10-06 08:58:36 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2003-10-06 08:58:36 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2003-10-06 08:58:36 +00:00
*
* 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.
2003-10-06 08:58:36 +00:00
*
* 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.
2003-10-06 08:58:36 +00:00
*
* 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
2003-10-06 08:58:36 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
2003-10-06 08:58:36 +00:00
#include "ChartModelHelper.hxx"
#include "macros.hxx"
#include "DiagramHelper.hxx"
2003-10-06 08:58:36 +00:00
#ifndef _COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_
#include <com/sun/star/chart2/XChartDocument.hpp>
2003-10-06 08:58:36 +00:00
#endif
#ifndef _COM_SUN_STAR_CHART2_XCHARTTYPECONTAINER_HPP_
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XCOORDINATESYSTEMCONTAINER_HPP_
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_XDATASERIESCONTAINER_HPP_
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_ASPECTS_HPP_
#include <com/sun/star/embed/Aspects.hpp>
#endif
#ifndef _COM_SUN_STAR_EMBED_XVISUALOBJECT_HPP_
#include <com/sun/star/embed/XVisualObject.hpp>
2003-10-06 08:58:36 +00:00
#endif
// header for define DBG_ASSERT
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
//.............................................................................
namespace chart
{
//.............................................................................
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
2003-10-06 08:58:36 +00:00
//static
uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< frame::XModel >& xModel )
{
uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
if( xChartDoc.is())
return ChartModelHelper::findDiagram( xChartDoc );
2003-10-06 08:58:36 +00:00
return NULL;
}
// static
uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< chart2::XChartDocument >& xChartDoc )
2003-10-06 08:58:36 +00:00
{
try
2003-10-06 08:58:36 +00:00
{
if( xChartDoc.is())
return xChartDoc->getFirstDiagram();
2003-10-06 08:58:36 +00:00
}
catch( uno::Exception & ex )
2003-10-06 08:58:36 +00:00
{
ASSERT_EXCEPTION( ex );
2003-10-06 08:58:36 +00:00
}
return NULL;
2003-10-06 08:58:36 +00:00
}
// static
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
const uno::Reference< XChartDocument > & xChartDoc )
2003-10-06 08:58:36 +00:00
{
::std::vector< uno::Reference< XDataSeries > > aResult;
uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
if( xDiagram.is())
aResult = DiagramHelper::getDataSeriesFromDiagram( xDiagram );
2003-10-06 08:58:36 +00:00
return aResult;
}
// static
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
const uno::Reference< frame::XModel > & xModel )
2003-10-06 08:58:36 +00:00
{
return getDataSeries( uno::Reference< chart2::XChartDocument >( xModel, uno::UNO_QUERY ));
2003-10-06 08:58:36 +00:00
}
2003-11-08 21:52:47 +00:00
uno::Reference< XChartType > ChartModelHelper::getChartTypeOfSeries(
const uno::Reference< frame::XModel >& xModel
, const uno::Reference< XDataSeries >& xGivenDataSeries )
{
return DiagramHelper::getChartTypeOfSeries( ChartModelHelper::findDiagram( xModel ), xGivenDataSeries );
}
//static
uno::Reference< XCoordinateSystem > ChartModelHelper::getCoordinateSystemOfChartType(
const uno::Reference< frame::XModel >& xModel
, const uno::Reference< XChartType >& xGivenChartType )
{
return DiagramHelper::getCoordinateSystemOfChartType( ChartModelHelper::findDiagram( xModel ), xGivenChartType );
}
awt::Size ChartModelHelper::getPageSize( const uno::Reference< frame::XModel >& xModel )
{
awt::Size aPageSize( 8000, 7000 );
uno::Reference< embed::XVisualObject > xVisualObject(xModel,uno::UNO_QUERY);
DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size");
if( xVisualObject.is() )
aPageSize = xVisualObject->getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
return aPageSize;
}
void ChartModelHelper::setPageSize( const awt::Size& rSize, const uno::Reference< frame::XModel >& xModel )
{
uno::Reference< embed::XVisualObject > xVisualObject(xModel,uno::UNO_QUERY);
DBG_ASSERT(xVisualObject.is(),"need xVisualObject for page size");
if( xVisualObject.is() )
xVisualObject->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, rSize );
2003-11-08 21:52:47 +00:00
}
2003-10-06 08:58:36 +00:00
//.............................................................................
} //namespace chart
//.............................................................................