summaryrefslogtreecommitdiff
path: root/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2007-05-22 16:23:39 +0000
committerVladimir Glazounov <vg@openoffice.org>2007-05-22 16:23:39 +0000
commitb4b17c1fb8fc2d92fee5f0e18f01402cdf4c819e (patch)
tree492198127b1c09cf59ed5942c39e1b04bad5edf5 /chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
parent05fe5dcc2fcd1b66756bcb4656d3ff5d3eb356b5 (diff)
INTEGRATION: CWS chart2mst3 (1.1.2); FILE ADDED
2006/02/17 20:57:50 iha 1.1.2.7: enlarge validity of api wrapper objects to lifetime of new chartmodel 2005/10/11 09:20:00 bm 1.1.2.6: license header change 2005/07/01 14:50:56 iha 1.1.2.5: init outparamter correctly 2005/06/21 12:53:11 iha 1.1.2.4: removed superfluous check 2005/06/17 20:17:33 iha 1.1.2.3: corrected parameter HasAmbiguousValue 2005/05/12 16:13:55 bm 1.1.2.2: namespace rtl for OUString missing 2005/05/09 16:25:19 iha 1.1.2.1: new baseclass for wrapped properties that occur on the diagram and also at single series or datapoints Issue number: Submitted by: Reviewed by:
Diffstat (limited to 'chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx')
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx186
1 files changed, 186 insertions, 0 deletions
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
new file mode 100644
index 000000000000..1fc08b1513ae
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: WrappedSeriesOrDiagramProperty.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: vg $ $Date: 2007-05-22 17:23:39 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX
+#define CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX
+
+#include "WrappedProperty.hxx"
+#include "Chart2ModelContact.hxx"
+#include "macros.hxx"
+#include "DiagramHelper.hxx"
+
+#ifndef _COM_SUN_STAR_CHART2_XDATASERIES_HPP_
+#include <com/sun/star/chart2/XDataSeries.hpp>
+#endif
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+//.............................................................................
+namespace chart
+{
+namespace wrapper
+{
+
+//PROPERTYTYPE is the type of the outer property
+
+template< typename PROPERTYTYPE >
+class WrappedSeriesOrDiagramProperty : public WrappedProperty
+{
+public:
+ virtual PROPERTYTYPE getValueFromSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet ) const =0;
+ virtual void setValueToSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet, PROPERTYTYPE aNewValue ) const =0;
+
+ explicit WrappedSeriesOrDiagramProperty( const ::rtl::OUString& rName, const ::com::sun::star::uno::Any& rDefaulValue
+ , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )//if !spChart2ModelContact.get() this property does belong to a single series and not to the whole diagram
+ : WrappedProperty(rName,::rtl::OUString())
+ , m_spChart2ModelContact(spChart2ModelContact)
+ , m_aOuterValue(rDefaulValue)
+ , m_aDefaultValue(rDefaulValue)
+ {
+ }
+ virtual ~WrappedSeriesOrDiagramProperty() {};
+
+ bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const
+ {
+ bool bHasDetectableInnerValue = false;
+ rHasAmbiguousValue = false;
+ if( m_spChart2ModelContact.get() )
+ {
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >::const_iterator aIter =
+ aSeriesVector.begin();
+ for( ; aIter != aSeriesVector.end(); aIter++ )
+ {
+ PROPERTYTYPE aCurValue = getValueFromSeries( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >::query( *aIter ) );
+ if( !bHasDetectableInnerValue )
+ rValue = aCurValue;
+ else
+ {
+ if( rValue != aCurValue )
+ {
+ rHasAmbiguousValue = true;
+ break;
+ }
+ else
+ rValue = aCurValue;
+ }
+ bHasDetectableInnerValue = true;
+ }
+ }
+ return bHasDetectableInnerValue;
+ }
+ void setInnerValue( PROPERTYTYPE aNewValue ) const
+ {
+ if( m_spChart2ModelContact.get() )
+ {
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >::const_iterator aIter =
+ aSeriesVector.begin();
+ for( ; aIter != aSeriesVector.end(); aIter++ )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSeriesPropertySet( *aIter, ::com::sun::star::uno::UNO_QUERY );
+ if( xSeriesPropertySet.is() )
+ {
+ setValueToSeries( xSeriesPropertySet, aNewValue );
+ }
+ }
+ }
+ }
+ void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
+ throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+ {
+ PROPERTYTYPE aNewValue;
+ if( ! (rOuterValue >>= aNewValue) )
+ throw ::com::sun::star::lang::IllegalArgumentException( C2U("statistic property requires different type"), 0, 0 );
+
+ if( m_spChart2ModelContact.get() )
+ {
+ m_aOuterValue = rOuterValue;
+
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aOldValue;
+ if( detectInnerValue( aOldValue, bHasAmbiguousValue ) )
+ {
+ if( bHasAmbiguousValue || aNewValue != aOldValue )
+ setInnerValue( aNewValue );
+ }
+ }
+ else
+ {
+ setValueToSeries( xInnerPropertySet, aNewValue );
+ }
+ }
+
+ ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const
+ throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+ {
+ if( m_spChart2ModelContact.get() )
+ {
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aValue;
+ if( detectInnerValue( aValue, bHasAmbiguousValue ) )
+ {
+ m_aOuterValue <<= aValue;
+ }
+ return m_aOuterValue;
+ }
+ else
+ {
+ ::com::sun::star::uno::Any aRet( m_aDefaultValue );
+ aRet <<= getValueFromSeries( xInnerPropertySet );
+ return aRet;
+ }
+ }
+
+ ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const
+ throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+ {
+ return m_aDefaultValue;
+ }
+
+protected:
+ ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable ::com::sun::star::uno::Any m_aOuterValue;
+ ::com::sun::star::uno::Any m_aDefaultValue;
+};
+
+} //namespace wrapper
+} //namespace chart
+//.............................................................................
+
+// CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX
+#endif