1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #ifndef _SVXGRAPHACCESSIBLECONTEXT_HXX
22 #define _SVXGRAPHACCESSIBLECONTEXT_HXX
24 #include <cppuhelper/compbase7.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/accessibility/XAccessible.hpp>
27 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
28 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
29 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
30 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
31 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
32 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
33 #include <cppuhelper/weak.hxx>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/lang/XServiceName.hpp>
37 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
38 #include <osl/mutex.hxx>
39 #include <comphelper/broadcasthelper.hxx>
40 #include <svl/lstner.hxx>
45 #include <comphelper/servicehelper.hxx>
46 #include <svx/rectenum.hxx>
47 #include <svx/AccessibleShapeTreeInfo.hxx>
48 #include <svx/IAccessibleViewForwarder.hxx>
49 #include <svx/AccessibleShape.hxx>
51 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
66 This base class provides an implementation of the
67 <code>AccessibleContext</code> service.
70 typedef ::cppu::WeakAggComponentImplHelper7
<
71 ::com::sun::star::accessibility::XAccessible
,
72 ::com::sun::star::accessibility::XAccessibleComponent
,
73 ::com::sun::star::accessibility::XAccessibleContext
,
74 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
75 ::com::sun::star::accessibility::XAccessibleSelection
,
76 ::com::sun::star::lang::XServiceInfo
,
77 ::com::sun::star::lang::XServiceName
>
78 SvxGraphCtrlAccessibleContext_Base
;
80 class SvxGraphCtrlAccessibleContext
: public SvxGraphCtrlAccessibleContext_Base
, ::comphelper::OBaseMutex
, SfxListener
, ::accessibility::IAccessibleViewForwarder
83 friend class GraphCtrl
;
85 //===== internal ========================================================
86 SvxGraphCtrlAccessibleContext(
87 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& rxParent
,
88 GraphCtrl
& rRepresentation
,
89 const OUString
* pName
= NULL
,
90 const OUString
* pDescription
= NULL
);
92 void Notify( SfxBroadcaster
& aBC
, const SfxHint
& aHint
);
95 virtual ~SvxGraphCtrlAccessibleContext();
97 //===== XAccessible =====================================================
99 /// Return the XAccessibleContext.
100 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
101 getAccessibleContext (void) throw (::com::sun::star::uno::RuntimeException
);
103 //===== XAccessibleComponent ============================================
105 virtual sal_Bool SAL_CALL
containsPoint( const ::com::sun::star::awt::Point
& rPoint
) throw (::com::sun::star::uno::RuntimeException
);
106 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const ::com::sun::star::awt::Point
& rPoint
) throw (::com::sun::star::uno::RuntimeException
);
107 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds() throw (::com::sun::star::uno::RuntimeException
);
108 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation() throw (::com::sun::star::uno::RuntimeException
);
109 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException
);
110 virtual ::com::sun::star::awt::Size SAL_CALL
getSize() throw (::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
addFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
removeFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
113 virtual void SAL_CALL
grabFocus() throw (::com::sun::star::uno::RuntimeException
);
114 virtual ::com::sun::star::uno::Any SAL_CALL
getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException
);
116 virtual sal_Int32 SAL_CALL
getForeground (void)
117 throw (::com::sun::star::uno::RuntimeException
);
119 virtual sal_Int32 SAL_CALL
getBackground (void)
120 throw (::com::sun::star::uno::RuntimeException
);
123 //===== XAccessibleContext ==============================================
125 virtual sal_Int32 SAL_CALL
getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException
);
126 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleChild (sal_Int32 nIndex
) throw (::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IndexOutOfBoundsException
);
127 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException
);
128 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException
);
129 virtual sal_Int16 SAL_CALL
getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException
);
130 virtual OUString SAL_CALL
getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException
);
131 virtual OUString SAL_CALL
getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException
);
132 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException
);
133 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException
);
134 virtual ::com::sun::star::lang::Locale SAL_CALL
getLocale (void) throw (::com::sun::star::uno::RuntimeException
, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
135 // virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
136 // virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
138 //===== XAccessibleEventBroadcaster =====================================
140 virtual void SAL_CALL
addAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
removeAccessibleEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
) throw (com::sun::star::uno::RuntimeException
);
143 //===== XServiceInfo ====================================================
145 virtual OUString SAL_CALL
getImplementationName (void) throw (::com::sun::star::uno::RuntimeException
);
146 virtual sal_Bool SAL_CALL
supportsService (const OUString
& sServiceName
) throw (::com::sun::star::uno::RuntimeException
);
147 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException
);
149 //===== XTypeProvider ===================================================
151 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
getImplementationId (void) throw (::com::sun::star::uno::RuntimeException
);
153 //===== XServiceName ====================================================
155 virtual OUString SAL_CALL
getServiceName (void) throw (::com::sun::star::uno::RuntimeException
);
157 //===== XAccessibleSelection =============================================
159 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
160 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
161 virtual void SAL_CALL
clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException
);
162 virtual void SAL_CALL
selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException
);
163 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException
);
164 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
);
165 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
167 //===== IAccessibleViewforwarder ========================================
169 virtual sal_Bool
IsValid (void) const;
170 virtual Rectangle
GetVisibleArea() const;
171 virtual Point
LogicToPixel (const Point
& rPoint
) const;
172 virtual Size
LogicToPixel (const Size
& rSize
) const;
173 virtual Point
PixelToLogic (const Point
& rPoint
) const;
174 virtual Size
PixelToLogic (const Size
& rSize
) const;
177 //===== internals ========================================================
179 void checkChildIndexOnSelection( long nIndexOfChild
) throw (::com::sun::star::lang::IndexOutOfBoundsException
);
183 /** This method is used by the graph control to tell the
184 accessibility object about a new model and view.
186 void setModelAndView (SdrModel
* pModel
, SdrView
* pView
);
189 static ::com::sun::star::uno::Sequence
< sal_Int8
> getUniqueId( void );
192 /** Return the object's current bounding box relative to the desktop,
193 i.e in absolute pixel coordinates.
195 The returned rectangle is a bounding box of the object given in
196 absolute screen coordinates.
197 @raise DisposedException
198 When the object is already disposed then a
199 <type>DisposedException</type> is thrown.
201 virtual Rectangle
GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException
);
203 /// Return the object's current bounding box relative to the parent object.
204 virtual Rectangle
GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException
);
206 virtual void SAL_CALL
disposing();
209 SdrObject
* getSdrObject( sal_Int32 nIndex
)
210 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IndexOutOfBoundsException
);
212 void CommitChange (sal_Int16 aEventId
, const ::com::sun::star::uno::Any
& rNewValue
, const ::com::sun::star::uno::Any
& rOldValue
);
213 void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
);
215 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessible( const SdrObject
* pObj
);
217 accessibility::AccessibleShapeTreeInfo maTreeInfo
;
219 /// Reference to the parent object.
220 ::com::sun::star::uno::Reference
<
221 ::com::sun::star::accessibility::XAccessible
> mxParent
;
223 /** Description of this object. This is not a constant because it can
224 be set from the outside.
226 OUString msDescription
;
228 /** Name of this object.
232 /// map of accessible shapes
233 struct SdrObjectCompareLess
235 bool operator()(const SdrObject
* p1
, const SdrObject
* p2
) const
240 typedef ::std::map
< const SdrObject
*, ::accessibility::AccessibleShape
*, SdrObjectCompareLess
> ShapesMapType
;
241 ShapesMapType mxShapes
;
243 GraphCtrl
* mpControl
;
249 /// client id in the AccessibleEventNotifier queue
250 sal_uInt32 mnClientId
;
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */