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() 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() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : /** Set the current index in the accessibility parent
97 :
98 : @attention This method does not lock the SolarMutex,
99 : leaving that to the calling code. This is because only
100 : there potential deadlock situations can be resolved. Thus,
101 : make sure SolarMutex is locked when calling this.
102 : */
103 : void SetIndexInParent( sal_Int32 nIndex );
104 :
105 : /** Set the edit engine offset
106 :
107 : @attention This method does not lock the SolarMutex,
108 : leaving that to the calling code. This is because only
109 : there potential deadlock situations can be resolved. Thus,
110 : make sure SolarMutex is locked when calling this.
111 : */
112 : void SetEEOffset( const Point& rOffset );
113 :
114 : /** Set the EditEngine offset
115 :
116 : @attention This method does not lock the SolarMutex,
117 : leaving that to the calling code. This is because only
118 : there potential deadlock situations can be resolved. Thus,
119 : make sure SolarMutex is locked when calling this.
120 : */
121 : void SetEditSource( SvxEditSource* pEditSource );
122 :
123 : /** Dispose this object
124 :
125 : Notifies and deregisters the listeners, drops all references.
126 : */
127 : void Dispose();
128 :
129 : /** Set the current paragraph number
130 :
131 : @attention This method does not lock the SolarMutex,
132 : leaving that to the calling code. This is because only
133 : there potential deadlock situations can be resolved. Thus,
134 : make sure SolarMutex is locked when calling this.
135 : */
136 : void SetParagraphIndex( sal_Int32 nIndex );
137 :
138 : /** Query the current paragraph number (0 - nParas-1)
139 :
140 : @attention This method does not lock the SolarMutex,
141 : leaving that to the calling code. This is because only
142 : there potential deadlock situations can be resolved. Thus,
143 : make sure SolarMutex is locked when calling this.
144 : */
145 0 : sal_Int32 GetParagraphIndex() const { return mnParagraphIndex; }
146 :
147 : /// Calls all Listener objects to tell them the change. Don't hold locks when calling this!
148 : 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;
149 :
150 : private:
151 : AccessibleImageBullet( const AccessibleImageBullet& ) SAL_DELETED_FUNCTION;
152 : AccessibleImageBullet& operator= ( const AccessibleImageBullet& ) SAL_DELETED_FUNCTION;
153 :
154 : // syntactic sugar for FireEvent
155 : void GotPropertyEvent( const ::com::sun::star::uno::Any& rNewValue, const sal_Int16 nEventId ) const;
156 : void LostPropertyEvent( const ::com::sun::star::uno::Any& rOldValue, const sal_Int16 nEventId ) const;
157 :
158 : // maintain state set and send STATE_CHANGE events
159 : void SetState( const sal_Int16 nStateId );
160 : void UnSetState( const sal_Int16 nStateId );
161 :
162 : SvxEditSource& GetEditSource() const;
163 :
164 0 : int getNotifierClientId() const { return mnNotifierClientId; }
165 :
166 : /** Query the SvxTextForwarder for EditEngine access.
167 :
168 : @attention This method does not lock the SolarMutex,
169 : leaving that to the calling code. This is because only
170 : there potential deadlock situations can be resolved. Thus,
171 : make sure SolarMutex is locked when calling this.
172 : */
173 : SvxTextForwarder& GetTextForwarder() const;
174 :
175 : /** Query the SvxViewForwarder for EditEngine access.
176 :
177 : @attention This method does not lock the SolarMutex,
178 : leaving that to the calling code. This is because only
179 : there potential deadlock situations can be resolved. Thus,
180 : make sure SolarMutex is locked when calling this.
181 : */
182 : SvxViewForwarder& GetViewForwarder() const;
183 :
184 0 : const Point& GetEEOffset() const { return maEEOffset; }
185 :
186 : // the paragraph index in the edit engine (guarded by solar mutex)
187 : sal_Int32 mnParagraphIndex;
188 :
189 : // our current index in the parent (guarded by solar mutex)
190 : sal_Int32 mnIndexInParent;
191 :
192 : // the current edit source (guarded by solar mutex)
193 : SvxEditSource* mpEditSource;
194 :
195 : // the offset of the underlying EditEngine from the shape/cell (guarded by solar mutex)
196 : Point maEEOffset;
197 :
198 : // the current state set (updated from SetState/UnSetState and guarded by solar mutex)
199 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > mxStateSet;
200 :
201 : /// The shape we're the accessible for (unguarded)
202 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent;
203 :
204 : /// Our listeners (guarded by maMutex)
205 : int mnNotifierClientId;
206 : };
207 :
208 : } // end of namespace accessibility
209 :
210 : #endif
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|