Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_EDITENG_ACCESSIBLEIMAGEBULLET_HXX
21 : #define INCLUDED_EDITENG_ACCESSIBLEIMAGEBULLET_HXX
22 :
23 : #include <tools/gen.hxx>
24 : #include <cppuhelper/weakref.hxx>
25 : #include <cppuhelper/implbase5.hxx>
26 :
27 : #include <cppuhelper/interfacecontainer.hxx>
28 : #include <com/sun/star/uno/Reference.hxx>
29 : #include <com/sun/star/lang/XServiceInfo.hpp>
30 : #include <com/sun/star/accessibility/XAccessible.hpp>
31 : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
32 : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
33 : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
34 : #include <editeng/AccessibleParaManager.hxx>
35 : #include <editeng/unoedsrc.hxx>
36 :
37 : namespace accessibility
38 : {
39 : typedef ::cppu::WeakImplHelper5< ::com::sun::star::accessibility::XAccessible,
40 : ::com::sun::star::accessibility::XAccessibleContext,
41 : ::com::sun::star::accessibility::XAccessibleComponent,
42 : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
43 : ::com::sun::star::lang::XServiceInfo > AccessibleImageBulletInterfaceBase;
44 :
45 : /** This class implements the image bullets for the EditEngine/Outliner UAA
46 : */
47 : class AccessibleImageBullet : public AccessibleImageBulletInterfaceBase
48 : {
49 :
50 : public:
51 : /// Create accessible object for given parent
52 : AccessibleImageBullet ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rParent );
53 :
54 : virtual ~AccessibleImageBullet ();
55 :
56 : // XInterface
57 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface (const ::com::sun::star::uno::Type & rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
58 :
59 : // XAccessible
60 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
61 :
62 : // XAccessibleContext
63 : virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
64 : 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, std::exception) SAL_OVERRIDE;
65 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 : virtual sal_Int16 SAL_CALL getAccessibleRole() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 : /// Maximal length of text returned by getAccessibleDescription()
69 : enum { MaxDescriptionLen = 40 };
70 : virtual OUString SAL_CALL getAccessibleDescription() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 : virtual OUString SAL_CALL getAccessibleName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 :
76 : // XAccessibleEventBroadcaster
77 : virtual void SAL_CALL addAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 : virtual void SAL_CALL removeAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 :
80 : // XAccessibleComponent
81 : virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 : 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, std::exception) SAL_OVERRIDE;
83 : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 : virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 : virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 : virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 : virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 :
91 : // XServiceInfo
92 : virtual OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 : virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : // XServiceName
97 : virtual OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException);
98 :
99 : /** Set the current index in the accessibility parent
100 :
101 : @attention This method does not lock the SolarMutex,
102 : leaving that to the calling code. This is because only
103 : there potential deadlock situations can be resolved. Thus,
104 : make sure SolarMutex is locked when calling this.
105 : */
106 : void SetIndexInParent( sal_Int32 nIndex );
107 :
108 : /** Set the edit engine offset
109 :
110 : @attention This method does not lock the SolarMutex,
111 : leaving that to the calling code. This is because only
112 : there potential deadlock situations can be resolved. Thus,
113 : make sure SolarMutex is locked when calling this.
114 : */
115 : void SetEEOffset( const Point& rOffset );
116 :
117 : /** Set the EditEngine offset
118 :
119 : @attention This method does not lock the SolarMutex,
120 : leaving that to the calling code. This is because only
121 : there potential deadlock situations can be resolved. Thus,
122 : make sure SolarMutex is locked when calling this.
123 : */
124 : void SetEditSource( SvxEditSource* pEditSource );
125 :
126 : /** Dispose this object
127 :
128 : Notifies and deregisters the listeners, drops all references.
129 : */
130 : void Dispose();
131 :
132 : /** Set the current paragraph number
133 :
134 : @attention This method does not lock the SolarMutex,
135 : leaving that to the calling code. This is because only
136 : there potential deadlock situations can be resolved. Thus,
137 : make sure SolarMutex is locked when calling this.
138 : */
139 : void SetParagraphIndex( sal_Int32 nIndex );
140 :
141 : /** Query the current paragraph number (0 - nParas-1)
142 :
143 : @attention This method does not lock the SolarMutex,
144 : leaving that to the calling code. This is because only
145 : there potential deadlock situations can be resolved. Thus,
146 : make sure SolarMutex is locked when calling this.
147 : */
148 0 : sal_Int32 GetParagraphIndex() const { return mnParagraphIndex; }
149 :
150 : /// Calls all Listener objects to tell them the change. Don't hold locks when calling this!
151 : virtual void FireEvent(const sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue = ::com::sun::star::uno::Any(), const ::com::sun::star::uno::Any& rOldValue = ::com::sun::star::uno::Any() ) const;
152 :
153 : private:
154 :
155 : // declared, but not defined
156 : AccessibleImageBullet( const AccessibleImageBullet& );
157 : AccessibleImageBullet& operator= ( const AccessibleImageBullet& );
158 :
159 : // syntactic sugar for FireEvent
160 : void GotPropertyEvent( const ::com::sun::star::uno::Any& rNewValue, const sal_Int16 nEventId ) const;
161 : void LostPropertyEvent( const ::com::sun::star::uno::Any& rOldValue, const sal_Int16 nEventId ) const;
162 :
163 : // maintain state set and send STATE_CHANGE events
164 : void SetState( const sal_Int16 nStateId );
165 : void UnSetState( const sal_Int16 nStateId );
166 :
167 : SvxEditSource& GetEditSource() const;
168 :
169 0 : int getNotifierClientId() const { return mnNotifierClientId; }
170 :
171 : /** Query the SvxTextForwarder for EditEngine access.
172 :
173 : @attention This method does not lock the SolarMutex,
174 : leaving that to the calling code. This is because only
175 : there potential deadlock situations can be resolved. Thus,
176 : make sure SolarMutex is locked when calling this.
177 : */
178 : SvxTextForwarder& GetTextForwarder() const;
179 :
180 : /** Query the SvxViewForwarder for EditEngine access.
181 :
182 : @attention This method does not lock the SolarMutex,
183 : leaving that to the calling code. This is because only
184 : there potential deadlock situations can be resolved. Thus,
185 : make sure SolarMutex is locked when calling this.
186 : */
187 : SvxViewForwarder& GetViewForwarder() const;
188 :
189 0 : const Point& GetEEOffset() const { return maEEOffset; }
190 :
191 : // the paragraph index in the edit engine (guarded by solar mutex)
192 : sal_Int32 mnParagraphIndex;
193 :
194 : // our current index in the parent (guarded by solar mutex)
195 : sal_Int32 mnIndexInParent;
196 :
197 : // the current edit source (guarded by solar mutex)
198 : SvxEditSource* mpEditSource;
199 :
200 : // the offset of the underlying EditEngine from the shape/cell (guarded by solar mutex)
201 : Point maEEOffset;
202 :
203 : // the current state set (updated from SetState/UnSetState and guarded by solar mutex)
204 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > mxStateSet;
205 :
206 : mutable osl::Mutex maMutex;
207 :
208 : /// The shape we're the accessible for (unguarded)
209 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent;
210 :
211 : /// Our listeners (guarded by maMutex)
212 : int mnNotifierClientId;
213 : };
214 :
215 : } // end of namespace accessibility
216 :
217 : #endif
218 :
219 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|