Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "AccessibleDrawDocumentView.hxx"
30 : : #include <com/sun/star/drawing/XDrawPage.hpp>
31 : : #include <com/sun/star/drawing/XDrawView.hpp>
32 : : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
33 : : #include <com/sun/star/drawing/XShapes.hpp>
34 : : #include <com/sun/star/container/XChild.hpp>
35 : : #include <com/sun/star/frame/XController.hpp>
36 : : #include <com/sun/star/frame/XFrame.hpp>
37 : : #include <com/sun/star/document/XEventBroadcaster.hpp>
38 : : #include <com/sun/star/beans/XPropertySet.hpp>
39 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
40 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 : : #include <rtl/ustring.h>
43 : : #include<sfx2/viewfrm.hxx>
44 : :
45 : : #include <svx/AccessibleShape.hxx>
46 : :
47 : : #include <svx/svdobj.hxx>
48 : : #include <svx/svdmodel.hxx>
49 : : #include <svx/unoapi.hxx>
50 : : #include <svx/unoshcol.hxx>
51 : : #include <toolkit/helper/vclunohelper.hxx>
52 : : #include "Window.hxx"
53 : : #include <vcl/svapp.hxx>
54 : :
55 : :
56 : : #include "ViewShell.hxx"
57 : : #include "View.hxx"
58 : : #include <memory>
59 : :
60 : : #include "accessibility.hrc"
61 : : #include "sdresid.hxx"
62 : : #include <osl/mutex.hxx>
63 : :
64 : : using ::rtl::OUString;
65 : : using namespace ::com::sun::star;
66 : : using namespace ::com::sun::star::uno;
67 : : using namespace ::com::sun::star::accessibility;
68 : :
69 : : namespace accessibility {
70 : :
71 : :
72 : : //===== internal ============================================================
73 : :
74 : 6 : AccessibleDrawDocumentView::AccessibleDrawDocumentView (
75 : : ::sd::Window* pSdWindow,
76 : : ::sd::ViewShell* pViewShell,
77 : : const uno::Reference<frame::XController>& rxController,
78 : : const uno::Reference<XAccessible>& rxParent)
79 : : : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
80 : 6 : mpChildrenManager (NULL)
81 : : {
82 : : OSL_TRACE ("AccessibleDrawDocumentView");
83 [ + - ]: 6 : UpdateAccessibleName();
84 : 6 : }
85 : :
86 : :
87 : :
88 : :
89 : 6 : AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void)
90 : : {
91 : : OSL_TRACE ("~AccessibleDrawDocumentView");
92 : : DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
93 : : "~AccessibleDrawDocumentView: object has not been disposed");
94 [ - + ]: 12 : }
95 : :
96 : :
97 : :
98 : :
99 : 6 : void AccessibleDrawDocumentView::Init (void)
100 : : {
101 [ + - ]: 6 : AccessibleDocumentViewBase::Init ();
102 : :
103 : : // Determine the list of shapes on the current page.
104 : 6 : uno::Reference<drawing::XShapes> xShapeList;
105 [ + - ]: 6 : uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
106 [ + - ]: 6 : if (xView.is())
107 : : xShapeList = uno::Reference<drawing::XShapes> (
108 [ + - ][ + - ]: 6 : xView->getCurrentPage(), uno::UNO_QUERY);
[ + - ][ + - ]
109 : :
110 : : // Create the children manager.
111 [ + - ][ + - ]: 6 : mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
[ + - ]
112 [ + - ]: 6 : if (mpChildrenManager != NULL)
113 : : {
114 : : // Create the page shape and initialize it. The shape is acquired
115 : : // before initialization and released after transferring ownership
116 : : // to the children manager to prevent premature disposing of the
117 : : // shape.
118 [ + - ]: 6 : AccessiblePageShape* pPage = CreateDrawPageShape();
119 [ + - ]: 6 : if (pPage != NULL)
120 : : {
121 : 6 : pPage->acquire();
122 [ + - ]: 6 : pPage->Init();
123 : : mpChildrenManager->AddAccessibleShape (
124 [ + - ][ + - ]: 6 : std::auto_ptr<AccessibleShape>(pPage));
[ + - ]
125 : 6 : pPage->release();
126 [ + - ]: 6 : mpChildrenManager->Update ();
127 : : }
128 [ + - ]: 6 : mpChildrenManager->UpdateSelection ();
129 : 6 : }
130 : 6 : }
131 : :
132 : :
133 : :
134 : :
135 : 0 : void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
136 : : const IAccessibleViewForwarder* pViewForwarder)
137 : : {
138 : 0 : AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
139 [ # # ]: 0 : if (mpChildrenManager != NULL)
140 : 0 : mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
141 : 0 : }
142 : :
143 : :
144 : :
145 : :
146 : : /** The page shape is created on every call at the moment (provided that
147 : : every thing goes well).
148 : : */
149 : 14 : AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
150 : : {
151 : 14 : AccessiblePageShape* pShape = NULL;
152 : :
153 : : // Create a shape that represents the actual draw page.
154 [ + - ]: 14 : uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
155 [ + - ]: 14 : if (xView.is())
156 : : {
157 : : uno::Reference<beans::XPropertySet> xSet (
158 [ + - ][ + - ]: 14 : uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY));
[ + - ]
159 [ + - ]: 14 : if (xSet.is())
160 : : {
161 : : // Create a rectangle shape that will represent the draw page.
162 [ + - ]: 14 : uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY);
163 : 14 : uno::Reference<drawing::XShape> xRectangle;
164 [ + - ]: 14 : if (xFactory.is())
165 [ + - ]: 14 : xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance ("com.sun.star.drawing.RectangleShape"),
166 [ + - ][ + - ]: 14 : uno::UNO_QUERY);
[ + - ]
167 : :
168 : : // Set the shape's size and position.
169 [ + - ]: 14 : if (xRectangle.is())
170 : : {
171 : 14 : uno::Any aValue;
172 : 14 : awt::Point aPosition;
173 : 14 : awt::Size aSize;
174 : :
175 : : // Set size and position of the shape to those of the draw
176 : : // page.
177 [ + - ][ + - ]: 14 : aValue = xSet->getPropertyValue ("BorderLeft");
178 : 14 : aValue >>= aPosition.X;
179 [ + - ][ + - ]: 14 : aValue = xSet->getPropertyValue ("BorderTop");
180 : 14 : aValue >>= aPosition.Y;
181 [ + - ][ + - ]: 14 : xRectangle->setPosition (aPosition);
182 : :
183 [ + - ][ + - ]: 14 : aValue = xSet->getPropertyValue ("Width");
184 : 14 : aValue >>= aSize.Width;
185 [ + - ][ + - ]: 14 : aValue = xSet->getPropertyValue ("Height");
186 : 14 : aValue >>= aSize.Height;
187 [ + - ][ + - ]: 14 : xRectangle->setSize (aSize);
188 : :
189 : : // Create the accessible object for the shape and
190 : : // initialize it.
191 : : pShape = new AccessiblePageShape (
192 [ + - ][ + - ]: 14 : xView->getCurrentPage(), this, maShapeTreeInfo);
[ + - ][ + - ]
193 : 14 : }
194 : 14 : }
195 : : }
196 : 14 : return pShape;
197 : : }
198 : :
199 : :
200 : :
201 : :
202 : : //===== XAccessibleContext ==================================================
203 : :
204 : : sal_Int32 SAL_CALL
205 : 26 : AccessibleDrawDocumentView::getAccessibleChildCount (void)
206 : : throw (uno::RuntimeException)
207 : : {
208 : 26 : ThrowIfDisposed ();
209 : :
210 : 26 : long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount();
211 : :
212 : : // Forward request to children manager.
213 [ + - ]: 26 : if (mpChildrenManager != NULL)
214 : 26 : mpChildCount += mpChildrenManager->GetChildCount ();
215 : :
216 : 26 : return mpChildCount;
217 : : }
218 : :
219 : :
220 : :
221 : :
222 : : uno::Reference<XAccessible> SAL_CALL
223 : 16 : AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex)
224 : : throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
225 : : {
226 [ + - ]: 16 : ThrowIfDisposed ();
227 : :
228 [ + - ]: 16 : ::osl::ClearableMutexGuard aGuard (maMutex);
229 : :
230 : : // Take care of children of the base class.
231 [ + - ]: 16 : sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount();
232 [ - + ]: 16 : if (nCount > 0)
233 : : {
234 [ # # ]: 0 : if (nIndex < nCount)
235 [ # # ]: 0 : return AccessibleDocumentViewBase::getAccessibleChild(nIndex);
236 : : else
237 : 0 : nIndex -= nCount;
238 : : }
239 : :
240 : : // Create a copy of the pointer to the children manager and release the
241 : : // mutex before calling any of its methods.
242 : 16 : ChildrenManager* pChildrenManager = mpChildrenManager;
243 [ + - ]: 16 : aGuard.clear();
244 : :
245 : : // Forward request to children manager.
246 [ + - ]: 16 : if (pChildrenManager != NULL)
247 : : {
248 [ + - ]: 16 : return pChildrenManager->GetChild (nIndex);
249 : : }
250 : : else
251 : : throw lang::IndexOutOfBoundsException (
252 : : "no accessible child with index " + rtl::OUString::valueOf(nIndex),
253 [ # # ][ # # ]: 16 : static_cast<uno::XWeak*>(this));
[ + - ]
254 : : }
255 : :
256 : :
257 : :
258 : :
259 : : //===== XEventListener ======================================================
260 : :
261 : : void SAL_CALL
262 : 18 : AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject)
263 : : throw (::com::sun::star::uno::RuntimeException)
264 : : {
265 : 18 : ThrowIfDisposed ();
266 : :
267 : 12 : AccessibleDocumentViewBase::disposing (rEventObject);
268 [ - + ]: 12 : if (rEventObject.Source == mxModel)
269 : : {
270 [ # # ][ # # ]: 0 : ::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex());
271 : : // maShapeTreeInfo has been modified in base class.
272 [ # # ]: 0 : if (mpChildrenManager != NULL)
273 [ # # ][ # # ]: 0 : mpChildrenManager->SetInfo (maShapeTreeInfo);
274 : : }
275 : 12 : }
276 : :
277 : :
278 : :
279 : :
280 : : //===== XPropertyChangeListener =============================================
281 : :
282 : : void SAL_CALL
283 : 28 : AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
284 : : throw (::com::sun::star::uno::RuntimeException)
285 : : {
286 : 28 : ThrowIfDisposed ();
287 : :
288 : 28 : AccessibleDocumentViewBase::propertyChange (rEventObject);
289 : :
290 : : OSL_TRACE ("AccessibleDrawDocumentView::propertyChange");
291 [ + + ]: 28 : if ( rEventObject.PropertyName == "CurrentPage" )
292 : : {
293 : : OSL_TRACE (" current page changed");
294 : :
295 : : // Update the accessible name to reflect the current slide.
296 [ + - ]: 8 : UpdateAccessibleName();
297 : :
298 : : // The current page changed. Update the children manager accordingly.
299 [ + - ]: 8 : uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
300 [ + - ][ + - ]: 8 : if (xView.is() && mpChildrenManager!=NULL)
[ + - ]
301 : : {
302 : : // Inform the children manager to forget all children and give
303 : : // him the new ones.
304 [ + - ]: 8 : mpChildrenManager->ClearAccessibleShapeList ();
305 : : mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
306 [ + - ][ + - ]: 8 : xView->getCurrentPage(), uno::UNO_QUERY));
[ + - ][ + - ]
307 : :
308 : : // Create the page shape and initialize it. The shape is
309 : : // acquired before initialization and released after
310 : : // transferring ownership to the children manager to prevent
311 : : // premature disposing of the shape.
312 [ + - ]: 8 : AccessiblePageShape* pPage = CreateDrawPageShape ();
313 [ + - ]: 8 : if (pPage != NULL)
314 : : {
315 : 8 : pPage->acquire();
316 [ + - ]: 8 : pPage->Init();
317 : : mpChildrenManager->AddAccessibleShape (
318 [ + - ][ + - ]: 8 : std::auto_ptr<AccessibleShape>(pPage));
[ + - ]
319 [ + - ]: 8 : mpChildrenManager->Update (false);
320 : 8 : pPage->release();
321 : : }
322 : : }
323 : : else
324 : 8 : OSL_TRACE ("View invalid");
325 : : }
326 [ + - ]: 20 : else if ( rEventObject.PropertyName == "VisibleArea" )
327 : : {
328 : : OSL_TRACE (" visible area changed");
329 [ + - ]: 20 : if (mpChildrenManager != NULL)
330 : : mpChildrenManager->ViewForwarderChanged (
331 : : IAccessibleViewForwarderListener::VISIBLE_AREA,
332 : 20 : &maViewForwarder);
333 : : }
334 : : else
335 : : {
336 : : OSL_TRACE (" unhandled");
337 : : }
338 : : OSL_TRACE (" done");
339 : 28 : }
340 : :
341 : :
342 : :
343 : : //===== XServiceInfo ========================================================
344 : :
345 : : ::rtl::OUString SAL_CALL
346 : 2 : AccessibleDrawDocumentView::getImplementationName (void)
347 : : throw (::com::sun::star::uno::RuntimeException)
348 : : {
349 : 2 : return ::rtl::OUString("AccessibleDrawDocumentView");
350 : : }
351 : :
352 : :
353 : :
354 : :
355 : : ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
356 : 0 : AccessibleDrawDocumentView::getSupportedServiceNames (void)
357 : : throw (::com::sun::star::uno::RuntimeException)
358 : : {
359 : 0 : ThrowIfDisposed();
360 : : // Get list of supported service names from base class...
361 : : uno::Sequence<OUString> aServiceNames =
362 : 0 : AccessibleDocumentViewBase::getSupportedServiceNames();
363 : 0 : sal_Int32 nCount (aServiceNames.getLength());
364 : :
365 : : // ...and add additional names.
366 [ # # ]: 0 : aServiceNames.realloc (nCount + 1);
367 [ # # ][ # # ]: 0 : static const OUString sAdditionalServiceName ("com.sun.star.drawing.AccessibleDrawDocumentView");
368 [ # # ]: 0 : aServiceNames[nCount] = sAdditionalServiceName;
369 : :
370 : 0 : return aServiceNames;
371 : : }
372 : :
373 : :
374 : :
375 : :
376 : : /// Create a name for this view.
377 : : ::rtl::OUString
378 : 14 : AccessibleDrawDocumentView::CreateAccessibleName (void)
379 : : throw (::com::sun::star::uno::RuntimeException)
380 : : {
381 : 14 : rtl::OUString sName;
382 : :
383 [ + - ]: 14 : uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
384 [ + - ]: 14 : if (xInfo.is())
385 : : {
386 [ + - ][ + - ]: 14 : uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
387 [ + - ]: 14 : OUString sFirstService = aServices[0];
388 [ + - ]: 14 : if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
389 : : {
390 [ - + ][ # # ]: 14 : if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
[ # # ][ - + ]
391 : : {
392 [ # # ]: 0 : SolarMutexGuard aGuard;
393 : :
394 [ # # ][ # # ]: 0 : sName = SD_RESSTR(SID_SD_A11Y_I_DRAWVIEW_N);
[ # # ]
395 : : }
396 : : else
397 : : {
398 [ + - ]: 14 : SolarMutexGuard aGuard;
399 : :
400 [ + - ][ + - ]: 14 : sName = SD_RESSTR(SID_SD_A11Y_D_DRAWVIEW_N);
[ + - ]
401 : : }
402 : : }
403 [ # # ]: 0 : else if ( sFirstService == "com.sun.star.presentation.NotesView" )
404 : : {
405 [ # # ]: 0 : SolarMutexGuard aGuard;
406 : :
407 [ # # ][ # # ]: 0 : sName = SD_RESSTR(SID_SD_A11Y_I_NOTESVIEW_N);
[ # # ]
408 : : }
409 [ # # ]: 0 : else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
410 : : {
411 [ # # ]: 0 : SolarMutexGuard aGuard;
412 : :
413 [ # # ][ # # ]: 0 : sName = SD_RESSTR(SID_SD_A11Y_I_HANDOUTVIEW_N);
[ # # ]
414 : : }
415 : : else
416 : : {
417 : 0 : sName = sFirstService;
418 [ + - ]: 14 : }
419 : : }
420 : : else
421 : : {
422 : 0 : sName = "AccessibleDrawDocumentView";
423 : : }
424 : 14 : return sName;
425 : : }
426 : :
427 : :
428 : :
429 : :
430 : : /** Create a description for this view. Use the model's description or URL
431 : : if a description is not available.
432 : : */
433 : : ::rtl::OUString
434 : 0 : AccessibleDrawDocumentView::CreateAccessibleDescription (void)
435 : : throw (::com::sun::star::uno::RuntimeException)
436 : : {
437 : 0 : rtl::OUString sDescription;
438 : :
439 [ # # ]: 0 : uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
440 [ # # ]: 0 : if (xInfo.is())
441 : : {
442 [ # # ][ # # ]: 0 : uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
443 [ # # ]: 0 : OUString sFirstService = aServices[0];
444 [ # # ]: 0 : if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
445 : : {
446 [ # # ][ # # ]: 0 : if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
[ # # ][ # # ]
447 : : {
448 [ # # ]: 0 : SolarMutexGuard aGuard;
449 : :
450 [ # # ][ # # ]: 0 : sDescription = SD_RESSTR(SID_SD_A11Y_I_DRAWVIEW_D);
[ # # ]
451 : : }
452 : : else
453 : : {
454 [ # # ]: 0 : SolarMutexGuard aGuard;
455 : :
456 [ # # ][ # # ]: 0 : sDescription = SD_RESSTR(SID_SD_A11Y_D_DRAWVIEW_D);
[ # # ]
457 : : }
458 : : }
459 [ # # ]: 0 : else if ( sFirstService == "com.sun.star.presentation.NotesView" )
460 : : {
461 [ # # ]: 0 : SolarMutexGuard aGuard;
462 : :
463 [ # # ][ # # ]: 0 : sDescription = SD_RESSTR(SID_SD_A11Y_I_NOTESVIEW_D);
[ # # ]
464 : : }
465 [ # # ]: 0 : else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
466 : : {
467 [ # # ]: 0 : SolarMutexGuard aGuard;
468 : :
469 [ # # ][ # # ]: 0 : sDescription = SD_RESSTR(SID_SD_A11Y_I_HANDOUTVIEW_D);
[ # # ]
470 : : }
471 : : else
472 : : {
473 : 0 : sDescription = sFirstService;
474 [ # # ]: 0 : }
475 : : }
476 : : else
477 : : {
478 : 0 : sDescription = "Accessible Draw Document";
479 : : }
480 : 0 : return sDescription;
481 : : }
482 : :
483 : :
484 : :
485 : :
486 : : /** Return selection state of specified child
487 : : */
488 : : sal_Bool
489 : 0 : AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex )
490 : : throw (uno::RuntimeException)
491 : : {
492 [ # # ]: 0 : const SolarMutexGuard aSolarGuard;
493 [ # # ]: 0 : uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY );
494 : 0 : sal_Bool bRet = sal_False;
495 : :
496 : : OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" );
497 : :
498 [ # # ][ # # ]: 0 : if( xSel.is() && ( 0 <= nAccessibleChildIndex ) )
[ # # ]
499 : : {
500 [ # # ][ # # ]: 0 : uno::Any aAny( xSel->getSelection() );
501 : 0 : uno::Reference< drawing::XShapes > xShapes;
502 : :
503 [ # # ]: 0 : aAny >>= xShapes;
504 : :
505 [ # # ]: 0 : if( xShapes.is() )
506 : : {
507 [ # # ]: 0 : AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) );
508 : :
509 [ # # ]: 0 : if( pAcc )
510 : : {
511 [ # # ]: 0 : uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
512 : :
513 [ # # ]: 0 : if( xShape.is() )
514 : : {
515 [ # # ][ # # ]: 0 : for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i )
[ # # ][ # # ]
[ # # ]
516 [ # # ][ # # ]: 0 : if( xShapes->getByIndex( i ) == xShape )
[ # # ][ # # ]
517 : 0 : bRet = sal_True;
518 : 0 : }
519 : : }
520 : 0 : }
521 : : }
522 : :
523 [ # # ]: 0 : return( bRet );
524 : : }
525 : :
526 : :
527 : :
528 : :
529 : : /** Select or delselect the specified shapes. The corresponding accessible
530 : : shapes are notified over the selection change listeners registered with
531 : : the XSelectionSupplier of the controller.
532 : : */
533 : : void
534 : 4 : AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
535 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
536 : : {
537 [ + - ]: 4 : const SolarMutexGuard aSolarGuard;
538 [ + - ]: 4 : uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY );
539 : :
540 [ + - ]: 4 : if( xSel.is() )
541 : : {
542 : 4 : uno::Any aAny;
543 : :
544 [ + + ]: 4 : if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex )
545 : : {
546 : : // Select or deselect all children.
547 : :
548 [ + - ]: 2 : if( !bSelect )
549 [ + - ][ + - ]: 2 : xSel->select( aAny );
550 : : else
551 : : {
552 [ # # ][ # # ]: 0 : uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() );
553 : :
554 [ # # ][ # # ]: 0 : for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
555 : : {
556 [ # # ]: 0 : AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) );
557 : :
558 [ # # ][ # # ]: 0 : if( pAcc && pAcc->GetXShape().is() )
[ # # ]
[ # # # # ]
[ # # ]
559 [ # # ][ # # ]: 0 : xShapes->add( pAcc->GetXShape() );
[ # # ]
560 : : }
561 : :
562 [ # # ][ # # ]: 0 : if( xShapes->getCount() )
[ # # ]
563 : : {
564 [ # # ]: 0 : aAny <<= xShapes;
565 [ # # ][ # # ]: 0 : xSel->select( aAny );
566 : 0 : }
567 : : }
568 : : }
569 [ + - ]: 2 : else if( nAccessibleChildIndex >= 0 )
570 : : {
571 : : // Select or deselect only the child with index
572 : : // nAccessibleChildIndex.
573 : :
574 : : AccessibleShape* pAcc = AccessibleShape::getImplementation(
575 [ + - ]: 2 : getAccessibleChild( nAccessibleChildIndex ));
576 : :
577 : : // Add or remove the shape that is made accessible from the
578 : : // selection of the controller.
579 [ + - ]: 2 : if( pAcc )
580 : : {
581 [ + - ]: 2 : uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
582 : :
583 [ + - ]: 2 : if( xShape.is() )
584 : : {
585 : 2 : uno::Reference< drawing::XShapes > xShapes;
586 : 2 : sal_Bool bFound = sal_False;
587 : :
588 [ + - ][ + - ]: 2 : aAny = xSel->getSelection();
589 [ + - ]: 2 : aAny >>= xShapes;
590 : :
591 : : // Search shape to be selected in current selection.
592 [ - + ]: 2 : if (xShapes.is())
593 : : {
594 [ # # ][ # # ]: 0 : sal_Int32 nCount = xShapes->getCount();
595 [ # # ][ # # ]: 0 : for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i )
[ # # ]
596 [ # # ][ # # ]: 0 : if( xShapes->getByIndex( i ) == xShape )
[ # # ][ # # ]
597 : 0 : bFound = sal_True;
598 : : }
599 : : else
600 : : // Create an empty selection to add the shape to.
601 [ + - ][ + - ]: 2 : xShapes = new SvxShapeCollection();
602 : :
603 : : // Update the selection.
604 [ + - ][ + - ]: 2 : if( !bFound && bSelect )
605 [ + - ][ + - ]: 2 : xShapes->add( xShape );
606 [ # # ][ # # ]: 0 : else if( bFound && !bSelect )
607 [ # # ][ # # ]: 0 : xShapes->remove( xShape );
608 : :
609 [ + - ]: 2 : aAny <<= xShapes;
610 [ + - ][ + - ]: 2 : xSel->select( aAny );
611 : 2 : }
612 : : }
613 : 4 : }
614 [ + - ]: 4 : }
615 : 4 : }
616 : :
617 : :
618 : :
619 : :
620 : 0 : void AccessibleDrawDocumentView::Activated (void)
621 : : {
622 [ # # ]: 0 : if (mpChildrenManager != NULL)
623 : : {
624 : 0 : mpChildrenManager->UpdateSelection();
625 : : // When none of the children has the focus then claim it for the
626 : : // view.
627 [ # # ]: 0 : if ( ! mpChildrenManager->HasFocus())
628 : 0 : SetState (AccessibleStateType::FOCUSED);
629 : : else
630 : 0 : ResetState (AccessibleStateType::FOCUSED);
631 : : }
632 : 0 : }
633 : :
634 : :
635 : :
636 : :
637 : 0 : void AccessibleDrawDocumentView::Deactivated (void)
638 : : {
639 [ # # ]: 0 : if (mpChildrenManager != NULL)
640 : 0 : mpChildrenManager->RemoveFocus();
641 : 0 : ResetState (AccessibleStateType::FOCUSED);
642 : 0 : }
643 : :
644 : :
645 : :
646 : :
647 : 6 : void AccessibleDrawDocumentView::impl_dispose (void)
648 : : {
649 [ - + ]: 6 : if (mpChildrenManager != NULL)
650 : : {
651 [ # # ]: 0 : delete mpChildrenManager;
652 : 0 : mpChildrenManager = NULL;
653 : : }
654 : :
655 : 6 : AccessibleDocumentViewBase::impl_dispose();
656 : 6 : }
657 : :
658 : :
659 : :
660 : : /** This method is called from the component helper base class while
661 : : disposing.
662 : : */
663 : 6 : void SAL_CALL AccessibleDrawDocumentView::disposing (void)
664 : : {
665 : :
666 : : // Release resources.
667 [ + - ]: 6 : if (mpChildrenManager != NULL)
668 : : {
669 [ + - ]: 6 : delete mpChildrenManager;
670 : 6 : mpChildrenManager = NULL;
671 : : }
672 : :
673 : : // Forward call to base classes.
674 : 6 : AccessibleDocumentViewBase::disposing ();
675 : 6 : }
676 : :
677 : :
678 : :
679 : :
680 : 14 : void AccessibleDrawDocumentView::UpdateAccessibleName (void)
681 : : {
682 [ + - ]: 14 : OUString sNewName (CreateAccessibleName());
683 : 14 : sNewName += ": ";
684 : :
685 : : // Add the number of the current slide.
686 [ + - ]: 14 : uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
687 [ + - ]: 14 : if (xView.is())
688 : : {
689 [ + - ][ + - ]: 14 : uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY);
[ + - ]
690 [ + - ]: 14 : if (xProperties.is())
691 : : try
692 : : {
693 : 14 : sal_Int16 nPageNumber (0);
694 [ + - ][ + - ]: 14 : if (xProperties->getPropertyValue("Number") >>= nPageNumber)
[ + - # # ]
695 : : {
696 : 14 : sNewName += OUString::valueOf(sal_Int32(nPageNumber));
697 : : }
698 : : }
699 [ # # ]: 0 : catch (beans::UnknownPropertyException&)
700 : : {
701 : 14 : }
702 : : }
703 : :
704 : : // Add the number of pages/slides.
705 [ + - ]: 14 : Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY);
706 [ + - ]: 14 : if (xPagesSupplier.is())
707 : : {
708 [ + - ][ + - ]: 14 : Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY);
[ + - ]
709 [ + - ]: 14 : if (xPages.is())
710 : : {
711 : 14 : sNewName += " / ";
712 [ + - ][ + - ]: 14 : sNewName += OUString::valueOf(xPages->getCount());
713 : 14 : }
714 : : }
715 : :
716 [ + - ]: 14 : SetAccessibleName (sNewName, AutomaticallyCreated);
717 : 14 : }
718 : :
719 : : } // end of namespace accessibility
720 : :
721 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|