xref: /AOO41X/main/sd/source/ui/accessibility/AccessibleDocumentViewBase.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
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
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 "AccessibleDocumentViewBase.hxx"
27cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
28cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
30cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
33cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp>
34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <rtl/ustring.h>
39cdf0e10cSrcweir #include<sfx2/viewfrm.hxx>
40*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
41*0deba7fbSSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
42*0deba7fbSSteve Yin #include <sfx2/objsh.hxx>
43*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
44cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <svx/svdobj.hxx>
47cdf0e10cSrcweir #include <svx/svdmodel.hxx>
48cdf0e10cSrcweir #include <svx/unoapi.hxx>
49cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
50cdf0e10cSrcweir #include "Window.hxx"
51cdf0e10cSrcweir #include <vcl/svapp.hxx>
52*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
53*0deba7fbSSteve Yin #include "OutlineViewShell.hxx"
54cdf0e10cSrcweir 
55*0deba7fbSSteve Yin #include "SlideViewShell.hxx"
56cdf0e10cSrcweir 
57*0deba7fbSSteve Yin #include <svx/svdlayer.hxx>
58*0deba7fbSSteve Yin #include <editeng/editobj.hxx>
59*0deba7fbSSteve Yin #include "LayerTabBar.hxx"
60*0deba7fbSSteve Yin #include <svtools/colorcfg.hxx>
61*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
62cdf0e10cSrcweir #include "ViewShell.hxx"
63cdf0e10cSrcweir #include "View.hxx"
64cdf0e10cSrcweir #include <memory>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir using ::rtl::OUString;
67cdf0e10cSrcweir using namespace ::com::sun::star;
68cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
69cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir class SfxViewFrame;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir namespace accessibility {
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //=====  internal  ============================================================
76cdf0e10cSrcweir AccessibleDocumentViewBase::AccessibleDocumentViewBase (
77cdf0e10cSrcweir     ::sd::Window* pSdWindow,
78cdf0e10cSrcweir     ::sd::ViewShell* pViewShell,
79cdf0e10cSrcweir     const uno::Reference<frame::XController>& rxController,
80cdf0e10cSrcweir     const uno::Reference<XAccessible>& rxParent)
81cdf0e10cSrcweir     : AccessibleContextBase (rxParent, AccessibleRole::DOCUMENT),
82cdf0e10cSrcweir       mpWindow (pSdWindow),
83cdf0e10cSrcweir       mxController (rxController),
84cdf0e10cSrcweir       mxModel (NULL),
85cdf0e10cSrcweir       maViewForwarder (
86cdf0e10cSrcweir         static_cast<SdrPaintView*>(pViewShell->GetView()),
87cdf0e10cSrcweir         *static_cast<OutputDevice*>(pSdWindow))
88cdf0e10cSrcweir {
89cdf0e10cSrcweir     if (mxController.is())
90cdf0e10cSrcweir         mxModel = mxController->getModel();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     // Fill the shape tree info.
93cdf0e10cSrcweir     maShapeTreeInfo.SetModelBroadcaster (
94cdf0e10cSrcweir         uno::Reference<document::XEventBroadcaster>(
95cdf0e10cSrcweir             mxModel, uno::UNO_QUERY));
96cdf0e10cSrcweir     maShapeTreeInfo.SetController (mxController);
97cdf0e10cSrcweir     maShapeTreeInfo.SetSdrView (pViewShell->GetView());
98cdf0e10cSrcweir     maShapeTreeInfo.SetWindow (pSdWindow);
99cdf0e10cSrcweir     maShapeTreeInfo.SetViewForwarder (&maViewForwarder);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     mxWindow = ::VCLUnoHelper::GetInterface (pSdWindow);
102*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
103*0deba7fbSSteve Yin 	mpViewShell = pViewShell;
104*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir AccessibleDocumentViewBase::~AccessibleDocumentViewBase (void)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     // At this place we should be disposed.  You may want to add a
113cdf0e10cSrcweir     // corresponding assertion into the destructor of a derived class.
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir void AccessibleDocumentViewBase::Init (void)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     // Finish the initialization of the shape tree info container.
122cdf0e10cSrcweir     maShapeTreeInfo.SetDocumentWindow (this);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     // Register as window listener to stay up to date with its size and
125cdf0e10cSrcweir     // position.
126cdf0e10cSrcweir     mxWindow->addWindowListener (this);
127cdf0e10cSrcweir     // Register as focus listener to
128cdf0e10cSrcweir     mxWindow->addFocusListener (this);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     // Determine the list of shapes on the current page.
131cdf0e10cSrcweir     uno::Reference<drawing::XShapes> xShapeList;
132cdf0e10cSrcweir     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
133cdf0e10cSrcweir     if (xView.is())
134cdf0e10cSrcweir         xShapeList = uno::Reference<drawing::XShapes> (
135cdf0e10cSrcweir             xView->getCurrentPage(), uno::UNO_QUERY);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     // Register this object as dispose event listener at the model.
138cdf0e10cSrcweir 	if (mxModel.is())
139cdf0e10cSrcweir 		mxModel->addEventListener (
140cdf0e10cSrcweir             static_cast<awt::XWindowListener*>(this));
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     // Register as property change listener at the controller.
143cdf0e10cSrcweir     uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
144cdf0e10cSrcweir     if (xSet.is())
145cdf0e10cSrcweir         xSet->addPropertyChangeListener (
146cdf0e10cSrcweir             OUString (RTL_CONSTASCII_USTRINGPARAM("")),
147cdf0e10cSrcweir             static_cast<beans::XPropertyChangeListener*>(this));
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     // Register this object as dispose event listener at the controller.
150cdf0e10cSrcweir     if (mxController.is())
151cdf0e10cSrcweir         mxController->addEventListener (
152cdf0e10cSrcweir             static_cast<awt::XWindowListener*>(this));
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     // Register at VCL Window to be informed of activated and deactivated
155cdf0e10cSrcweir     // OLE objects.
156cdf0e10cSrcweir     Window* pWindow = maShapeTreeInfo.GetWindow();
157cdf0e10cSrcweir     if (pWindow != NULL)
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         maWindowLink = LINK(
160cdf0e10cSrcweir             this, AccessibleDocumentViewBase, WindowChildEventListener);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir         pWindow->AddChildEventListener (maWindowLink);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         sal_uInt16 nCount = pWindow->GetChildCount();
165cdf0e10cSrcweir         for (sal_uInt16 i=0; i<nCount; i++)
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir             Window* pChildWindow = pWindow->GetChild (i);
168cdf0e10cSrcweir             if (pChildWindow &&
169cdf0e10cSrcweir                 (AccessibleRole::EMBEDDED_OBJECT
170cdf0e10cSrcweir                     ==pChildWindow->GetAccessibleRole()))
171cdf0e10cSrcweir             {
172cdf0e10cSrcweir                 SetAccessibleOLEObject (pChildWindow->GetAccessible());
173cdf0e10cSrcweir             }
174cdf0e10cSrcweir         }
175cdf0e10cSrcweir     }
176*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
177*0deba7fbSSteve Yin 	SfxObjectShell* pObjShell = mpViewShell->GetViewFrame()->GetObjectShell();
178*0deba7fbSSteve Yin 	if(!pObjShell->IsReadOnly())
179*0deba7fbSSteve Yin 		SetState(AccessibleStateType::EDITABLE);
180*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 
186cdf0e10cSrcweir IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener,
187cdf0e10cSrcweir     VclSimpleEvent*, pEvent)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir     OSL_ASSERT(pEvent!=NULL && pEvent->ISA(VclWindowEvent));
190cdf0e10cSrcweir     if (pEvent!=NULL && pEvent->ISA(VclWindowEvent))
191cdf0e10cSrcweir     {
192cdf0e10cSrcweir         VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent);
193cdf0e10cSrcweir         //      DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
194cdf0e10cSrcweir         switch (pWindowEvent->GetId())
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             case VCLEVENT_OBJECT_DYING:
197cdf0e10cSrcweir             {
198cdf0e10cSrcweir                 // Window is dying.  Unregister from VCL Window.
199cdf0e10cSrcweir                 // This is also attempted in the disposing() method.
200cdf0e10cSrcweir                 Window* pWindow = maShapeTreeInfo.GetWindow();
201cdf0e10cSrcweir                 Window* pDyingWindow = static_cast<Window*>(
202cdf0e10cSrcweir                     pWindowEvent->GetWindow());
203cdf0e10cSrcweir                 if (pWindow==pDyingWindow && pWindow!=NULL && maWindowLink.IsSet())
204cdf0e10cSrcweir                 {
205cdf0e10cSrcweir                     pWindow->RemoveChildEventListener (maWindowLink);
206cdf0e10cSrcweir                     maWindowLink = Link();
207cdf0e10cSrcweir                 }
208cdf0e10cSrcweir             }
209cdf0e10cSrcweir             break;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir             case VCLEVENT_WINDOW_SHOW:
212cdf0e10cSrcweir             {
213cdf0e10cSrcweir                 // A new window has been created.  Is it an OLE object?
214cdf0e10cSrcweir                 Window* pChildWindow = static_cast<Window*>(
215cdf0e10cSrcweir                     pWindowEvent->GetData());
216cdf0e10cSrcweir                 if (pChildWindow!=NULL
217cdf0e10cSrcweir                     && (pChildWindow->GetAccessibleRole()
218cdf0e10cSrcweir                         == AccessibleRole::EMBEDDED_OBJECT))
219cdf0e10cSrcweir                 {
220cdf0e10cSrcweir                     SetAccessibleOLEObject (pChildWindow->GetAccessible());
221cdf0e10cSrcweir                 }
222cdf0e10cSrcweir             }
223cdf0e10cSrcweir             break;
224cdf0e10cSrcweir 
225cdf0e10cSrcweir             case VCLEVENT_WINDOW_HIDE:
226cdf0e10cSrcweir             {
227cdf0e10cSrcweir                 // A window has been destroyed.  Has that been an OLE
228cdf0e10cSrcweir                 // object?
229cdf0e10cSrcweir                 Window* pChildWindow = static_cast<Window*>(
230cdf0e10cSrcweir                     pWindowEvent->GetData());
231cdf0e10cSrcweir                 if (pChildWindow!=NULL
232cdf0e10cSrcweir                     && (pChildWindow->GetAccessibleRole()
233cdf0e10cSrcweir                         == AccessibleRole::EMBEDDED_OBJECT))
234cdf0e10cSrcweir                 {
235cdf0e10cSrcweir                     SetAccessibleOLEObject (NULL);
236cdf0e10cSrcweir                 }
237cdf0e10cSrcweir             }
238cdf0e10cSrcweir             break;
239cdf0e10cSrcweir         }
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     return 0;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //=====  IAccessibleViewForwarderListener  ====================================
249cdf0e10cSrcweir 
250cdf0e10cSrcweir void AccessibleDocumentViewBase::ViewForwarderChanged(ChangeType, const IAccessibleViewForwarder* )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     // Empty
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
258cdf0e10cSrcweir //=====  XAccessibleContext  ==================================================
259cdf0e10cSrcweir 
260cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
261cdf0e10cSrcweir    	AccessibleDocumentViewBase::getAccessibleParent (void)
262cdf0e10cSrcweir     throw (uno::RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     ThrowIfDisposed ();
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     return AccessibleContextBase::getAccessibleParent();
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 
271cdf0e10cSrcweir sal_Int32 SAL_CALL
272cdf0e10cSrcweir     AccessibleDocumentViewBase::getAccessibleChildCount (void)
273cdf0e10cSrcweir     throw (uno::RuntimeException)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     ThrowIfDisposed ();
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     if (mxAccessibleOLEObject.is())
278cdf0e10cSrcweir         return 1;
279cdf0e10cSrcweir     else
280cdf0e10cSrcweir         return 0;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 
286cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
287cdf0e10cSrcweir     AccessibleDocumentViewBase::getAccessibleChild (sal_Int32 nIndex)
288cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir     ThrowIfDisposed ();
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
293cdf0e10cSrcweir     if (mxAccessibleOLEObject.is())
294cdf0e10cSrcweir         if (nIndex == 0)
295cdf0e10cSrcweir             return mxAccessibleOLEObject;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir     throw lang::IndexOutOfBoundsException (
298cdf0e10cSrcweir         ::rtl::OUString::createFromAscii ("no child with index ")
299cdf0e10cSrcweir         + rtl::OUString::valueOf(nIndex),
300cdf0e10cSrcweir 		NULL);
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 
306cdf0e10cSrcweir //=====  XAccessibleComponent  ================================================
307cdf0e10cSrcweir 
308cdf0e10cSrcweir /** Iterate over all children and test whether the specified point lies
309cdf0e10cSrcweir     within one of their bounding boxes.  Return the first child for which
310cdf0e10cSrcweir     this is true.
311cdf0e10cSrcweir */
312cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL
313cdf0e10cSrcweir     AccessibleDocumentViewBase::getAccessibleAtPoint (
314cdf0e10cSrcweir         const awt::Point& aPoint)
315cdf0e10cSrcweir     throw (uno::RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     ThrowIfDisposed ();
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
320cdf0e10cSrcweir     uno::Reference<XAccessible> xChildAtPosition;
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     sal_Int32 nChildCount = getAccessibleChildCount ();
323cdf0e10cSrcweir     for (sal_Int32 i=nChildCount-1; i>=0; --i)
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         Reference<XAccessible> xChild (getAccessibleChild (i));
326cdf0e10cSrcweir         if (xChild.is())
327cdf0e10cSrcweir         {
328cdf0e10cSrcweir             Reference<XAccessibleComponent> xChildComponent (
329cdf0e10cSrcweir                 xChild->getAccessibleContext(), uno::UNO_QUERY);
330cdf0e10cSrcweir             if (xChildComponent.is())
331cdf0e10cSrcweir             {
332cdf0e10cSrcweir                 awt::Rectangle aBBox (xChildComponent->getBounds());
333cdf0e10cSrcweir                 if ( (aPoint.X >= aBBox.X)
334cdf0e10cSrcweir                     && (aPoint.Y >= aBBox.Y)
335cdf0e10cSrcweir                     && (aPoint.X < aBBox.X+aBBox.Width)
336cdf0e10cSrcweir                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
337cdf0e10cSrcweir                 {
338cdf0e10cSrcweir                     xChildAtPosition = xChild;
339cdf0e10cSrcweir                     break;
340cdf0e10cSrcweir                 }
341cdf0e10cSrcweir             }
342cdf0e10cSrcweir         }
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir     // Have not found a child under the given point.  Returning empty
346cdf0e10cSrcweir     // reference to indicate this.
347cdf0e10cSrcweir     return xChildAtPosition;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 
353cdf0e10cSrcweir awt::Rectangle SAL_CALL
354cdf0e10cSrcweir     AccessibleDocumentViewBase::getBounds (void)
355cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir     ThrowIfDisposed ();
358cdf0e10cSrcweir 
359cdf0e10cSrcweir     // Transform visible area into screen coordinates.
360cdf0e10cSrcweir     ::Rectangle aVisibleArea (
361cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
362cdf0e10cSrcweir     ::Point aPixelTopLeft (
363cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
364cdf0e10cSrcweir             aVisibleArea.TopLeft()));
365cdf0e10cSrcweir     ::Point aPixelSize (
366cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
367cdf0e10cSrcweir             aVisibleArea.BottomRight())
368cdf0e10cSrcweir         - aPixelTopLeft);
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     // Prepare to subtract the parent position to transform into relative
371cdf0e10cSrcweir     // coordinates.
372cdf0e10cSrcweir     awt::Point aParentPosition;
373cdf0e10cSrcweir     Reference<XAccessible> xParent = getAccessibleParent ();
374cdf0e10cSrcweir     if (xParent.is())
375cdf0e10cSrcweir     {
376cdf0e10cSrcweir         Reference<XAccessibleComponent> xParentComponent (
377cdf0e10cSrcweir             xParent->getAccessibleContext(), uno::UNO_QUERY);
378cdf0e10cSrcweir         if (xParentComponent.is())
379cdf0e10cSrcweir             aParentPosition = xParentComponent->getLocationOnScreen();
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     return awt::Rectangle (
383cdf0e10cSrcweir         aPixelTopLeft.X() - aParentPosition.X,
384cdf0e10cSrcweir         aPixelTopLeft.Y() - aParentPosition.Y,
385cdf0e10cSrcweir         aPixelSize.X(),
386cdf0e10cSrcweir         aPixelSize.Y());
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 
392cdf0e10cSrcweir awt::Point SAL_CALL
393cdf0e10cSrcweir     AccessibleDocumentViewBase::getLocation (void)
394cdf0e10cSrcweir     throw (uno::RuntimeException)
395cdf0e10cSrcweir {
396cdf0e10cSrcweir     ThrowIfDisposed ();
397cdf0e10cSrcweir     awt::Rectangle aBoundingBox (getBounds());
398cdf0e10cSrcweir     return awt::Point (aBoundingBox.X, aBoundingBox.Y);
399cdf0e10cSrcweir }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 
404cdf0e10cSrcweir awt::Point SAL_CALL
405cdf0e10cSrcweir     AccessibleDocumentViewBase::getLocationOnScreen (void)
406cdf0e10cSrcweir     throw (uno::RuntimeException)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir     ThrowIfDisposed ();
409cdf0e10cSrcweir     ::Point aLogicalPoint (maShapeTreeInfo.GetViewForwarder()->GetVisibleArea().TopLeft());
410cdf0e10cSrcweir     ::Point aPixelPoint (maShapeTreeInfo.GetViewForwarder()->LogicToPixel (aLogicalPoint));
411cdf0e10cSrcweir     return awt::Point (aPixelPoint.X(), aPixelPoint.Y());
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 
417cdf0e10cSrcweir awt::Size SAL_CALL
418cdf0e10cSrcweir     AccessibleDocumentViewBase::getSize (void)
419cdf0e10cSrcweir     throw (uno::RuntimeException)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir     ThrowIfDisposed ();
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     // Transform visible area into screen coordinates.
424cdf0e10cSrcweir     ::Rectangle aVisibleArea (
425cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
426cdf0e10cSrcweir     ::Point aPixelTopLeft (
427cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
428cdf0e10cSrcweir             aVisibleArea.TopLeft()));
429cdf0e10cSrcweir     ::Point aPixelSize (
430cdf0e10cSrcweir         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
431cdf0e10cSrcweir             aVisibleArea.BottomRight())
432cdf0e10cSrcweir         - aPixelTopLeft);
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     return awt::Size (aPixelSize.X(), aPixelSize.Y());
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 
440cdf0e10cSrcweir //=====  XInterface  ==========================================================
441cdf0e10cSrcweir 
442cdf0e10cSrcweir uno::Any SAL_CALL
443cdf0e10cSrcweir     AccessibleDocumentViewBase::queryInterface (const uno::Type & rType)
444cdf0e10cSrcweir     throw (uno::RuntimeException)
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
447cdf0e10cSrcweir     if ( ! aReturn.hasValue())
448cdf0e10cSrcweir         aReturn = ::cppu::queryInterface (rType,
449cdf0e10cSrcweir             static_cast<XAccessibleComponent*>(this),
450cdf0e10cSrcweir             static_cast<XAccessibleSelection*>(this),
451cdf0e10cSrcweir             static_cast<lang::XEventListener*>(
452cdf0e10cSrcweir                 static_cast<awt::XWindowListener*>(this)),
453cdf0e10cSrcweir             static_cast<beans::XPropertyChangeListener*>(this),
454cdf0e10cSrcweir             static_cast<awt::XWindowListener*>(this),
455cdf0e10cSrcweir             static_cast<awt::XFocusListener*>(this)
456*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
457*0deba7fbSSteve Yin 		   ,static_cast<XAccessibleExtendedAttributes*>(this)
458*0deba7fbSSteve Yin 		   ,static_cast<XAccessibleGetAccFlowTo*>(this)
459*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
460cdf0e10cSrcweir             );
461cdf0e10cSrcweir     return aReturn;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 
467cdf0e10cSrcweir void SAL_CALL
468cdf0e10cSrcweir     AccessibleDocumentViewBase::acquire (void)
469cdf0e10cSrcweir     throw ()
470cdf0e10cSrcweir {
471cdf0e10cSrcweir     AccessibleContextBase::acquire ();
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 
477cdf0e10cSrcweir void SAL_CALL
478cdf0e10cSrcweir     AccessibleDocumentViewBase::release (void)
479cdf0e10cSrcweir     throw ()
480cdf0e10cSrcweir {
481cdf0e10cSrcweir     AccessibleContextBase::release ();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 
487cdf0e10cSrcweir //=====  XServiceInfo  ========================================================
488cdf0e10cSrcweir 
489cdf0e10cSrcweir ::rtl::OUString SAL_CALL
490cdf0e10cSrcweir     AccessibleDocumentViewBase::getImplementationName (void)
491cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
492cdf0e10cSrcweir {
493cdf0e10cSrcweir 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 
499cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
500cdf0e10cSrcweir     AccessibleDocumentViewBase::getSupportedServiceNames (void)
501cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir     ThrowIfDisposed ();
504cdf0e10cSrcweir     return AccessibleContextBase::getSupportedServiceNames ();
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 
511cdf0e10cSrcweir //=====  XTypeProvider  =======================================================
512cdf0e10cSrcweir 
513cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
514cdf0e10cSrcweir     AccessibleDocumentViewBase::getTypes (void)
515cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
516cdf0e10cSrcweir {
517cdf0e10cSrcweir     ThrowIfDisposed ();
518cdf0e10cSrcweir 
519cdf0e10cSrcweir     // Get list of types from the context base implementation, ...
520cdf0e10cSrcweir 	uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
521cdf0e10cSrcweir     // ... get list of types from component base implementation, ...
522cdf0e10cSrcweir 	uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 
525cdf0e10cSrcweir     // ...and add the additional type for the component, ...
526cdf0e10cSrcweir     const uno::Type aLangEventListenerType =
527cdf0e10cSrcweir      	::getCppuType((const uno::Reference<lang::XEventListener>*)0);
528cdf0e10cSrcweir     const uno::Type aPropertyChangeListenerType =
529cdf0e10cSrcweir      	::getCppuType((const uno::Reference<beans::XPropertyChangeListener>*)0);
530cdf0e10cSrcweir     const uno::Type aWindowListenerType =
531cdf0e10cSrcweir      	::getCppuType((const uno::Reference<awt::XWindowListener>*)0);
532cdf0e10cSrcweir     const uno::Type aFocusListenerType =
533cdf0e10cSrcweir      	::getCppuType((const uno::Reference<awt::XFocusListener>*)0);
534cdf0e10cSrcweir     const uno::Type aEventBroadcaster =
535cdf0e10cSrcweir      	::getCppuType((const uno::Reference<XAccessibleEventBroadcaster>*)0);
536cdf0e10cSrcweir 
537cdf0e10cSrcweir     // ... and merge them all into one list.
538cdf0e10cSrcweir     sal_Int32 nTypeCount (aTypeList.getLength()),
539cdf0e10cSrcweir         nComponentTypeCount (aComponentTypeList.getLength()),
540cdf0e10cSrcweir         i;
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     aTypeList.realloc (nTypeCount + nComponentTypeCount + 5);
543cdf0e10cSrcweir 
544cdf0e10cSrcweir     for (i=0; i<nComponentTypeCount; i++)
545cdf0e10cSrcweir         aTypeList[nTypeCount + i] = aComponentTypeList[i];
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
548cdf0e10cSrcweir     aTypeList[nTypeCount + i++] = aPropertyChangeListenerType;
549cdf0e10cSrcweir     aTypeList[nTypeCount + i++] = aWindowListenerType;
550cdf0e10cSrcweir     aTypeList[nTypeCount + i++] = aFocusListenerType;
551cdf0e10cSrcweir     aTypeList[nTypeCount + i++] = aEventBroadcaster;
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	return aTypeList;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 
559cdf0e10cSrcweir void AccessibleDocumentViewBase::impl_dispose()
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     // Unregister from VCL Window.
562cdf0e10cSrcweir     Window* pWindow = maShapeTreeInfo.GetWindow();
563cdf0e10cSrcweir     if (maWindowLink.IsSet())
564cdf0e10cSrcweir     {
565cdf0e10cSrcweir         if (pWindow)
566cdf0e10cSrcweir             pWindow->RemoveChildEventListener (maWindowLink);
567cdf0e10cSrcweir         maWindowLink = Link();
568cdf0e10cSrcweir     }
569cdf0e10cSrcweir     else
570cdf0e10cSrcweir     {
571cdf0e10cSrcweir         DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing");
572cdf0e10cSrcweir     }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     // Unregister from window.
575cdf0e10cSrcweir     if (mxWindow.is())
576cdf0e10cSrcweir     {
577cdf0e10cSrcweir         mxWindow->removeWindowListener (this);
578cdf0e10cSrcweir         mxWindow->removeFocusListener (this);
579cdf0e10cSrcweir         mxWindow = NULL;
580cdf0e10cSrcweir     }
581cdf0e10cSrcweir 
582cdf0e10cSrcweir     // Unregister form the model.
583cdf0e10cSrcweir     if (mxModel.is())
584cdf0e10cSrcweir         mxModel->removeEventListener (
585cdf0e10cSrcweir             static_cast<awt::XWindowListener*>(this));
586cdf0e10cSrcweir 
587cdf0e10cSrcweir     // Unregister from the controller.
588cdf0e10cSrcweir     if (mxController.is())
589cdf0e10cSrcweir     {
590cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
591cdf0e10cSrcweir         if (xSet.is())
592cdf0e10cSrcweir             xSet->removePropertyChangeListener (
593cdf0e10cSrcweir                 OUString (RTL_CONSTASCII_USTRINGPARAM("")),
594cdf0e10cSrcweir                 static_cast<beans::XPropertyChangeListener*>(this));
595cdf0e10cSrcweir 
596cdf0e10cSrcweir         mxController->removeEventListener (
597cdf0e10cSrcweir             static_cast<awt::XWindowListener*>(this));
598cdf0e10cSrcweir     }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     // Propagate change of controller down the shape tree.
601cdf0e10cSrcweir     maShapeTreeInfo.SetControllerBroadcaster (NULL);
602cdf0e10cSrcweir 
603cdf0e10cSrcweir     // Reset the model reference.
604cdf0e10cSrcweir     mxModel = NULL;
605cdf0e10cSrcweir     // Reset the model reference.
606cdf0e10cSrcweir     mxController = NULL;
607cdf0e10cSrcweir 
608cdf0e10cSrcweir     maShapeTreeInfo.SetDocumentWindow (NULL);
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 
614cdf0e10cSrcweir //=====  XEventListener  ======================================================
615cdf0e10cSrcweir 
616cdf0e10cSrcweir void SAL_CALL
617cdf0e10cSrcweir     AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject)
618cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
619cdf0e10cSrcweir {
620cdf0e10cSrcweir     ThrowIfDisposed ();
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     // Register this object as dispose event and document::XEventListener
623cdf0e10cSrcweir     // listener at the model.
624cdf0e10cSrcweir 
625cdf0e10cSrcweir     if ( ! rEventObject.Source.is())
626cdf0e10cSrcweir     {
627cdf0e10cSrcweir         // Paranoia. Can this really happen?
628cdf0e10cSrcweir     }
629cdf0e10cSrcweir     else if (rEventObject.Source == mxModel || rEventObject.Source == mxController)
630cdf0e10cSrcweir     {
631cdf0e10cSrcweir         impl_dispose();
632cdf0e10cSrcweir     }
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir //=====  XPropertyChangeListener  =============================================
636cdf0e10cSrcweir 
637cdf0e10cSrcweir void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& )
638cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir     // Empty
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 
646cdf0e10cSrcweir //=====  XWindowListener  =====================================================
647cdf0e10cSrcweir 
648cdf0e10cSrcweir void SAL_CALL
649cdf0e10cSrcweir     AccessibleDocumentViewBase::windowResized (const ::com::sun::star::awt::WindowEvent& )
650cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
651cdf0e10cSrcweir {
652cdf0e10cSrcweir     if( IsDisposed() )
653cdf0e10cSrcweir         return;
654cdf0e10cSrcweir 
655cdf0e10cSrcweir     ViewForwarderChanged (
656cdf0e10cSrcweir         IAccessibleViewForwarderListener::VISIBLE_AREA,
657cdf0e10cSrcweir         &maViewForwarder);
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 
663cdf0e10cSrcweir void SAL_CALL
664cdf0e10cSrcweir     AccessibleDocumentViewBase::windowMoved (const ::com::sun::star::awt::WindowEvent& )
665cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
666cdf0e10cSrcweir {
667cdf0e10cSrcweir     if( IsDisposed() )
668cdf0e10cSrcweir         return;
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     ViewForwarderChanged (
671cdf0e10cSrcweir         IAccessibleViewForwarderListener::VISIBLE_AREA,
672cdf0e10cSrcweir         &maViewForwarder);
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 
678cdf0e10cSrcweir void SAL_CALL
679cdf0e10cSrcweir     AccessibleDocumentViewBase::windowShown (const ::com::sun::star::lang::EventObject& )
680cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     if( IsDisposed() )
683cdf0e10cSrcweir         return;
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     ViewForwarderChanged (
686cdf0e10cSrcweir         IAccessibleViewForwarderListener::VISIBLE_AREA,
687cdf0e10cSrcweir         &maViewForwarder);
688cdf0e10cSrcweir }
689cdf0e10cSrcweir 
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 
693cdf0e10cSrcweir void SAL_CALL
694cdf0e10cSrcweir     AccessibleDocumentViewBase::windowHidden (const ::com::sun::star::lang::EventObject& )
695cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
696cdf0e10cSrcweir {
697cdf0e10cSrcweir     if( IsDisposed() )
698cdf0e10cSrcweir         return;
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     ViewForwarderChanged (
701cdf0e10cSrcweir         IAccessibleViewForwarderListener::VISIBLE_AREA,
702cdf0e10cSrcweir         &maViewForwarder);
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 
708cdf0e10cSrcweir //=====  XFocusListener  ==================================================
709cdf0e10cSrcweir 
710cdf0e10cSrcweir void AccessibleDocumentViewBase::focusGained (const ::com::sun::star::awt::FocusEvent& e)
711cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
712cdf0e10cSrcweir {
713cdf0e10cSrcweir     ThrowIfDisposed ();
714cdf0e10cSrcweir     if (e.Source == mxWindow)
715cdf0e10cSrcweir         Activated ();
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir void AccessibleDocumentViewBase::focusLost (const ::com::sun::star::awt::FocusEvent& e)
719cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir     ThrowIfDisposed ();
722cdf0e10cSrcweir     if (e.Source == mxWindow)
723cdf0e10cSrcweir         Deactivated ();
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 
729cdf0e10cSrcweir //=====  protected internal  ==================================================
730cdf0e10cSrcweir 
731cdf0e10cSrcweir // This method is called from the component helper base class while disposing.
732cdf0e10cSrcweir void SAL_CALL AccessibleDocumentViewBase::disposing (void)
733cdf0e10cSrcweir {
734cdf0e10cSrcweir     impl_dispose();
735cdf0e10cSrcweir 
736cdf0e10cSrcweir     AccessibleContextBase::disposing ();
737cdf0e10cSrcweir }
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 
742cdf0e10cSrcweir ///	Create a name for this view.
743cdf0e10cSrcweir ::rtl::OUString
744cdf0e10cSrcweir     AccessibleDocumentViewBase::CreateAccessibleName (void)
745cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir 	return ::rtl::OUString (
748cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
749cdf0e10cSrcweir }
750cdf0e10cSrcweir 
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 
754cdf0e10cSrcweir /** Create a description for this view.  Use the model's description or URL
755cdf0e10cSrcweir     if a description is not available.
756cdf0e10cSrcweir */
757cdf0e10cSrcweir ::rtl::OUString
758cdf0e10cSrcweir     AccessibleDocumentViewBase::CreateAccessibleDescription (void)
759cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
760cdf0e10cSrcweir {
761cdf0e10cSrcweir 	rtl::OUString sDescription;
762cdf0e10cSrcweir 
763cdf0e10cSrcweir     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
764cdf0e10cSrcweir     if (xInfo.is())
765cdf0e10cSrcweir     {
766cdf0e10cSrcweir         OUString sFirstService = xInfo->getSupportedServiceNames()[0];
767cdf0e10cSrcweir         if (sFirstService == OUString (
768cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView")))
769cdf0e10cSrcweir         {
770cdf0e10cSrcweir             sDescription = OUString (RTL_CONSTASCII_USTRINGPARAM("Draw Document"));
771cdf0e10cSrcweir         }
772cdf0e10cSrcweir         else
773cdf0e10cSrcweir             sDescription = sFirstService;
774cdf0e10cSrcweir     }
775cdf0e10cSrcweir     else
776cdf0e10cSrcweir         sDescription = OUString (
777cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document"));
778cdf0e10cSrcweir 	return sDescription;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 
784cdf0e10cSrcweir void AccessibleDocumentViewBase::Activated (void)
785cdf0e10cSrcweir {
786cdf0e10cSrcweir     // Empty.  Overwrite to do something usefull.
787cdf0e10cSrcweir }
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 
792cdf0e10cSrcweir void AccessibleDocumentViewBase::Deactivated (void)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     // Empty.  Overwrite to do something usefull.
795cdf0e10cSrcweir }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 
800cdf0e10cSrcweir void AccessibleDocumentViewBase::SetAccessibleOLEObject (
801cdf0e10cSrcweir     const Reference <XAccessible>& xOLEObject)
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     // Send child event about removed accessible OLE object if necessary.
804cdf0e10cSrcweir     if (mxAccessibleOLEObject != xOLEObject)
805cdf0e10cSrcweir         if (mxAccessibleOLEObject.is())
806cdf0e10cSrcweir             CommitChange (
807cdf0e10cSrcweir                 AccessibleEventId::CHILD,
808cdf0e10cSrcweir                 uno::Any(),
809cdf0e10cSrcweir                 uno::makeAny (mxAccessibleOLEObject));
810cdf0e10cSrcweir 
811cdf0e10cSrcweir     // Assume that the accessible OLE Object disposes itself correctly.
812cdf0e10cSrcweir 
813cdf0e10cSrcweir     {
814cdf0e10cSrcweir         ::osl::MutexGuard aGuard (maMutex);
815cdf0e10cSrcweir         mxAccessibleOLEObject = xOLEObject;
816cdf0e10cSrcweir     }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir     // Send child event about new accessible OLE object if necessary.
819cdf0e10cSrcweir     if (mxAccessibleOLEObject.is())
820cdf0e10cSrcweir         CommitChange (
821cdf0e10cSrcweir             AccessibleEventId::CHILD,
822cdf0e10cSrcweir             uno::makeAny (mxAccessibleOLEObject),
823cdf0e10cSrcweir             uno::Any());
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 
829cdf0e10cSrcweir //=====  methods from AccessibleSelectionBase ==================================================
830cdf0e10cSrcweir 
831cdf0e10cSrcweir // return the member maMutex;
832cdf0e10cSrcweir ::osl::Mutex&
833cdf0e10cSrcweir     AccessibleDocumentViewBase::implGetMutex()
834cdf0e10cSrcweir {
835cdf0e10cSrcweir     return( maMutex );
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir // return ourself as context in default case
839cdf0e10cSrcweir uno::Reference< XAccessibleContext >
840cdf0e10cSrcweir     AccessibleDocumentViewBase::implGetAccessibleContext()
841cdf0e10cSrcweir     throw (uno::RuntimeException)
842cdf0e10cSrcweir {
843cdf0e10cSrcweir     return( this );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir // return sal_False in default case
847cdf0e10cSrcweir sal_Bool
848cdf0e10cSrcweir     AccessibleDocumentViewBase::implIsSelected( sal_Int32 )
849cdf0e10cSrcweir     throw (uno::RuntimeException)
850cdf0e10cSrcweir {
851cdf0e10cSrcweir     return( sal_False );
852cdf0e10cSrcweir }
853cdf0e10cSrcweir 
854cdf0e10cSrcweir // return nothing in default case
855cdf0e10cSrcweir void
856cdf0e10cSrcweir     AccessibleDocumentViewBase::implSelect( sal_Int32, sal_Bool )
857cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
858cdf0e10cSrcweir {
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
862*0deba7fbSSteve Yin uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes()
863*0deba7fbSSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
864*0deba7fbSSteve Yin {
865*0deba7fbSSteve Yin 	uno::Any anyAtrribute;
866*0deba7fbSSteve Yin 	rtl::OUString sValue;
867*0deba7fbSSteve Yin 	if (mpViewShell && mpViewShell->ISA(::sd::DrawViewShell))
868*0deba7fbSSteve Yin 	{
869*0deba7fbSSteve Yin 		::sd::DrawViewShell* pDrViewSh = (::sd::DrawViewShell*) mpViewShell;
870*0deba7fbSSteve Yin 		rtl::OUString sName;
871*0deba7fbSSteve Yin 		String sDisplay;
872*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii("page-name:");
873*0deba7fbSSteve Yin 			// MT IA2: Not used...
874*0deba7fbSSteve Yin 			// SdPage*	pCurrPge = pDrViewSh->getCurrentPage();
875*0deba7fbSSteve Yin 			SdDrawDocument* pDoc = pDrViewSh->GetDoc();
876*0deba7fbSSteve Yin 			sDisplay = pDrViewSh->getCurrentPage()->GetName();
877*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
878*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) );
879*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) );
880*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) );
881*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) );
882*0deba7fbSSteve Yin 			sValue = sName + sDisplay ;
883*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";page-number:");
884*0deba7fbSSteve Yin 			sValue += sName;
885*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32((sal_Int16)((sal_uInt16)((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) ;
886*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";total-pages:");
887*0deba7fbSSteve Yin 			sValue += sName;
888*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32(pDrViewSh->GetPageTabControl()->GetPageCount()) ;
889*0deba7fbSSteve Yin 			sValue +=  rtl::OUString::createFromAscii(";");
890*0deba7fbSSteve Yin 		if(pDrViewSh->IsLayerModeActive() )
891*0deba7fbSSteve Yin 		{
892*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii("page-name:");
893*0deba7fbSSteve Yin 			sValue = sName;
894*0deba7fbSSteve Yin 			sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId());
895*0deba7fbSSteve Yin 			if( pDoc )
896*0deba7fbSSteve Yin 			{
897*0deba7fbSSteve Yin 				SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
898*0deba7fbSSteve Yin 				SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sDisplay, sal_False);
899*0deba7fbSSteve Yin 				if( aSdrLayer )
900*0deba7fbSSteve Yin 				{
901*0deba7fbSSteve Yin 					String layerAltText = aSdrLayer->GetTitle();
902*0deba7fbSSteve Yin 					if(  layerAltText.Len() > 0)
903*0deba7fbSSteve Yin 					{
904*0deba7fbSSteve Yin 						sName = rtl::OUString::createFromAscii(" ");
905*0deba7fbSSteve Yin 						sDisplay = sDisplay + sName;
906*0deba7fbSSteve Yin 						sDisplay += layerAltText;
907*0deba7fbSSteve Yin 					}
908*0deba7fbSSteve Yin 				}
909*0deba7fbSSteve Yin 			}
910*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
911*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ));
912*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ));
913*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ));
914*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
915*0deba7fbSSteve Yin 			sValue +=  sDisplay;
916*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";page-number:");
917*0deba7fbSSteve Yin 			sValue += sName;
918*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32(pDrViewSh->GetActiveTabLayerIndex()+1) ;
919*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";total-pages:");
920*0deba7fbSSteve Yin 			sValue += sName;
921*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32(pDrViewSh->GetLayerTabControl()->GetPageCount()) ;
922*0deba7fbSSteve Yin 			sValue +=  rtl::OUString::createFromAscii(";");
923*0deba7fbSSteve Yin 		}
924*0deba7fbSSteve Yin 	}
925*0deba7fbSSteve Yin 	if (mpViewShell && mpViewShell->ISA(::sd::PresentationViewShell))
926*0deba7fbSSteve Yin 	{
927*0deba7fbSSteve Yin 		::sd::PresentationViewShell* pPresViewSh = (::sd::PresentationViewShell*) mpViewShell;
928*0deba7fbSSteve Yin 		SdPage*	pCurrPge = pPresViewSh->getCurrentPage();
929*0deba7fbSSteve Yin 		SdDrawDocument* pDoc = pPresViewSh->GetDoc();
930*0deba7fbSSteve Yin 		SdPage*	pNotesPge = (SdPage*)pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, PK_NOTES);
931*0deba7fbSSteve Yin 		if (pNotesPge)
932*0deba7fbSSteve Yin 		{
933*0deba7fbSSteve Yin 			SdrObject* pNotesObj = pNotesPge->GetPresObj(PRESOBJ_NOTES);
934*0deba7fbSSteve Yin 			if (pNotesObj)
935*0deba7fbSSteve Yin 			{
936*0deba7fbSSteve Yin 				OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject();
937*0deba7fbSSteve Yin 				if (pPara)
938*0deba7fbSSteve Yin 				{
939*0deba7fbSSteve Yin 					sValue += rtl::OUString::createFromAscii("note:");
940*0deba7fbSSteve Yin 					const EditTextObject& rEdit = pPara->GetTextObject();
941*0deba7fbSSteve Yin 					for (sal_uInt16 i=0;i<rEdit.GetParagraphCount();i++)
942*0deba7fbSSteve Yin 					{
943*0deba7fbSSteve Yin 						String strNote = rEdit.GetText(i);
944*0deba7fbSSteve Yin 						strNote.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
945*0deba7fbSSteve Yin 						strNote.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ));
946*0deba7fbSSteve Yin 						strNote.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ));
947*0deba7fbSSteve Yin 						strNote.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ));
948*0deba7fbSSteve Yin 						strNote.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
949*0deba7fbSSteve Yin 						sValue += rtl::OUString( strNote );
950*0deba7fbSSteve Yin 						sValue += rtl::OUString::createFromAscii(";");//to divide each paragraph
951*0deba7fbSSteve Yin 					}
952*0deba7fbSSteve Yin 				}
953*0deba7fbSSteve Yin 			}
954*0deba7fbSSteve Yin 		}
955*0deba7fbSSteve Yin 	}
956*0deba7fbSSteve Yin 	if (mpViewShell && mpViewShell->ISA(::sd::OutlineViewShell) )
957*0deba7fbSSteve Yin 	{
958*0deba7fbSSteve Yin 		rtl::OUString sName;
959*0deba7fbSSteve Yin 		String sDisplay;
960*0deba7fbSSteve Yin 		SdPage*	pCurrPge = mpViewShell->GetActualPage();
961*0deba7fbSSteve Yin 		SdDrawDocument* pDoc = mpViewShell->GetDoc();
962*0deba7fbSSteve Yin 		if(pCurrPge && pDoc)
963*0deba7fbSSteve Yin 		{
964*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii("page-name:");
965*0deba7fbSSteve Yin 			sDisplay = pCurrPge->GetName();
966*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) );
967*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) );
968*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) );
969*0deba7fbSSteve Yin 			sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) );
970*0deba7fbSSteve Yin 			sValue = sName + sDisplay ;
971*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";page-number:");
972*0deba7fbSSteve Yin 			sValue += sName;
973*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32((sal_Int16)((sal_uInt16)((pCurrPge->GetPageNum()-1)>>1) + 1)) ;
974*0deba7fbSSteve Yin 			sName = rtl::OUString::createFromAscii(";total-pages:");
975*0deba7fbSSteve Yin 			sValue += sName;
976*0deba7fbSSteve Yin 			sValue += String::CreateFromInt32(pDoc->GetSdPageCount(PK_STANDARD)) ;
977*0deba7fbSSteve Yin 			sValue +=  rtl::OUString::createFromAscii(";");
978*0deba7fbSSteve Yin 		}
979*0deba7fbSSteve Yin 	}
980*0deba7fbSSteve Yin 	if (sValue.getLength())
981*0deba7fbSSteve Yin 		anyAtrribute <<= sValue;
982*0deba7fbSSteve Yin 	return anyAtrribute;
983*0deba7fbSSteve Yin }
984*0deba7fbSSteve Yin ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
985*0deba7fbSSteve Yin 		SAL_CALL AccessibleDocumentViewBase::get_AccFlowTo(const ::com::sun::star::uno::Any&, sal_Int32 )
986*0deba7fbSSteve Yin 		throw ( ::com::sun::star::uno::RuntimeException )
987*0deba7fbSSteve Yin {
988*0deba7fbSSteve Yin 	::com::sun::star::uno::Sequence< uno::Any> aRet;
989*0deba7fbSSteve Yin 
990*0deba7fbSSteve Yin 	return aRet;
991*0deba7fbSSteve Yin }
992*0deba7fbSSteve Yin 
993*0deba7fbSSteve Yin sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground(  )
994*0deba7fbSSteve Yin         throw (uno::RuntimeException)
995*0deba7fbSSteve Yin {
996*0deba7fbSSteve Yin     return COL_BLACK;
997*0deba7fbSSteve Yin }
998*0deba7fbSSteve Yin 
999*0deba7fbSSteve Yin sal_Int32 SAL_CALL AccessibleDocumentViewBase::getBackground(  )
1000*0deba7fbSSteve Yin         throw (uno::RuntimeException)
1001*0deba7fbSSteve Yin {
1002*0deba7fbSSteve Yin 	 ThrowIfDisposed ();
1003*0deba7fbSSteve Yin     ::osl::MutexGuard aGuard (maMutex);
1004*0deba7fbSSteve Yin     return mpViewShell->GetView()->getColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
1005*0deba7fbSSteve Yin }
1006*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
1007cdf0e10cSrcweir } // end of namespace accessibility
1008