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_AXISWRAPPER_HXX
28 #define CHART_AXISWRAPPER_HXX
29 
30 #include "WrappedPropertySet.hxx"
31 #include "ReferenceSizePropertyProvider.hxx"
32 #include "ServiceMacros.hxx"
33 #include <cppuhelper/implbase5.hxx>
34 #include <comphelper/uno3.hxx>
35 #include <cppuhelper/interfacecontainer.hxx>
36 #include <com/sun/star/chart/XAxis.hpp>
37 #include <com/sun/star/chart2/XAxis.hpp>
38 #include <com/sun/star/frame/XModel.hpp>
39 #include <com/sun/star/drawing/XShape.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/uno/XComponentContext.hpp>
43 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
44 
45 #include <boost/shared_ptr.hpp>
46 
47 namespace chart
48 {
49 namespace wrapper
50 {
51 class Chart2ModelContact;
52 
53 class AxisWrapper : public ::cppu::ImplInheritanceHelper5<
54                       WrappedPropertySet
55                     , com::sun::star::chart::XAxis
56                     , com::sun::star::drawing::XShape
57                     , com::sun::star::lang::XComponent
58                     , com::sun::star::lang::XServiceInfo
59                     , com::sun::star::util::XNumberFormatsSupplier
60                     >
61                     , public ReferenceSizePropertyProvider
62 {
63 public:
64     enum tAxisType
65     {
66         X_AXIS,
67         Y_AXIS,
68         Z_AXIS,
69         SECOND_X_AXIS,
70         SECOND_Y_AXIS
71     };
72 
73     AxisWrapper( tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
74     virtual ~AxisWrapper();
75 
76     static void getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis );
77 
78     /// XServiceInfo declarations
79     APPHELPER_XSERVICEINFO_DECL()
80 
81     //ReferenceSizePropertyProvider
82     virtual void updateReferenceSize();
83     virtual ::com::sun::star::uno::Any getReferenceSize();
84     virtual ::com::sun::star::awt::Size getCurrentSizeForReference();
85 
86     // ____ XComponent ____
87     virtual void SAL_CALL dispose()
88         throw (::com::sun::star::uno::RuntimeException);
89     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
90                                             ::com::sun::star::lang::XEventListener >& xListener )
91         throw (::com::sun::star::uno::RuntimeException);
92     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
93                                                ::com::sun::star::lang::XEventListener >& aListener )
94         throw (::com::sun::star::uno::RuntimeException);
95 
96     // ____ chart::XAxis ____
97     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getAxisTitle(  ) throw (::com::sun::star::uno::RuntimeException);
98     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMajorGrid(  ) throw (::com::sun::star::uno::RuntimeException);
99     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMinorGrid(  ) throw (::com::sun::star::uno::RuntimeException);
100 
101     // ____ XShape ____
102     virtual ::com::sun::star::awt::Point SAL_CALL getPosition()
103         throw (::com::sun::star::uno::RuntimeException);
104     virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition )
105         throw (::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::awt::Size SAL_CALL getSize()
107         throw (::com::sun::star::uno::RuntimeException);
108     virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize )
109         throw (::com::sun::star::beans::PropertyVetoException,
110                ::com::sun::star::uno::RuntimeException);
111 
112     // ____ XShapeDescriptor (base of XShape) ____
113     virtual ::rtl::OUString SAL_CALL getShapeType()
114         throw (::com::sun::star::uno::RuntimeException);
115 
116     // ____ XNumberFormatsSupplier ____
117     virtual ::com::sun::star::uno::Reference<
118                 ::com::sun::star::beans::XPropertySet > SAL_CALL getNumberFormatSettings()
119             throw (::com::sun::star::uno::RuntimeException);
120     virtual ::com::sun::star::uno::Reference<
121                 ::com::sun::star::util::XNumberFormats > SAL_CALL getNumberFormats()
122             throw (::com::sun::star::uno::RuntimeException);
123 
124 protected:
125     // ____ WrappedPropertySet ____
126     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence();
127     virtual const std::vector< WrappedProperty* > createWrappedProperties();
128     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet();
129 
130 private: //methods
131     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > getAxis();
132 
133 private: //member
134     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
135 	::cppu::OInterfaceContainerHelper           m_aEventListenerContainer;
136 
137     tAxisType           m_eType;
138     ::com::sun::star::uno::Any m_aTemporaryHelpStepValue;
139 
140     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xAxisTitle;
141     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xMajorGrid;
142     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >   m_xMinorGrid;
143 };
144 
145 } //  namespace wrapper
146 } //  namespace chart
147 
148 // CHART_AXISWRAPPER_HXX
149 #endif
150