Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef THUMBNAILVIEWACC_HXX
30 : : #define THUMBNAILVIEWACC_HXX
31 : :
32 : : #include <osl/mutex.hxx>
33 : : #include <cppuhelper/implbase5.hxx>
34 : : #include <cppuhelper/compbase6.hxx>
35 : : #include <comphelper/broadcasthelper.hxx>
36 : :
37 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
38 : : #include <com/sun/star/accessibility/XAccessible.hpp>
39 : : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
40 : : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
41 : : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
42 : : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
43 : : #include <com/sun/star/lang/DisposedException.hpp>
44 : :
45 : : #include <vector>
46 : :
47 : : class ThumbnailView;
48 : : class ThumbnailViewItem;
49 : :
50 : : typedef ::cppu::PartialWeakComponentImplHelper6<
51 : : ::com::sun::star::accessibility::XAccessible,
52 : : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
53 : : ::com::sun::star::accessibility::XAccessibleContext,
54 : : ::com::sun::star::accessibility::XAccessibleComponent,
55 : : ::com::sun::star::accessibility::XAccessibleSelection,
56 : : ::com::sun::star::lang::XUnoTunnel >
57 : : ValueSetAccComponentBase;
58 : :
59 : : class ThumbnailViewAcc :
60 : : public ::comphelper::OBaseMutex,
61 : : public ValueSetAccComponentBase
62 : : {
63 : : public:
64 : :
65 : : ThumbnailViewAcc( ThumbnailView* pParent, bool bIsTransientChildrenDisabled );
66 : : ~ThumbnailViewAcc();
67 : :
68 : : void FireAccessibleEvent( short nEventId,
69 : : const ::com::sun::star::uno::Any& rOldValue,
70 : : const ::com::sun::star::uno::Any& rNewValue );
71 : :
72 : 0 : sal_Bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
73 : :
74 : : static ThumbnailViewAcc* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
75 : :
76 : : public:
77 : :
78 : : /** Called by the corresponding ValueSet when it gets the focus.
79 : : Stores the new focus state and broadcasts a state change event.
80 : : */
81 : : void GetFocus (void);
82 : :
83 : : /** Called by the corresponding ValueSet when it loses the focus.
84 : : Stores the new focus state and broadcasts a state change event.
85 : : */
86 : : void LoseFocus (void);
87 : :
88 : : // XComponent
89 : 0 : virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
90 : 0 : { WeakComponentImplHelperBase::dispose(); }
91 : 0 : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
92 : 0 : { WeakComponentImplHelperBase::addEventListener(xListener); }
93 : 0 : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
94 : 0 : { WeakComponentImplHelperBase::removeEventListener(xListener); }
95 : :
96 : : // XAccessible
97 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
98 : :
99 : : // XAccessibleEventBroadcaster
100 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
101 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
102 : :
103 : : // XAccessibleContext
104 : : virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
105 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
106 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
107 : : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
108 : : virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
109 : : virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
110 : : virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
111 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
112 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
113 : : virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
114 : :
115 : : // XAccessibleComponent
116 : : virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
117 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
118 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
119 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
120 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
121 : : virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
122 : : virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
123 : : virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
124 : : virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
125 : : virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
126 : :
127 : : // XAccessibleSelection
128 : : virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
129 : : virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
130 : : virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException);
131 : : virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException);
132 : : virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
133 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
134 : : virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
135 : :
136 : : // XUnoTunnel
137 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
138 : :
139 : : private:
140 : : ::std::vector< ::com::sun::star::uno::Reference<
141 : : ::com::sun::star::accessibility::XAccessibleEventListener > > mxEventListeners;
142 : : ThumbnailView* mpParent;
143 : : bool mbIsTransientChildrenDisabled;
144 : : /// The current FOCUSED state.
145 : : bool mbIsFocused;
146 : :
147 : : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
148 : :
149 : : /** Tell all listeners that the object is dying. This callback is
150 : : usually called from the WeakComponentImplHelper class.
151 : : */
152 : : virtual void SAL_CALL disposing (void);
153 : :
154 : : /** Return the number of items. This takes the None-Item into account.
155 : : */
156 : : sal_uInt16 getItemCount (void) const;
157 : :
158 : : /** Return the item associated with the given index. The None-Item is
159 : : taken into account which, when present, is taken to be the first
160 : : (with index 0) item.
161 : : @param nIndex
162 : : Index of the item to return. The index 0 denotes the None-Item
163 : : when present.
164 : : @return
165 : : Returns NULL when the given index is out of range.
166 : : */
167 : : ThumbnailViewItem* getItem (sal_uInt16 nIndex) const;
168 : :
169 : : /** Check whether or not the object has been disposed (or is in the
170 : : state of beeing disposed). If that is the case then
171 : : DisposedException is thrown to inform the (indirect) caller of the
172 : : foul deed.
173 : : */
174 : : void ThrowIfDisposed (void)
175 : : throw (::com::sun::star::lang::DisposedException);
176 : : };
177 : :
178 : : class ThumbnailViewItemAcc : public ::cppu::WeakImplHelper5< ::com::sun::star::accessibility::XAccessible,
179 : : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
180 : : ::com::sun::star::accessibility::XAccessibleContext,
181 : : ::com::sun::star::accessibility::XAccessibleComponent,
182 : : ::com::sun::star::lang::XUnoTunnel >
183 : : {
184 : : private:
185 : :
186 : : ::std::vector< ::com::sun::star::uno::Reference<
187 : : ::com::sun::star::accessibility::XAccessibleEventListener > > mxEventListeners;
188 : : ::osl::Mutex maMutex;
189 : : ThumbnailViewItem* mpParent;
190 : : bool mbIsTransientChildrenDisabled;
191 : :
192 : : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
193 : :
194 : : public:
195 : :
196 : : ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled );
197 : : ~ThumbnailViewItemAcc();
198 : :
199 : : void ParentDestroyed();
200 : :
201 : : void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
202 : : sal_Bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
203 : :
204 : : static ThumbnailViewItemAcc* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
205 : :
206 : : public:
207 : :
208 : : // XAccessible
209 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
210 : :
211 : : // XAccessibleEventBroadcaster
212 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
213 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
214 : :
215 : : // XAccessibleContext
216 : : virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
217 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
218 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
219 : : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
220 : : virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
221 : : virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
222 : : virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
223 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
224 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
225 : : virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
226 : :
227 : : // XAccessibleComponent
228 : : virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
229 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
230 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
231 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
232 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
233 : : virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
234 : : virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
235 : : virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
236 : : virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
237 : : virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
238 : :
239 : : // XUnoTunnel
240 : : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
241 : : };
242 : :
243 : : #endif // THUMBNAILVIEWACC_HXX
244 : :
245 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|