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 : #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>
33 :
34 : #include <svx/AccessibleShape.hxx>
35 :
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>
41 : #include "Window.hxx"
42 : #include "ViewShell.hxx"
43 : #include "OutlineViewShell.hxx"
44 : #include "View.hxx"
45 : #include "AccessibleOutlineView.hxx"
46 : #include "AccessibleOutlineEditSource.hxx"
47 :
48 : #include <memory>
49 :
50 : #include "accessibility.hrc"
51 : #include "sdresid.hxx"
52 : #include <osl/mutex.hxx>
53 :
54 : using namespace ::com::sun::star;
55 : using namespace ::com::sun::star::accessibility;
56 :
57 : namespace accessibility {
58 :
59 :
60 : //===== internal ============================================================
61 :
62 0 : 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 0 : maTextHelper( ::std::auto_ptr< SvxEditSource >( NULL ) )
69 : {
70 0 : SolarMutexGuard aGuard;
71 :
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 0 : if( pViewShell && pSdWindow )
75 : {
76 0 : ::sd::View* pView = pViewShell->GetView();
77 :
78 0 : if (pView && pView->ISA(::sd::OutlineView))
79 : {
80 : OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>(
81 0 : pView)->GetViewByWindow( pSdWindow );
82 : SdrOutliner* pOutliner =
83 0 : static_cast< ::sd::OutlineView*>(pView)->GetOutliner();
84 :
85 0 : if( pOutlineView && pOutliner )
86 : {
87 : maTextHelper.SetEditSource( ::std::auto_ptr< SvxEditSource >( new AccessibleOutlineEditSource(
88 0 : *pOutliner, *pView, *pOutlineView, *pSdWindow ) ) );
89 : }
90 : }
91 0 : }
92 0 : }
93 :
94 :
95 0 : AccessibleOutlineView::~AccessibleOutlineView (void)
96 : {
97 : OSL_TRACE ("~AccessibleOutlineView");
98 0 : }
99 :
100 :
101 0 : void AccessibleOutlineView::Init (void)
102 : {
103 : // Set event source _before_ starting to listen
104 0 : maTextHelper.SetEventSource(this);
105 :
106 0 : AccessibleDocumentViewBase::Init ();
107 0 : }
108 :
109 :
110 0 : void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType,
111 : const IAccessibleViewForwarder* pViewForwarder)
112 : {
113 0 : AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
114 :
115 0 : UpdateChildren();
116 0 : }
117 :
118 :
119 : //===== XAccessibleContext ==================================================
120 :
121 : sal_Int32 SAL_CALL
122 0 : AccessibleOutlineView::getAccessibleChildCount (void)
123 : throw (uno::RuntimeException)
124 : {
125 0 : ThrowIfDisposed ();
126 :
127 : // forward
128 0 : return maTextHelper.GetChildCount();
129 : }
130 :
131 :
132 : uno::Reference<XAccessible> SAL_CALL
133 0 : AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex)
134 : throw (::com::sun::star::uno::RuntimeException)
135 : {
136 0 : ThrowIfDisposed ();
137 : // Forward request to children manager.
138 0 : return maTextHelper.GetChild(nIndex);
139 : }
140 :
141 : //===== XAccessibleEventBroadcaster ========================================
142 :
143 0 : void SAL_CALL AccessibleOutlineView::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
144 : {
145 : // delegate listener handling to children manager.
146 0 : if ( ! IsDisposed())
147 0 : maTextHelper.AddEventListener(xListener);
148 0 : }
149 :
150 0 : void SAL_CALL AccessibleOutlineView::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
151 : {
152 : // forward
153 0 : if ( ! IsDisposed())
154 0 : maTextHelper.RemoveEventListener(xListener);
155 0 : }
156 :
157 : //===== XServiceInfo ========================================================
158 :
159 : ::rtl::OUString SAL_CALL
160 0 : AccessibleOutlineView::getImplementationName (void)
161 : throw (::com::sun::star::uno::RuntimeException)
162 : {
163 0 : return ::rtl::OUString("AccessibleOutlineView");
164 : }
165 :
166 :
167 : //===== XEventListener ======================================================
168 :
169 : void SAL_CALL
170 0 : AccessibleOutlineView::disposing (const lang::EventObject& rEventObject)
171 : throw (::com::sun::star::uno::RuntimeException)
172 : {
173 0 : AccessibleDocumentViewBase::disposing (rEventObject);
174 0 : }
175 :
176 : //===== protected internal ==================================================
177 :
178 0 : void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent )
179 : {
180 : // delegate listener handling to children manager.
181 0 : maTextHelper.FireEvent(aEvent);
182 0 : }
183 :
184 0 : void AccessibleOutlineView::Activated (void)
185 : {
186 0 : SolarMutexGuard aGuard;
187 :
188 : // delegate listener handling to children manager.
189 0 : maTextHelper.SetFocus(sal_True);
190 0 : }
191 :
192 0 : void AccessibleOutlineView::Deactivated (void)
193 : {
194 0 : SolarMutexGuard aGuard;
195 :
196 : // delegate listener handling to children manager.
197 0 : maTextHelper.SetFocus(sal_False);
198 0 : }
199 :
200 0 : void SAL_CALL AccessibleOutlineView::disposing (void)
201 : {
202 : // dispose children
203 0 : maTextHelper.Dispose();
204 :
205 0 : AccessibleDocumentViewBase::disposing ();
206 0 : }
207 :
208 : //===== XPropertyChangeListener =============================================
209 :
210 : void SAL_CALL
211 0 : AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
212 : throw (::com::sun::star::uno::RuntimeException)
213 : {
214 0 : ThrowIfDisposed ();
215 :
216 0 : AccessibleDocumentViewBase::propertyChange (rEventObject);
217 :
218 : OSL_TRACE ("AccessibleOutlineView::propertyChange");
219 0 : if ( rEventObject.PropertyName == "CurrentPage" )
220 : {
221 : OSL_TRACE (" current page changed");
222 :
223 : // The current page changed. Update the children accordingly.
224 0 : UpdateChildren();
225 : }
226 0 : else if ( rEventObject.PropertyName == "VisibleArea" )
227 : {
228 : OSL_TRACE (" visible area changed");
229 :
230 : // The visible area changed. Update the children accordingly.
231 0 : UpdateChildren();
232 : }
233 : else
234 : {
235 : OSL_TRACE (" unhandled");
236 : }
237 : OSL_TRACE (" done");
238 0 : }
239 :
240 :
241 : /// Create a name for this view.
242 : ::rtl::OUString
243 0 : AccessibleOutlineView::CreateAccessibleName (void)
244 : throw (::com::sun::star::uno::RuntimeException)
245 : {
246 0 : SolarMutexGuard aGuard;
247 :
248 0 : return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N) );
249 : }
250 :
251 :
252 : /** Create a description for this view. Use the model's description or URL
253 : if a description is not available.
254 : */
255 : ::rtl::OUString
256 0 : AccessibleOutlineView::CreateAccessibleDescription (void)
257 : throw (::com::sun::star::uno::RuntimeException)
258 : {
259 0 : SolarMutexGuard aGuard;
260 :
261 0 : return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D) );
262 : }
263 :
264 0 : void AccessibleOutlineView::UpdateChildren()
265 : {
266 0 : SolarMutexGuard aGuard;
267 :
268 : // Update visible children
269 0 : maTextHelper.UpdateChildren();
270 0 : }
271 :
272 : } // end of namespace accessibility
273 :
274 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|