summaryrefslogtreecommitdiff
path: root/chart2/source/controller/chartapiwrapper
diff options
context:
space:
mode:
authorBjörn Milcke <bm@openoffice.org>2003-12-18 12:50:56 +0000
committerBjörn Milcke <bm@openoffice.org>2003-12-18 12:50:56 +0000
commit77a0557b67340195176d6b51571ad1a9f9ff9f26 (patch)
tree6fc7543d35ff53a4f2b4b3a67120fbd022950f05 /chart2/source/controller/chartapiwrapper
parent1c3ad7b9ebdc7a3560257bc32dcff08793dc759c (diff)
moved from model/oldapi
Diffstat (limited to 'chart2/source/controller/chartapiwrapper')
-rw-r--r--chart2/source/controller/chartapiwrapper/AxisWrapper.cxx944
-rw-r--r--chart2/source/controller/chartapiwrapper/AxisWrapper.hxx228
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx341
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx175
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx768
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx479
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx205
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx898
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx365
-rw-r--r--chart2/source/controller/chartapiwrapper/LegendWrapper.cxx512
-rw-r--r--chart2/source/controller/chartapiwrapper/LegendWrapper.hxx225
-rw-r--r--chart2/source/controller/chartapiwrapper/TitleWrapper.cxx582
-rw-r--r--chart2/source/controller/chartapiwrapper/TitleWrapper.hxx226
-rw-r--r--chart2/source/controller/chartapiwrapper/makefile.mk89
14 files changed, 6037 insertions, 0 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
new file mode 100644
index 000000000000..d561dbf98b49
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
@@ -0,0 +1,944 @@
+/*************************************************************************
+ *
+ * $RCSfile: AxisWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:18 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "AxisWrapper.hxx"
+#include "macros.hxx"
+#include "InlineContainer.hxx"
+#include "algohelper.hxx"
+#include "MeterHelper.hxx"
+#include "Scaling.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_CHARTAXISARRANGEORDERTYPE_HPP_
+#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
+#endif
+
+#include "CharacterProperties.hxx"
+#include "LineProperties.hxx"
+#include "UserDefinedProperties.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 ::drafts::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::property::OPropertySet;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Axis" ));
+
+enum
+{
+ PROP_AXIS_MAX,
+ PROP_AXIS_MIN,
+ PROP_AXIS_ORIGIN,
+ PROP_AXIS_STEPMAIN,
+ PROP_AXIS_STEPHELP,
+ PROP_AXIS_AUTO_MAX,
+ PROP_AXIS_AUTO_MIN,
+ PROP_AXIS_AUTO_ORIGIN,
+ PROP_AXIS_AUTO_STEPMAIN,
+ PROP_AXIS_AUTO_STEPHELP,
+ PROP_AXIS_LOGARITHMIC,
+ PROP_AXIS_DISPLAY_LABELS,
+ PROP_AXIS_TEXT_ROTATION,
+ PROP_AXIS_MARKS,
+ PROP_AXIS_HELPMARKS,
+ PROP_AXIS_OVERLAP,
+ PROP_AXIS_GAP_WIDTH,
+ PROP_AXIS_ARRANGE_ORDER,
+ PROP_AXIS_TEXTBREAK,
+ PROP_AXIS_CAN_OVERLAP,
+ PROP_AXIS_NUMBERFORMAT
+};
+
+typedef ::std::map< sal_Int32, ::rtl::OUString > lcl_PropertyMapType;
+typedef ::comphelper::MakeMap< sal_Int32, ::rtl::OUString > lcl_MakePropertyMapType;
+
+lcl_PropertyMapType & lcl_GetPropertyMap()
+{
+ static lcl_PropertyMapType aMap(
+ lcl_MakePropertyMapType
+ ( PROP_AXIS_DISPLAY_LABELS, C2U( "DisplayLabels" ))
+ ( PROP_AXIS_TEXT_ROTATION, C2U( "TextRotation" ))
+ // preliminary
+ ( PROP_AXIS_MARKS, C2U( "MajorTickmarks" ))
+ // preliminary
+ ( PROP_AXIS_HELPMARKS, C2U( "MinorTickmarks" ))
+ ( PROP_AXIS_ARRANGE_ORDER, C2U( "ArrangeOrder" ))
+ ( PROP_AXIS_TEXTBREAK, C2U( "TextBreak" ))
+ ( PROP_AXIS_CAN_OVERLAP, C2U( "TextOverlap" ))
+ // has to be converted
+ ( PROP_AXIS_NUMBERFORMAT, C2U( "NumberFormat" ))
+ );
+
+ return aMap;
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "Max" ),
+ PROP_AXIS_MAX,
+ ::getCppuType( reinterpret_cast< const double * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Min" ),
+ PROP_AXIS_MIN,
+ ::getCppuType( reinterpret_cast< const double * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Origin" ),
+ PROP_AXIS_ORIGIN,
+ ::getCppuType( reinterpret_cast< const double * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "StepMain" ),
+ PROP_AXIS_STEPMAIN,
+ ::getCppuType( reinterpret_cast< const double * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "StepHelp" ),
+ PROP_AXIS_STEPHELP,
+ ::getCppuType( reinterpret_cast< const double * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "AutoMax" ),
+ PROP_AXIS_AUTO_MAX,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "AutoMin" ),
+ PROP_AXIS_AUTO_MIN,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "AutoOrigin" ),
+ PROP_AXIS_AUTO_ORIGIN,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "AutoStepMain" ),
+ PROP_AXIS_AUTO_STEPMAIN,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "AutoStepHelp" ),
+ PROP_AXIS_AUTO_STEPHELP,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Logarithmic" ),
+ PROP_AXIS_LOGARITHMIC,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "DisplayLabels" ),
+ PROP_AXIS_DISPLAY_LABELS,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "TextRotation" ),
+ PROP_AXIS_TEXT_ROTATION,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Marks" ),
+ PROP_AXIS_MARKS,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "HelpMarks" ),
+ PROP_AXIS_HELPMARKS,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Overlap" ),
+ PROP_AXIS_OVERLAP,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "Gapwidth" ),
+ PROP_AXIS_GAP_WIDTH,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "ArrangeOrder" ),
+ PROP_AXIS_ARRANGE_ORDER,
+ ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "TextBreak" ),
+ PROP_AXIS_TEXTBREAK,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "TextCanOverlap" ),
+ PROP_AXIS_CAN_OVERLAP,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "NumberFormat" ),
+ PROP_AXIS_NUMBERFORMAT,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::LineProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+AxisWrapper::AxisWrapper(
+ eAxisType eType,
+ const uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram > & xDia,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex ) :
+ OPropertySet( _rMutex ),
+ m_rMutex( _rMutex ),
+ m_xContext( xContext ),
+ m_eType( eType ),
+ m_aEventListenerContainer( _rMutex ),
+ m_xDiagram( xDia )
+{
+ try
+ {
+ uno::Reference< chart2::XAxisContainer > xAxisCnt( m_xDiagram, uno::UNO_QUERY_THROW );
+ ::rtl::OUString aId;
+
+ switch( eType )
+ {
+ case X_AXIS:
+ aId = MeterHelper::makeAxisIdentifier( 0, 0 ); break;
+ case Y_AXIS:
+ aId = MeterHelper::makeAxisIdentifier( 1, 0 ); break;
+ case Z_AXIS:
+ aId = MeterHelper::makeAxisIdentifier( 2, 0 ); break;
+ case SECOND_X_AXIS:
+ aId = MeterHelper::makeAxisIdentifier( 0, 1 ); break;
+ case SECOND_Y_AXIS:
+ aId = MeterHelper::makeAxisIdentifier( 1, 1 ); break;
+ }
+
+ if( aId.getLength() > 0 )
+ m_xAxis = xAxisCnt->getAxisByIdentifier( aId );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ m_xAxisProperties.set( m_xAxis, uno::UNO_QUERY );
+ m_xAxisFastProperties.set( m_xAxis, uno::UNO_QUERY );
+}
+
+AxisWrapper::~AxisWrapper()
+{}
+
+::osl::Mutex & AxisWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XComponent ____
+void SAL_CALL AxisWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xDiagram = NULL;
+ m_xAxis = NULL;
+ m_xAxisProperties = NULL;
+ m_xAxisFastProperties = NULL;
+ // \--
+}
+
+void SAL_CALL AxisWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL AxisWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+sal_Bool SAL_CALL AxisWrapper::convertFastPropertyValue
+ ( uno::Any & rConvertedValue,
+ uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (lang::IllegalArgumentException)
+{
+ switch( nHandle )
+ {
+ case PROP_AXIS_TEXT_ROTATION:
+ {
+ // /--
+ MutexGuard aGuard( GetMutex());
+ if( m_xAxisProperties.is())
+ getFastPropertyValue( rOldValue, nHandle );
+
+ sal_Int32 nVal;
+ if( rValue >>= nVal )
+ {
+ double fDoubleDegrees = ( static_cast< double >( nVal ) / 100.0 );
+ rConvertedValue <<= fDoubleDegrees;
+ return sal_True;
+ }
+ break;
+ // \--
+ }
+
+ default:
+ return OPropertySet::convertFastPropertyValue(
+ rConvertedValue, rOldValue, nHandle, rValue );
+ }
+
+ return sal_False;
+}
+
+void SAL_CALL AxisWrapper::setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle, const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+
+ // try same handle for FastPropertySet. Caution! Works for global
+ // properties like FillProperties, LineProperties and CharacterProperties
+ if( nHandle > FAST_PROPERTY_ID_START )
+ {
+ if( m_xAxisFastProperties.is() )
+ m_xAxisFastProperties->setFastPropertyValue( nHandle, rValue );
+ }
+ else
+ {
+ switch( nHandle )
+ {
+ case PROP_AXIS_MAX:
+ case PROP_AXIS_MIN:
+ case PROP_AXIS_ORIGIN:
+ case PROP_AXIS_STEPMAIN:
+ case PROP_AXIS_STEPHELP:
+ case PROP_AXIS_AUTO_MAX:
+ case PROP_AXIS_AUTO_MIN:
+ case PROP_AXIS_AUTO_ORIGIN:
+ case PROP_AXIS_AUTO_STEPMAIN:
+ case PROP_AXIS_AUTO_STEPHELP:
+ case PROP_AXIS_LOGARITHMIC:
+ if( m_xAxis.is())
+ setFastMeterPropertyValue_NoBroadcast( nHandle, rValue );
+ break;
+
+ case PROP_AXIS_DISPLAY_LABELS:
+ case PROP_AXIS_TEXT_ROTATION:
+ case PROP_AXIS_MARKS:
+ case PROP_AXIS_HELPMARKS:
+ case PROP_AXIS_OVERLAP:
+ case PROP_AXIS_GAP_WIDTH:
+ case PROP_AXIS_ARRANGE_ORDER:
+ case PROP_AXIS_TEXTBREAK:
+ case PROP_AXIS_CAN_OVERLAP:
+ case PROP_AXIS_NUMBERFORMAT:
+ if( m_xAxisProperties.is())
+ {
+ lcl_PropertyMapType & rMap( lcl_GetPropertyMap());
+ lcl_PropertyMapType::const_iterator aIt( rMap.find( nHandle ));
+
+ if( aIt != rMap.end())
+ {
+ // found in map
+ m_xAxisProperties->setPropertyValue( (*aIt).second, rValue );
+ }
+ }
+ break;
+ }
+ }
+ // \--
+}
+
+void SAL_CALL AxisWrapper::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ if( ! m_xAxis.is())
+ return;
+
+ // try same handle for FastPropertySet. Caution! Works for global
+ // properties like FillProperties, LineProperties and CharacterProperties
+ if( nHandle > FAST_PROPERTY_ID_START )
+ {
+ if( m_xAxisFastProperties.is() )
+ rValue = m_xAxisFastProperties->getFastPropertyValue( nHandle );
+ }
+ else
+ {
+ switch( nHandle )
+ {
+ case PROP_AXIS_MAX:
+ case PROP_AXIS_MIN:
+ case PROP_AXIS_ORIGIN:
+ case PROP_AXIS_STEPMAIN:
+ case PROP_AXIS_STEPHELP:
+ case PROP_AXIS_AUTO_MAX:
+ case PROP_AXIS_AUTO_MIN:
+ case PROP_AXIS_AUTO_ORIGIN:
+ case PROP_AXIS_AUTO_STEPMAIN:
+ case PROP_AXIS_AUTO_STEPHELP:
+ case PROP_AXIS_LOGARITHMIC:
+ getFastMeterPropertyValue( rValue, nHandle );
+ break;
+
+ case PROP_AXIS_DISPLAY_LABELS:
+ case PROP_AXIS_MARKS:
+ case PROP_AXIS_HELPMARKS:
+ case PROP_AXIS_OVERLAP:
+ case PROP_AXIS_GAP_WIDTH:
+ case PROP_AXIS_ARRANGE_ORDER:
+ case PROP_AXIS_TEXTBREAK:
+ case PROP_AXIS_CAN_OVERLAP:
+ case PROP_AXIS_NUMBERFORMAT:
+ if( m_xAxisProperties.is())
+ {
+ lcl_PropertyMapType & rMap( lcl_GetPropertyMap());
+ lcl_PropertyMapType::const_iterator aIt( rMap.find( nHandle ));
+
+ if( aIt != rMap.end())
+ {
+ // found in map
+ rValue = m_xAxisProperties->getPropertyValue( (*aIt).second );
+ }
+ }
+ break;
+
+ case PROP_AXIS_TEXT_ROTATION:
+ if( m_xAxisProperties.is())
+ {
+ double fDoubleDegrees = 0.0;
+ uno::Any aAny( m_xAxisProperties->getPropertyValue( C2U("TextRotation") ));
+ if( aAny >>= fDoubleDegrees )
+ {
+ sal_Int32 nDeg = static_cast< sal_Int32 >(
+ ::rtl::math::round( fDoubleDegrees * 100.0 ));
+ rValue <<= nDeg;
+ }
+ }
+ break;
+ }
+ }
+ // \--
+}
+
+void AxisWrapper::setFastMeterPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle, const uno::Any& rValue )
+{
+ OSL_ASSERT( m_xAxis.is());
+
+ bool bSetScale = false;
+ bool bSetIncrement = false;
+ bool bSetOrigin = false;
+
+ uno::Reference< chart2::XBoundedCoordinateSystem > xCooSys( m_xAxis->getCoordinateSystem());
+ sal_Int32 nDim = m_xAxis->getRepresentedDimension();
+ uno::Reference< chart2::XIncrement > xInc( m_xAxis->getIncrement());
+ uno::Reference< chart2::XScale > xScale;
+ uno::Sequence< uno::Any > aOrigin;
+
+ chart2::ScaleData aScaleData;
+ chart2::IncrementData aIncData;
+
+ if( xInc.is())
+ aIncData = xInc->getIncrementData();
+
+ if( xCooSys.is())
+ {
+ xScale.set( xCooSys->getScaleByDimension( nDim ));
+ if( xScale.is())
+ aScaleData = xScale->getScaleData();
+ aOrigin = xCooSys->getOrigin();
+ }
+
+ sal_Bool bBool;
+ switch( nHandle )
+ {
+ case PROP_AXIS_MAX:
+ aScaleData.Maximum = rValue;
+ bSetScale = true;
+ break;
+ case PROP_AXIS_MIN:
+ aScaleData.Minimum = rValue;
+ bSetScale = true;
+ break;
+ case PROP_AXIS_STEPMAIN:
+ aIncData.Distance = rValue;
+ bSetIncrement = true;
+ break;
+ case PROP_AXIS_STEPHELP:
+ if( aIncData.Distance.hasValue())
+ {
+ // todo: evaluate PostEquidistant
+ uno::Sequence< chart2::SubIncrement > aSubIncs( xInc->getSubIncrements());
+ if( aSubIncs.getLength() == 0 )
+ aSubIncs.realloc( 1 );
+
+ double fStepMain, fStepHelp;
+ if( (rValue >>= fStepHelp) &&
+ (aIncData.Distance >>= fStepMain) &&
+ (fStepHelp != 0.0) )
+ {
+ // approximate interval count
+ sal_Int32 nIntervalCount = static_cast< sal_Int32 >
+ (fStepMain / fStepHelp);
+
+ aSubIncs[ 0 ].IntervalCount <<= nIntervalCount;
+ xInc->setSubIncrements( aSubIncs );
+ }
+ }
+ break;
+ case PROP_AXIS_AUTO_MAX:
+ if( (rValue >>= bBool ) &&
+ bBool )
+ aScaleData.Maximum = uno::Any();
+ else
+ // todo: get former auto-value from view
+ aScaleData.Maximum <<= (double)(10.0);
+ bSetScale = true;
+ break;
+ case PROP_AXIS_AUTO_MIN:
+ if( (rValue >>= bBool ) &&
+ bBool )
+ aScaleData.Minimum = uno::Any();
+ else
+ // todo: get former auto-value from view
+ aScaleData.Minimum <<= (double)(0.0);
+ bSetScale = true;
+ break;
+ case PROP_AXIS_AUTO_STEPMAIN:
+ if( (rValue >>= bBool ) &&
+ bBool )
+ aIncData.Distance = uno::Any();
+ else
+ // todo: get former auto-value from view
+ aIncData.Distance <<= (double)(1.0);
+ bSetIncrement = true;
+ break;
+ case PROP_AXIS_AUTO_STEPHELP:
+ {
+ uno::Sequence< chart2::SubIncrement > aSubIncs( xInc->getSubIncrements());
+ if( aSubIncs.getLength() == 0 )
+ aSubIncs.realloc( 1 );
+
+ if( (rValue >>= bBool ) &&
+ bBool )
+ aSubIncs[ 0 ].IntervalCount = uno::Any();
+ else
+ // todo: get former auto-value from view
+ aSubIncs[ 0 ].IntervalCount <<= (sal_Int32)(5);
+ xInc->setSubIncrements( aSubIncs );
+ break;
+ }
+
+ case PROP_AXIS_ORIGIN:
+ {
+ OSL_ASSERT( nDim < aOrigin.getLength());
+
+ if( nDim < aOrigin.getLength())
+ {
+ aOrigin[ nDim ] = rValue;
+ bSetOrigin = true;
+ }
+ break;
+ }
+ case PROP_AXIS_AUTO_ORIGIN:
+ {
+ OSL_ASSERT( nDim < aOrigin.getLength());
+
+ if( nDim < aOrigin.getLength() &&
+ ( rValue >>= bBool ) )
+ {
+ if( bBool )
+ aOrigin[ nDim ] = uno::Any();
+ else
+ // todo: get former auto-value from view
+ aOrigin[ nDim ] <<= (double)(0.0);
+ }
+ bSetOrigin = true;
+ break;
+ }
+ case PROP_AXIS_LOGARITHMIC:
+ if( rValue >>= bBool )
+ {
+ uno::Reference< lang::XServiceName > xServiceName( aScaleData.Scaling, uno::UNO_QUERY );
+ bool bWasLogarithm =
+ ( xServiceName.is() &&
+ (xServiceName->getServiceName()).equals(
+ C2U( "com.sun.star.chart2.LogarithmicScaling" )));
+
+ if( bBool != bWasLogarithm )
+ {
+ if( bBool )
+ aScaleData.Scaling = new LogarithmicScaling( 10.0 );
+ else
+ aScaleData.Scaling = new LinearScaling( 1.0, 0.0 );
+ bSetScale = true;
+ }
+ }
+ break;
+ }
+
+ if( bSetScale &&
+ xScale.is() )
+ xScale->setScaleData( aScaleData );
+ if( bSetIncrement &&
+ xInc.is() )
+ xInc->setIncrementData( aIncData );
+ if( bSetOrigin &&
+ xCooSys.is() )
+ xCooSys->setOrigin( aOrigin );
+}
+
+void AxisWrapper::getFastMeterPropertyValue
+ ( uno::Any & rValue,
+ sal_Int32 nHandle ) const
+{
+ OSL_ASSERT( m_xAxis.is());
+
+ uno::Reference< chart2::XBoundedCoordinateSystem > xCooSys( m_xAxis->getCoordinateSystem());
+ sal_Int32 nDim = m_xAxis->getRepresentedDimension();
+ uno::Reference< chart2::XIncrement > xInc( m_xAxis->getIncrement());
+ uno::Sequence< uno::Any > aOrigin;
+
+ chart2::ScaleData aScaleData;
+ chart2::IncrementData aIncData;
+
+ if( xInc.is())
+ aIncData = xInc->getIncrementData();
+
+ if( xCooSys.is())
+ {
+ uno::Reference< chart2::XScale > xScale( xCooSys->getScaleByDimension( nDim ));
+ if( xScale.is())
+ aScaleData = xScale->getScaleData();
+ aOrigin = xCooSys->getOrigin();
+ }
+
+ switch( nHandle )
+ {
+ case PROP_AXIS_MAX:
+ // todo: If value is auto, we need the explicit value from the view
+ rValue = aScaleData.Maximum;
+ break;
+ case PROP_AXIS_MIN:
+ // todo: If value is auto, we need the explicit value from the view
+ rValue = aScaleData.Minimum;
+ break;
+ case PROP_AXIS_STEPMAIN:
+ // todo: If value is auto, we need the explicit value from the view
+ rValue = aIncData.Distance;
+ break;
+ case PROP_AXIS_STEPHELP:
+ // todo: If value is auto, we need the explicit value from the view
+ if( aIncData.Distance.hasValue())
+ {
+ // todo: evaluate PostEquidistant
+ uno::Sequence< chart2::SubIncrement > aSubIncs( xInc->getSubIncrements());
+ if( aSubIncs.getLength() > 0 )
+ {
+ double fStepMain;
+ sal_Int32 nIntervalCount;
+ if( (aIncData.Distance >>= fStepMain) &&
+ (aSubIncs[ 0 ].IntervalCount >>= nIntervalCount) &&
+ nIntervalCount > 0 )
+ {
+ rValue <<= ( fStepMain / static_cast< double >( nIntervalCount ) );
+ }
+ }
+ }
+ break;
+ case PROP_AXIS_AUTO_MAX:
+ rValue <<= (sal_Bool)( ! aScaleData.Maximum.hasValue());
+ break;
+ case PROP_AXIS_AUTO_MIN:
+ rValue <<= (sal_Bool)( ! aScaleData.Minimum.hasValue());
+ break;
+ case PROP_AXIS_AUTO_STEPMAIN:
+ rValue <<= (sal_Bool)( ! aIncData.Distance.hasValue());
+ break;
+ case PROP_AXIS_AUTO_STEPHELP:
+ {
+ uno::Sequence< chart2::SubIncrement > aSubIncs( xInc->getSubIncrements());
+ if( aSubIncs.getLength() > 0 )
+ rValue <<= (sal_Bool)( ! aSubIncs[ 0 ].IntervalCount.hasValue() );
+ break;
+ }
+
+ case PROP_AXIS_ORIGIN:
+ OSL_ASSERT( nDim < aOrigin.getLength());
+ // todo: If value is auto, we need the explicit value from the view
+ rValue = aOrigin[ nDim ];
+ break;
+ case PROP_AXIS_AUTO_ORIGIN:
+ OSL_ASSERT( nDim < aOrigin.getLength());
+ rValue <<= (sal_Bool)( ! aOrigin[ nDim ].hasValue());
+ break;
+
+ case PROP_AXIS_LOGARITHMIC:
+ {
+ uno::Reference< lang::XServiceName > xServiceName( aScaleData.Scaling, uno::UNO_QUERY );
+ rValue <<= static_cast< sal_Bool >
+ ( xServiceName.is() &&
+ (xServiceName->getServiceName()).equals(
+ C2U( "com.sun.star.chart2.LogarithmicScaling" )));
+ break;
+ }
+ }
+}
+
+// --------------------------------------------------------------------------------
+
+// ____ OPropertySet ____
+uno::Any AxisWrapper::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ CharacterProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ LineProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL AxisWrapper::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ AxisWrapper::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
+uno::Sequence< ::rtl::OUString > AxisWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 3 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartAxis" );
+ aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 2 ] = C2U( "com.sun.star.style.CharacterProperties" );
+// aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
+// aServices[ 4 ] = C2U( "com.sun.star.drawing.LineProperties" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( AxisWrapper, lcl_aServiceName );
+
+// needed by MSC compiler
+using impl::AxisWrapper_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( AxisWrapper, AxisWrapper_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( AxisWrapper, AxisWrapper_Base, OPropertySet )
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
new file mode 100644
index 000000000000..c4f9da1bcb9a
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * $RCSfile: AxisWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_AXISWRAPPER_HXX
+#define CHART_AXISWRAPPER_HXX
+
+#include "OPropertySet.hxx"
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
+#include <cppuhelper/implbase2.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAM_HPP_
+#include <drafts/com/sun/star/chart2/XDiagram.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+
+namespace drafts {
+namespace com { namespace sun { namespace star {
+namespace chart2
+{
+ class XAxis;
+}
+}}}
+}
+
+namespace chart
+{
+namespace wrapper
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper2<
+ com::sun::star::lang::XComponent,
+ com::sun::star::lang::XServiceInfo >
+ AxisWrapper_Base;
+}
+
+class AxisWrapper :
+ public impl::AxisWrapper_Base,
+ public ::property::OPropertySet
+{
+public:
+ enum eAxisType
+ {
+ X_AXIS,
+ Y_AXIS,
+ Z_AXIS,
+ SECOND_X_AXIS,
+ SECOND_Y_AXIS
+ };
+
+ AxisWrapper( eAxisType eType,
+ const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram > & xDia,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex );
+ virtual ~AxisWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+ throw(::com::sun::star::beans::UnknownPropertyException);
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue
+ ( ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+ virtual void SAL_CALL getFastPropertyValue
+ ( ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const;
+
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ eAxisType m_eType;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram >
+ m_xDiagram;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XAxis >
+ m_xAxis;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xAxisProperties;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XFastPropertySet >
+ m_xAxisFastProperties;
+
+ /** precondition: m_xAxis.is(), mutex is locked
+ */
+ void getFastMeterPropertyValue( ::com::sun::star::uno::Any & rValue, sal_Int32 nHandle ) const;
+
+ /** precondition: m_xAxis.is(), mutex is locked
+ */
+ void setFastMeterPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue );
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_AXISWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
new file mode 100644
index 000000000000..b9a73f676997
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -0,0 +1,341 @@
+/*************************************************************************
+ *
+ * $RCSfile: ChartDataWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "ChartDataWrapper.hxx"
+#include "macros.hxx"
+#include "algohelper.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLED_HPP_
+#include <drafts/com/sun/star/chart2/XTitled.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XNUMERICALDATASEQUENCE_HPP_
+#include <drafts/com/sun/star/chart2/XNumericalDataSequence.hpp>
+#endif
+
+#include "CharacterProperties.hxx"
+#include "LineProperties.hxx"
+#include "FillProperties.hxx"
+
+#include <algorithm>
+
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+using ::osl::MutexGuard;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" ));
+
+void lcl_addValueSequence( uno::Reference< chart2::XDataSeriesTreeParent > xParent,
+ ::std::vector< uno::Reference< chart2::XDataSequence > > & rOutSeqVector )
+{
+ if( xParent.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren());
+ for( sal_Int32 i = 0; i < aChildren.getLength(); ++i )
+ {
+ uno::Reference< chart2::XDataSource > aSource( aChildren[ i ], uno::UNO_QUERY );
+ if( aSource.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSequence > > aSequences(
+ aSource->getDataSequences());
+ const sal_Int32 nLength = aSequences.getLength();
+ for( sal_Int32 j = 0; j < nLength; ++j )
+ {
+ uno::Reference< beans::XPropertySet > xProp( aSequences[ j ], uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ ::rtl::OUString aRole;
+ if( ( xProp->getPropertyValue( C2U( "Role" )) >>= aRole ) &&
+ aRole.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "values" )) )
+ {
+ rOutSeqVector.push_back( aSequences[ j ] );
+ }
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY );
+ if( xNewParent.is())
+ lcl_addValueSequence( xNewParent, rOutSeqVector );
+ }
+ }
+ }
+}
+
+struct lcl_DataSequenceToDoubleSeq : public ::std::unary_function<
+ uno::Sequence< double >,
+ uno::Reference< chart2::XDataSequence > >
+{
+ uno::Sequence< double > operator() ( const uno::Reference< chart2::XDataSequence > & xSeq )
+ {
+ uno::Reference< chart2::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
+ if( xNumSeq.is())
+ {
+ return xNumSeq->getNumericalData();
+ }
+ else
+ {
+ uno::Sequence< uno::Any > aValues = xSeq->getData();
+ uno::Sequence< double > aResult( aValues.getLength());
+ const sal_Int32 nLength = aValues.getLength();
+ for( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ if( ! ( aValues[ i ] >>= aResult[ i ]) )
+ {
+ ::rtl::math::setNan( & aResult[ i ] );
+ }
+ }
+ return aResult;
+ }
+ }
+};
+
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+ChartDataWrapper::ChartDataWrapper( const uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument > & xModel,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & rMutex ) :
+ m_rMutex( rMutex ),
+ m_xContext( xContext ),
+ m_xChartDoc( xModel ),
+ m_aEventListenerContainer( rMutex )
+{
+}
+
+ChartDataWrapper::~ChartDataWrapper()
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+}
+
+::osl::Mutex & ChartDataWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XChartDataArray ____
+uno::Sequence< uno::Sequence< double > > SAL_CALL ChartDataWrapper::getData()
+ throw (uno::RuntimeException)
+{
+ ::std::vector< uno::Reference< chart2::XDataSequence > > aSequences;
+
+ // get data from data series
+ if( m_xChartDoc.is())
+ {
+ uno::Reference< chart2::XDiagram > xDia(
+ m_xChartDoc->getDiagram() );
+ if( xDia.is())
+ {
+ uno::Reference< chart2::XDataSeriesTreeParent > xRoot( xDia->getTree());
+ lcl_addValueSequence( xRoot, aSequences );
+ }
+ }
+
+ uno::Sequence< uno::Sequence< double > > aDoubleSeq( aSequences.size() );
+
+ ::std::transform( aSequences.begin(), aSequences.end(),
+ aDoubleSeq.getArray(),
+ lcl_DataSequenceToDoubleSeq() );
+
+ return aDoubleSeq;
+}
+
+void SAL_CALL ChartDataWrapper::setData(
+ const uno::Sequence< uno::Sequence< double > >& aData )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+ return uno::Sequence< ::rtl::OUString >();
+}
+
+void SAL_CALL ChartDataWrapper::setRowDescriptions(
+ const uno::Sequence< ::rtl::OUString >& aRowDescriptions )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+}
+
+uno::Sequence<
+ ::rtl::OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+ return uno::Sequence< ::rtl::OUString >();
+}
+
+void SAL_CALL ChartDataWrapper::setColumnDescriptions(
+ const uno::Sequence< ::rtl::OUString >& aColumnDescriptions )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+}
+
+
+// ____ XChartData (base of XChartDataArray) ____
+void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener(
+ const uno::Reference<
+ ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( aListener );
+}
+
+void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener(
+ const uno::Reference<
+ ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+double SAL_CALL ChartDataWrapper::getNotANumber()
+ throw (uno::RuntimeException)
+{
+ double fNan;
+ ::rtl::math::setNan( & fNan );
+ return fNan;
+}
+
+sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber )
+ throw (uno::RuntimeException)
+{
+ return static_cast< sal_Bool >( ::rtl::math::isNan( nNumber ) );
+}
+
+// ____ XEventListener ____
+void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& Source )
+ throw (uno::RuntimeException)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xChartDoc = NULL;
+ // \--
+}
+
+// ::com::sun::star::chart::ChartDataChangeEvent aEvent;
+// aEvent.Type = chart::ChartDataChangeType_ALL;
+// aEvent.StartColumn = 0;
+// aEvent.EndColumn = 0;
+// aEvent.StartRow = 0;
+// aEvent.EndRow = 0;
+void ChartDataWrapper::fireChartDataChangeEvent(
+ ::com::sun::star::chart::ChartDataChangeEvent& aEvent )
+{
+ if( ! m_aEventListenerContainer.getLength() )
+ return;
+
+ uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this ));
+ OSL_ASSERT( xSrc.is());
+ if( xSrc.is() )
+ aEvent.Source = xSrc;
+
+ ::cppu::OInterfaceIteratorHelper aIter( m_aEventListenerContainer );
+
+ while( aIter.hasMoreElements() )
+ {
+ uno::Reference<
+ ::com::sun::star::chart::XChartDataChangeEventListener > xListener(
+ aIter.next(), uno::UNO_QUERY );
+ xListener->chartDataChanged( aEvent );
+ }
+}
+
+
+// --------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > ChartDataWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 2 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDataArray" );
+ aServices[ 1 ] = C2U( "com.sun.star.chart.ChartData" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( ChartDataWrapper, lcl_aServiceName );
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
new file mode 100644
index 000000000000..9604a6b1afb5
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * $RCSfile: ChartDataWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:35 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_CHARTDATAWRAPPER_HXX
+#define CHART_CHARTDATAWRAPPER_HXX
+
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CHART_XCHARTDATAARRAY_HPP_
+#include <com/sun/star/chart/XChartDataArray.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_
+#include <drafts/com/sun/star/chart2/XChartDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+
+namespace chart
+{
+namespace wrapper
+{
+
+class ChartDataWrapper : public
+ ::cppu::WeakImplHelper3<
+ com::sun::star::chart::XChartDataArray,
+ com::sun::star::lang::XServiceInfo,
+ com::sun::star::lang::XEventListener >
+{
+public:
+ ChartDataWrapper( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument > & xModel,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & rMutex );
+ virtual ~ChartDataWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+protected:
+ // ____ XChartDataArray ____
+ virtual ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ double > > SAL_CALL getData()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence<
+ double > >& aData )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence<
+ ::rtl::OUString > SAL_CALL getRowDescriptions()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString >& aRowDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence<
+ ::rtl::OUString > SAL_CALL getColumnDescriptions()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence<
+ ::rtl::OUString >& aColumnDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartData (base of XChartDataArray) ____
+ virtual void SAL_CALL addChartDataChangeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeChartDataChangeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getNotANumber()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isNotANumber( double nNumber )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XEventListener ____
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent );
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument >
+ m_xChartDoc;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_CHARTDATAWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
new file mode 100644
index 000000000000..a4788c6c8f03
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -0,0 +1,768 @@
+/*************************************************************************
+ *
+ * $RCSfile: ChartDocumentWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "ChartDocumentWrapper.hxx"
+#include "algohelper.hxx"
+#include "macros.hxx"
+#include "InlineContainer.hxx"
+#include "DataSeriesTreeHelper.hxx"
+
+#include "TitleWrapper.hxx"
+#include "ChartDataWrapper.hxx"
+#include "DiagramWrapper.hxx"
+#include "LegendWrapper.hxx"
+
+#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
+#include <com/sun/star/lang/DisposedException.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLED_HPP_
+#include <drafts/com/sun/star/chart2/XTitled.hpp>
+#endif
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+using namespace ::com::sun::star::chart;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+static const ::rtl::OUString lcl_aImplName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.ChartAPIWrapper" ));
+
+enum eServiceType
+{
+ SERVICE_NAME_AREA_DIAGRAM = 0,
+ SERVICE_NAME_BAR_DIAGRAM,
+ SERVICE_NAME_DONUT_DIAGRAM,
+ SERVICE_NAME_LINE_DIAGRAM,
+ SERVICE_NAME_NET_DIAGRAM,
+ SERVICE_NAME_PIE_DIAGRAM,
+ SERVICE_NAME_STOCK_DIAGRAM,
+ SERVICE_NAME_XY_DIAGRAM,
+
+ SERVICE_NAME_DASH_TABLE,
+ SERVICE_NAME_GARDIENT_TABLE,
+ SERVICE_NAME_HATCH_TABLE,
+ SERVICE_NAME_BITMAP_TABLE,
+ SERVICE_NAME_TRANSP_GRADIENT_TABLE,
+ SERVICE_NAME_MARKER_TABLE,
+
+ SERVICE_NAME_NAMESPACE_MAP,
+ SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER,
+ SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER
+};
+
+typedef ::std::map< ::rtl::OUString, enum eServiceType > tServiceNameMap;
+typedef ::comphelper::MakeMap< ::rtl::OUString, enum eServiceType > tMakeServiceNameMap;
+
+tServiceNameMap & lcl_getStaticServiceNameMap()
+{
+ static tServiceNameMap aServiceNameMap(
+ tMakeServiceNameMap
+ ( C2U( "com.sun.star.chart.AreaDiagram" ), SERVICE_NAME_AREA_DIAGRAM )
+ ( C2U( "com.sun.star.chart.BarDiagram" ), SERVICE_NAME_BAR_DIAGRAM )
+ ( C2U( "com.sun.star.chart.DonutDiagram" ), SERVICE_NAME_DONUT_DIAGRAM )
+ ( C2U( "com.sun.star.chart.LineDiagram" ), SERVICE_NAME_LINE_DIAGRAM )
+ ( C2U( "com.sun.star.chart.NetDiagram" ), SERVICE_NAME_NET_DIAGRAM )
+ ( C2U( "com.sun.star.chart.PieDiagram" ), SERVICE_NAME_PIE_DIAGRAM )
+ ( C2U( "com.sun.star.chart.StockDiagram" ), SERVICE_NAME_STOCK_DIAGRAM )
+ ( C2U( "com.sun.star.chart.XYDiagram" ), SERVICE_NAME_XY_DIAGRAM )
+
+ ( C2U( "com.sun.star.drawing.DashTable" ), SERVICE_NAME_DASH_TABLE )
+ ( C2U( "com.sun.star.drawing.GradientTable" ), SERVICE_NAME_GARDIENT_TABLE )
+ ( C2U( "com.sun.star.drawing.HatchTable" ), SERVICE_NAME_HATCH_TABLE )
+ ( C2U( "com.sun.star.drawing.BitmapTable" ), SERVICE_NAME_BITMAP_TABLE )
+ ( C2U( "com.sun.star.drawing.TransparencyGradientTable" ), SERVICE_NAME_TRANSP_GRADIENT_TABLE )
+ ( C2U( "com.sun.star.drawing.MarkerTable" ), SERVICE_NAME_MARKER_TABLE )
+
+ ( C2U( "com.sun.star.xml.NamespaceMap" ), SERVICE_NAME_NAMESPACE_MAP )
+ ( C2U( "com.sun.star.document.ExportGraphicObjectResolver" ), SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER )
+ ( C2U( "com.sun.star.document.ImportGraphicObjectResolver" ), SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER )
+ );
+
+ return aServiceNameMap;
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+namespace wrapper
+{
+
+ChartDocumentWrapper::ChartDocumentWrapper(
+ const Reference< uno::XComponentContext > & xContext ) :
+ m_xContext( xContext ),
+ m_bIsDisposed( false )
+{
+ // note: do not listen at m_xModel. This is the owner of the object and
+ // calls dispose() itself
+}
+
+ChartDocumentWrapper::~ChartDocumentWrapper()
+{
+ stopAllComponentListening();
+}
+
+::osl::Mutex & ChartDocumentWrapper::GetMutex() const
+{
+ return m_aMutex;
+}
+
+// ____ XInterface (for new interfaces) ____
+uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType )
+ throw (uno::RuntimeException)
+{
+ if( m_xDelegator.is())
+ return m_xDelegator->queryInterface( aType );
+ else
+ return queryAggregation( aType );
+}
+
+// ____ chart::XChartDocument (old API wrapper) ____
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xTitle.is() &&
+ m_xChartDoc.is())
+ {
+ try
+ {
+ uno::Reference< chart2::XTitled > xTitled( m_xChartDoc, uno::UNO_QUERY_THROW );
+ m_xTitle = new TitleWrapper( xTitled->getTitle(), m_xContext, GetMutex() );
+ Reference< lang::XComponent > xComp( m_xTitle, uno::UNO_QUERY_THROW );
+ startComponentListening( xComp );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xTitle;
+}
+
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xSubTitle.is() &&
+ m_xChartDoc.is() )
+ {
+ try
+ {
+ uno::Reference< chart2::XTitled > xTitled( m_xChartDoc->getDiagram(), uno::UNO_QUERY_THROW );
+ m_xSubTitle = new TitleWrapper( xTitled->getTitle(), m_xContext, GetMutex() );
+ Reference< lang::XComponent > xComp( m_xSubTitle, uno::UNO_QUERY_THROW );
+ startComponentListening( xComp );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xSubTitle;
+}
+
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getLegend()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xLegend.is())
+ {
+ m_xLegend = new LegendWrapper( m_xChartDoc, m_xContext, GetMutex() );
+ Reference< lang::XComponent > xComp( m_xLegend, uno::UNO_QUERY );
+ if( xComp.is())
+ startComponentListening( xComp );
+ }
+
+ return m_xLegend;
+}
+
+Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getArea()
+ throw (uno::RuntimeException)
+{
+ return m_xChartDoc->getPageBackground();
+}
+
+Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xDiagram.is() &&
+ m_xChartDoc.is() )
+ {
+ try
+ {
+ m_xDiagram = new DiagramWrapper(
+ m_xChartDoc->getDiagram(),
+ m_xContext, GetMutex() );
+ Reference< lang::XComponent > xComp( m_xDiagram, uno::UNO_QUERY );
+ startComponentListening( xComp );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xDiagram;
+}
+
+void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram )
+ throw (uno::RuntimeException)
+{
+ if( xDiagram.is() &&
+ xDiagram != m_xDiagram )
+ {
+ // set new wrapped diagram at new chart. This requires the old
+ // diagram given as parameter to implement the new interface. If
+ // this is not possible throw an exception
+ Reference< chart2::XDiagramProvider > xNewDiaProvider( xDiagram, uno::UNO_QUERY_THROW );
+ Reference< chart2::XDiagram > xNewDia( xNewDiaProvider->getDiagram());
+
+ try
+ {
+ // stop listening and dispose old diagram
+ if( m_xDiagram.is())
+ {
+ Reference< lang::XComponent > xComp( m_xDiagram, uno::UNO_QUERY_THROW );
+ stopComponentListening( xComp );
+ xComp->dispose();
+ }
+
+ // set the new diagram and start listening
+ m_xChartDoc->setDiagram( xNewDia );
+ m_xDiagram = xDiagram;
+ Reference< lang::XComponent > xComp( m_xDiagram, uno::UNO_QUERY_THROW );
+ startComponentListening( xComp );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+}
+
+Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xChartData.is())
+ {
+ m_xChartData = new ChartDataWrapper( m_xChartDoc, m_xContext, GetMutex());
+ }
+
+ return m_xChartData;
+}
+
+void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xData )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "not implemented" );
+}
+
+// ____ XModel ____
+sal_Bool SAL_CALL ChartDocumentWrapper::attachResource(
+ const ::rtl::OUString& URL,
+ const Sequence< beans::PropertyValue >& Arguments )
+ throw (uno::RuntimeException)
+{
+ return m_xModel->attachResource( URL, Arguments );
+}
+
+::rtl::OUString SAL_CALL ChartDocumentWrapper::getURL()
+ throw (uno::RuntimeException)
+{
+ return m_xModel->getURL();
+}
+
+Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs()
+ throw (uno::RuntimeException)
+{
+ return m_xModel->getArgs();
+}
+
+void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::XController >& Controller )
+ throw (uno::RuntimeException)
+{
+ m_xModel->connectController( Controller );
+}
+
+void SAL_CALL ChartDocumentWrapper::disconnectController(
+ const Reference< frame::XController >& Controller )
+ throw (uno::RuntimeException)
+{
+ m_xModel->disconnectController( Controller );
+}
+
+void SAL_CALL ChartDocumentWrapper::lockControllers()
+ throw (uno::RuntimeException)
+{
+ m_xModel->lockControllers();
+}
+
+void SAL_CALL ChartDocumentWrapper::unlockControllers()
+ throw (uno::RuntimeException)
+{
+ m_xModel->unlockControllers();
+}
+
+sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked()
+ throw (uno::RuntimeException)
+{
+ return m_xModel->hasControllersLocked();
+}
+
+Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController()
+ throw (uno::RuntimeException)
+{
+ return Reference< frame::XController >();
+}
+
+void SAL_CALL ChartDocumentWrapper::setCurrentController(
+ const Reference< frame::XController >& Controller )
+ throw (container::NoSuchElementException,
+ uno::RuntimeException)
+{
+ m_xModel->setCurrentController( Controller );
+}
+
+Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection()
+ throw (uno::RuntimeException)
+{
+ return m_xModel->getCurrentSelection();
+}
+
+
+// ____ XComponent ____
+void SAL_CALL ChartDocumentWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ if( m_bIsDisposed )
+ throw lang::DisposedException(
+ C2U("ChartDocumentWrapper is disposed" ),
+ static_cast< ::cppu::OWeakObject* >( this ));
+
+ m_bIsDisposed = true;
+
+ try
+ {
+ m_xModel->dispose();
+ }
+ catch( lang::DisposedException )
+ {
+ // this is ok, don't panic
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+
+ Reference< lang::XComponent > xComp;
+ if( m_xTitle.is())
+ {
+ try
+ {
+ xComp.set( m_xTitle, uno::UNO_QUERY );
+ if( xComp.is())
+ {
+ stopComponentListening( xComp );
+ xComp->dispose();
+ }
+ m_xTitle = NULL;
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ if( m_xSubTitle.is())
+ {
+ try
+ {
+ xComp.set( m_xSubTitle, uno::UNO_QUERY );
+ if( xComp.is())
+ {
+ stopComponentListening( xComp );
+ xComp->dispose();
+ }
+ m_xSubTitle = NULL;
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+ if( m_xDiagram.is())
+ {
+ try
+ {
+ xComp.set( m_xDiagram, uno::UNO_QUERY );
+ if( xComp.is())
+ {
+ stopComponentListening( xComp );
+ xComp->dispose();
+ }
+ m_xDiagram = NULL;
+ }
+ catch( uno::Exception &ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+}
+
+void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_xModel->addEventListener( xListener );
+}
+
+void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_xModel->removeEventListener( aListener );
+}
+
+
+// ____ XNumberFormatsSupplier ____
+uno::Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getNumberFormatSettings()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+ return uno::Reference< beans::XPropertySet >();
+}
+
+uno::Reference< util::XNumberFormats > SAL_CALL ChartDocumentWrapper::getNumberFormats()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+ return uno::Reference< util::XNumberFormats >();
+}
+
+
+// ____ XDrawPageSupplier ____
+uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+ return uno::Reference< drawing::XDrawPage >();
+}
+
+
+// ____ XMultiServiceFactory ____
+uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
+ const ::rtl::OUString& aServiceSpecifier )
+ throw (uno::Exception,
+ uno::RuntimeException)
+{
+ uno::Reference< uno::XInterface > xResult;
+ bool bServiceFound = false;
+ tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
+
+ tServiceNameMap::const_iterator aIt( rMap.find( aServiceSpecifier ));
+ if( aIt != rMap.end())
+ {
+ bool bCreateDiagram = false;
+ uno::Reference< lang::XMultiServiceFactory > xManagerFact(
+ m_xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate;
+
+ switch( (*aIt).second )
+ {
+ case SERVICE_NAME_AREA_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Area" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_BAR_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Bar" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_DONUT_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Ring" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_LINE_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Line" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_NET_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Net" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_PIE_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.Pie" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_STOCK_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.StockLowHighClose" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_XY_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance(
+ C2U( "com.sun.star.chart2.template.ScatterSymbol" )), uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+
+ case SERVICE_NAME_DASH_TABLE:
+// xDashTable = SvxUnoDashTable_createInstance( m_pModel );
+ break;
+ case SERVICE_NAME_GARDIENT_TABLE:
+// xGradientTable = SvxUnoGradientTable_createInstance( m_pModel );
+ break;
+ case SERVICE_NAME_HATCH_TABLE:
+// xHatchTable = SvxUnoHatchTable_createInstance( m_pModel );
+ break;
+ case SERVICE_NAME_BITMAP_TABLE:
+// xBitmapTable = SvxUnoBitmapTable_createInstance( m_pModel );
+ break;
+ case SERVICE_NAME_TRANSP_GRADIENT_TABLE:
+// xTransparencyGradientTable = SvxUnoTransGradientTable_createInstance( m_pModel );
+ break;
+ case SERVICE_NAME_MARKER_TABLE:
+// xMarkerTable = SvxUnoMarkerTable_createInstance( m_pModel );
+ break;
+
+ case SERVICE_NAME_NAMESPACE_MAP:
+// static sal_uInt16 aWhichIds[] = { SCHATTR_USER_DEFINED_ATTR, 0 };
+// xResult = svx::NamespaceMap_createInstance( aWhichIds, &m_pModel->GetPool() );
+ break;
+ case SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER:
+// xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE ));
+ break;
+ case SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER:
+// xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ ));
+ break;
+ }
+
+ if( bCreateDiagram && xTemplate.is() )
+ {
+ try
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq(
+ helper::DataSeriesTreeHelper::getDataSeriesFromDiagram(
+ m_xChartDoc->getDiagram() ));
+
+ uno::Reference< chart2::XDiagram > xDia(
+ xTemplate->createDiagram( aSeriesSeq ));
+ xResult = static_cast< ::cppu::OWeakObject* >(
+ new DiagramWrapper( xDia, m_xContext, GetMutex()));
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ bServiceFound = true;
+ }
+ else
+ {
+ // try to create a shape
+ try
+ {
+// xResult = SvxUnoDrawMSFactory::createInstance( aServiceSpecifier );
+ bServiceFound = true;
+ }
+ catch( const uno::Exception& aEx )
+ {
+ // couldn't create shape
+ }
+ }
+
+ // finally, try to create an addin
+ if( ! bServiceFound )
+ {
+// uno::Reference< util::XRefreshable > xAddIn = GetAddInCollection().GetAddInByName( aServiceSpecifier );
+// if( xAddIn.is())
+// {
+// xResult = xAddIn;
+ bServiceFound = true;
+// }
+ }
+
+ return xResult;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstanceWithArguments(
+ const ::rtl::OUString& ServiceSpecifier,
+ const uno::Sequence< uno::Any >& Arguments )
+ throw (uno::Exception,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( Arguments.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" );
+
+ return createInstance( ServiceSpecifier );
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames()
+ throw (uno::RuntimeException)
+{
+ tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
+ uno::Sequence< ::rtl::OUString > aResult( rMap.size());
+
+ ::std::transform( rMap.begin(), rMap.end(),
+ aResult.getArray(),
+ ::std::select1st< tServiceNameMap::value_type >() );
+
+ return aResult;
+
+// // shapes
+// // uno::Sequence< OUString > aDrawServices( SvxUnoDrawMSFactory::getAvailableServiceNames() );
+// // const OUString * pArr = aDrawServices.getConstArray();
+// // aServices.insert( aServices.end(), pArr, pArr + aDrawServices.getLength() );
+// }
+
+
+ // add-ins
+ // uno::Sequence< OUString > aAddIns( GetAddInCollection().GetAddInNames() );
+// pArr = aAddIns.getConstArray();
+// aServices.insert( aServices.end(), pArr, pArr + aAddIns.getLength() );
+
+// return helper::VectorToSequence( aServices );
+}
+
+// ____ XAggregation ____
+void SAL_CALL ChartDocumentWrapper::setDelegator(
+ const uno::Reference< uno::XInterface >& rDelegator )
+ throw (uno::RuntimeException)
+{
+ m_xDelegator = rDelegator;
+ m_xModel.set( m_xDelegator, uno::UNO_QUERY );
+ m_xChartDoc.set( m_xDelegator, uno::UNO_QUERY );
+}
+
+uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& aType )
+ throw (uno::RuntimeException)
+{
+ return impl::ChartDocumentWrapper_Base::queryInterface( aType );
+}
+
+// ____ ::utl::OEventListenerAdapter ____
+void ChartDocumentWrapper::_disposing( const lang::EventObject& _rSource )
+{
+ if( _rSource.Source == m_xTitle )
+ m_xTitle = NULL;
+ if( _rSource.Source == m_xSubTitle )
+ m_xSubTitle = NULL;
+ if( _rSource.Source == m_xDiagram )
+ m_xDiagram = NULL;
+}
+
+// ================================================================================
+
+uno::Sequence< ::rtl::OUString > ChartDocumentWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 4 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDocument" );
+ aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartDocumentWrapper" );
+ aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
+ return aServices;
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( ChartDocumentWrapper, lcl_aImplName );
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
new file mode 100644
index 000000000000..a5e01a9ba934
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -0,0 +1,479 @@
+/*************************************************************************
+ *
+ * $RCSfile: DataSeriesPointWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "DataSeriesPointWrapper.hxx"
+#include "macros.hxx"
+#include "InlineContainer.hxx"
+#include "algohelper.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_CHARTAXISASSIGN_HPP_
+#include <com/sun/star/chart/ChartAxisAssign.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_CHARTDATACAPTION_HPP_
+#include <com/sun/star/chart/ChartDataCaption.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_DATAPOINTLABEL_HPP_
+#include <drafts/com/sun/star/chart2/DataPointLabel.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_TRANSPARENCYSTYLE_HPP_
+#include <drafts/com/sun/star/chart2/TransparencyStyle.hpp>
+#endif
+
+#include "LineProperties.hxx"
+#include "FillProperties.hxx"
+#include "CharacterProperties.hxx"
+#include "UserDefinedProperties.hxx"
+
+#include <algorithm>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::property::OPropertySet;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.DataSeries" ));
+
+enum
+{
+ PROP_SERIES_ATTACHED_AXIS,
+ PROP_SERIES_DATA_CAPTION
+};
+
+typedef ::std::map< sal_Int32, ::rtl::OUString > lcl_PropertyMapType;
+typedef ::comphelper::MakeMap< sal_Int32, ::rtl::OUString > lcl_MakePropertyMapType;
+
+lcl_PropertyMapType & lcl_GetPropertyMapLine()
+{
+ static lcl_PropertyMapType aMap(
+ lcl_MakePropertyMapType
+ ( ::chart::LineProperties::PROP_LINE_TRANSPARENCE, C2U( "Transparency" ))
+ ( ::chart::LineProperties::PROP_LINE_COLOR, C2U( "Color" ))
+ ( ::chart::LineProperties::PROP_LINE_STYLE, C2U( "LineStyle" ))
+ );
+
+ return aMap;
+};
+
+lcl_PropertyMapType & lcl_GetPropertyMapFilled()
+{
+ static lcl_PropertyMapType aMap(
+ lcl_MakePropertyMapType
+ // Note: FillStyle has same name but must be mapped (ids differ)
+ ( ::chart::FillProperties::PROP_FILL_STYLE, C2U( "FillStyle" ))
+ ( ::chart::FillProperties::PROP_FILL_COLOR, C2U( "Color" ) )
+ ( ::chart::FillProperties::PROP_FILL_TRANSPARENCE, C2U( "Transparency" ))
+ ( ::chart::FillProperties::PROP_FILL_GRADIENT, C2U( "Gradient" ))
+ ( ::chart::FillProperties::PROP_FILL_HATCH, C2U( "Hatch" ))
+
+ ( ::chart::LineProperties::PROP_LINE_STYLE, C2U( "BorderStyle" ))
+ ( ::chart::LineProperties::PROP_LINE_COLOR, C2U( "BorderColor" ))
+ ( ::chart::LineProperties::PROP_LINE_WIDTH, C2U( "BorderWidth" ))
+ );
+
+ return aMap;
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "Axis" ),
+ PROP_SERIES_ATTACHED_AXIS,
+ ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+
+ rOutProperties.push_back(
+ Property( C2U( "DataCaption" ),
+ PROP_SERIES_DATA_CAPTION,
+ ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_SERIES_ATTACHED_AXIS ));
+ rOutMap[ PROP_SERIES_ATTACHED_AXIS ] =
+ uno::makeAny( sal_Int32( ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y ) );
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_SERIES_DATA_CAPTION ));
+ rOutMap[ PROP_SERIES_DATA_CAPTION ] =
+ uno::makeAny( sal_Int32( ::com::sun::star::chart::ChartDataCaption::NONE ) );
+}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LineProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::FillProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::CharacterProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+DataSeriesPointWrapper::DataSeriesPointWrapper(
+ eParentType eType,
+ const uno::Reference< beans::XPropertySet > & xParentProperties,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex ) :
+ OPropertySet( _rMutex ),
+ m_rMutex( _rMutex ),
+ m_xContext( xContext ),
+ m_aEventListenerContainer( _rMutex ),
+ m_eParentType( eType ),
+ m_xParentProperties( xParentProperties ),
+ m_xParentFastProperties( xParentProperties, uno::UNO_QUERY )
+{}
+
+DataSeriesPointWrapper::~DataSeriesPointWrapper()
+{}
+
+::osl::Mutex & DataSeriesPointWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XComponent ____
+void SAL_CALL DataSeriesPointWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xParentProperties = NULL;
+ m_xParentFastProperties = NULL;
+ // \--
+}
+
+void SAL_CALL DataSeriesPointWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL DataSeriesPointWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// ____ XEventListener ____
+void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& Source )
+ throw (uno::RuntimeException)
+{
+}
+
+
+sal_Bool SAL_CALL DataSeriesPointWrapper::convertFastPropertyValue
+ ( uno::Any & rConvertedValue,
+ uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (lang::IllegalArgumentException)
+{
+ getFastPropertyValue( rOldValue, nHandle );
+
+ switch( nHandle )
+ {
+ case PROP_SERIES_DATA_CAPTION:
+ {
+ sal_Int32 nCaptionStyle;
+ if( rValue >>= nCaptionStyle )
+ {
+ chart2::DataPointLabel aConvertedLabel;
+
+ if( nCaptionStyle & ::com::sun::star::chart::ChartDataCaption::VALUE )
+ aConvertedLabel.ShowNumber = true;
+ if( nCaptionStyle & ::com::sun::star::chart::ChartDataCaption::PERCENT )
+ aConvertedLabel.ShowNumberInPercent = true;
+ if( nCaptionStyle & ::com::sun::star::chart::ChartDataCaption::TEXT )
+ aConvertedLabel.ShowCategoryName = true;
+ if( nCaptionStyle & ::com::sun::star::chart::ChartDataCaption::SYMBOL )
+ aConvertedLabel.ShowLegendSymbol = true;
+
+ rConvertedValue <<= aConvertedLabel;
+ }
+ else
+ return sal_False;
+ }
+ break;
+
+ default:
+ rConvertedValue = rValue;
+ break;
+ }
+
+ return sal_True;
+}
+
+void SAL_CALL DataSeriesPointWrapper::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ if( ! m_xParentProperties.is())
+ return;
+
+ lcl_PropertyMapType & rMap( lcl_GetPropertyMapFilled());
+ lcl_PropertyMapType::const_iterator aIt( rMap.find( nHandle ));
+ if( aIt == rMap.end())
+ {
+ OPropertySet::getFastPropertyValue( rValue, nHandle );
+ }
+ else
+ {
+ rValue = m_xParentProperties->getPropertyValue( (*aIt).second );
+ }
+ // \--
+}
+
+void SAL_CALL DataSeriesPointWrapper::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ if( m_xParentProperties.is())
+ {
+ // /--
+ MutexGuard aGuard( GetMutex());
+
+ lcl_PropertyMapType & rMap( lcl_GetPropertyMapFilled());
+ lcl_PropertyMapType::const_iterator aIt( rMap.find( nHandle ));
+
+ if( aIt != rMap.end())
+ {
+ // found in map
+ m_xParentProperties->setPropertyValue( (*aIt).second, rValue );
+ }
+ else
+ {
+ // try same handle for FastPropertySet. Caution! Works for global
+ // properties like FillProperties, LineProperties and
+ // CharacterProperties
+ if( m_xParentFastProperties.is() && nHandle > FAST_PROPERTY_ID_START )
+ m_xParentFastProperties->setFastPropertyValue( nHandle, rValue );
+ else
+ {
+ // get name for property handle
+ try
+ {
+ ::rtl::OUString aPropName;
+ getInfoHelper().fillPropertyMembersByHandle( & aPropName, NULL, nHandle );
+ m_xParentProperties->setPropertyValue( aPropName, rValue );
+ }
+ catch( beans::UnknownPropertyException ex )
+ {
+ OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+ }
+ }
+
+ if( nHandle == FillProperties::PROP_FILL_TRANSPARENCE )
+ {
+ m_xParentProperties->setPropertyValue(
+ C2U( "TransparencyStyle" ),
+ uno::makeAny( chart2::TransparencyStyle_LINEAR ));
+ }
+ }
+ // \--
+ }
+ else
+ OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+}
+
+// --------------------------------------------------------------------------------
+
+// ____ OPropertySet ____
+uno::Any DataSeriesPointWrapper::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ LineProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ FillProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ CharacterProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL DataSeriesPointWrapper::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ DataSeriesPointWrapper::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
+uno::Sequence< ::rtl::OUString > DataSeriesPointWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 7 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDataRowProperties" );
+ aServices[ 1 ] = C2U( "com.sun.star.chart.ChartDataPointProperties" );
+ aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" );
+ aServices[ 4 ] = C2U( "com.sun.star.drawing.FillProperties" );
+ aServices[ 5 ] = C2U( "com.sun.star.drawing.LineProperties" );
+ aServices[ 6 ] = C2U( "com.sun.star.drawing.CharacterProperties" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( DataSeriesPointWrapper, lcl_aServiceName );
+
+// needed by MSC compiler
+using impl::DataSeriesPointWrapper_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( DataSeriesPointWrapper, DataSeriesPointWrapper_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataSeriesPointWrapper, DataSeriesPointWrapper_Base, OPropertySet )
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
new file mode 100644
index 000000000000..6bb4c4ec9b5f
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * $RCSfile: DataSeriesPointWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:36 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_DATASERIESPOINTWRAPPER_HXX
+#define CHART_DATASERIESPOINTWRAPPER_HXX
+
+#include "OPropertySet.hxx"
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
+#include <com/sun/star/lang/XEventListener.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDATASERIES_HPP_
+#include <drafts/com/sun/star/chart2/XDataSeries.hpp>
+#endif
+
+namespace chart
+{
+namespace wrapper
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper3<
+ com::sun::star::lang::XServiceInfo,
+ com::sun::star::lang::XComponent,
+ com::sun::star::lang::XEventListener >
+ DataSeriesPointWrapper_Base;
+}
+
+class DataSeriesPointWrapper :
+ public impl::DataSeriesPointWrapper_Base,
+ public ::property::OPropertySet
+{
+public:
+ enum eParentType
+ {
+ DATA_SERIES,
+ DATA_POINT
+ };
+
+ DataSeriesPointWrapper( eParentType eType,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & xParentProperties,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex );
+ virtual ~DataSeriesPointWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+ throw(::com::sun::star::beans::UnknownPropertyException);
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue
+ ( ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+
+ virtual void SAL_CALL getFastPropertyValue
+ ( ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const;
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XEventListener ____
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+
+ eParentType m_eParentType;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xParentProperties;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XFastPropertySet >
+ m_xParentFastProperties;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_DATASERIESPOINTWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
new file mode 100644
index 000000000000..4b10cfe9d28b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -0,0 +1,898 @@
+/*************************************************************************
+ *
+ * $RCSfile: DiagramWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "DiagramWrapper.hxx"
+#include "macros.hxx"
+#include "algohelper.hxx"
+#include "TitleWrapper.hxx"
+#include "DataSeriesPointWrapper.hxx"
+#include "AxisWrapper.hxx"
+#include "MeterHelper.hxx"
+#include "DataSeriesTreeHelper.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLED_HPP_
+#include <drafts/com/sun/star/chart2/XTitled.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPEGROUP_HPP_
+#include <drafts/com/sun/star/chart2/XChartTypeGroup.hpp>
+#endif
+
+#include "LineProperties.hxx"
+#include "FillProperties.hxx"
+#include "UserDefinedProperties.hxx"
+
+#include <algorithm>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::property::OPropertySet;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Diagram" ));
+
+enum
+{
+ PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS,
+ PROP_DIAGRAM_PERCENT_STACKED,
+ PROP_DIAGRAM_STACKED,
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "AttributedDataPoints" ),
+ PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS,
+ ::getCppuType( reinterpret_cast< const uno::Sequence< uno::Sequence< sal_Int32 > > * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ // see com.sun.star.chart.StackableDiagram
+ rOutProperties.push_back(
+ Property( C2U( "Percent" ),
+ PROP_DIAGRAM_PERCENT_STACKED,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+ rOutProperties.push_back(
+ Property( C2U( "Stacked" ),
+ PROP_DIAGRAM_STACKED,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_DIAGRAM_PERCENT_STACKED ));
+ rOutMap[ PROP_DIAGRAM_PERCENT_STACKED ] =
+ uno::makeAny( sal_False );
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_DIAGRAM_STACKED ));
+ rOutMap[ PROP_DIAGRAM_STACKED ] =
+ uno::makeAny( sal_False );
+}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LineProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::FillProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+void lcl_getDataSeriesByIndex(
+ uno::Reference< chart2::XDataSeriesTreeParent > xParent,
+ uno::Reference< chart2::XDataSeries > & rOutSeries,
+ sal_Int32 nIndex,
+ sal_Int32 nCurrentIndex = 0 )
+{
+ if( xParent.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren());
+ for( sal_Int32 i = 0; i < aChildren.getLength(); ++i )
+ {
+ uno::Reference< chart2::XDataSeries > aDataSeries( aChildren[ i ], uno::UNO_QUERY );
+ if( aDataSeries.is())
+ {
+ if( nCurrentIndex == nIndex )
+ {
+ rOutSeries = aDataSeries;
+ return;
+ }
+
+ ++nCurrentIndex;
+ }
+ else
+ {
+ uno::Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY );
+ if( xNewParent.is())
+ lcl_getDataSeriesByIndex( xNewParent, rOutSeries, nIndex, nCurrentIndex );
+ }
+ }
+ }
+}
+
+void lcl_addDataSeries(
+ uno::Reference< chart2::XDataSeriesTreeParent > xParent,
+ ::std::vector< uno::Reference< chart2::XDataSeries > > & rOutSeriesVec )
+{
+ if( xParent.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren());
+ for( sal_Int32 i = 0; i < aChildren.getLength(); ++i )
+ {
+ uno::Reference< chart2::XDataSeries > aDataSeries( aChildren[ i ], uno::UNO_QUERY );
+ if( aDataSeries.is())
+ {
+ rOutSeriesVec.push_back( aDataSeries );
+ }
+ else
+ {
+ uno::Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY );
+ if( xNewParent.is())
+ lcl_addDataSeries( xNewParent, rOutSeriesVec );
+ }
+ }
+ }
+}
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+DiagramWrapper::DiagramWrapper(
+ const uno::Reference< chart2::XDiagram > & xDia,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex ) :
+ OPropertySet( _rMutex ),
+ m_rMutex( _rMutex ),
+ m_xContext( xContext ),
+ m_aEventListenerContainer( _rMutex ),
+ m_xDiagram( xDia )
+{}
+
+DiagramWrapper::~DiagramWrapper()
+{}
+
+::osl::Mutex & DiagramWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XDiagram ____
+::rtl::OUString SAL_CALL DiagramWrapper::getDiagramType()
+ throw (uno::RuntimeException)
+{
+ ::rtl::OUString aTypeName;
+
+ if( ! m_xDiagram.is())
+ return aTypeName;
+
+ // find first element in tree (must be a ChartTypeGroup) and take its type
+ uno::Reference< chart2::XDataSeriesTreeParent > xParent( m_xDiagram->getTree());
+ if( xParent.is())
+ {
+ uno::Sequence< uno::Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren());
+ if( aChildren.getLength() > 0 )
+ {
+ uno::Reference< chart2::XChartTypeGroup > xGroup( aChildren[ 0 ], uno::UNO_QUERY );
+ if( xGroup.is())
+ {
+ uno::Reference< chart2::XChartType > xType( xGroup->getChartType() );
+ if( xType.is())
+ {
+ aTypeName = xType->getChartType();
+ }
+ }
+ }
+ }
+
+ // ToDo: Necessary? New chart could use old strings, API users
+ // (e.g. xmloff) have to deal with new types?
+
+ // ToDo: If necessary, use a map
+
+ // convert new names to old ones
+ if( aTypeName.getLength() > 0 )
+ {
+ if( aTypeName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.BarChart" )))
+ aTypeName = C2U( "com.sun.star.chart.BarDiagram" );
+ if( aTypeName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.AreaChart" )))
+ aTypeName = C2U( "com.sun.star.chart.AreaDiagram" );
+ if( aTypeName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart2.PieChart" )))
+ aTypeName = C2U( "com.sun.star.chart.PieDiagram" );
+ }
+
+ return aTypeName;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow )
+ throw (lang::IndexOutOfBoundsException,
+ uno::RuntimeException)
+{
+ uno::Reference< chart2::XDataSeries > xSeries;
+
+ if( nRow >= 0 )
+ lcl_getDataSeriesByIndex( m_xDiagram->getTree(), xSeries, nRow );
+
+ if( ! xSeries.is() )
+ throw lang::IndexOutOfBoundsException(
+ C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this ));
+
+ return new DataSeriesPointWrapper(
+ DataSeriesPointWrapper::DATA_SERIES,
+ uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ),
+ m_xContext, GetMutex() );
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow )
+ throw (lang::IndexOutOfBoundsException,
+ uno::RuntimeException)
+{
+ uno::Reference< chart2::XDataSeries > xSeries;
+
+ if( nRow >= 0 )
+ lcl_getDataSeriesByIndex( m_xDiagram->getTree(), xSeries, nRow );
+
+ if( ! xSeries.is() )
+ throw lang::IndexOutOfBoundsException(
+ C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this ));
+
+ // may throw an IllegalArgumentException
+ uno::Reference< beans::XPropertySet > xPointProp(
+ xSeries->getDataPointByIndex( nCol ));
+
+ return new DataSeriesPointWrapper(
+ DataSeriesPointWrapper::DATA_POINT, xPointProp, m_xContext, GetMutex() );
+}
+
+// ____ XShape (base of XDiagram) ____
+awt::Point SAL_CALL DiagramWrapper::getPosition()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+awt::Size SAL_CALL DiagramWrapper::getSize()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize )
+ throw (beans::PropertyVetoException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+::rtl::OUString SAL_CALL DiagramWrapper::getShapeType()
+ throw (uno::RuntimeException)
+{
+ return C2U( "com.sun.star.chart.Diagram" );
+}
+
+// ____ XAxisZSupplier ____
+uno::Reference<
+ drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xZAxisTitle.is())
+ {
+ try
+ {
+ uno::Reference< chart2::XAxisContainer > xAxisCnt( m_xDiagram, uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::XTitled > xAxisTitled(
+ xAxisCnt->getAxisByIdentifier( MeterHelper::makeAxisIdentifier( 2, 0 ) ),
+ uno::UNO_QUERY_THROW );
+ m_xZAxisTitle = new TitleWrapper( xAxisTitled->getTitle(), m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xZAxisTitle, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xZAxisTitle;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+
+// ____ XTwoAxisXSupplier ____
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xSecondXAxis.is())
+ {
+ m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_xDiagram, m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xSecondXAxis, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+
+ return m_xSecondXAxis;
+}
+
+
+// ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
+uno::Reference<
+ drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xXAxisTitle.is())
+ {
+ try
+ {
+ uno::Reference< chart2::XAxisContainer > xAxisCnt( m_xDiagram, uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::XTitled > xAxisTitled(
+ xAxisCnt->getAxisByIdentifier( MeterHelper::makeAxisIdentifier( 0, 0 ) ),
+ uno::UNO_QUERY_THROW );
+ m_xXAxisTitle = new TitleWrapper( xAxisTitled->getTitle(), m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xXAxisTitle, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xXAxisTitle;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xXAxis.is())
+ {
+ m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_xDiagram, m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xXAxis, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+
+ return m_xXAxis;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+
+// ____ XTwoAxisYSupplier ____
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xSecondYAxis.is())
+ {
+ m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_xDiagram, m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xSecondYAxis, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+
+ return m_xSecondYAxis;
+}
+
+
+// ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
+uno::Reference<
+ drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xYAxisTitle.is())
+ {
+ try
+ {
+ uno::Reference< chart2::XAxisContainer > xAxisCnt( m_xDiagram, uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::XTitled > xAxisTitled(
+ xAxisCnt->getAxisByIdentifier( MeterHelper::makeAxisIdentifier( 1, 0 ) ),
+ uno::UNO_QUERY_THROW );
+ m_xYAxisTitle = new TitleWrapper( xAxisTitled->getTitle(), m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xYAxisTitle, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
+
+ return m_xYAxisTitle;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis()
+ throw (uno::RuntimeException)
+{
+ if( ! m_xYAxis.is())
+ {
+ m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_xDiagram, m_xContext, GetMutex() );
+ uno::Reference< lang::XComponent > xComp( m_xYAxis, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->addEventListener( this );
+ }
+
+ return m_xYAxis;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+
+// ____ XStatisticDisplay ____
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getUpBar()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDownBar()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getMinMaxLine()
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not implemented yet!" );
+ throw uno::RuntimeException();
+}
+
+// ____ X3DDisplay ____
+uno::Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getWall()
+ throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > aResult;
+
+ if( m_xDiagram.is())
+ aResult.set( m_xDiagram->getWall() );
+
+ return aResult;
+}
+
+uno::Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getFloor()
+ throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > aResult;
+
+ if( m_xDiagram.is())
+ aResult.set( m_xDiagram->getFloor() );
+
+ throw uno::RuntimeException();
+}
+
+// ____ XComponent ____
+void SAL_CALL DiagramWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xDiagram = NULL;
+ m_xXAxisTitle = NULL;
+ m_xYAxisTitle = NULL;
+ m_xZAxisTitle = NULL;
+ m_xXAxis = NULL;
+ m_xYAxis = NULL;
+ m_xZAxis = NULL;
+ m_xSecondXAxis = NULL;
+ m_xSecondYAxis = NULL;
+ // \--
+}
+
+void SAL_CALL DiagramWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL DiagramWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// ____ XEventListener ____
+void SAL_CALL DiagramWrapper::disposing( const lang::EventObject& Source )
+ throw (uno::RuntimeException)
+{
+}
+
+
+// sal_Bool SAL_CALL DiagramWrapper::convertFastPropertyValue
+// ( uno::Any & rConvertedValue,
+// uno::Any & rOldValue,
+// sal_Int32 nHandle,
+// const uno::Any& rValue )
+// throw (lang::IllegalArgumentException)
+// {
+// }
+
+void SAL_CALL DiagramWrapper::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ uno::Reference< beans::XPropertySet > xDiaProp( m_xDiagram, uno::UNO_QUERY );
+
+ switch( nHandle )
+ {
+ case PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS:
+ if( m_xDiagram.is() &&
+ xDiaProp.is())
+ {
+ ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVec;
+ lcl_addDataSeries( m_xDiagram->getTree(), aSeriesVec );
+ uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVec.size() );
+
+ ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt =
+ aSeriesVec.begin();
+ sal_Int32 i = 0;
+ for( ; aIt != aSeriesVec.end(); ++aIt, ++i )
+ {
+ uno::Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ uno::Any aVal(
+ xProp->getPropertyValue( C2U( "AttributedDataPoints" )));
+ uno::Sequence< sal_Int32 > aSeq;
+ if( aVal >>= aSeq )
+ aResult[ i ] = aSeq;
+ }
+ }
+ rValue <<= aResult;
+ }
+ break;
+
+ case PROP_DIAGRAM_PERCENT_STACKED:
+ {
+ sal_Bool bIsStacked = (
+ helper::DataSeriesTreeHelper::getStackMode(
+ m_xDiagram->getTree()) == chart2::StackMode_STACKED_PERCENT);
+ rValue <<= bIsStacked;
+ }
+ break;
+
+ case PROP_DIAGRAM_STACKED:
+ {
+ sal_Bool bIsStacked = (
+ helper::DataSeriesTreeHelper::getStackMode(
+ m_xDiagram->getTree()) == chart2::StackMode_STACKED);
+ rValue <<= bIsStacked;
+ }
+ break;
+
+ default:
+ OPropertySet::getFastPropertyValue( rValue, nHandle );
+ break;
+ }
+ // \--
+}
+
+void SAL_CALL DiagramWrapper::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ sal_Bool bValue;
+ switch( nHandle )
+ {
+ case PROP_DIAGRAM_PERCENT_STACKED:
+ if( rValue >>= bValue )
+ {
+ helper::DataSeriesTreeHelper::setStackMode(
+ m_xDiagram->getTree(),
+ bValue
+ ? chart2::StackMode_STACKED_PERCENT
+ : chart2::StackMode_NONE );
+ }
+ break;
+
+ case PROP_DIAGRAM_STACKED:
+ if( rValue >>= bValue )
+ {
+ helper::DataSeriesTreeHelper::setStackMode(
+ m_xDiagram->getTree(),
+ bValue
+ ? chart2::StackMode_STACKED
+ : chart2::StackMode_NONE );
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// ____ XDiagramProvider ____
+uno::Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram()
+ throw (uno::RuntimeException)
+{
+ return m_xDiagram;
+}
+
+void SAL_CALL DiagramWrapper::setDiagram(
+ const uno::Reference< chart2::XDiagram >& xDiagram )
+ throw (uno::RuntimeException)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xDiagram = xDiagram;
+
+ // invalidate all children using the old diagram
+ m_xXAxisTitle = NULL;
+ m_xYAxisTitle = NULL;
+ m_xZAxisTitle = NULL;
+ m_xXAxis = NULL;
+ m_xYAxis = NULL;
+ m_xZAxis = NULL;
+ m_xSecondXAxis = NULL;
+ m_xSecondYAxis = NULL;
+ // \--
+}
+
+// --------------------------------------------------------------------------------
+
+// ____ OPropertySet ____
+uno::Any DiagramWrapper::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ LineProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ FillProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL DiagramWrapper::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ DiagramWrapper::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
+uno::Sequence< ::rtl::OUString > DiagramWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 3 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.Diagram" );
+ aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 2 ] = C2U( "com.sun.star.chart.StackableDiagram" );
+// aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" );
+// aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" );
+// aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( DiagramWrapper, lcl_aServiceName );
+
+// needed by MSC compiler
+using impl::DiagramWrapper_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( DiagramWrapper, DiagramWrapper_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( DiagramWrapper, DiagramWrapper_Base, OPropertySet )
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
new file mode 100644
index 000000000000..390c4db05a70
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * $RCSfile: DiagramWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_DIAGRAMWRAPPER_HXX
+#define CHART_DIAGRAMWRAPPER_HXX
+
+#include "OPropertySet.hxx"
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE10_HXX_
+#include <cppuhelper/implbase10.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CHART_XDIAGRAM_HPP_
+#include <com/sun/star/chart/XDiagram.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_XAXISZSUPPLIER_HPP_
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_XTWOAXISXSUPPLIER_HPP_
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_XTWOAXISYSUPPLIER_HPP_
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_XSTATISTICDISPLAY_HPP_
+#include <com/sun/star/chart/XStatisticDisplay.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_X3DDISPLAY_HPP_
+#include <com/sun/star/chart/X3DDisplay.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
+#include <com/sun/star/lang/XEventListener.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAM_HPP_
+#include <drafts/com/sun/star/chart2/XDiagram.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XDIAGRAMPROVIDER_HPP_
+#include <drafts/com/sun/star/chart2/XDiagramProvider.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPETEMPLATE_HPP_
+#include <drafts/com/sun/star/chart2/XChartTypeTemplate.hpp>
+#endif
+
+namespace drafts {
+namespace com { namespace sun { namespace star {
+namespace chart2
+{
+ class XTitle;
+}
+}}}
+}
+
+namespace chart
+{
+namespace wrapper
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper10<
+ ::com::sun::star::chart::XDiagram,
+ ::com::sun::star::chart::XAxisZSupplier,
+ ::com::sun::star::chart::XTwoAxisXSupplier, // : XAxisXSupplier
+ ::com::sun::star::chart::XTwoAxisYSupplier, // : XAxisYSupplier
+ ::com::sun::star::chart::XStatisticDisplay,
+ ::com::sun::star::chart::X3DDisplay,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XComponent,
+ ::com::sun::star::lang::XEventListener,
+ ::drafts::com::sun::star::chart2::XDiagramProvider >
+ DiagramWrapper_Base;
+}
+
+class DiagramWrapper :
+ public impl::DiagramWrapper_Base,
+ public ::property::OPropertySet
+{
+public:
+
+ DiagramWrapper( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram > & xDia,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex );
+ virtual ~DiagramWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+ throw(::com::sun::star::beans::UnknownPropertyException);
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+// virtual sal_Bool SAL_CALL convertFastPropertyValue
+// ( ::com::sun::star::uno::Any & rConvertedValue,
+// ::com::sun::star::uno::Any & rOldValue,
+// sal_Int32 nHandle,
+// const ::com::sun::star::uno::Any& rValue )
+// throw (::com::sun::star::lang::IllegalArgumentException);
+
+ virtual void SAL_CALL getFastPropertyValue
+ ( ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const;
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XDiagram ____
+ virtual ::rtl::OUString SAL_CALL getDiagramType()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getDataRowProperties( sal_Int32 nRow )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ____ XShape (base of XDiagram) ____
+ virtual ::com::sun::star::awt::Point SAL_CALL getPosition()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize )
+ throw (::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual ::rtl::OUString SAL_CALL getShapeType()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XAxisZSupplier ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape > SAL_CALL getZAxisTitle()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getZMainGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getZHelpGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getZAxis()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XTwoAxisXSupplier ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryXAxis()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape > SAL_CALL getXAxisTitle()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getXAxis()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getXMainGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getXHelpGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XTwoAxisYSupplier ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryYAxis()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape > SAL_CALL getYAxisTitle()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getYAxis()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getYHelpGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getYMainGrid()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XStatisticDisplay ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getUpBar()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getDownBar()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getMinMaxLine()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ X3DDisplay ____
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getWall()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > SAL_CALL getFloor()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XEventListener ____
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XDiagramProvider ____
+ virtual ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram > SAL_CALL getDiagram()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram >& xDiagram )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XDiagram >
+ m_xDiagram;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape >
+ m_xXAxisTitle;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape >
+ m_xYAxisTitle;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape >
+ m_xZAxisTitle;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xXAxis;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xYAxis;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xZAxis;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xSecondXAxis;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xSecondYAxis;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_DIAGRAMWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
new file mode 100644
index 000000000000..c6c0e916755a
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
@@ -0,0 +1,512 @@
+/*************************************************************************
+ *
+ * $RCSfile: LegendWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "LegendWrapper.hxx"
+#include "macros.hxx"
+#include "InlineContainer.hxx"
+#include "algohelper.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLED_HPP_
+#include <drafts/com/sun/star/chart2/XTitled.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CHART_CHARTLEGENDPOSITION_HPP_
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_LEGENDPOSITION_HPP_
+#include <drafts/com/sun/star/chart2/LegendPosition.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_LEGENDEXPANSION_HPP_
+#include <drafts/com/sun/star/chart2/LegendExpansion.hpp>
+#endif
+
+#include "CharacterProperties.hxx"
+#include "LineProperties.hxx"
+#include "FillProperties.hxx"
+#include "UserDefinedProperties.hxx"
+
+#include <algorithm>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::property::OPropertySet;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" ));
+
+enum
+{
+ PROP_LEGEND_ALIGNMENT
+};
+
+typedef ::std::map< sal_Int32, ::rtl::OUString > lcl_PropertyMapType;
+typedef ::comphelper::MakeMap< sal_Int32, ::rtl::OUString > lcl_MakePropertyMapType;
+
+lcl_PropertyMapType & lcl_GetPropertyMap()
+{
+ static lcl_PropertyMapType aMap(
+ lcl_MakePropertyMapType
+ ( PROP_LEGEND_ALIGNMENT, C2U( "Alignment" ))
+ );
+
+ return aMap;
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "Alignment" ),
+ PROP_LEGEND_ALIGNMENT,
+ ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendPosition * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_LEGEND_ALIGNMENT ));
+ rOutMap[ PROP_LEGEND_ALIGNMENT ] =
+ uno::makeAny( ::com::sun::star::chart::ChartLegendPosition_RIGHT );
+}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::LineProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::FillProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+LegendWrapper::LegendWrapper(
+ const uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument > & xModel,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex ) :
+ OPropertySet( _rMutex ),
+ m_rMutex( _rMutex ),
+ m_xContext( xContext ),
+ m_aEventListenerContainer( _rMutex ),
+ m_xChartDoc( xModel )
+{
+ if( m_xChartDoc.is())
+ {
+ uno::Reference< chart2::XDiagram > xDia( m_xChartDoc->getDiagram());
+ if( xDia.is())
+ m_xLegend.set( xDia->getLegend());
+ }
+
+ m_xLegendProp.set( m_xLegend, uno::UNO_QUERY );
+ m_xLegendFastProp.set( m_xLegend, uno::UNO_QUERY );
+}
+
+LegendWrapper::~LegendWrapper()
+{}
+
+::osl::Mutex & LegendWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XShape ____
+awt::Point SAL_CALL LegendWrapper::getPosition()
+ throw (uno::RuntimeException)
+{
+ return awt::Point( 0, 0 );
+}
+
+void SAL_CALL LegendWrapper::setPosition( const awt::Point& aPosition )
+ throw (uno::RuntimeException)
+{
+}
+
+awt::Size SAL_CALL LegendWrapper::getSize()
+ throw (uno::RuntimeException)
+{
+ return awt::Size( 0, 0 );
+}
+
+void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize )
+ throw (beans::PropertyVetoException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "trying to set size of title" );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+::rtl::OUString SAL_CALL LegendWrapper::getShapeType()
+ throw (uno::RuntimeException)
+{
+ return C2U( "com.sun.star.chart.ChartLegend" );
+}
+
+// ____ XComponent ____
+void SAL_CALL LegendWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xChartDoc = NULL;
+ m_xLegend = NULL;
+ m_xLegendProp = NULL;
+ m_xLegendFastProp = NULL;
+ // \--
+}
+
+void SAL_CALL LegendWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL LegendWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+sal_Bool SAL_CALL LegendWrapper::convertFastPropertyValue
+ ( uno::Any & rConvertedValue,
+ uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (lang::IllegalArgumentException)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ switch( nHandle )
+ {
+ case PROP_LEGEND_ALIGNMENT:
+ {
+ getFastPropertyValue( rOldValue, nHandle );
+
+ ::com::sun::star::chart::ChartLegendPosition ePos;
+ chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END;
+
+ if( rValue >>= ePos )
+ {
+ switch( ePos )
+ {
+ case ::com::sun::star::chart::ChartLegendPosition_LEFT:
+ eNewPos = chart2::LegendPosition_LINE_START;
+ break;
+ case ::com::sun::star::chart::ChartLegendPosition_RIGHT:
+ eNewPos = chart2::LegendPosition_LINE_END;
+ break;
+ case ::com::sun::star::chart::ChartLegendPosition_TOP:
+ eNewPos = chart2::LegendPosition_PAGE_START;
+ break;
+ case ::com::sun::star::chart::ChartLegendPosition_BOTTOM:
+ eNewPos = chart2::LegendPosition_PAGE_END;
+ break;
+
+ default: // NONE
+ break;
+ }
+ rConvertedValue <<= eNewPos;
+ return sal_True;
+ }
+ break;
+ }
+
+ default:
+ return OPropertySet::convertFastPropertyValue(
+ rConvertedValue, rOldValue, nHandle, rValue );
+ }
+
+ rConvertedValue = rValue;
+
+ return sal_True;
+ // \--
+}
+
+void SAL_CALL LegendWrapper::setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+
+ // try same handle for FastPropertySet. Caution! Works for global
+ // properties like FillProperties, LineProperties and CharacterProperties
+ if( nHandle > FAST_PROPERTY_ID_START )
+ {
+ if( m_xLegendFastProp.is() )
+ m_xLegendFastProp->setFastPropertyValue( nHandle, rValue );
+ }
+ else
+ {
+ switch( nHandle )
+ {
+ case PROP_LEGEND_ALIGNMENT:
+ m_xLegendProp->setPropertyValue( C2U( "AnchorPosition" ), rValue );
+ chart2::LegendPosition ePos;
+ if( rValue >>= ePos )
+ {
+ chart2::LegendExpansion eExp = chart2::LegendExpansion_WIDE;
+ if( ePos == chart2::LegendPosition_LINE_END ||
+ ePos == chart2::LegendPosition_LINE_START )
+ eExp = chart2::LegendExpansion_HIGH;
+
+ m_xLegendProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExp ));
+ }
+ }
+ }
+ // \--
+}
+
+void SAL_CALL LegendWrapper::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ switch( nHandle )
+ {
+ case PROP_LEGEND_ALIGNMENT:
+ if( m_xLegendProp.is())
+ {
+ ::com::sun::star::chart::ChartLegendPosition ePos;
+ chart2::LegendPosition eNewPos;
+
+ if( m_xLegendProp->getPropertyValue( C2U( "AnchorPosition" )) >>= eNewPos )
+ {
+ switch( eNewPos )
+ {
+ case chart2::LegendPosition_LINE_START:
+ ePos = ::com::sun::star::chart::ChartLegendPosition_LEFT;
+ break;
+ case chart2::LegendPosition_LINE_END:
+ ePos = ::com::sun::star::chart::ChartLegendPosition_RIGHT;
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ ePos = ::com::sun::star::chart::ChartLegendPosition_TOP;
+ break;
+ case chart2::LegendPosition_PAGE_END:
+ ePos = ::com::sun::star::chart::ChartLegendPosition_BOTTOM;
+ break;
+
+ default:
+ ePos = ::com::sun::star::chart::ChartLegendPosition_NONE;
+ break;
+ }
+ rValue <<= ePos;
+ }
+ }
+ break;
+
+ default:
+ if( m_xLegendFastProp.is())
+ {
+ // Note: handles must be identical ! (Is the case with the
+ // shared helpers for Character-, Line- and FillProperties
+ rValue = m_xLegendFastProp->getFastPropertyValue( nHandle );
+ }
+ else
+ OPropertySet::getFastPropertyValue( rValue, nHandle );
+ break;
+ }
+ // \--
+}
+
+// --------------------------------------------------------------------------------
+
+// ____ OPropertySet ____
+uno::Any LegendWrapper::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ CharacterProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ LineProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ FillProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL LegendWrapper::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ LegendWrapper::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
+uno::Sequence< ::rtl::OUString > LegendWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 4 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartLegend" );
+ aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" );
+ aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" );
+// aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" );
+// aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" );
+// aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( LegendWrapper, lcl_aServiceName );
+
+// needed by MSC compiler
+using impl::LegendWrapper_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( LegendWrapper, LegendWrapper_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( LegendWrapper, LegendWrapper_Base, OPropertySet )
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
new file mode 100644
index 000000000000..505320a65df8
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * $RCSfile: LegendWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:38 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_LEGENDWRAPPER_HXX
+#define CHART_LEGENDWRAPPER_HXX
+
+#include "OPropertySet.hxx"
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTDOCUMENT_HPP_
+#include <drafts/com/sun/star/chart2/XChartDocument.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XLEGEND_HPP_
+#include <drafts/com/sun/star/chart2/XLegend.hpp>
+#endif
+
+namespace drafts {
+namespace com { namespace sun { namespace star {
+namespace chart2
+{
+ class XTitle;
+}
+}}}
+}
+
+namespace chart
+{
+namespace wrapper
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper3<
+ com::sun::star::drawing::XShape,
+ com::sun::star::lang::XComponent,
+ com::sun::star::lang::XServiceInfo >
+ LegendWrapper_Base;
+}
+
+class LegendWrapper :
+ public impl::LegendWrapper_Base,
+ public ::property::OPropertySet
+{
+public:
+ LegendWrapper( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument > & xModel,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex );
+ virtual ~LegendWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+ throw(::com::sun::star::beans::UnknownPropertyException);
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue
+ ( ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+ virtual void SAL_CALL getFastPropertyValue
+ ( ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const;
+
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XShape ____
+ virtual ::com::sun::star::awt::Point SAL_CALL getPosition()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize )
+ throw (::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual ::rtl::OUString SAL_CALL getShapeType()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XChartDocument >
+ m_xChartDoc;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XLegend >
+ m_xLegend;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xLegendProp;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XFastPropertySet >
+ m_xLegendFastProp;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_LEGENDWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
new file mode 100644
index 000000000000..1a5e60a82b44
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
@@ -0,0 +1,582 @@
+/*************************************************************************
+ *
+ * $RCSfile: TitleWrapper.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:38 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#include "TitleWrapper.hxx"
+#include "macros.hxx"
+#include "InlineContainer.hxx"
+#include "algohelper.hxx"
+
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+
+#include "CharacterProperties.hxx"
+#include "LineProperties.hxx"
+#include "FillProperties.hxx"
+#include "UserDefinedProperties.hxx"
+
+#include <algorithm>
+
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+
+using namespace ::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::property::OPropertySet;
+
+namespace
+{
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" ));
+
+enum
+{
+ PROP_TITLE_STRING,
+ PROP_TITLE_TEXT_ROTATION,
+ PROP_TITLE_TEXT_STACKED
+};
+
+typedef ::std::map< sal_Int32, ::rtl::OUString > lcl_PropertyMapType;
+typedef ::comphelper::MakeMap< sal_Int32, ::rtl::OUString > lcl_MakePropertyMapType;
+
+lcl_PropertyMapType & lcl_GetPropertyMap()
+{
+ static lcl_PropertyMapType aMap(
+ lcl_MakePropertyMapType
+ ( PROP_TITLE_TEXT_ROTATION, C2U( "TextRotation" ))
+ ( PROP_TITLE_TEXT_STACKED, C2U( "StackCharacters" ))
+ );
+
+ return aMap;
+};
+
+void lcl_AddPropertiesToVector(
+ ::std::vector< Property > & rOutProperties )
+{
+ rOutProperties.push_back(
+ Property( C2U( "String" ),
+ PROP_TITLE_STRING,
+ ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID ));
+
+ rOutProperties.push_back(
+ Property( C2U( "TextRotation" ),
+ PROP_TITLE_TEXT_ROTATION,
+ ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+ rOutProperties.push_back(
+ Property( C2U( "StackedText" ),
+ PROP_TITLE_TEXT_STACKED,
+ ::getBooleanCppuType(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT ));
+}
+
+void lcl_AddDefaultsToMap(
+ ::chart::helper::tPropertyValueMap & rOutMap )
+{
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_TITLE_TEXT_ROTATION ));
+ rOutMap[ PROP_TITLE_TEXT_ROTATION ] =
+ uno::makeAny( sal_Int32( 0 ) );
+ OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_TITLE_TEXT_STACKED ));
+ rOutMap[ PROP_TITLE_TEXT_STACKED ] =
+ uno::makeAny( sal_Bool( sal_False ) );
+}
+
+const uno::Sequence< Property > & lcl_GetPropertySequence()
+{
+ static uno::Sequence< Property > aPropSeq;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aPropSeq.getLength() )
+ {
+ // get properties
+ ::std::vector< ::com::sun::star::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::LineProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::FillProperties::AddPropertiesToVector(
+ aProperties, /* bIncludeStyleProperties = */ false );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ // and sort them for access via bsearch
+ ::std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::helper::PropertyNameLess() );
+
+ // transfer result to static Sequence
+ aPropSeq = ::chart::helper::VectorToSequence( aProperties );
+ }
+
+ return aPropSeq;
+}
+
+::cppu::IPropertyArrayHelper & lcl_getInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aArrayHelper(
+ lcl_GetPropertySequence(),
+ /* bSorted = */ sal_True );
+
+ return aArrayHelper;
+}
+
+} // anonymous namespace
+
+// --------------------------------------------------------------------------------
+
+namespace chart
+{
+namespace wrapper
+{
+
+TitleWrapper::TitleWrapper(
+ const uno::Reference<
+ ::drafts::com::sun::star::chart2::XTitle > & xTitle,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex ) :
+ OPropertySet( _rMutex ),
+ m_rMutex( _rMutex ),
+ m_xContext( xContext ),
+ m_aEventListenerContainer( _rMutex ),
+ m_xTitle( xTitle )
+{
+ if( m_xTitle.is())
+ {
+ m_xTitleProp.set( m_xTitle, uno::UNO_QUERY );
+ m_xTitleFastProp.set( m_xTitle, uno::UNO_QUERY );
+ }
+}
+
+TitleWrapper::~TitleWrapper()
+{}
+
+::osl::Mutex & TitleWrapper::GetMutex() const
+{
+ return m_rMutex;
+}
+
+// ____ XShape ____
+awt::Point SAL_CALL TitleWrapper::getPosition()
+ throw (uno::RuntimeException)
+{
+ return awt::Point( 0, 0 );
+}
+
+void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition )
+ throw (uno::RuntimeException)
+{
+}
+
+awt::Size SAL_CALL TitleWrapper::getSize()
+ throw (uno::RuntimeException)
+{
+ return awt::Size( 0, 0 );
+}
+
+void SAL_CALL TitleWrapper::setSize( const awt::Size& aSize )
+ throw (beans::PropertyVetoException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( false, "trying to set size of title" );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+::rtl::OUString SAL_CALL TitleWrapper::getShapeType()
+ throw (uno::RuntimeException)
+{
+ return C2U( "com.sun.star.chart.ChartTitle" );
+}
+
+// ____ XComponent ____
+void SAL_CALL TitleWrapper::dispose()
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( *this ) );
+
+ // /--
+ MutexGuard aGuard( GetMutex());
+ m_xTitle = NULL;
+ m_xTitleProp = NULL;
+ m_xTitleFastProp = NULL;
+ // \--
+}
+
+void SAL_CALL TitleWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL TitleWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+sal_Bool SAL_CALL TitleWrapper::convertFastPropertyValue
+ ( uno::Any & rConvertedValue,
+ uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (lang::IllegalArgumentException)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ switch( nHandle )
+ {
+ case PROP_TITLE_TEXT_ROTATION:
+ {
+ getFastPropertyValue( rOldValue, nHandle );
+
+ sal_Int32 nVal;
+ if( rValue >>= nVal )
+ {
+ double fDoubleDegrees = ( static_cast< double >( nVal ) / 100.0 );
+ rConvertedValue <<= fDoubleDegrees;
+ return sal_True;
+ }
+ break;
+ }
+
+ default:
+ return OPropertySet::convertFastPropertyValue(
+ rConvertedValue, rOldValue, nHandle, rValue );
+ }
+
+ rConvertedValue = rValue;
+
+ return sal_True;
+ // \--
+}
+
+void SAL_CALL TitleWrapper::setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+
+ if( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP )
+ {
+ setFastCharacterPropertyValue( nHandle, rValue );
+ }
+ // try same handle for FastPropertySet. Caution! Works for global
+ // properties like FillProperties, LineProperties and CharacterProperties
+ else if( nHandle > FAST_PROPERTY_ID_START )
+ {
+ if( m_xTitleFastProp.is() )
+ m_xTitleFastProp->setFastPropertyValue( nHandle, rValue );
+ }
+ else
+ {
+ switch( nHandle )
+ {
+ case PROP_TITLE_STRING:
+ if( m_xTitle.is())
+ {
+ ::rtl::OUString aString;
+
+ if( rValue >>= aString )
+ {
+ uno::Sequence<
+ uno::Reference<
+ ::drafts::com::sun::star::chart2::XFormattedString > >
+ aStrings( 1 );
+
+ aStrings[ 0 ].set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "drafts.com.sun.star.chart2.FormattedString" ),
+ m_xContext ),
+ uno::UNO_QUERY );
+
+ if( aStrings[ 0 ].is())
+ aStrings[ 0 ]->setString( aString );
+
+ m_xTitle->setText( aStrings );
+ }
+ else
+ {
+ throw lang::IllegalArgumentException(
+ C2U( "Type Mismatch for property String" ),
+ static_cast< ::cppu::OWeakObject * >( this ),
+ 1 );
+ }
+ }
+ break;
+
+ case PROP_TITLE_TEXT_ROTATION:
+ case PROP_TITLE_TEXT_STACKED:
+ if( m_xTitleProp.is())
+ {
+ lcl_PropertyMapType & rMap( lcl_GetPropertyMap());
+ lcl_PropertyMapType::const_iterator aIt( rMap.find( nHandle ));
+
+ if( aIt != rMap.end())
+ {
+ // found in map
+ m_xTitleProp->setPropertyValue( (*aIt).second, rValue );
+ }
+ }
+ break;
+ }
+ }
+ // \--
+}
+
+void SAL_CALL TitleWrapper::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // /--
+ MutexGuard aGuard( GetMutex());
+ if( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP )
+ {
+ getFastCharacterPropertyValue( rValue, nHandle );
+ }
+ else
+ {
+ switch( nHandle )
+ {
+ case PROP_TITLE_STRING:
+ if( m_xTitle.is())
+ {
+ uno::Sequence<
+ uno::Reference<
+ ::drafts::com::sun::star::chart2::XFormattedString > >
+ aStrings( m_xTitle->getText());
+
+ ::rtl::OUStringBuffer aBuf;
+ for( sal_Int32 i = 0; i < aStrings.getLength(); ++i )
+ {
+ aBuf.append( aStrings[ i ]->getString());
+ }
+ rValue <<= aBuf.makeStringAndClear();
+ }
+ break;
+
+ default:
+ if( m_xTitleFastProp.is())
+ {
+ // Note: handles must be identical ! (Is the case with the
+ // shared helpers for Character-, Line- and FillProperties
+ rValue = m_xTitleFastProp->getFastPropertyValue( nHandle );
+ }
+ else
+ OPropertySet::getFastPropertyValue( rValue, nHandle );
+ break;
+ }
+ }
+ // \--
+}
+
+void TitleWrapper::getFastCharacterPropertyValue(
+ uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
+
+ uno::Reference< beans::XFastPropertySet > xProp;
+
+ if( m_xTitle.is())
+ {
+ uno::Sequence<
+ uno::Reference<
+ ::drafts::com::sun::star::chart2::XFormattedString > >
+ aStrings( m_xTitle->getText());
+
+ if( aStrings.getLength() > 0 )
+ {
+ xProp.set( aStrings[0], uno::UNO_QUERY );
+ }
+ }
+
+ // Note: handles must be identical ! (Is the case with the
+ // shared helpers for Character-, Line- and FillProperties
+ if( xProp.is())
+ rValue = xProp->getFastPropertyValue( nHandle );
+}
+
+void TitleWrapper::setFastCharacterPropertyValue(
+ sal_Int32 nHandle,
+ const uno::Any& rValue )
+ throw (uno::Exception)
+{
+ OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
+
+ if( m_xTitle.is())
+ {
+ uno::Sequence<
+ uno::Reference<
+ ::drafts::com::sun::star::chart2::XFormattedString > >
+ aStrings( m_xTitle->getText());
+
+ for( sal_Int32 i = 0; i < aStrings.getLength(); ++i )
+ {
+ uno::Reference< beans::XFastPropertySet > xStringProp( aStrings[ i ], uno::UNO_QUERY );
+ if( xStringProp.is())
+ {
+ // Note: handles must be identical ! (Is the case with the
+ // shared helpers for Character-, Line- and FillProperties
+ xStringProp->setFastPropertyValue( nHandle, rValue );
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------------------
+
+// ____ OPropertySet ____
+uno::Any TitleWrapper::GetDefaultValue( sal_Int32 nHandle ) const
+ throw(beans::UnknownPropertyException)
+{
+ static helper::tPropertyValueMap aStaticDefaults;
+
+ // /--
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( 0 == aStaticDefaults.size() )
+ {
+ // initialize defaults
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ CharacterProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ LineProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ FillProperties::AddDefaultsToMap(
+ aStaticDefaults,
+ /* bIncludeStyleProperties = */ false );
+ }
+
+ helper::tPropertyValueMap::const_iterator aFound(
+ aStaticDefaults.find( nHandle ));
+
+ if( aFound == aStaticDefaults.end())
+ return uno::Any();
+
+ return (*aFound).second;
+ // \--
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL TitleWrapper::getInfoHelper()
+{
+ return lcl_getInfoHelper();
+}
+
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL
+ TitleWrapper::getPropertySetInfo()
+ throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XPropertySetInfo > xInfo;
+
+ // /--
+ MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is())
+ {
+ xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo(
+ getInfoHelper());
+ }
+
+ return xInfo;
+ // \--
+}
+
+uno::Sequence< ::rtl::OUString > TitleWrapper::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aServices( 4 );
+ aServices[ 0 ] = C2U( "com.sun.star.chart.ChartTitle" );
+ aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" );
+ aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" );
+ aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" );
+// aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" );
+// aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" );
+// aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" );
+
+ return aServices;
+}
+
+// ================================================================================
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+APPHELPER_XSERVICEINFO_IMPL( TitleWrapper, lcl_aServiceName );
+
+// needed by MSC compiler
+using impl::TitleWrapper_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( TitleWrapper, TitleWrapper_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( TitleWrapper, TitleWrapper_Base, OPropertySet )
+
+} // namespace wrapper
+} // namespace chart
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
new file mode 100644
index 000000000000..f66a534aed37
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * $RCSfile: TitleWrapper.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: bm $ $Date: 2003-12-18 13:49:39 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 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
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2003 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef CHART_TITLEWRAPPER_HXX
+#define CHART_TITLEWRAPPER_HXX
+
+#include "OPropertySet.hxx"
+#include "ServiceMacros.hxx"
+
+#ifndef _CPPUHELPER_IMPLBASE3_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
+#include <com/sun/star/drawing/XShape.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
+#include <com/sun/star/lang/XComponent.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XTITLE_HPP_
+#include <drafts/com/sun/star/chart2/XTitle.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
+
+namespace drafts {
+namespace com { namespace sun { namespace star {
+namespace chart2
+{
+ class XTitle;
+}
+}}}
+}
+
+namespace chart
+{
+namespace wrapper
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper3<
+ com::sun::star::drawing::XShape,
+ com::sun::star::lang::XComponent,
+ com::sun::star::lang::XServiceInfo >
+ TitleWrapper_Base;
+}
+
+class TitleWrapper :
+ public impl::TitleWrapper_Base,
+ public ::property::OPropertySet
+{
+public:
+ TitleWrapper( const ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XTitle > & xTitle,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > & xContext,
+ ::osl::Mutex & _rMutex );
+ virtual ~TitleWrapper();
+
+ ::osl::Mutex & GetMutex() const;
+
+ /// XServiceInfo declarations
+ APPHELPER_XSERVICEINFO_DECL()
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
+ throw(::com::sun::star::beans::UnknownPropertyException);
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue
+ ( ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+ virtual void SAL_CALL getFastPropertyValue
+ ( ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle ) const;
+
+ // ____ XPropertySet ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XShape ____
+ virtual ::com::sun::star::awt::Point SAL_CALL getPosition()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize )
+ throw (::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual ::rtl::OUString SAL_CALL getShapeType()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // character properties have to be handled differently (via the XFormattedString elements)
+ void getFastCharacterPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ void setFastCharacterPropertyValue(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::uno::Exception);
+
+private:
+ mutable ::osl::Mutex & m_rMutex;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+
+ ::cppu::OInterfaceContainerHelper
+ m_aEventListenerContainer;
+
+ ::com::sun::star::uno::Reference<
+ ::drafts::com::sun::star::chart2::XTitle >
+ m_xTitle;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet >
+ m_xTitleProp;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XFastPropertySet >
+ m_xTitleFastProp;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// CHART_TITLEWRAPPER_HXX
+#endif
diff --git a/chart2/source/controller/chartapiwrapper/makefile.mk b/chart2/source/controller/chartapiwrapper/makefile.mk
new file mode 100644
index 000000000000..890f7ea77c18
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/makefile.mk
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: bm $ $Date: 2003-12-18 13:48:26 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 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
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ= ..$/..$/..
+PRJNAME= chart2
+TARGET= chchartapiwrapper
+
+PRJINC= $(PRJ)$/source
+
+ENABLE_EXCEPTIONS= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+# --- export library -------------------------------------------------
+
+#Specifies object files to bind into linked libraries.
+SLOFILES= \
+ $(SLO)$/AxisWrapper.obj \
+ $(SLO)$/ChartDataWrapper.obj \
+ $(SLO)$/ChartDocumentWrapper.obj \
+ $(SLO)$/DataSeriesPointWrapper.obj \
+ $(SLO)$/DiagramWrapper.obj \
+ $(SLO)$/LegendWrapper.obj \
+ $(SLO)$/TitleWrapper.obj
+
+# --- Targets -----------------------------------------------------------------
+
+.INCLUDE: target.mk