15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
105b190011SAndrew Rist  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125b190011SAndrew Rist  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
195b190011SAndrew Rist  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx"
27cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
28cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
34cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
37cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
38cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39cdf0e10cSrcweir #include <rtl/ustring.h>
40cdf0e10cSrcweir #include<sfx2/viewfrm.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <svx/svdobj.hxx>
45cdf0e10cSrcweir #include <svx/svdmodel.hxx>
46cdf0e10cSrcweir #include <svx/unoapi.hxx>
47cdf0e10cSrcweir #include <svx/unoshcol.hxx>
48cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
49cdf0e10cSrcweir #include "Window.hxx"
50cdf0e10cSrcweir #include <vcl/svapp.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include "ViewShell.hxx"
54cdf0e10cSrcweir #include "View.hxx"
55*0deba7fbSSteve Yin #include "DrawDocShell.hxx"
56*0deba7fbSSteve Yin #include <drawdoc.hxx>
57*0deba7fbSSteve Yin #include <algorithm>
58*0deba7fbSSteve Yin #include "sdpage.hxx"
59*0deba7fbSSteve Yin #include "slideshow.hxx"
60*0deba7fbSSteve Yin #include "anminfo.hxx"
61cdf0e10cSrcweir #include <memory>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include "accessibility.hrc"
64cdf0e10cSrcweir #include "sdresid.hxx"
65cdf0e10cSrcweir #include <vos/mutex.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using ::rtl::OUString;
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir using namespace ::com::sun::star::uno;
70cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir class SfxViewFrame;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
75cdf0e10cSrcweir 
76cdf0e10cSrcweir namespace accessibility {
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79*0deba7fbSSteve Yin struct XShapePosCompareHelper
80*0deba7fbSSteve Yin {
operator ()accessibility::XShapePosCompareHelper81*0deba7fbSSteve Yin 	bool operator() ( const uno::Reference<drawing::XShape>& xshape1,
82*0deba7fbSSteve Yin 		const uno::Reference<drawing::XShape>& xshape2 ) const
83*0deba7fbSSteve Yin 	{
84*0deba7fbSSteve Yin 		// modify the compare method to return the Z-Order, not layout order
85*0deba7fbSSteve Yin 		SdrObject* pObj1 = GetSdrObjectFromXShape(xshape1);
86*0deba7fbSSteve Yin 		SdrObject* pObj2 = GetSdrObjectFromXShape(xshape2);
87*0deba7fbSSteve Yin 		if(pObj1 && pObj2)
88*0deba7fbSSteve Yin 			return pObj1->GetOrdNum() < pObj2->GetOrdNum();
89*0deba7fbSSteve Yin 		else
90*0deba7fbSSteve Yin 			return 0;
91*0deba7fbSSteve Yin 	}
92*0deba7fbSSteve Yin };
93cdf0e10cSrcweir //=====  internal  ============================================================
94cdf0e10cSrcweir 
AccessibleDrawDocumentView(::sd::Window * pSdWindow,::sd::ViewShell * pViewShell,const uno::Reference<frame::XController> & rxController,const uno::Reference<XAccessible> & rxParent)95cdf0e10cSrcweir AccessibleDrawDocumentView::AccessibleDrawDocumentView (
96cdf0e10cSrcweir     ::sd::Window* pSdWindow,
97cdf0e10cSrcweir     ::sd::ViewShell* pViewShell,
98cdf0e10cSrcweir     const uno::Reference<frame::XController>& rxController,
99cdf0e10cSrcweir     const uno::Reference<XAccessible>& rxParent)
100cdf0e10cSrcweir     : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
101*0deba7fbSSteve Yin       mpSdViewSh( pViewShell ),
102cdf0e10cSrcweir       mpChildrenManager (NULL)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     OSL_TRACE ("AccessibleDrawDocumentView");
105cdf0e10cSrcweir     UpdateAccessibleName();
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
~AccessibleDrawDocumentView(void)111cdf0e10cSrcweir AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     OSL_TRACE ("~AccessibleDrawDocumentView");
114cdf0e10cSrcweir     DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
115cdf0e10cSrcweir         "~AccessibleDrawDocumentView: object has not been disposed");
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 
Init(void)121cdf0e10cSrcweir void AccessibleDrawDocumentView::Init (void)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     AccessibleDocumentViewBase::Init ();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     // Determine the list of shapes on the current page.
126cdf0e10cSrcweir     uno::Reference<drawing::XShapes> xShapeList;
127cdf0e10cSrcweir     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
128cdf0e10cSrcweir     if (xView.is())
129cdf0e10cSrcweir         xShapeList = uno::Reference<drawing::XShapes> (
130cdf0e10cSrcweir             xView->getCurrentPage(), uno::UNO_QUERY);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     // Create the children manager.
133cdf0e10cSrcweir     mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
134cdf0e10cSrcweir     if (mpChildrenManager != NULL)
135cdf0e10cSrcweir     {
136cdf0e10cSrcweir         // Create the page shape and initialize it.  The shape is acquired
137cdf0e10cSrcweir         // before initialization and released after transferring ownership
138cdf0e10cSrcweir         // to the children manager to prevent premature disposing of the
139cdf0e10cSrcweir         // shape.
140cdf0e10cSrcweir         AccessiblePageShape* pPage = CreateDrawPageShape();
141cdf0e10cSrcweir         if (pPage != NULL)
142cdf0e10cSrcweir         {
143cdf0e10cSrcweir             pPage->acquire();
144cdf0e10cSrcweir             pPage->Init();
145cdf0e10cSrcweir             mpChildrenManager->AddAccessibleShape (
146cdf0e10cSrcweir                 std::auto_ptr<AccessibleShape>(pPage));
147cdf0e10cSrcweir             pPage->release();
148cdf0e10cSrcweir             mpChildrenManager->Update ();
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir         mpChildrenManager->UpdateSelection ();
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
ViewForwarderChanged(ChangeType aChangeType,const IAccessibleViewForwarder * pViewForwarder)157cdf0e10cSrcweir void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
158cdf0e10cSrcweir     const IAccessibleViewForwarder* pViewForwarder)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
161cdf0e10cSrcweir     if (mpChildrenManager != NULL)
162cdf0e10cSrcweir         mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 
168cdf0e10cSrcweir /**  The page shape is created on every call at the moment (provided that
169cdf0e10cSrcweir      every thing goes well).
170cdf0e10cSrcweir */
CreateDrawPageShape(void)171cdf0e10cSrcweir AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     AccessiblePageShape* pShape = NULL;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     // Create a shape that represents the actual draw page.
176cdf0e10cSrcweir     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
177cdf0e10cSrcweir     if (xView.is())
178cdf0e10cSrcweir     {
179cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xSet (
180cdf0e10cSrcweir             uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY));
181cdf0e10cSrcweir         if (xSet.is())
182cdf0e10cSrcweir         {
183cdf0e10cSrcweir             // Create a rectangle shape that will represent the draw page.
184cdf0e10cSrcweir             uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY);
185cdf0e10cSrcweir             uno::Reference<drawing::XShape> xRectangle;
186cdf0e10cSrcweir             if (xFactory.is())
187cdf0e10cSrcweir                 xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance (
188cdf0e10cSrcweir                     OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.RectangleShape"))),
189cdf0e10cSrcweir                     uno::UNO_QUERY);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir             // Set the shape's size and position.
192cdf0e10cSrcweir             if (xRectangle.is())
193cdf0e10cSrcweir             {
194cdf0e10cSrcweir                 uno::Any aValue;
195cdf0e10cSrcweir                 awt::Point aPosition;
196cdf0e10cSrcweir                 awt::Size aSize;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir                 // Set size and position of the shape to those of the draw
199cdf0e10cSrcweir                 // page.
200cdf0e10cSrcweir                 aValue = xSet->getPropertyValue (
201cdf0e10cSrcweir                     OUString (RTL_CONSTASCII_USTRINGPARAM("BorderLeft")));
202cdf0e10cSrcweir                 aValue >>= aPosition.X;
203cdf0e10cSrcweir                 aValue = xSet->getPropertyValue (
204cdf0e10cSrcweir                     OUString (RTL_CONSTASCII_USTRINGPARAM("BorderTop")));
205cdf0e10cSrcweir                 aValue >>= aPosition.Y;
206cdf0e10cSrcweir                 xRectangle->setPosition (aPosition);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir                 aValue = xSet->getPropertyValue (
209cdf0e10cSrcweir                     OUString (RTL_CONSTASCII_USTRINGPARAM("Width")));
210cdf0e10cSrcweir                 aValue >>= aSize.Width;
211cdf0e10cSrcweir                 aValue = xSet->getPropertyValue (
212cdf0e10cSrcweir                     OUString (RTL_CONSTASCII_USTRINGPARAM("Height")));
213cdf0e10cSrcweir                 aValue >>= aSize.Height;
214cdf0e10cSrcweir                 xRectangle->setSize (aSize);
215cdf0e10cSrcweir 
216cdf0e10cSrcweir                 // Create the accessible object for the shape and
217cdf0e10cSrcweir                 // initialize it.
218cdf0e10cSrcweir                 pShape = new AccessiblePageShape (
219cdf0e10cSrcweir                     xView->getCurrentPage(), this, maShapeTreeInfo);
220cdf0e10cSrcweir             }
221cdf0e10cSrcweir         }
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir     return pShape;
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
229cdf0e10cSrcweir //=====  XAccessibleContext  ==================================================
230cdf0e10cSrcweir 
231cdf0e10cSrcweir sal_Int32 SAL_CALL
getAccessibleChildCount(void)232cdf0e10cSrcweir     AccessibleDrawDocumentView::getAccessibleChildCount (void)
233cdf0e10cSrcweir     throw (uno::RuntimeException)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir     ThrowIfDisposed ();
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount();
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     // Forward request to children manager.
240cdf0e10cSrcweir     if (mpChildrenManager != NULL)
241cdf0e10cSrcweir         mpChildCount += mpChildrenManager->GetChildCount ();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     return mpChildCount;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 
249cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)250cdf0e10cSrcweir     AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex)
251cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
252cdf0e10cSrcweir {
253cdf0e10cSrcweir     ThrowIfDisposed ();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     ::osl::ClearableMutexGuard aGuard (maMutex);
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     // Take care of children of the base class.
258cdf0e10cSrcweir     sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount();
259cdf0e10cSrcweir     if (nCount > 0)
260cdf0e10cSrcweir     {
261cdf0e10cSrcweir         if (nIndex < nCount)
262cdf0e10cSrcweir             return AccessibleDocumentViewBase::getAccessibleChild(nIndex);
263cdf0e10cSrcweir         else
264cdf0e10cSrcweir             nIndex -= nCount;
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     // Create a copy of the pointer to the children manager and release the
268cdf0e10cSrcweir     // mutex before calling any of its methods.
269cdf0e10cSrcweir     ChildrenManager* pChildrenManager = mpChildrenManager;
270cdf0e10cSrcweir     aGuard.clear();
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     // Forward request to children manager.
273cdf0e10cSrcweir     if (pChildrenManager != NULL)
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         return pChildrenManager->GetChild (nIndex);
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir     else
278cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException (
279cdf0e10cSrcweir             ::rtl::OUString::createFromAscii ("no accessible child with index ")
280cdf0e10cSrcweir             + rtl::OUString::valueOf(nIndex),
281cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284*0deba7fbSSteve Yin OUString SAL_CALL
getAccessibleName(void)285*0deba7fbSSteve Yin 	AccessibleDrawDocumentView::getAccessibleName(void)
286*0deba7fbSSteve Yin 	throw (::com::sun::star::uno::RuntimeException)
287*0deba7fbSSteve Yin {
288*0deba7fbSSteve Yin 	OUString sName = String( SdResId(SID_SD_A11Y_D_PRESENTATION) );
289*0deba7fbSSteve Yin 	::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() );
290*0deba7fbSSteve Yin 	if ( pSdView )
291*0deba7fbSSteve Yin 	{
292*0deba7fbSSteve Yin 		SdDrawDocument* pDoc = pSdView->GetDoc();
293*0deba7fbSSteve Yin 		if ( pDoc )
294*0deba7fbSSteve Yin 		{
295*0deba7fbSSteve Yin 			rtl::OUString sFileName = pDoc->getDocAccTitle();
296*0deba7fbSSteve Yin 			if ( !sFileName.getLength() )
297*0deba7fbSSteve Yin 			{
298*0deba7fbSSteve Yin 				::sd::DrawDocShell* pDocSh = pSdView->GetDocSh();
299*0deba7fbSSteve Yin 				if ( pDocSh )
300*0deba7fbSSteve Yin 				{
301*0deba7fbSSteve Yin 					sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME );
302*0deba7fbSSteve Yin 				}
303*0deba7fbSSteve Yin 			}
304*0deba7fbSSteve Yin 
305*0deba7fbSSteve Yin 			OUString sReadOnly;
306*0deba7fbSSteve Yin 			if(pDoc->getDocReadOnly())
307*0deba7fbSSteve Yin 			{
308*0deba7fbSSteve Yin 				sReadOnly = String(SdResId(SID_SD_A11Y_D_PRESENTATION_READONLY));
309*0deba7fbSSteve Yin 			}
310*0deba7fbSSteve Yin 
311*0deba7fbSSteve Yin 			if ( sFileName.getLength() )
312*0deba7fbSSteve Yin 			{
313*0deba7fbSSteve Yin 				sName = sFileName + sReadOnly + OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName;
314*0deba7fbSSteve Yin 			}
315*0deba7fbSSteve Yin 		}
316*0deba7fbSSteve Yin 	}
317cdf0e10cSrcweir 
318*0deba7fbSSteve Yin 	return sName;
319*0deba7fbSSteve Yin }
320cdf0e10cSrcweir //=====  XEventListener  ======================================================
321cdf0e10cSrcweir 
322cdf0e10cSrcweir void SAL_CALL
disposing(const lang::EventObject & rEventObject)323cdf0e10cSrcweir     AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject)
324cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     ThrowIfDisposed ();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     AccessibleDocumentViewBase::disposing (rEventObject);
329cdf0e10cSrcweir     if (rEventObject.Source == mxModel)
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         ::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex());
332cdf0e10cSrcweir         // maShapeTreeInfo has been modified in base class.
333cdf0e10cSrcweir         if (mpChildrenManager != NULL)
334cdf0e10cSrcweir             mpChildrenManager->SetInfo (maShapeTreeInfo);
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 
341cdf0e10cSrcweir //=====  XPropertyChangeListener  =============================================
342cdf0e10cSrcweir 
343cdf0e10cSrcweir void SAL_CALL
propertyChange(const beans::PropertyChangeEvent & rEventObject)344cdf0e10cSrcweir     AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
345cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     ThrowIfDisposed ();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     AccessibleDocumentViewBase::propertyChange (rEventObject);
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     OSL_TRACE ("AccessibleDrawDocumentView::propertyChange");
352*0deba7fbSSteve Yin     // add page switch event for slide show mode
353*0deba7fbSSteve Yin     if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage")) ||
354*0deba7fbSSteve Yin 		rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("PageChange")) )
355cdf0e10cSrcweir     {
356cdf0e10cSrcweir         OSL_TRACE ("    current page changed");
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         // Update the accessible name to reflect the current slide.
359cdf0e10cSrcweir         UpdateAccessibleName();
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         // The current page changed.  Update the children manager accordingly.
362cdf0e10cSrcweir         uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
363cdf0e10cSrcweir         if (xView.is() && mpChildrenManager!=NULL)
364cdf0e10cSrcweir         {
365cdf0e10cSrcweir             // Inform the children manager to forget all children and give
366cdf0e10cSrcweir             // him the new ones.
367cdf0e10cSrcweir             mpChildrenManager->ClearAccessibleShapeList ();
368cdf0e10cSrcweir             mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
369cdf0e10cSrcweir                 xView->getCurrentPage(), uno::UNO_QUERY));
370cdf0e10cSrcweir 
371cdf0e10cSrcweir             // Create the page shape and initialize it.  The shape is
372cdf0e10cSrcweir             // acquired before initialization and released after
373cdf0e10cSrcweir             // transferring ownership to the children manager to prevent
374cdf0e10cSrcweir             // premature disposing of the shape.
375cdf0e10cSrcweir             AccessiblePageShape* pPage = CreateDrawPageShape ();
376cdf0e10cSrcweir             if (pPage != NULL)
377cdf0e10cSrcweir             {
378cdf0e10cSrcweir                 pPage->acquire();
379cdf0e10cSrcweir                 pPage->Init();
380cdf0e10cSrcweir                 mpChildrenManager->AddAccessibleShape (
381cdf0e10cSrcweir                     std::auto_ptr<AccessibleShape>(pPage));
382cdf0e10cSrcweir                 mpChildrenManager->Update (false);
383cdf0e10cSrcweir                 pPage->release();
384cdf0e10cSrcweir             }
385cdf0e10cSrcweir         }
386cdf0e10cSrcweir         else
387cdf0e10cSrcweir             OSL_TRACE ("View invalid");
388*0deba7fbSSteve Yin 		CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue);
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir     else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea")))
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         OSL_TRACE ("    visible area changed");
393cdf0e10cSrcweir         if (mpChildrenManager != NULL)
394cdf0e10cSrcweir             mpChildrenManager->ViewForwarderChanged (
395cdf0e10cSrcweir                 IAccessibleViewForwarderListener::VISIBLE_AREA,
396cdf0e10cSrcweir                 &maViewForwarder);
397cdf0e10cSrcweir     }
398*0deba7fbSSteve Yin 	else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("ActiveLayer")))
399*0deba7fbSSteve Yin 	{
400*0deba7fbSSteve Yin 		CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue);
401*0deba7fbSSteve Yin 	}
402*0deba7fbSSteve Yin     else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("UpdateAcc")))
403*0deba7fbSSteve Yin     {
404*0deba7fbSSteve Yin         OSL_TRACE ("    acc on current page should be updated");
405*0deba7fbSSteve Yin 
406*0deba7fbSSteve Yin         // The current page changed.  Update the children manager accordingly.
407*0deba7fbSSteve Yin         uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
408*0deba7fbSSteve Yin         if (xView.is() && mpChildrenManager!=NULL)
409*0deba7fbSSteve Yin         {
410*0deba7fbSSteve Yin             // Inform the children manager to forget all children and give
411*0deba7fbSSteve Yin             // him the new ones.
412*0deba7fbSSteve Yin             mpChildrenManager->ClearAccessibleShapeList ();
413*0deba7fbSSteve Yin 			// update the slide show page's accessible info
414*0deba7fbSSteve Yin             //mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
415*0deba7fbSSteve Yin             //    xView->getCurrentPage(), uno::UNO_QUERY));
416*0deba7fbSSteve Yin 	    rtl::Reference< sd::SlideShow > xSlideshow( sd::SlideShow::GetSlideShow( mpSdViewSh->GetViewShellBase() ) );
417*0deba7fbSSteve Yin 	    if( xSlideshow.is() && xSlideshow->isRunning() && xSlideshow->isFullScreen() )
418*0deba7fbSSteve Yin 	    {
419*0deba7fbSSteve Yin 		    ::com::sun::star::uno::Reference< drawing::XDrawPage > xSlide;
420*0deba7fbSSteve Yin 			// MT IA2: Not used...
421*0deba7fbSSteve Yin 			// sal_Int32 currentPageIndex = xSlideshow->getCurrentPageIndex();
422*0deba7fbSSteve Yin 			::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > mpSlideController = xSlideshow->getController();
423*0deba7fbSSteve Yin 			if( mpSlideController.is() )
424*0deba7fbSSteve Yin 			{
425*0deba7fbSSteve Yin 				xSlide = mpSlideController->getCurrentSlide();
426*0deba7fbSSteve Yin 				if (xSlide.is())
427*0deba7fbSSteve Yin 				{
428*0deba7fbSSteve Yin 					mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
429*0deba7fbSSteve Yin 				                xSlide, uno::UNO_QUERY));
430*0deba7fbSSteve Yin 				}
431*0deba7fbSSteve Yin 			}
432*0deba7fbSSteve Yin 	    }
433*0deba7fbSSteve Yin             // Create the page shape and initialize it.  The shape is
434*0deba7fbSSteve Yin             // acquired before initialization and released after
435*0deba7fbSSteve Yin             // transferring ownership to the children manager to prevent
436*0deba7fbSSteve Yin             // premature disposing of the shape.
437*0deba7fbSSteve Yin             AccessiblePageShape* pPage = CreateDrawPageShape ();
438*0deba7fbSSteve Yin             if (pPage != NULL)
439*0deba7fbSSteve Yin             {
440*0deba7fbSSteve Yin                 pPage->acquire();
441*0deba7fbSSteve Yin                 pPage->Init();
442*0deba7fbSSteve Yin                 mpChildrenManager->AddAccessibleShape (
443*0deba7fbSSteve Yin                     std::auto_ptr<AccessibleShape>(pPage));
444*0deba7fbSSteve Yin                 mpChildrenManager->Update (false);
445*0deba7fbSSteve Yin                 pPage->release();
446*0deba7fbSSteve Yin             }
447*0deba7fbSSteve Yin 	}
448*0deba7fbSSteve Yin     }
449cdf0e10cSrcweir     else
450cdf0e10cSrcweir     {
451cdf0e10cSrcweir         OSL_TRACE ("  unhandled");
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir     OSL_TRACE ("  done");
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 
458cdf0e10cSrcweir //=====  XServiceInfo  ========================================================
459cdf0e10cSrcweir 
460cdf0e10cSrcweir ::rtl::OUString SAL_CALL
getImplementationName(void)461cdf0e10cSrcweir     AccessibleDrawDocumentView::getImplementationName (void)
462cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
463cdf0e10cSrcweir {
464cdf0e10cSrcweir 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
465cdf0e10cSrcweir         "AccessibleDrawDocumentView"));
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 
471cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
getSupportedServiceNames(void)472cdf0e10cSrcweir     AccessibleDrawDocumentView::getSupportedServiceNames (void)
473cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
474cdf0e10cSrcweir {
475cdf0e10cSrcweir     ThrowIfDisposed();
476cdf0e10cSrcweir     // Get list of supported service names from base class...
477cdf0e10cSrcweir     uno::Sequence<OUString> aServiceNames =
478cdf0e10cSrcweir         AccessibleDocumentViewBase::getSupportedServiceNames();
479cdf0e10cSrcweir     sal_Int32 nCount (aServiceNames.getLength());
480cdf0e10cSrcweir 
481cdf0e10cSrcweir     // ...and add additional names.
482cdf0e10cSrcweir     aServiceNames.realloc (nCount + 1);
483cdf0e10cSrcweir     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
484cdf0e10cSrcweir         "com.sun.star.drawing.AccessibleDrawDocumentView"));
485cdf0e10cSrcweir     aServiceNames[nCount] = sAdditionalServiceName;
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     return aServiceNames;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490*0deba7fbSSteve Yin //=====  XInterface  ==========================================================
491*0deba7fbSSteve Yin 
492*0deba7fbSSteve Yin uno::Any SAL_CALL
queryInterface(const uno::Type & rType)493*0deba7fbSSteve Yin     AccessibleDrawDocumentView::queryInterface (const uno::Type & rType)
494*0deba7fbSSteve Yin     throw (uno::RuntimeException)
495*0deba7fbSSteve Yin {
496*0deba7fbSSteve Yin     uno::Any aReturn = AccessibleDocumentViewBase::queryInterface (rType);
497*0deba7fbSSteve Yin     if ( ! aReturn.hasValue())
498*0deba7fbSSteve Yin         aReturn = ::cppu::queryInterface (rType,
499*0deba7fbSSteve Yin             static_cast<XAccessibleGroupPosition*>(this)
500*0deba7fbSSteve Yin             );
501*0deba7fbSSteve Yin     return aReturn;
502*0deba7fbSSteve Yin }
503cdf0e10cSrcweir 
504*0deba7fbSSteve Yin void SAL_CALL
acquire(void)505*0deba7fbSSteve Yin     AccessibleDrawDocumentView::acquire (void)
506*0deba7fbSSteve Yin     throw ()
507*0deba7fbSSteve Yin {
508*0deba7fbSSteve Yin     AccessibleDocumentViewBase::acquire ();
509*0deba7fbSSteve Yin }
510*0deba7fbSSteve Yin void SAL_CALL
release(void)511*0deba7fbSSteve Yin     AccessibleDrawDocumentView::release (void)
512*0deba7fbSSteve Yin     throw ()
513*0deba7fbSSteve Yin {
514*0deba7fbSSteve Yin     AccessibleDocumentViewBase::release ();
515*0deba7fbSSteve Yin }
516*0deba7fbSSteve Yin //=====  XAccessibleGroupPosition  =========================================
517*0deba7fbSSteve Yin uno::Sequence< sal_Int32 > SAL_CALL
getGroupPosition(const uno::Any & rAny)518*0deba7fbSSteve Yin     AccessibleDrawDocumentView::getGroupPosition( const uno::Any& rAny )
519*0deba7fbSSteve Yin     throw (uno::RuntimeException)
520*0deba7fbSSteve Yin {
521*0deba7fbSSteve Yin 	// we will return the:
522*0deba7fbSSteve Yin 	// [0] group level(always be 0 now)
523*0deba7fbSSteve Yin 	// [1] similar items counts in the group
524*0deba7fbSSteve Yin 	// [2] the position of the object in the group
525*0deba7fbSSteve Yin 	uno::Sequence< sal_Int32 > aRet( 3 );
526*0deba7fbSSteve Yin 	//get the xShape of the current selected drawing object
527*0deba7fbSSteve Yin 	uno::Reference<XAccessibleContext> xAccContent;
528*0deba7fbSSteve Yin 	rAny >>= xAccContent;
529*0deba7fbSSteve Yin 	if ( !xAccContent.is() )
530*0deba7fbSSteve Yin 	{
531*0deba7fbSSteve Yin 		return aRet;
532*0deba7fbSSteve Yin 	}
533*0deba7fbSSteve Yin 	AccessibleShape* pAcc = AccessibleShape::getImplementation( xAccContent );
534*0deba7fbSSteve Yin 	if ( !pAcc )
535*0deba7fbSSteve Yin 	{
536*0deba7fbSSteve Yin 		return aRet;
537*0deba7fbSSteve Yin 	}
538*0deba7fbSSteve Yin 	uno::Reference< drawing::XShape > xCurShape = pAcc->GetXShape();
539*0deba7fbSSteve Yin 	if ( !xCurShape.is() )
540*0deba7fbSSteve Yin 	{
541*0deba7fbSSteve Yin 		return aRet;
542*0deba7fbSSteve Yin 	}
543*0deba7fbSSteve Yin 	//find all the child in the page, insert them into a vector and sort
544*0deba7fbSSteve Yin 	if ( mpChildrenManager == NULL )
545*0deba7fbSSteve Yin 	{
546*0deba7fbSSteve Yin 		return aRet;
547*0deba7fbSSteve Yin 	}
548*0deba7fbSSteve Yin 	std::vector< uno::Reference<drawing::XShape> > vXShapes;
549*0deba7fbSSteve Yin 	sal_Int32 nCount = mpChildrenManager->GetChildCount();
550*0deba7fbSSteve Yin 	//get pointer of SdView & SdrPageView for further use.
551*0deba7fbSSteve Yin 	SdrPageView* pPV = NULL;
552*0deba7fbSSteve Yin 	::sd::View* pSdView = NULL;
553*0deba7fbSSteve Yin 	if ( mpSdViewSh )
554*0deba7fbSSteve Yin 	{
555*0deba7fbSSteve Yin 		pSdView = mpSdViewSh->GetView();
556*0deba7fbSSteve Yin 		pPV = pSdView->GetSdrPageView();
557*0deba7fbSSteve Yin 	}
558*0deba7fbSSteve Yin 	for ( sal_Int32 i = 0; i < nCount; i++ )
559*0deba7fbSSteve Yin 	{
560*0deba7fbSSteve Yin 		uno::Reference< drawing::XShape > xShape = mpChildrenManager->GetChildShape(i);
561*0deba7fbSSteve Yin 		if ( xShape.is() )
562*0deba7fbSSteve Yin 		{
563*0deba7fbSSteve Yin 			//if the object is visable in the page, we add it into the group list.
564*0deba7fbSSteve Yin 			SdrObject* pObj = GetSdrObjectFromXShape(xShape);
565*0deba7fbSSteve Yin 			if ( pObj && pPV && pSdView && pSdView->IsObjMarkable( pObj, pPV ) )
566*0deba7fbSSteve Yin 			{
567*0deba7fbSSteve Yin 				vXShapes.push_back( xShape );
568*0deba7fbSSteve Yin 			}
569*0deba7fbSSteve Yin 		}
570*0deba7fbSSteve Yin 	}
571*0deba7fbSSteve Yin 	std::sort( vXShapes.begin(), vXShapes.end(), XShapePosCompareHelper() );
572*0deba7fbSSteve Yin 	//get the the index of the selected object in the group
573*0deba7fbSSteve Yin 	std::vector< uno::Reference<drawing::XShape> >::iterator aIter;
574*0deba7fbSSteve Yin 	//we start counting position from 1
575*0deba7fbSSteve Yin 	sal_Int32 nPos = 1;
576*0deba7fbSSteve Yin 	for ( aIter = vXShapes.begin(); aIter != vXShapes.end(); aIter++, nPos++ )
577*0deba7fbSSteve Yin 	{
578*0deba7fbSSteve Yin 		if ( (*aIter).get() == xCurShape.get() )
579*0deba7fbSSteve Yin 		{
580*0deba7fbSSteve Yin 			sal_Int32* pArray = aRet.getArray();
581*0deba7fbSSteve Yin 			pArray[0] = 1; //it should be 1 based, not 0 based.
582*0deba7fbSSteve Yin 			pArray[1] = vXShapes.size();
583*0deba7fbSSteve Yin 			pArray[2] = nPos;
584*0deba7fbSSteve Yin 			break;
585*0deba7fbSSteve Yin 		}
586*0deba7fbSSteve Yin 	}
587*0deba7fbSSteve Yin 	return aRet;
588*0deba7fbSSteve Yin }
getObjectLink(const uno::Any & rAny)589*0deba7fbSSteve Yin ::rtl::OUString AccessibleDrawDocumentView::getObjectLink( const uno::Any& rAny )
590*0deba7fbSSteve Yin 	throw (uno::RuntimeException)
591*0deba7fbSSteve Yin {
592*0deba7fbSSteve Yin 	::rtl::OUString aRet;
593*0deba7fbSSteve Yin 	//get the xShape of the current selected drawing object
594*0deba7fbSSteve Yin 	uno::Reference<XAccessibleContext> xAccContent;
595*0deba7fbSSteve Yin 	rAny >>= xAccContent;
596*0deba7fbSSteve Yin 	if ( !xAccContent.is() )
597*0deba7fbSSteve Yin 	{
598*0deba7fbSSteve Yin 		return aRet;
599*0deba7fbSSteve Yin 	}
600*0deba7fbSSteve Yin 	AccessibleShape* pAcc = AccessibleShape::getImplementation( xAccContent );
601*0deba7fbSSteve Yin 	if ( !pAcc )
602*0deba7fbSSteve Yin 	{
603*0deba7fbSSteve Yin 		return aRet;
604*0deba7fbSSteve Yin 	}
605*0deba7fbSSteve Yin 	uno::Reference< drawing::XShape > xCurShape = pAcc->GetXShape();
606*0deba7fbSSteve Yin 	if ( !xCurShape.is() )
607*0deba7fbSSteve Yin 	{
608*0deba7fbSSteve Yin 		return aRet;
609*0deba7fbSSteve Yin 	}
610*0deba7fbSSteve Yin 	SdrObject* pObj = GetSdrObjectFromXShape(xCurShape);
611*0deba7fbSSteve Yin 	if (pObj)
612*0deba7fbSSteve Yin 	{
613*0deba7fbSSteve Yin 		SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj);
614*0deba7fbSSteve Yin 		if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
615*0deba7fbSSteve Yin 			aRet = (::rtl::OUString)pInfo->GetBookmark();
616*0deba7fbSSteve Yin 	}
617*0deba7fbSSteve Yin 	return aRet;
618*0deba7fbSSteve Yin }
619cdf0e10cSrcweir ///	Create a name for this view.
620cdf0e10cSrcweir ::rtl::OUString
CreateAccessibleName(void)621cdf0e10cSrcweir     AccessibleDrawDocumentView::CreateAccessibleName (void)
622cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
623cdf0e10cSrcweir {
624cdf0e10cSrcweir 	rtl::OUString sName;
625cdf0e10cSrcweir 
626cdf0e10cSrcweir     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
627cdf0e10cSrcweir     if (xInfo.is())
628cdf0e10cSrcweir     {
629cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
630cdf0e10cSrcweir         OUString sFirstService = aServices[0];
631cdf0e10cSrcweir         if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView")))
632cdf0e10cSrcweir         {
633cdf0e10cSrcweir             if( aServices.getLength() >= 2 &&
634cdf0e10cSrcweir                 aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView")))
635cdf0e10cSrcweir             {
636cdf0e10cSrcweir                 ::vos::OGuard aGuard( Application::GetSolarMutex() );
637cdf0e10cSrcweir 
638cdf0e10cSrcweir                 sName = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_N) );
639cdf0e10cSrcweir             }
640cdf0e10cSrcweir             else
641cdf0e10cSrcweir             {
642cdf0e10cSrcweir                 ::vos::OGuard aGuard( Application::GetSolarMutex() );
643cdf0e10cSrcweir 
644cdf0e10cSrcweir                 sName = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_N) );
645cdf0e10cSrcweir             }
646cdf0e10cSrcweir         }
647cdf0e10cSrcweir         else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView")))
648cdf0e10cSrcweir         {
649cdf0e10cSrcweir             ::vos::OGuard aGuard( Application::GetSolarMutex() );
650cdf0e10cSrcweir 
651cdf0e10cSrcweir             sName = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_N) );
652cdf0e10cSrcweir         }
653cdf0e10cSrcweir         else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView")))
654cdf0e10cSrcweir         {
655cdf0e10cSrcweir             ::vos::OGuard aGuard( Application::GetSolarMutex() );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir             sName = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_N) );
658cdf0e10cSrcweir         }
659cdf0e10cSrcweir         else
660cdf0e10cSrcweir         {
661cdf0e10cSrcweir             sName = sFirstService;
662cdf0e10cSrcweir         }
663cdf0e10cSrcweir     }
664cdf0e10cSrcweir     else
665cdf0e10cSrcweir     {
666cdf0e10cSrcweir         sName = OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDrawDocumentView"));
667cdf0e10cSrcweir     }
668cdf0e10cSrcweir 	return sName;
669cdf0e10cSrcweir }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 
673cdf0e10cSrcweir 
674cdf0e10cSrcweir /** Create a description for this view.  Use the model's description or URL
675cdf0e10cSrcweir     if a description is not available.
676cdf0e10cSrcweir */
677cdf0e10cSrcweir ::rtl::OUString
CreateAccessibleDescription(void)678cdf0e10cSrcweir     AccessibleDrawDocumentView::CreateAccessibleDescription (void)
679cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
680cdf0e10cSrcweir {
681cdf0e10cSrcweir 	rtl::OUString sDescription;
682cdf0e10cSrcweir 
683cdf0e10cSrcweir     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
684cdf0e10cSrcweir     if (xInfo.is())
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
687cdf0e10cSrcweir         OUString sFirstService = aServices[0];
688cdf0e10cSrcweir         if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView")))
689cdf0e10cSrcweir         {
690cdf0e10cSrcweir             if( aServices.getLength() >= 2 &&
691cdf0e10cSrcweir                 aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView")))
692cdf0e10cSrcweir             {
693cdf0e10cSrcweir                 ::vos::OGuard aGuard( Application::GetSolarMutex() );
694cdf0e10cSrcweir 
695cdf0e10cSrcweir                 sDescription = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_D) );
696cdf0e10cSrcweir             }
697cdf0e10cSrcweir             else
698cdf0e10cSrcweir             {
699cdf0e10cSrcweir                 ::vos::OGuard aGuard( Application::GetSolarMutex() );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir                 sDescription = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_D) );
702cdf0e10cSrcweir             }
703cdf0e10cSrcweir         }
704cdf0e10cSrcweir         else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView")))
705cdf0e10cSrcweir         {
706cdf0e10cSrcweir             ::vos::OGuard aGuard( Application::GetSolarMutex() );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir             sDescription = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_D) );
709cdf0e10cSrcweir         }
710cdf0e10cSrcweir         else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView")))
711cdf0e10cSrcweir         {
712cdf0e10cSrcweir             ::vos::OGuard aGuard( Application::GetSolarMutex() );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir             sDescription = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_D) );
715cdf0e10cSrcweir         }
716cdf0e10cSrcweir         else
717cdf0e10cSrcweir         {
718cdf0e10cSrcweir             sDescription = sFirstService;
719cdf0e10cSrcweir         }
720cdf0e10cSrcweir     }
721cdf0e10cSrcweir     else
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         sDescription = OUString(RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document"));
724cdf0e10cSrcweir     }
725cdf0e10cSrcweir 	return sDescription;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 
730cdf0e10cSrcweir 
731cdf0e10cSrcweir /** Return selection state of specified child
732cdf0e10cSrcweir */
733cdf0e10cSrcweir sal_Bool
implIsSelected(sal_Int32 nAccessibleChildIndex)734cdf0e10cSrcweir     AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex )
735cdf0e10cSrcweir     throw (uno::RuntimeException)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     const vos::OGuard                           aSolarGuard( Application::GetSolarMutex() );
738cdf0e10cSrcweir     uno::Reference< view::XSelectionSupplier >  xSel( mxController, uno::UNO_QUERY );
739cdf0e10cSrcweir     sal_Bool                                    bRet = sal_False;
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 	OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" );
742cdf0e10cSrcweir 
743cdf0e10cSrcweir     if( xSel.is() && ( 0 <= nAccessibleChildIndex ) )
744cdf0e10cSrcweir     {
745cdf0e10cSrcweir         uno::Any                            aAny( xSel->getSelection() );
746cdf0e10cSrcweir         uno::Reference< drawing::XShapes >  xShapes;
747cdf0e10cSrcweir 
748cdf0e10cSrcweir         aAny >>= xShapes;
749cdf0e10cSrcweir 
750cdf0e10cSrcweir         if( xShapes.is() )
751cdf0e10cSrcweir         {
752cdf0e10cSrcweir             AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) );
753cdf0e10cSrcweir 
754cdf0e10cSrcweir             if( pAcc )
755cdf0e10cSrcweir             {
756cdf0e10cSrcweir                 uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
757cdf0e10cSrcweir 
758cdf0e10cSrcweir                 if( xShape.is() )
759cdf0e10cSrcweir                 {
760cdf0e10cSrcweir                     for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i )
761cdf0e10cSrcweir                         if( xShapes->getByIndex( i ) == xShape )
762cdf0e10cSrcweir                             bRet = sal_True;
763cdf0e10cSrcweir                 }
764cdf0e10cSrcweir             }
765cdf0e10cSrcweir         }
766cdf0e10cSrcweir     }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir     return( bRet );
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 
773cdf0e10cSrcweir 
774cdf0e10cSrcweir /** Select or delselect the specified shapes.  The corresponding accessible
775cdf0e10cSrcweir     shapes are notified over the selection change listeners registered with
776cdf0e10cSrcweir     the XSelectionSupplier of the controller.
777cdf0e10cSrcweir */
778cdf0e10cSrcweir void
implSelect(sal_Int32 nAccessibleChildIndex,sal_Bool bSelect)779cdf0e10cSrcweir     AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
780cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     const vos::OGuard                           aSolarGuard( Application::GetSolarMutex() );
783cdf0e10cSrcweir     uno::Reference< view::XSelectionSupplier >  xSel( mxController, uno::UNO_QUERY );
784cdf0e10cSrcweir     AccessibleShape* pAccessibleChild;
785cdf0e10cSrcweir 
786cdf0e10cSrcweir     if( xSel.is() )
787cdf0e10cSrcweir     {
788cdf0e10cSrcweir         uno::Any aAny;
789cdf0e10cSrcweir 
790cdf0e10cSrcweir         if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex )
791cdf0e10cSrcweir         {
792cdf0e10cSrcweir             // Select or deselect all children.
793cdf0e10cSrcweir 
794cdf0e10cSrcweir             if( !bSelect )
795cdf0e10cSrcweir                 xSel->select( aAny );
796cdf0e10cSrcweir             else
797cdf0e10cSrcweir             {
798cdf0e10cSrcweir                 uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() );
799cdf0e10cSrcweir 
800cdf0e10cSrcweir                 for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
801cdf0e10cSrcweir                 {
802cdf0e10cSrcweir                     AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) );
803cdf0e10cSrcweir 
804cdf0e10cSrcweir                     if( pAcc && pAcc->GetXShape().is() )
805cdf0e10cSrcweir                     {
806cdf0e10cSrcweir                         xShapes->add( pAcc->GetXShape() );
807cdf0e10cSrcweir                         pAccessibleChild = pAcc;
808cdf0e10cSrcweir                     }
809cdf0e10cSrcweir                 }
810cdf0e10cSrcweir 
811cdf0e10cSrcweir                 if( xShapes->getCount() )
812cdf0e10cSrcweir                 {
813cdf0e10cSrcweir                     aAny <<= xShapes;
814cdf0e10cSrcweir                     xSel->select( aAny );
815cdf0e10cSrcweir                 }
816cdf0e10cSrcweir             }
817cdf0e10cSrcweir         }
818cdf0e10cSrcweir         else if( nAccessibleChildIndex >= 0 )
819cdf0e10cSrcweir         {
820cdf0e10cSrcweir             // Select or deselect only the child with index
821cdf0e10cSrcweir             // nAccessibleChildIndex.
822cdf0e10cSrcweir 
823cdf0e10cSrcweir             AccessibleShape* pAcc = AccessibleShape::getImplementation(
824cdf0e10cSrcweir                 getAccessibleChild( nAccessibleChildIndex ));
825cdf0e10cSrcweir             pAccessibleChild = pAcc;
826cdf0e10cSrcweir 
827cdf0e10cSrcweir             // Add or remove the shape that is made accessible from the
828cdf0e10cSrcweir             // selection of the controller.
829cdf0e10cSrcweir             if( pAcc )
830cdf0e10cSrcweir             {
831cdf0e10cSrcweir                 uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
832cdf0e10cSrcweir 
833cdf0e10cSrcweir                 if( xShape.is() )
834cdf0e10cSrcweir                 {
835cdf0e10cSrcweir                     uno::Reference< drawing::XShapes >  xShapes;
836cdf0e10cSrcweir                     sal_Bool                            bFound = sal_False;
837cdf0e10cSrcweir 
838cdf0e10cSrcweir                     aAny = xSel->getSelection();
839cdf0e10cSrcweir                     aAny >>= xShapes;
840cdf0e10cSrcweir 
841cdf0e10cSrcweir                     // Search shape to be selected in current selection.
842cdf0e10cSrcweir                     if (xShapes.is())
843cdf0e10cSrcweir                     {
844cdf0e10cSrcweir                         sal_Int32 nCount = xShapes->getCount();
845cdf0e10cSrcweir                         for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i )
846cdf0e10cSrcweir                             if( xShapes->getByIndex( i ) == xShape )
847cdf0e10cSrcweir                                 bFound = sal_True;
848cdf0e10cSrcweir                     }
849cdf0e10cSrcweir                     else
850cdf0e10cSrcweir                         // Create an empty selection to add the shape to.
851cdf0e10cSrcweir                         xShapes = new SvxShapeCollection();
852cdf0e10cSrcweir 
853cdf0e10cSrcweir                     // Update the selection.
854cdf0e10cSrcweir                     if( !bFound && bSelect )
855cdf0e10cSrcweir                         xShapes->add( xShape );
856cdf0e10cSrcweir                     else if( bFound && !bSelect )
857cdf0e10cSrcweir                         xShapes->remove( xShape );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir                     aAny <<= xShapes;
860cdf0e10cSrcweir                     xSel->select( aAny );
861cdf0e10cSrcweir                 }
862cdf0e10cSrcweir             }
863cdf0e10cSrcweir         }
864cdf0e10cSrcweir     }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 
Activated(void)870cdf0e10cSrcweir void AccessibleDrawDocumentView::Activated (void)
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     if (mpChildrenManager != NULL)
873cdf0e10cSrcweir     {
874*0deba7fbSSteve Yin 	sal_Bool bChange = sal_False;
875cdf0e10cSrcweir         // When none of the children has the focus then claim it for the
876cdf0e10cSrcweir         // view.
877cdf0e10cSrcweir         if ( ! mpChildrenManager->HasFocus())
878*0deba7fbSSteve Yin 	{
879cdf0e10cSrcweir             SetState (AccessibleStateType::FOCUSED);
880*0deba7fbSSteve Yin 	    bChange = sal_True;
881*0deba7fbSSteve Yin 	}
882cdf0e10cSrcweir         else
883cdf0e10cSrcweir             ResetState (AccessibleStateType::FOCUSED);
884*0deba7fbSSteve Yin 	mpChildrenManager->UpdateSelection();
885*0deba7fbSSteve Yin 	// if the child gets focus in UpdateSelection(), needs to reset the focus on document.
886*0deba7fbSSteve Yin 	if (mpChildrenManager->HasFocus() && bChange)
887*0deba7fbSSteve Yin 		ResetState (AccessibleStateType::FOCUSED);
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 
Deactivated(void)894cdf0e10cSrcweir void AccessibleDrawDocumentView::Deactivated (void)
895cdf0e10cSrcweir {
896cdf0e10cSrcweir     if (mpChildrenManager != NULL)
897cdf0e10cSrcweir         mpChildrenManager->RemoveFocus();
898cdf0e10cSrcweir     ResetState (AccessibleStateType::FOCUSED);
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 
impl_dispose(void)904cdf0e10cSrcweir void AccessibleDrawDocumentView::impl_dispose (void)
905cdf0e10cSrcweir {
906cdf0e10cSrcweir     if (mpChildrenManager != NULL)
907cdf0e10cSrcweir     {
908cdf0e10cSrcweir         delete mpChildrenManager;
909cdf0e10cSrcweir         mpChildrenManager = NULL;
910cdf0e10cSrcweir     }
911cdf0e10cSrcweir 
912cdf0e10cSrcweir     AccessibleDocumentViewBase::impl_dispose();
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 
917cdf0e10cSrcweir /** This method is called from the component helper base class while
918cdf0e10cSrcweir     disposing.
919cdf0e10cSrcweir */
disposing(void)920cdf0e10cSrcweir void SAL_CALL AccessibleDrawDocumentView::disposing (void)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir 
923cdf0e10cSrcweir     // Release resources.
924cdf0e10cSrcweir     if (mpChildrenManager != NULL)
925cdf0e10cSrcweir     {
926cdf0e10cSrcweir         delete mpChildrenManager;
927cdf0e10cSrcweir         mpChildrenManager = NULL;
928cdf0e10cSrcweir     }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     // Forward call to base classes.
931cdf0e10cSrcweir     AccessibleDocumentViewBase::disposing ();
932cdf0e10cSrcweir }
933cdf0e10cSrcweir 
934*0deba7fbSSteve Yin ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
get_AccFlowTo(const::com::sun::star::uno::Any & rAny,sal_Int32 nType)935*0deba7fbSSteve Yin 		SAL_CALL AccessibleDrawDocumentView::get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
936*0deba7fbSSteve Yin 		throw ( ::com::sun::star::uno::RuntimeException )
937*0deba7fbSSteve Yin {
938*0deba7fbSSteve Yin 	const sal_Int32 SPELLCHECKFLOWTO = 1;
939*0deba7fbSSteve Yin 	const sal_Int32 FINDREPLACEFLOWTO = 2;
940*0deba7fbSSteve Yin 	if ( nType == SPELLCHECKFLOWTO )
941*0deba7fbSSteve Yin 	{
942*0deba7fbSSteve Yin 		uno::Reference< ::com::sun::star::drawing::XShape > xShape;
943*0deba7fbSSteve Yin 		rAny >>= xShape;
944*0deba7fbSSteve Yin 		if ( mpChildrenManager && xShape.is() )
945*0deba7fbSSteve Yin 		{
946*0deba7fbSSteve Yin 			uno::Reference < XAccessible > xAcc = mpChildrenManager->GetChild(xShape);
947*0deba7fbSSteve Yin 			uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY );
948*0deba7fbSSteve Yin 			if ( xAccSelection.is() )
949*0deba7fbSSteve Yin 			{
950*0deba7fbSSteve Yin 				if ( xAccSelection->getSelectedAccessibleChildCount() )
951*0deba7fbSSteve Yin 				{
952*0deba7fbSSteve Yin 					uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 );
953*0deba7fbSSteve Yin 					if ( xSel.is() )
954*0deba7fbSSteve Yin 					{
955*0deba7fbSSteve Yin 						uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
956*0deba7fbSSteve Yin 						if ( xSelContext.is() )
957*0deba7fbSSteve Yin 						{
958*0deba7fbSSteve Yin 							//if in sw we find the selected paragraph here
959*0deba7fbSSteve Yin 							if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
960*0deba7fbSSteve Yin 							{
961*0deba7fbSSteve Yin 								uno::Sequence<uno::Any> aRet( 1 );
962*0deba7fbSSteve Yin 								aRet[0] = uno::makeAny( xSel );
963*0deba7fbSSteve Yin 								return aRet;
964*0deba7fbSSteve Yin 							}
965*0deba7fbSSteve Yin 						}
966*0deba7fbSSteve Yin 					}
967*0deba7fbSSteve Yin 				}
968*0deba7fbSSteve Yin 			}
969*0deba7fbSSteve Yin 			uno::Reference<XAccessible> xPara = GetSelAccContextInTable();
970*0deba7fbSSteve Yin 			if ( xPara.is() )
971*0deba7fbSSteve Yin 			{
972*0deba7fbSSteve Yin 				uno::Sequence<uno::Any> aRet( 1 );
973*0deba7fbSSteve Yin 				aRet[0] = uno::makeAny( xPara );
974*0deba7fbSSteve Yin 				return aRet;
975*0deba7fbSSteve Yin 			}
976*0deba7fbSSteve Yin 		}
977*0deba7fbSSteve Yin 		else
978*0deba7fbSSteve Yin 		{
979*0deba7fbSSteve Yin 			goto Rt;
980*0deba7fbSSteve Yin 		}
981*0deba7fbSSteve Yin 	}
982*0deba7fbSSteve Yin 	else if ( nType == FINDREPLACEFLOWTO )
983*0deba7fbSSteve Yin 	{
984*0deba7fbSSteve Yin 		sal_Int32 nChildCount = getSelectedAccessibleChildCount();
985*0deba7fbSSteve Yin 		if ( nChildCount )
986*0deba7fbSSteve Yin 		{
987*0deba7fbSSteve Yin 			uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 );
988*0deba7fbSSteve Yin 			if ( xSel.is() )
989*0deba7fbSSteve Yin 			{
990*0deba7fbSSteve Yin 				uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY );
991*0deba7fbSSteve Yin 				if ( xAccChildSelection.is() )
992*0deba7fbSSteve Yin 				{
993*0deba7fbSSteve Yin 					if ( xAccChildSelection->getSelectedAccessibleChildCount() )
994*0deba7fbSSteve Yin 					{
995*0deba7fbSSteve Yin 						uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 );
996*0deba7fbSSteve Yin 						if ( xChildSel.is() )
997*0deba7fbSSteve Yin 						{
998*0deba7fbSSteve Yin 							uno::Reference < XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() );
999*0deba7fbSSteve Yin 							if ( xChildSelContext.is() &&
1000*0deba7fbSSteve Yin 								xChildSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
1001*0deba7fbSSteve Yin 							{
1002*0deba7fbSSteve Yin 								uno::Sequence<uno::Any> aRet( 1 );
1003*0deba7fbSSteve Yin 								aRet[0] = uno::makeAny( xChildSel );
1004*0deba7fbSSteve Yin 								return aRet;
1005*0deba7fbSSteve Yin 							}
1006*0deba7fbSSteve Yin 						}
1007*0deba7fbSSteve Yin 					}
1008*0deba7fbSSteve Yin 				}
1009*0deba7fbSSteve Yin 			}
1010*0deba7fbSSteve Yin 		}
1011*0deba7fbSSteve Yin 		else
1012*0deba7fbSSteve Yin 		{
1013*0deba7fbSSteve Yin 			uno::Reference<XAccessible> xPara = GetSelAccContextInTable();
1014*0deba7fbSSteve Yin 			if ( xPara.is() )
1015*0deba7fbSSteve Yin 			{
1016*0deba7fbSSteve Yin 				uno::Sequence<uno::Any> aRet( 1 );
1017*0deba7fbSSteve Yin 				aRet[0] = uno::makeAny( xPara );
1018*0deba7fbSSteve Yin 				return aRet;
1019*0deba7fbSSteve Yin 			}
1020*0deba7fbSSteve Yin 		}
1021*0deba7fbSSteve Yin 	}
1022*0deba7fbSSteve Yin 
1023*0deba7fbSSteve Yin Rt:
1024*0deba7fbSSteve Yin 	::com::sun::star::uno::Sequence< uno::Any> aRet;
1025*0deba7fbSSteve Yin 	return aRet;
1026*0deba7fbSSteve Yin }
GetSelAccContextInTable()1027*0deba7fbSSteve Yin uno::Reference<XAccessible> AccessibleDrawDocumentView::GetSelAccContextInTable()
1028*0deba7fbSSteve Yin {
1029*0deba7fbSSteve Yin 	uno::Reference<XAccessible> xRet;
1030*0deba7fbSSteve Yin 	sal_Int32 nCount = mpChildrenManager ? mpChildrenManager->GetChildCount() : 0;
1031*0deba7fbSSteve Yin 	if ( nCount )
1032*0deba7fbSSteve Yin 	{
1033*0deba7fbSSteve Yin 		for ( sal_Int32 i = 0; i < nCount; i++ )
1034*0deba7fbSSteve Yin 		{
1035*0deba7fbSSteve Yin 			try
1036*0deba7fbSSteve Yin 			{
1037*0deba7fbSSteve Yin 				uno::Reference<XAccessible> xObj = mpChildrenManager->GetChild(i);
1038*0deba7fbSSteve Yin 				if ( xObj.is() )
1039*0deba7fbSSteve Yin 				{
1040*0deba7fbSSteve Yin 					uno::Reference<XAccessibleContext> xObjContext( xObj, uno::UNO_QUERY );
1041*0deba7fbSSteve Yin 					if ( xObjContext.is() && xObjContext->getAccessibleRole() == AccessibleRole::TABLE )
1042*0deba7fbSSteve Yin 					{
1043*0deba7fbSSteve Yin 						uno::Reference<XAccessibleSelection> xObjSelection( xObj, uno::UNO_QUERY );
1044*0deba7fbSSteve Yin 						if ( xObjSelection.is() && xObjSelection->getSelectedAccessibleChildCount() )
1045*0deba7fbSSteve Yin 						{
1046*0deba7fbSSteve Yin 							uno::Reference<XAccessible> xCell = xObjSelection->getSelectedAccessibleChild(0);
1047*0deba7fbSSteve Yin 							if ( xCell.is() )
1048*0deba7fbSSteve Yin 							{
1049*0deba7fbSSteve Yin 								uno::Reference<XAccessibleSelection> xCellSel( xCell, uno::UNO_QUERY );
1050*0deba7fbSSteve Yin 								if ( xCellSel.is() && xCellSel->getSelectedAccessibleChildCount() )
1051*0deba7fbSSteve Yin 								{
1052*0deba7fbSSteve Yin 									uno::Reference<XAccessible> xPara = xCellSel->getSelectedAccessibleChild( 0 );
1053*0deba7fbSSteve Yin 									if ( xPara.is() )
1054*0deba7fbSSteve Yin 									{
1055*0deba7fbSSteve Yin 										uno::Reference<XAccessibleContext> xParaContext( xPara, uno::UNO_QUERY );
1056*0deba7fbSSteve Yin 										if ( xParaContext.is() &&
1057*0deba7fbSSteve Yin 											xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
1058*0deba7fbSSteve Yin 										{
1059*0deba7fbSSteve Yin 											xRet = xPara;
1060*0deba7fbSSteve Yin 											return xRet;
1061*0deba7fbSSteve Yin 										}
1062*0deba7fbSSteve Yin 									}
1063*0deba7fbSSteve Yin 								}
1064*0deba7fbSSteve Yin 							}
1065*0deba7fbSSteve Yin 						}
1066*0deba7fbSSteve Yin 					}
1067*0deba7fbSSteve Yin 				}
1068*0deba7fbSSteve Yin 			}
1069*0deba7fbSSteve Yin 			catch ( lang::IndexOutOfBoundsException )
1070*0deba7fbSSteve Yin 			{
1071*0deba7fbSSteve Yin 				uno::Reference<XAccessible> xEmpty;
1072*0deba7fbSSteve Yin 				return xEmpty;
1073*0deba7fbSSteve Yin 			}
1074*0deba7fbSSteve Yin 			catch ( uno::RuntimeException )
1075*0deba7fbSSteve Yin 			{
1076*0deba7fbSSteve Yin 				uno::Reference<XAccessible> xEmpty;
1077*0deba7fbSSteve Yin 				return xEmpty;
1078*0deba7fbSSteve Yin 			}
1079*0deba7fbSSteve Yin 		}
1080*0deba7fbSSteve Yin 	}
1081*0deba7fbSSteve Yin 
1082*0deba7fbSSteve Yin 	return xRet;
1083*0deba7fbSSteve Yin }
1084cdf0e10cSrcweir 
UpdateAccessibleName(void)1085cdf0e10cSrcweir void AccessibleDrawDocumentView::UpdateAccessibleName (void)
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir 	OUString sNewName (CreateAccessibleName());
1088cdf0e10cSrcweir     sNewName += A2S(": ");
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir     // Add the number of the current slide.
1091cdf0e10cSrcweir     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
1092cdf0e10cSrcweir     if (xView.is())
1093cdf0e10cSrcweir     {
1094cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY);
1095cdf0e10cSrcweir         if (xProperties.is())
1096cdf0e10cSrcweir             try
1097cdf0e10cSrcweir             {
1098cdf0e10cSrcweir                 sal_Int16 nPageNumber (0);
1099cdf0e10cSrcweir                 if (xProperties->getPropertyValue(A2S("Number")) >>= nPageNumber)
1100cdf0e10cSrcweir                 {
1101cdf0e10cSrcweir                     sNewName += OUString::valueOf(sal_Int32(nPageNumber));
1102cdf0e10cSrcweir                 }
1103cdf0e10cSrcweir             }
1104cdf0e10cSrcweir             catch (beans::UnknownPropertyException&)
1105cdf0e10cSrcweir             {
1106cdf0e10cSrcweir             }
1107cdf0e10cSrcweir     }
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir     // Add the number of pages/slides.
1110cdf0e10cSrcweir     Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY);
1111cdf0e10cSrcweir     if (xPagesSupplier.is())
1112cdf0e10cSrcweir     {
1113cdf0e10cSrcweir         Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY);
1114cdf0e10cSrcweir         if (xPages.is())
1115cdf0e10cSrcweir         {
1116cdf0e10cSrcweir             sNewName += A2S(" / ");
1117cdf0e10cSrcweir             sNewName += OUString::valueOf(xPages->getCount());
1118cdf0e10cSrcweir         }
1119cdf0e10cSrcweir     }
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir     SetAccessibleName (sNewName, AutomaticallyCreated);
1122cdf0e10cSrcweir }
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir } // end of namespace accessibility
1128