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 
24 
25 #ifndef _SD_ACCESSIBILITY_ACCESSIBLE_PAGE_SHAPE_HXX
26 #define _SD_ACCESSIBILITY_ACCESSIBLE_PAGE_SHAPE_HXX
27 
28 #include <svx/AccessibleShape.hxx>
29 #include <svx/AccessibleShapeTreeInfo.hxx>
30 #include <svx/IAccessibleViewForwarderListener.hxx>
31 #include <com/sun/star/accessibility/XAccessible.hpp>
32 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/drawing/XDrawPage.hpp>
35 #include <com/sun/star/lang/XEventListener.hpp>
36 
37 #include <svx/AccessibleTextHelper.hxx>
38 
39 namespace accessibility {
40 
41 /** A page shape represents the actual page as seen on the screen.
42 */
43 class AccessiblePageShape
44     :	public AccessibleShape
45 {
46 public:
47 	//=====  internal  ========================================================
48 
49     /** Create a new accessible object that makes the given shape accessible.
50         @param rxParent
51             The accessible parent object.  It will be used, for example when
52             the <member>getIndexInParent</member> method is called.
53         @param rShapeTreeInfo
54             Bundel of information passed to this shape and all of its desendants.
55         @param nIndex
56             Index used to disambiguate between objects that have the same
57             name.  Passing a value of -1 leads to the use of the object's
58             z-order instead.  Because that is not a good substitute, better
59             pass an ever increasing counter.
60         @attention
61             Always call the <member>init</member> method after creating a
62             new accessible shape.  This is one way to overcome the potential
63             problem of registering the new object with e.g. event
64             broadcasters.  That would delete the new object if a broadcaster
65             would not keep a strong reference to the new object.
66     */
67 	AccessiblePageShape (
68         const ::com::sun::star::uno::Reference<
69             ::com::sun::star::drawing::XDrawPage>& rxPage,
70         const ::com::sun::star::uno::Reference<
71             ::com::sun::star::accessibility::XAccessible>& rxParent,
72         const AccessibleShapeTreeInfo& rShapeTreeInfo,
73         long nIndex = -1);
74 
75 	virtual ~AccessiblePageShape (void);
76 
77     /** Initialize a new shape.  See the documentation of the constructor
78         for the reason of this method's existence.
79     */
80     virtual void Init (void);
81 
82 	//=====  XAccessibleContext  ==============================================
83 
84     ///	Returns always 0 because there can be no children.
85     virtual sal_Int32 SAL_CALL
86     	getAccessibleChildCount (void)
87         throw ();
88 
89     /**	Return the specified child.
90         @param nIndex
91             Index of the requested child.
92         @return
93             Reference of the requested child which is the accessible object
94             of a visible shape.
95         @raises IndexOutOfBoundsException
96             Throws always an exception because there are no children.
97     */
98     virtual ::com::sun::star::uno::Reference<
99             ::com::sun::star::accessibility::XAccessible> SAL_CALL
100     	getAccessibleChild (sal_Int32 nIndex)
101         throw (::com::sun::star::uno::RuntimeException);
102 
103 
104     //=====  XAccessibleComponent  ============================================
105 
106     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
107         throw (::com::sun::star::uno::RuntimeException);
108 
109     virtual sal_Int32 SAL_CALL getForeground (void)
110         throw (::com::sun::star::uno::RuntimeException);
111 
112     virtual sal_Int32 SAL_CALL getBackground (void)
113         throw (::com::sun::star::uno::RuntimeException);
114 
115     //=====  XComponent  ======================================================
116 
117     virtual void SAL_CALL
118         dispose (void)
119         throw (::com::sun::star::uno::RuntimeException);
120 
121 
122 	//=====  XServiceInfo  ====================================================
123 
124 	virtual ::rtl::OUString SAL_CALL
125     	getImplementationName (void)
126 	    throw (::com::sun::star::uno::RuntimeException);
127 
128     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
129         getSupportedServiceNames (void)
130         throw (::com::sun::star::uno::RuntimeException);
131 
132 
133     //=====  lang::XEventListener  ============================================
134 
135     virtual void SAL_CALL
136         disposing (const ::com::sun::star::lang::EventObject& Source)
137         throw (::com::sun::star::uno::RuntimeException);
138 
139 
140 	using AccessibleShape::disposing;
141 
142 protected:
143     /**	Create a base name string that contains the accessible name.
144     */
145 	virtual ::rtl::OUString
146     	CreateAccessibleBaseName (void)
147         throw (::com::sun::star::uno::RuntimeException);
148 
149 	virtual ::rtl::OUString
150     	CreateAccessibleName (void)
151         throw (::com::sun::star::uno::RuntimeException);
152 
153     ///	Create a description string that contains the accessible description.
154 	virtual ::rtl::OUString
155     	CreateAccessibleDescription (void)
156         throw (::com::sun::star::uno::RuntimeException);
157 
158 private:
159     ::com::sun::star::uno::Reference<
160         ::com::sun::star::drawing::XDrawPage> mxPage;
161 
162     /** Don't use the default constructor.  Use the public constructor that
163         takes the original shape and the parent as arguments instead.
164     */
165     explicit AccessiblePageShape (void);
166     /// Don't use the copy constructor.  Is there any use for it?
167     explicit AccessiblePageShape (const AccessiblePageShape&);
168     /// Don't use the assignment operator.  Do we need this?
169     AccessibleShape& operator= (const AccessiblePageShape&);
170 };
171 
172 } // end of namespace accessibility
173 
174 #endif
175