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 .
20 #include <com/sun/star/drawing/XDrawPage.hpp>
21 #include <com/sun/star/drawing/XDrawView.hpp>
22 #include <com/sun/star/drawing/XShapes.hpp>
23 #include <com/sun/star/container/XChild.hpp>
24 #include <com/sun/star/frame/XController.hpp>
25 #include <com/sun/star/frame/XFrame.hpp>
26 #include <com/sun/star/document/XEventBroadcaster.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <rtl/ustring.h>
32 #include<sfx2/viewfrm.hxx>
34 #include <svx/AccessibleShape.hxx>
36 #include <svx/svdobj.hxx>
37 #include <svx/svdmodel.hxx>
38 #include <svx/unoapi.hxx>
39 #include <toolkit/helper/vclunohelper.hxx>
40 #include <vcl/svapp.hxx>
42 #include "ViewShell.hxx"
43 #include "OutlineViewShell.hxx"
45 #include "AccessibleOutlineView.hxx"
46 #include "AccessibleOutlineEditSource.hxx"
50 #include "accessibility.hrc"
51 #include "sdresid.hxx"
52 #include <osl/mutex.hxx>
54 using namespace ::com::sun::star
;
55 using namespace ::com::sun::star::accessibility
;
57 namespace accessibility
{
60 //===== internal ============================================================
62 AccessibleOutlineView::AccessibleOutlineView (
63 ::sd::Window
* pSdWindow
,
64 ::sd::OutlineViewShell
* pViewShell
,
65 const uno::Reference
<frame::XController
>& rxController
,
66 const uno::Reference
<XAccessible
>& rxParent
)
67 : AccessibleDocumentViewBase (pSdWindow
, pViewShell
, rxController
, rxParent
),
68 maTextHelper( ::std::auto_ptr
< SvxEditSource
>( NULL
) )
70 SolarMutexGuard aGuard
;
72 // Beware! Here we leave the paths of the UNO API and descend into the
73 // depths of the core. Necessary for making the edit engine accessible.
74 if( pViewShell
&& pSdWindow
)
76 ::sd::View
* pView
= pViewShell
->GetView();
78 if (pView
&& pView
->ISA(::sd::OutlineView
))
80 OutlinerView
* pOutlineView
= static_cast< ::sd::OutlineView
*>(
81 pView
)->GetViewByWindow( pSdWindow
);
82 SdrOutliner
* pOutliner
=
83 static_cast< ::sd::OutlineView
*>(pView
)->GetOutliner();
85 if( pOutlineView
&& pOutliner
)
87 maTextHelper
.SetEditSource( ::std::auto_ptr
< SvxEditSource
>( new AccessibleOutlineEditSource(
88 *pOutliner
, *pView
, *pOutlineView
, *pSdWindow
) ) );
95 AccessibleOutlineView::~AccessibleOutlineView (void)
97 OSL_TRACE ("~AccessibleOutlineView");
101 void AccessibleOutlineView::Init (void)
103 // Set event source _before_ starting to listen
104 maTextHelper
.SetEventSource(this);
106 AccessibleDocumentViewBase::Init ();
110 void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType
,
111 const IAccessibleViewForwarder
* pViewForwarder
)
113 AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType
, pViewForwarder
);
119 //===== XAccessibleContext ==================================================
122 AccessibleOutlineView::getAccessibleChildCount (void)
123 throw (uno::RuntimeException
)
128 return maTextHelper
.GetChildCount();
132 uno::Reference
<XAccessible
> SAL_CALL
133 AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex
)
134 throw (::com::sun::star::uno::RuntimeException
)
137 // Forward request to children manager.
138 return maTextHelper
.GetChild(nIndex
);
141 //===== XAccessibleEventBroadcaster ========================================
143 void SAL_CALL
AccessibleOutlineView::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
145 // delegate listener handling to children manager.
147 maTextHelper
.AddEventListener(xListener
);
150 void SAL_CALL
AccessibleOutlineView::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
154 maTextHelper
.RemoveEventListener(xListener
);
157 //===== XServiceInfo ========================================================
160 AccessibleOutlineView::getImplementationName (void)
161 throw (::com::sun::star::uno::RuntimeException
)
163 return OUString("AccessibleOutlineView");
167 //===== XEventListener ======================================================
170 AccessibleOutlineView::disposing (const lang::EventObject
& rEventObject
)
171 throw (::com::sun::star::uno::RuntimeException
)
173 AccessibleDocumentViewBase::disposing (rEventObject
);
176 //===== protected internal ==================================================
178 void AccessibleOutlineView::FireEvent(const AccessibleEventObject
& aEvent
)
180 // delegate listener handling to children manager.
181 maTextHelper
.FireEvent(aEvent
);
184 void AccessibleOutlineView::Activated (void)
186 SolarMutexGuard aGuard
;
188 // delegate listener handling to children manager.
189 maTextHelper
.SetFocus(sal_True
);
192 void AccessibleOutlineView::Deactivated (void)
194 SolarMutexGuard aGuard
;
196 // delegate listener handling to children manager.
197 maTextHelper
.SetFocus(sal_False
);
200 void SAL_CALL
AccessibleOutlineView::disposing (void)
203 maTextHelper
.Dispose();
205 AccessibleDocumentViewBase::disposing ();
208 //===== XPropertyChangeListener =============================================
211 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent
& rEventObject
)
212 throw (::com::sun::star::uno::RuntimeException
)
216 AccessibleDocumentViewBase::propertyChange (rEventObject
);
218 OSL_TRACE ("AccessibleOutlineView::propertyChange");
219 if ( rEventObject
.PropertyName
== "CurrentPage" )
221 OSL_TRACE (" current page changed");
223 // The current page changed. Update the children accordingly.
226 else if ( rEventObject
.PropertyName
== "VisibleArea" )
228 OSL_TRACE (" visible area changed");
230 // The visible area changed. Update the children accordingly.
235 OSL_TRACE (" unhandled");
241 /// Create a name for this view.
243 AccessibleOutlineView::CreateAccessibleName (void)
244 throw (::com::sun::star::uno::RuntimeException
)
246 SolarMutexGuard aGuard
;
248 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N
) );
252 /** Create a description for this view. Use the model's description or URL
253 if a description is not available.
256 AccessibleOutlineView::CreateAccessibleDescription (void)
257 throw (::com::sun::star::uno::RuntimeException
)
259 SolarMutexGuard aGuard
;
261 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D
) );
264 void AccessibleOutlineView::UpdateChildren()
266 SolarMutexGuard aGuard
;
268 // Update visible children
269 maTextHelper
.UpdateChildren();
272 } // end of namespace accessibility
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */