2007/02/08 21:25:28 iha 1.1.2.17: resync m195 -> m202 2006/04/10 15:03:30 iha 1.1.2.16: api restructure axis, grids, scales and increments 2006/04/10 12:25:04 iha 1.1.2.15: api restructure axis, grids, scales and increments 2006/03/12 00:53:26 iha 1.1.2.14: merged ChartAPIValueProvider with Chart2ModelContact 2006/02/17 20:57:41 iha 1.1.2.13: enlarge validity of api wrapper objects to lifetime of new chartmodel 2006/01/27 09:51:15 bm 1.1.2.12: InlineContainer.hxx moved to comphelper 2005/12/07 12:24:59 iha 1.1.2.11: corrected method name 2005/11/18 18:19:52 iha 1.1.2.10: restructuring for proper subgrid support 2005/11/15 15:30:00 bm 1.1.2.9: garbage collection, disposing, reference release issues 2005/10/11 09:19:54 bm 1.1.2.8: license header change 2005/08/03 16:36:13 bm 1.1.2.7: algohelper.hxx split up into CommonFunctors.hxx ContainerHelper.hxx CloneHelper.hxx 2005/07/14 12:32:46 iha 1.1.2.6: remove unused parameter 'bIncludeStyleProperties' 2005/07/12 12:56:54 bm 1.1.2.5: use named properties for gradients etc. in chart model 2005/07/07 12:09:22 bm 1.1.2.4: some defaults are different in old chart 2005/05/31 19:07:13 iha 1.1.2.3: create old api without controller 2005/04/19 17:28:39 iha 1.1.2.2: improved old api support (introduced wrappedpropertyset ...) 2004/05/28 14:11:52 bm 1.1.2.1: wrapper for grids
235 lines
7.2 KiB
C++
235 lines
7.2 KiB
C++
/*************************************************************************
|
|
*
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
*
|
|
* $RCSfile: GridWrapper.cxx,v $
|
|
*
|
|
* $Revision: 1.2 $
|
|
*
|
|
* last change: $Author: vg $ $Date: 2007-05-22 17:18:14 $
|
|
*
|
|
* 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 "GridWrapper.hxx"
|
|
#include "macros.hxx"
|
|
#include "AxisHelper.hxx"
|
|
#include "Scaling.hxx"
|
|
#include "Chart2ModelContact.hxx"
|
|
#include "ContainerHelper.hxx"
|
|
#include "AxisIndexDefines.hxx"
|
|
|
|
#ifndef INCLUDED_COMPHELPER_INLINE_CONTAINER_HXX
|
|
#include <comphelper/InlineContainer.hxx>
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
#endif
|
|
|
|
#include "LineProperties.hxx"
|
|
// #include "NamedLineProperties.hxx"
|
|
#include "UserDefinedProperties.hxx"
|
|
// #include "WrappedNamedProperty.hxx"
|
|
#include "WrappedDefaultProperty.hxx"
|
|
|
|
#include <algorithm>
|
|
|
|
#ifndef _RTL_USTRBUF_HXX_
|
|
#include <rtl/ustrbuf.hxx>
|
|
#endif
|
|
#ifndef INCLUDED_RTL_MATH_HXX
|
|
#include <rtl/math.hxx>
|
|
#endif
|
|
|
|
using namespace ::com::sun::star;
|
|
using namespace ::com::sun::star::chart2;
|
|
|
|
using ::com::sun::star::beans::Property;
|
|
using ::osl::MutexGuard;
|
|
using ::com::sun::star::uno::Reference;
|
|
using ::com::sun::star::uno::Sequence;
|
|
using ::rtl::OUString;
|
|
|
|
namespace
|
|
{
|
|
static const OUString lcl_aServiceName(
|
|
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Grid" ));
|
|
|
|
const Sequence< Property > & lcl_GetPropertySequence()
|
|
{
|
|
static Sequence< Property > aPropSeq;
|
|
|
|
// /--
|
|
MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
if( 0 == aPropSeq.getLength() )
|
|
{
|
|
// get properties
|
|
::std::vector< ::com::sun::star::beans::Property > aProperties;
|
|
::chart::LineProperties::AddPropertiesToVector( aProperties );
|
|
// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties );
|
|
::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
|
|
|
|
// and sort them for access via bsearch
|
|
::std::sort( aProperties.begin(), aProperties.end(),
|
|
::chart::PropertyNameLess() );
|
|
|
|
// transfer result to static Sequence
|
|
aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties );
|
|
}
|
|
|
|
return aPropSeq;
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
// --------------------------------------------------------------------------------
|
|
|
|
namespace chart
|
|
{
|
|
namespace wrapper
|
|
{
|
|
|
|
GridWrapper::GridWrapper(
|
|
tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
|
|
m_spChart2ModelContact( spChart2ModelContact ),
|
|
m_aEventListenerContainer( m_aMutex ),
|
|
m_eType( eType )
|
|
{
|
|
}
|
|
|
|
GridWrapper::~GridWrapper()
|
|
{}
|
|
|
|
// static
|
|
void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
|
|
{
|
|
rnDimensionIndex = 1;
|
|
rbSubGrid = false;
|
|
|
|
switch( eType )
|
|
{
|
|
case X_MAIN_GRID:
|
|
rnDimensionIndex = 0; rbSubGrid = false; break;
|
|
case Y_MAIN_GRID:
|
|
rnDimensionIndex = 1; rbSubGrid = false; break;
|
|
case Z_MAIN_GRID:
|
|
rnDimensionIndex = 2; rbSubGrid = false; break;
|
|
case X_SUB_GRID:
|
|
rnDimensionIndex = 0; rbSubGrid = true; break;
|
|
case Y_SUB_GRID:
|
|
rnDimensionIndex = 1; rbSubGrid = true; break;
|
|
case Z_SUB_GRID:
|
|
rnDimensionIndex = 2; rbSubGrid = true; break;
|
|
}
|
|
}
|
|
|
|
// ____ XComponent ____
|
|
void SAL_CALL GridWrapper::dispose()
|
|
throw (uno::RuntimeException)
|
|
{
|
|
Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
|
|
m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
|
|
|
|
clearWrappedPropertySet();
|
|
}
|
|
|
|
void SAL_CALL GridWrapper::addEventListener(
|
|
const Reference< lang::XEventListener >& xListener )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
m_aEventListenerContainer.addInterface( xListener );
|
|
}
|
|
|
|
void SAL_CALL GridWrapper::removeEventListener(
|
|
const Reference< lang::XEventListener >& aListener )
|
|
throw (uno::RuntimeException)
|
|
{
|
|
m_aEventListenerContainer.removeInterface( aListener );
|
|
}
|
|
|
|
// ================================================================================
|
|
|
|
// WrappedPropertySet
|
|
|
|
Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
|
|
{
|
|
Reference< beans::XPropertySet > xRet;
|
|
try
|
|
{
|
|
Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
|
|
uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
|
|
|
|
sal_Int32 nDimensionIndex = 1;
|
|
bool bSubGrid = false;
|
|
getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
|
|
|
|
sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
|
|
xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) );
|
|
}
|
|
catch( uno::Exception & ex )
|
|
{
|
|
ASSERT_EXCEPTION( ex );
|
|
}
|
|
return xRet;
|
|
}
|
|
|
|
const Sequence< beans::Property >& GridWrapper::getPropertySequence()
|
|
{
|
|
return lcl_GetPropertySequence();
|
|
}
|
|
|
|
const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties()
|
|
{
|
|
::std::vector< ::chart::WrappedProperty* > aWrappedProperties;
|
|
|
|
// WrappedNamedProperty::addWrappedLineProperties( aWrappedProperties, m_spChart2ModelContact );
|
|
aWrappedProperties.push_back( new WrappedDefaultProperty( C2U("LineColor"), C2U("LineColor"), uno::makeAny( sal_Int32( 0x000000) ) ) ); // black
|
|
|
|
return aWrappedProperties;
|
|
}
|
|
|
|
// ================================================================================
|
|
|
|
Sequence< OUString > GridWrapper::getSupportedServiceNames_Static()
|
|
{
|
|
Sequence< OUString > aServices( 4 );
|
|
aServices[ 0 ] = C2U( "com.sun.star.chart.ChartGrid" );
|
|
aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
|
|
aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" );
|
|
aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
|
|
|
|
return aServices;
|
|
}
|
|
|
|
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
|
|
APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName );
|
|
|
|
} // namespace wrapper
|
|
} // namespace chart
|