1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleOutlineView.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <com/sun/star/drawing/XDrawPage.hpp>
34 #include <com/sun/star/drawing/XDrawView.hpp>
35 #include <com/sun/star/drawing/XShapes.hpp>
36 #include <com/sun/star/container/XChild.hpp>
37 #include <com/sun/star/frame/XController.hpp>
38 #include <com/sun/star/frame/XFrame.hpp>
39 #include <com/sun/star/document/XEventBroadcaster.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #ifndef _COM_SUN_STAR_ACCESSIBLE_ACCESSIBLEEVENTID_HPP_
42 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
44 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
45 #ifndef _COM_SUN_STAR_LANG_XMULSTISERVICEFACTORY_HPP_
46 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <rtl/ustring.h>
50 #include<sfx2/viewfrm.hxx>
53 #include <svx/AccessibleShape.hxx>
55 #include <svx/svdobj.hxx>
56 #include <svx/svdmodel.hxx>
57 #include <svx/unoapi.hxx>
58 #include <toolkit/helper/vclunohelper.hxx>
59 #include <vcl/svapp.hxx>
61 #include "ViewShell.hxx"
62 #include "OutlineViewShell.hxx"
64 #include "AccessibleOutlineView.hxx"
65 #include "AccessibleOutlineEditSource.hxx"
69 #include "accessibility.hrc"
70 #include "sdresid.hxx"
71 #include <vos/mutex.hxx>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::accessibility
;
76 namespace accessibility
{
79 //===== internal ============================================================
81 AccessibleOutlineView::AccessibleOutlineView (
82 ::sd::Window
* pSdWindow
,
83 ::sd::OutlineViewShell
* pViewShell
,
84 const uno::Reference
<frame::XController
>& rxController
,
85 const uno::Reference
<XAccessible
>& rxParent
)
86 : AccessibleDocumentViewBase (pSdWindow
, pViewShell
, rxController
, rxParent
),
87 maTextHelper( ::std::auto_ptr
< SvxEditSource
>( NULL
) )
89 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
91 // Beware! Here we leave the paths of the UNO API and descend into the
92 // depths of the core. Necessary for making the edit engine accessible.
93 if( pViewShell
&& pSdWindow
)
95 ::sd::View
* pView
= pViewShell
->GetView();
97 if (pView
&& pView
->ISA(::sd::OutlineView
))
99 OutlinerView
* pOutlineView
= static_cast< ::sd::OutlineView
*>(
100 pView
)->GetViewByWindow( pSdWindow
);
101 SdrOutliner
* pOutliner
=
102 static_cast< ::sd::OutlineView
*>(pView
)->GetOutliner();
104 if( pOutlineView
&& pOutliner
)
106 maTextHelper
.SetEditSource( ::std::auto_ptr
< SvxEditSource
>( new AccessibleOutlineEditSource(
107 *pOutliner
, *pView
, *pOutlineView
, *pSdWindow
) ) );
114 AccessibleOutlineView::~AccessibleOutlineView (void)
116 OSL_TRACE ("~AccessibleOutlineView");
120 void AccessibleOutlineView::Init (void)
122 // #105479# Set event source _before_ starting to listen
123 maTextHelper
.SetEventSource(this);
125 AccessibleDocumentViewBase::Init ();
129 void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType
,
130 const IAccessibleViewForwarder
* pViewForwarder
)
132 AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType
, pViewForwarder
);
138 //===== XAccessibleContext ==================================================
141 AccessibleOutlineView::getAccessibleChildCount (void)
142 throw (uno::RuntimeException
)
147 return maTextHelper
.GetChildCount();
151 uno::Reference
<XAccessible
> SAL_CALL
152 AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex
)
153 throw (::com::sun::star::uno::RuntimeException
)
156 // Forward request to children manager.
157 return maTextHelper
.GetChild(nIndex
);
160 //===== XAccessibleEventBroadcaster ========================================
162 void SAL_CALL
AccessibleOutlineView::addEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
164 // delegate listener handling to children manager.
166 maTextHelper
.AddEventListener(xListener
);
169 void SAL_CALL
AccessibleOutlineView::removeEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
173 maTextHelper
.RemoveEventListener(xListener
);
176 //===== XServiceInfo ========================================================
178 ::rtl::OUString SAL_CALL
179 AccessibleOutlineView::getImplementationName (void)
180 throw (::com::sun::star::uno::RuntimeException
)
182 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOutlineView"));
186 //===== XEventListener ======================================================
189 AccessibleOutlineView::disposing (const lang::EventObject
& rEventObject
)
190 throw (::com::sun::star::uno::RuntimeException
)
192 AccessibleDocumentViewBase::disposing (rEventObject
);
195 //===== protected internal ==================================================
197 void AccessibleOutlineView::FireEvent(const AccessibleEventObject
& aEvent
)
199 // delegate listener handling to children manager.
200 maTextHelper
.FireEvent(aEvent
);
203 void AccessibleOutlineView::Activated (void)
205 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
207 // delegate listener handling to children manager.
208 maTextHelper
.SetFocus(sal_True
);
211 void AccessibleOutlineView::Deactivated (void)
213 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
215 // delegate listener handling to children manager.
216 maTextHelper
.SetFocus(sal_False
);
219 void SAL_CALL
AccessibleOutlineView::disposing (void)
222 maTextHelper
.Dispose();
224 AccessibleDocumentViewBase::disposing ();
227 //===== XPropertyChangeListener =============================================
230 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent
& rEventObject
)
231 throw (::com::sun::star::uno::RuntimeException
)
235 AccessibleDocumentViewBase::propertyChange (rEventObject
);
237 OSL_TRACE ("AccessibleOutlineView::propertyChange");
238 if (rEventObject
.PropertyName
== ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage")))
240 OSL_TRACE (" current page changed");
242 // The current page changed. Update the children accordingly.
245 else if (rEventObject
.PropertyName
== ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea")))
247 OSL_TRACE (" visible area changed");
249 // The visible area changed. Update the children accordingly.
254 OSL_TRACE (" unhandled");
260 /// Create a name for this view.
262 AccessibleOutlineView::CreateAccessibleName (void)
263 throw (::com::sun::star::uno::RuntimeException
)
265 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
267 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N
) );
271 /** Create a description for this view. Use the model's description or URL
272 if a description is not available.
275 AccessibleOutlineView::CreateAccessibleDescription (void)
276 throw (::com::sun::star::uno::RuntimeException
)
278 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
280 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D
) );
283 void AccessibleOutlineView::UpdateChildren()
285 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
287 // Update visible children
288 maTextHelper
.UpdateChildren();
291 } // end of namespace accessibility