1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef CHART_DATASERIESPOINTWRAPPER_HXX
24 #define CHART_DATASERIESPOINTWRAPPER_HXX
25 
26 #include "ServiceMacros.hxx"
27 #include "WrappedPropertySet.hxx"
28 #include "ReferenceSizePropertyProvider.hxx"
29 #include <cppuhelper/implbase4.hxx>
30 #include <comphelper/uno3.hxx>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <com/sun/star/chart2/XDataSeries.hpp>
33 #include <com/sun/star/frame/XModel.hpp>
34 #include <com/sun/star/lang/XComponent.hpp>
35 #include <com/sun/star/lang/XEventListener.hpp>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/uno/XComponentContext.hpp>
39 
40 #include <boost/shared_ptr.hpp>
41 
42 namespace chart
43 {
44 
45 namespace wrapper
46 {
47 
48 class Chart2ModelContact;
49 
50 class DataSeriesPointWrapper : public ::cppu::ImplInheritanceHelper4<
51                                           WrappedPropertySet
52                                         , com::sun::star::lang::XServiceInfo
53                                         , com::sun::star::lang::XInitialization
54    	                                    , com::sun::star::lang::XComponent
55    	                                    , com::sun::star::lang::XEventListener
56                                         >
57                                         , public ReferenceSizePropertyProvider
58 
59 {
60 public:
61     enum eType
62     {
63         DATA_SERIES,
64         DATA_POINT
65     };
66 
67     //this constructor needs an initialize call afterwards
68     DataSeriesPointWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
69 
70     DataSeriesPointWrapper( eType eType
71             , sal_Int32 nSeriesIndexInNewAPI
72             , sal_Int32 nPointIndex //ignored for series
73             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact  );
74 
75     virtual ~DataSeriesPointWrapper();
76 
77     bool isSupportingAreaProperties();
78     bool isLinesForbidden();
79 
80     /// XServiceInfo declarations
81     APPHELPER_XSERVICEINFO_DECL()
82 
83     // ___lang::XInitialization___
84     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
85                 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
86 
87     //ReferenceSizePropertyProvider
88     virtual void updateReferenceSize();
89     virtual ::com::sun::star::uno::Any getReferenceSize();
90     virtual ::com::sun::star::awt::Size getCurrentSizeForReference();
91 
92 protected:
93     // ____ XComponent ____
94     virtual void SAL_CALL dispose()
95         throw (::com::sun::star::uno::RuntimeException);
96     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
97                                             ::com::sun::star::lang::XEventListener >& xListener )
98         throw (::com::sun::star::uno::RuntimeException);
99     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
100                                                ::com::sun::star::lang::XEventListener >& aListener )
101         throw (::com::sun::star::uno::RuntimeException);
102 
103     // ____ XEventListener ____
104     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
105         throw (::com::sun::star::uno::RuntimeException);
106 
107 protected:
108     // ____ WrappedPropertySet ____
109     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence();
110     virtual const std::vector< WrappedProperty* > createWrappedProperties();
111     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) 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);
112     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
113     virtual ::com::sun::star::uno::Reference<
114                         ::com::sun::star::beans::XPropertySet > getInnerPropertySet();
115 
116     virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
117     virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
118     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
119 
120     //own methods
121     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > getDataSeries();
122     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataPointProperties();
123 
124 private:
125 
126 	void SAL_CALL getStatisticsPropertyValue
127         ( ::com::sun::star::uno::Any& rValue,
128           sal_Int32 nHandle ) const;
129 
130     void SAL_CALL setStatisticsPropertyValue_NoBroadcast(
131         sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
132         throw (::com::sun::star::uno::Exception);
133 
134     // ----------------------------------------
135 
136     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
137 	::cppu::OInterfaceContainerHelper           m_aEventListenerContainer;
138 
139     eType               m_eType;
140     sal_Int32           m_nSeriesIndexInNewAPI;
141     sal_Int32           m_nPointIndex;
142 
143     sal_Bool            m_bLinesAllowed;
144 
145     //this should only be used, if the DataSeriesPointWrapper is initialized via the XInitialize interface
146     //because a big change in the chartmodel may leed to an dataseriespointer that's not connected to the model anymore
147     //with the indizes instead we are can aleays get the new dataseries
148     ::com::sun::star::uno::Reference<
149         ::com::sun::star::chart2::XDataSeries >     m_xDataSeries;
150 };
151 
152 } //  namespace wrapper
153 } //  namespace chart
154 
155 // CHART_DATASERIESPOINTWRAPPER_HXX
156 #endif
157