1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef CHART_COORDINATESYSTEM_HXX
28 #define CHART_COORDINATESYSTEM_HXX
29 
30 #include "ServiceMacros.hxx"
31 #include "OPropertySet.hxx"
32 #include "MutexContainer.hxx"
33 #include <cppuhelper/implbase6.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/chart2/XCoordinateSystem.hpp>
38 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
39 #include <com/sun/star/util/XCloneable.hpp>
40 #include <com/sun/star/util/XModifyBroadcaster.hpp>
41 #include <com/sun/star/util/XModifyListener.hpp>
42 
43 #include <vector>
44 
45 namespace chart
46 {
47 
48 namespace impl
49 {
50 typedef ::cppu::WeakImplHelper6
51     < ::com::sun::star::lang::XServiceInfo,
52       ::com::sun::star::chart2::XCoordinateSystem,
53       ::com::sun::star::chart2::XChartTypeContainer,
54       ::com::sun::star::util::XCloneable,
55       ::com::sun::star::util::XModifyBroadcaster,
56       ::com::sun::star::util::XModifyListener >
57     BaseCoordinateSystem_Base;
58 }
59 
60 class BaseCoordinateSystem :
61         public impl::BaseCoordinateSystem_Base,
62         public MutexContainer,
63         public ::property::OPropertySet
64 {
65 public:
66 	BaseCoordinateSystem(
67         const ::com::sun::star::uno::Reference<
68             ::com::sun::star::uno::XComponentContext > & xContext,
69         sal_Int32 nDimensionCount = 2,
70         sal_Bool bSwapXAndYAxis = sal_False );
71 	explicit BaseCoordinateSystem( const BaseCoordinateSystem & rSource );
72 	virtual ~BaseCoordinateSystem();
73 
74     // ____ OPropertySet ____
75     virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const
76         throw(::com::sun::star::beans::UnknownPropertyException);
77 
78 	virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
79 
80     // ____ XPropertySet ____
81     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
82         getPropertySetInfo()
83         throw (::com::sun::star::uno::RuntimeException);
84 
85     /// merge XInterface implementations
86  	DECLARE_XINTERFACE()
87     /// merge XTypeProvider implementations
88  	DECLARE_XTYPEPROVIDER()
89 
90 protected:
91     // ____ XCoordinateSystem ____
92     virtual ::sal_Int32 SAL_CALL getDimension()
93         throw (::com::sun::star::uno::RuntimeException);
94     // not implemented
95 //     virtual ::rtl::OUString SAL_CALL getCoordinateSystemType()
96 //         throw (::com::sun::star::uno::RuntimeException);
97     // not implemented
98 //     virtual ::rtl::OUString SAL_CALL getViewServiceName()
99 //         throw (::com::sun::star::uno::RuntimeException);
100     virtual void SAL_CALL setAxisByDimension(
101         ::sal_Int32 nDimension,
102         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis,
103         ::sal_Int32 nIndex )
104         throw (::com::sun::star::lang::IndexOutOfBoundsException,
105                ::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > SAL_CALL getAxisByDimension(
107         ::sal_Int32 nDimension, ::sal_Int32 nIndex )
108         throw (::com::sun::star::lang::IndexOutOfBoundsException,
109                ::com::sun::star::uno::RuntimeException);
110     virtual ::sal_Int32 SAL_CALL getMaximumAxisIndexByDimension( ::sal_Int32 nDimension )
111         throw (::com::sun::star::lang::IndexOutOfBoundsException,
112                ::com::sun::star::uno::RuntimeException);
113 
114     // ____ XChartTypeContainer ____
115     virtual void SAL_CALL addChartType(
116         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& aChartType )
117         throw (::com::sun::star::lang::IllegalArgumentException,
118                ::com::sun::star::uno::RuntimeException);
119     virtual void SAL_CALL removeChartType(
120         const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& aChartType )
121         throw (::com::sun::star::container::NoSuchElementException,
122                ::com::sun::star::uno::RuntimeException);
123     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > > SAL_CALL getChartTypes()
124         throw (::com::sun::star::uno::RuntimeException);
125     virtual void SAL_CALL setChartTypes(
126         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > >& aChartTypes )
127         throw (::com::sun::star::lang::IllegalArgumentException,
128                ::com::sun::star::uno::RuntimeException);
129 
130     // ____ XCloneable ____
131     // not implemented
132 //     virtual ::com::sun::star::uno::Reference<
133 //         ::com::sun::star::util::XCloneable > SAL_CALL createClone()
134 //         throw (::com::sun::star::uno::RuntimeException);
135 
136     // ____ XServiceInfo ____
137     // not implemented
138 //     virtual ::rtl::OUString SAL_CALL getImplementationName()
139 //         throw (::com::sun::star::uno::RuntimeException);
140 //     virtual ::sal_Bool SAL_CALL supportsService(
141 //         const ::rtl::OUString& ServiceName )
142 //         throw (::com::sun::star::uno::RuntimeException);
143 //     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
144 //         throw (::com::sun::star::uno::RuntimeException);
145 
146     // ____ XModifyBroadcaster ____
147     virtual void SAL_CALL addModifyListener(
148         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
149         throw (::com::sun::star::uno::RuntimeException);
150     virtual void SAL_CALL removeModifyListener(
151         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
152         throw (::com::sun::star::uno::RuntimeException);
153 
154     // ____ XModifyListener ____
155     virtual void SAL_CALL modified(
156         const ::com::sun::star::lang::EventObject& aEvent )
157         throw (::com::sun::star::uno::RuntimeException);
158 
159     // ____ XEventListener (base of XModifyListener) ____
160     virtual void SAL_CALL disposing(
161         const ::com::sun::star::lang::EventObject& Source )
162         throw (::com::sun::star::uno::RuntimeException);
163 
164     // ____ OPropertySet ____
165     virtual void firePropertyChangeEvent();
166 	using OPropertySet::disposing;
167 
168     void fireModifyEvent();
169 
170 protected:
171     ::com::sun::star::uno::Reference<
172         ::com::sun::star::uno::XComponentContext >        m_xContext;
173 
174     ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder;
175 
176 private:
177     sal_Int32                                             m_nDimensionCount;
178     typedef ::std::vector< ::std::vector< ::com::sun::star::uno::Reference<
179         ::com::sun::star::chart2::XAxis > > > tAxisVecVecType;
180     tAxisVecVecType m_aAllAxis; //outer sequence is the dimension; inner sequence is the axis index that indicates main or secondary axis
181     ::com::sun::star::uno::Sequence<
182             ::com::sun::star::uno::Any >                  m_aOrigin;
183     ::std::vector< ::com::sun::star::uno::Reference<
184         ::com::sun::star::chart2::XChartType > >          m_aChartTypes;
185 };
186 
187 } //  namespace chart
188 
189 // CHART_COORDINATESYSTEM_HXX
190 #endif
191