xref: /trunk/main/chart2/source/controller/inc/AccessibleChartView.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 _CHART2_ACCESSIBLE_CHART_VIEW_HXX
24 #define _CHART2_ACCESSIBLE_CHART_VIEW_HXX
25 
26 #include "AccessibleBase.hxx"
27 #include "MutexContainer.hxx"
28 #include "ServiceMacros.hxx"
29 #include <cppuhelper/implbase2.hxx>
30 // header for class WeakReference
31 #include <cppuhelper/weakref.hxx>
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #include <com/sun/star/frame/XModel.hpp>
34 #include <com/sun/star/lang/XInitialization.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/view/XSelectionSupplier.hpp>
38 #include <com/sun/star/view/XSelectionChangeListener.hpp>
39 #include <com/sun/star/awt/XWindow.hpp>
40 
41 #include <boost/shared_ptr.hpp>
42 
43 namespace accessibility
44 {
45 class IAccessibleViewForwarder;
46 }
47 
48 //.............................................................................
49 namespace chart
50 {
51 //.............................................................................
52 
53 class ExplicitValueProvider;
54 
55 namespace impl
56 {
57 typedef ::cppu::ImplInheritanceHelper2<
58         ::chart::AccessibleBase,
59         ::com::sun::star::lang::XInitialization,
60         ::com::sun::star::view::XSelectionChangeListener >
61     AccessibleChartView_Base;
62 }
63 
64 class AccessibleChartView :
65         public impl::AccessibleChartView_Base
66 {
67 public:
68     AccessibleChartView(
69         const ::com::sun::star::uno::Reference<
70             ::com::sun::star::uno::XComponentContext >& xContext, SdrView* pView );
71     virtual ~AccessibleChartView();
72 
73     // ____ WeakComponentHelper (called from XComponent::dispose()) ____
74     virtual void SAL_CALL disposing();
75 
76     // ____ lang::XInitialization ____
77     // 0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself
78     // 1: frame::XModel representing the chart model - offers access to object data
79     // 2: lang::XInterface representing the normal chart view - offers access to some extra object data
80     // 3: accessibility::XAccessible representing the parent accessible
81     // 4: awt::XWindow representing the view's window (is a vcl Window)
82     // all arguments are only valid until next initialization - don't keep them longer
83     virtual void SAL_CALL initialize(
84         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
85 
86     // ____ view::XSelectionChangeListener ____
87     virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent );
88 
89     // ________ XEventListener ________
90     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source );
91 
92     // ________ XAccessibleContext ________
93     virtual ::rtl::OUString SAL_CALL getAccessibleDescription();
94     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent();
95     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent();
96     virtual ::rtl::OUString SAL_CALL getAccessibleName();
97     virtual sal_Int16 SAL_CALL getAccessibleRole();
98 
99     // ________ XAccessibleComponent ________
100     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds();
101     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen();
102 
103 protected:
104     // ________ AccessibleChartElement ________
105     virtual ::com::sun::star::awt::Point   GetUpperLeftOnScreen() const;
106 
107 private: // methods
108     /** @return the result that m_xWindow->getPosSize() _should_ return.  It
109                 returns (0,0) as upper left corner.  When calling
110                 getAccessibleParent, you get the parent's parent, which contains
111                 a decoration.  Thus you have an offset of (currently) (2,2)
112                 which isn't taken into account.
113      */
114     virtual ::com::sun::star::awt::Rectangle GetWindowPosSize() const;
115 
116     ExplicitValueProvider* getExplicitValueProvider();
117 
118 private: // members
119     ::com::sun::star::uno::Reference<
120                        ::com::sun::star::uno::XComponentContext>    m_xContext;
121     ::com::sun::star::uno::WeakReference<
122                        ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier;
123     ::com::sun::star::uno::WeakReference<
124                        ::com::sun::star::frame::XModel >            m_xChartModel;
125     ::com::sun::star::uno::WeakReference<
126                        ::com::sun::star::uno::XInterface >          m_xChartView;
127     ::com::sun::star::uno::WeakReference<
128                         ::com::sun::star::awt::XWindow >            m_xWindow;
129     ::com::sun::star::uno::WeakReference<
130                        ::com::sun::star::accessibility::XAccessible > m_xParent;
131 
132     ::boost::shared_ptr< ObjectHierarchy >                          m_spObjectHierarchy;
133     AccessibleUniqueId                                              m_aCurrentSelectionOID;
134     SdrView*                                                        m_pSdrView;
135     ::accessibility::IAccessibleViewForwarder*                      m_pViewForwarder;
136 
137     //no default constructor
138     AccessibleChartView();
139 };
140 
141 //.............................................................................
142 } //namespace chart
143 //.............................................................................
144 #endif
145