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_DIAGRAMWRAPPER_HXX
28 #define CHART_DIAGRAMWRAPPER_HXX
29 
30 #include "WrappedPropertySet.hxx"
31 #include "ServiceMacros.hxx"
32 #include "DiagramHelper.hxx"
33 
34 #if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13)
35 #define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13
36 #define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13
37 #include "comphelper/implbase_var.hxx"
38 #endif
39 
40 #include <comphelper/uno3.hxx>
41 #include <cppuhelper/interfacecontainer.hxx>
42 #include <com/sun/star/chart2/XChartDocument.hpp>
43 #include <com/sun/star/chart2/XDiagram.hpp>
44 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <com/sun/star/chart/XDiagramPositioning.hpp>
46 #include <com/sun/star/chart2/XDiagramProvider.hpp>
47 #include <com/sun/star/chart2/XChartTypeTemplate.hpp>
48 #include <com/sun/star/chart2/XChartTypeManager.hpp>
49 #include <com/sun/star/chart/XDiagram.hpp>
50 #include <com/sun/star/chart/XAxisSupplier.hpp>
51 #include <com/sun/star/chart/XAxisZSupplier.hpp>
52 #include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
53 #include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
54 #include <com/sun/star/chart/XStatisticDisplay.hpp>
55 #include <com/sun/star/chart/X3DDisplay.hpp>
56 #include <com/sun/star/lang/XServiceInfo.hpp>
57 #include <com/sun/star/lang/XComponent.hpp>
58 #include <com/sun/star/lang/XEventListener.hpp>
59 #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
60 
61 #include <com/sun/star/chart/X3DDefaultSetter.hpp>
62 #include <boost/shared_ptr.hpp>
63 
64 namespace chart
65 {
66 namespace wrapper
67 {
68 
69 class Chart2ModelContact;
70 
71 class DiagramWrapper : public ::comphelper::ImplInheritanceHelper13<
72                       WrappedPropertySet
73                      , ::com::sun::star::chart::XDiagram
74                      , ::com::sun::star::chart::XAxisSupplier
75                      , ::com::sun::star::chart::XAxisZSupplier
76 	                 , ::com::sun::star::chart::XTwoAxisXSupplier	//	: XAxisXSupplier
77 	                 , ::com::sun::star::chart::XTwoAxisYSupplier	//	: XAxisYSupplier
78 	                 , ::com::sun::star::chart::XStatisticDisplay
79 	                 , ::com::sun::star::chart::X3DDisplay
80                      , ::com::sun::star::chart::X3DDefaultSetter
81 	                 , ::com::sun::star::lang::XServiceInfo
82    	                 , ::com::sun::star::lang::XComponent
83 //                      , ::com::sun::star::lang::XEventListener
84                      , ::com::sun::star::chart::XDiagramPositioning
85                      , ::com::sun::star::chart2::XDiagramProvider
86                      , ::com::sun::star::chart::XSecondAxisTitleSupplier
87                     >
88 {
89 public:
90     DiagramWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
91 	virtual ~DiagramWrapper();
92 
93     /// XServiceInfo declarations
94     APPHELPER_XSERVICEINFO_DECL()
95 
96     // ____ XComponent ____
97     virtual void SAL_CALL dispose()
98         throw (::com::sun::star::uno::RuntimeException);
99     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
100                                             ::com::sun::star::lang::XEventListener >& xListener )
101         throw (::com::sun::star::uno::RuntimeException);
102     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
103                                                ::com::sun::star::lang::XEventListener >& aListener )
104         throw (::com::sun::star::uno::RuntimeException);
105 
106     // ____ XDiagram ____
107     virtual ::rtl::OUString SAL_CALL getDiagramType()
108         throw (::com::sun::star::uno::RuntimeException);
109     virtual ::com::sun::star::uno::Reference<
110         ::com::sun::star::beans::XPropertySet > SAL_CALL getDataRowProperties( sal_Int32 nRow )
111         throw (::com::sun::star::lang::IndexOutOfBoundsException,
112                ::com::sun::star::uno::RuntimeException);
113     virtual ::com::sun::star::uno::Reference<
114         ::com::sun::star::beans::XPropertySet > SAL_CALL getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow )
115         throw (::com::sun::star::lang::IndexOutOfBoundsException,
116                ::com::sun::star::uno::RuntimeException);
117 
118     // ____ XShape (base of XDiagram) ____
119     virtual ::com::sun::star::awt::Point SAL_CALL getPosition()
120         throw (::com::sun::star::uno::RuntimeException);
121     virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition )
122         throw (::com::sun::star::uno::RuntimeException);
123     virtual ::com::sun::star::awt::Size SAL_CALL getSize()
124         throw (::com::sun::star::uno::RuntimeException);
125     virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize )
126         throw (::com::sun::star::beans::PropertyVetoException,
127                ::com::sun::star::uno::RuntimeException);
128 
129     // ____ XShapeDescriptor (base of XShape) ____
130     virtual ::rtl::OUString SAL_CALL getShapeType()
131         throw (::com::sun::star::uno::RuntimeException);
132 
133     // ____ XAxisSupplier ____
134     virtual ::com::sun::star::uno::Reference<
135         ::com::sun::star::chart::XAxis > SAL_CALL getAxis( sal_Int32 nDimensionIndex )
136         throw (::com::sun::star::uno::RuntimeException);
137     virtual ::com::sun::star::uno::Reference<
138         ::com::sun::star::chart::XAxis > SAL_CALL getSecondaryAxis( sal_Int32 nDimensionIndex )
139         throw (::com::sun::star::uno::RuntimeException);
140 
141     // ____ XAxisZSupplier ____
142     virtual ::com::sun::star::uno::Reference<
143         ::com::sun::star::drawing::XShape > SAL_CALL getZAxisTitle()
144         throw (::com::sun::star::uno::RuntimeException);
145     virtual ::com::sun::star::uno::Reference<
146         ::com::sun::star::beans::XPropertySet > SAL_CALL getZMainGrid()
147         throw (::com::sun::star::uno::RuntimeException);
148     virtual ::com::sun::star::uno::Reference<
149         ::com::sun::star::beans::XPropertySet > SAL_CALL getZHelpGrid()
150         throw (::com::sun::star::uno::RuntimeException);
151     virtual ::com::sun::star::uno::Reference<
152         ::com::sun::star::beans::XPropertySet > SAL_CALL getZAxis()
153         throw (::com::sun::star::uno::RuntimeException);
154 
155     // ____ XTwoAxisXSupplier ____
156     virtual ::com::sun::star::uno::Reference<
157         ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryXAxis()
158         throw (::com::sun::star::uno::RuntimeException);
159 
160     // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
161     virtual ::com::sun::star::uno::Reference<
162         ::com::sun::star::drawing::XShape > SAL_CALL getXAxisTitle()
163         throw (::com::sun::star::uno::RuntimeException);
164     virtual ::com::sun::star::uno::Reference<
165         ::com::sun::star::beans::XPropertySet > SAL_CALL getXAxis()
166         throw (::com::sun::star::uno::RuntimeException);
167     virtual ::com::sun::star::uno::Reference<
168         ::com::sun::star::beans::XPropertySet > SAL_CALL getXMainGrid()
169         throw (::com::sun::star::uno::RuntimeException);
170     virtual ::com::sun::star::uno::Reference<
171         ::com::sun::star::beans::XPropertySet > SAL_CALL getXHelpGrid()
172         throw (::com::sun::star::uno::RuntimeException);
173 
174     // ____ XTwoAxisYSupplier ____
175     virtual ::com::sun::star::uno::Reference<
176         ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryYAxis()
177         throw (::com::sun::star::uno::RuntimeException);
178 
179     // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
180     virtual ::com::sun::star::uno::Reference<
181         ::com::sun::star::drawing::XShape > SAL_CALL getYAxisTitle()
182         throw (::com::sun::star::uno::RuntimeException);
183     virtual ::com::sun::star::uno::Reference<
184         ::com::sun::star::beans::XPropertySet > SAL_CALL getYAxis()
185         throw (::com::sun::star::uno::RuntimeException);
186     virtual ::com::sun::star::uno::Reference<
187         ::com::sun::star::beans::XPropertySet > SAL_CALL getYHelpGrid()
188         throw (::com::sun::star::uno::RuntimeException);
189     virtual ::com::sun::star::uno::Reference<
190         ::com::sun::star::beans::XPropertySet > SAL_CALL getYMainGrid()
191         throw (::com::sun::star::uno::RuntimeException);
192 
193    // ____ XSecondAxisTitleSupplier ____
194     virtual ::com::sun::star::uno::Reference<
195         ::com::sun::star::drawing::XShape > SAL_CALL getSecondXAxisTitle()
196         throw (::com::sun::star::uno::RuntimeException);
197     virtual ::com::sun::star::uno::Reference<
198         ::com::sun::star::drawing::XShape > SAL_CALL getSecondYAxisTitle()
199         throw (::com::sun::star::uno::RuntimeException);
200 
201     // ____ XStatisticDisplay ____
202     virtual ::com::sun::star::uno::Reference<
203         ::com::sun::star::beans::XPropertySet > SAL_CALL getUpBar()
204         throw (::com::sun::star::uno::RuntimeException);
205     virtual ::com::sun::star::uno::Reference<
206         ::com::sun::star::beans::XPropertySet > SAL_CALL getDownBar()
207         throw (::com::sun::star::uno::RuntimeException);
208     virtual ::com::sun::star::uno::Reference<
209         ::com::sun::star::beans::XPropertySet > SAL_CALL getMinMaxLine()
210         throw (::com::sun::star::uno::RuntimeException);
211 
212     // ____ X3DDisplay ____
213     virtual ::com::sun::star::uno::Reference<
214         ::com::sun::star::beans::XPropertySet > SAL_CALL getWall()
215         throw (::com::sun::star::uno::RuntimeException);
216     virtual ::com::sun::star::uno::Reference<
217         ::com::sun::star::beans::XPropertySet > SAL_CALL getFloor()
218         throw (::com::sun::star::uno::RuntimeException);
219 
220     // ____ X3DDefaultSetter ____
221     virtual void SAL_CALL set3DSettingsToDefault() throw (::com::sun::star::uno::RuntimeException);
222     virtual void SAL_CALL setDefaultRotation() throw (::com::sun::star::uno::RuntimeException);
223     virtual void SAL_CALL setDefaultIllumination() throw (::com::sun::star::uno::RuntimeException);
224 
225 //     // ____ XEventListener ____
226 //     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
227 //         throw (::com::sun::star::uno::RuntimeException);
228 
229     // ____ XDiagramPositioning ____
230 
231     virtual void SAL_CALL setAutomaticDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
232     virtual ::sal_Bool SAL_CALL isAutomaticDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
233     virtual void SAL_CALL setDiagramPositionExcludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
234     virtual ::sal_Bool SAL_CALL isExcludingDiagramPositioning(  ) throw (::com::sun::star::uno::RuntimeException);
235     virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionExcludingAxes(  ) throw (::com::sun::star::uno::RuntimeException);
236     virtual void SAL_CALL setDiagramPositionIncludingAxes( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
237     virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxes(  ) throw (::com::sun::star::uno::RuntimeException);
238     virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxisTitles( const ::com::sun::star::awt::Rectangle& PositionRect ) throw (::com::sun::star::uno::RuntimeException);
239     virtual ::com::sun::star::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxisTitles(  ) throw (::com::sun::star::uno::RuntimeException);
240 
241     // ____ XDiagramProvider ____
242     virtual ::com::sun::star::uno::Reference<
243             ::com::sun::star::chart2::XDiagram > SAL_CALL getDiagram()
244         throw (::com::sun::star::uno::RuntimeException);
245     virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference<
246                                       ::com::sun::star::chart2::XDiagram >& xDiagram )
247         throw (::com::sun::star::uno::RuntimeException);
248 
249 protected:
250     // ____ WrappedPropertySet ____
251     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence();
252     virtual const std::vector< WrappedProperty* > createWrappedProperties();
253     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet();
254 
255 private:
256     void updateFromModel();
257 
258     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
259 	::cppu::OInterfaceContainerHelper           m_aEventListenerContainer;
260 
261     ::com::sun::star::uno::Reference<
262         ::com::sun::star::chart::XAxis >        m_xXAxis;
263     ::com::sun::star::uno::Reference<
264         ::com::sun::star::chart::XAxis >        m_xYAxis;
265     ::com::sun::star::uno::Reference<
266         ::com::sun::star::chart::XAxis >        m_xZAxis;
267     ::com::sun::star::uno::Reference<
268         ::com::sun::star::chart::XAxis >        m_xSecondXAxis;
269     ::com::sun::star::uno::Reference<
270         ::com::sun::star::chart::XAxis >        m_xSecondYAxis;
271 
272     ::com::sun::star::uno::Reference<
273         ::com::sun::star::beans::XPropertySet > m_xWall;
274     ::com::sun::star::uno::Reference<
275         ::com::sun::star::beans::XPropertySet > m_xFloor;
276 
277     ::com::sun::star::uno::Reference<
278         ::com::sun::star::beans::XPropertySet > m_xMinMaxLineWrapper;
279     ::com::sun::star::uno::Reference<
280         ::com::sun::star::beans::XPropertySet > m_xUpBarWrapper;
281     ::com::sun::star::uno::Reference<
282         ::com::sun::star::beans::XPropertySet > m_xDownBarWrapper;
283 };
284 
285 } //  namespace wrapper
286 } //  namespace chart
287 
288 // CHART_DIAGRAMWRAPPER_HXX
289 #endif
290