2003-10-06 08:58:36 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 00:27:25 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2005-09-08 00:27:25 +00:00
|
|
|
* $RCSfile: ChartModelHelper.cxx,v $
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2007-05-22 17:56:01 +00:00
|
|
|
* $Revision: 1.9 $
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2007-05-22 17:56:01 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2007-05-22 18:56:01 $
|
2003-10-06 08:58:36 +00:00
|
|
|
*
|
2005-09-08 00:27:25 +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
|
|
|
*
|
|
|
|
*
|
2005-09-08 00:27:25 +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
|
|
|
*
|
2005-09-08 00:27:25 +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
|
|
|
*
|
2005-09-08 00:27:25 +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
|
|
|
*
|
2005-09-08 00:27:25 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 12:22:25 +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"
|
2007-05-22 17:56:01 +00:00
|
|
|
#include "DiagramHelper.hxx"
|
2003-10-06 08:58:36 +00:00
|
|
|
|
2004-01-26 08:13:31 +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
|
2007-05-22 17:56:01 +00:00
|
|
|
#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;
|
2004-01-26 08:13:31 +00:00
|
|
|
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())
|
2007-05-22 17:56:01 +00:00
|
|
|
return ChartModelHelper::findDiagram( xChartDoc );
|
2003-10-06 08:58:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-22 17:56:01 +00:00
|
|
|
// static
|
|
|
|
uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< chart2::XChartDocument >& xChartDoc )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-05-22 17:56:01 +00:00
|
|
|
try
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-05-22 17:56:01 +00:00
|
|
|
if( xChartDoc.is())
|
|
|
|
return xChartDoc->getFirstDiagram();
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2007-05-22 17:56:01 +00:00
|
|
|
catch( uno::Exception & ex )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-05-22 17:56:01 +00:00
|
|
|
ASSERT_EXCEPTION( ex );
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
2007-05-22 17:56:01 +00:00
|
|
|
return NULL;
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
|
2007-05-22 17:56:01 +00:00
|
|
|
const uno::Reference< XChartDocument > & xChartDoc )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
|
|
|
::std::vector< uno::Reference< XDataSeries > > aResult;
|
2007-05-22 17:56:01 +00:00
|
|
|
|
|
|
|
uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
|
|
|
|
if( xDiagram.is())
|
|
|
|
aResult = DiagramHelper::getDataSeriesFromDiagram( xDiagram );
|
2003-10-06 08:58:36 +00:00
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
2007-05-22 17:56:01 +00:00
|
|
|
// static
|
|
|
|
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
|
|
|
|
const uno::Reference< frame::XModel > & xModel )
|
2003-10-06 08:58:36 +00:00
|
|
|
{
|
2007-05-22 17:56:01 +00:00
|
|
|
return getDataSeries( uno::Reference< chart2::XChartDocument >( xModel, uno::UNO_QUERY ));
|
2003-10-06 08:58:36 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 17:56:01 +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 )
|
|
|
|
{
|
2007-05-22 17:56:01 +00:00
|
|
|
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
|
|
|
|
//.............................................................................
|