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