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 
27cdf0e10cSrcweir #include "AccessibleSlideSorterObject.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "SlideSorter.hxx"
30cdf0e10cSrcweir #include "controller/SlideSorterController.hxx"
31cdf0e10cSrcweir #include "controller/SlsPageSelector.hxx"
32cdf0e10cSrcweir #include "controller/SlsFocusManager.hxx"
33cdf0e10cSrcweir #include "model/SlideSorterModel.hxx"
34cdf0e10cSrcweir #include "model/SlsPageDescriptor.hxx"
35cdf0e10cSrcweir #include "view/SlideSorterView.hxx"
36cdf0e10cSrcweir #include "view/SlsLayouter.hxx"
37cdf0e10cSrcweir #include "view/SlsPageObjectLayouter.hxx"
38cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
39cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx>
41cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "sdpage.hxx"
44cdf0e10cSrcweir #include "sdresid.hxx"
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "glob.hrc"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir using ::rtl::OUString;
50cdf0e10cSrcweir using namespace ::com::sun::star;
51cdf0e10cSrcweir using namespace ::com::sun::star::uno;
52cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace accessibility {
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 
AccessibleSlideSorterObject(const Reference<XAccessible> & rxParent,::sd::slidesorter::SlideSorter & rSlideSorter,sal_uInt16 nPageNumber)58cdf0e10cSrcweir AccessibleSlideSorterObject::AccessibleSlideSorterObject(
59cdf0e10cSrcweir     const Reference<XAccessible>& rxParent,
60cdf0e10cSrcweir     ::sd::slidesorter::SlideSorter& rSlideSorter,
61cdf0e10cSrcweir     sal_uInt16 nPageNumber)
62cdf0e10cSrcweir     : AccessibleSlideSorterObjectBase(::sd::MutexOwner::maMutex),
63cdf0e10cSrcweir       mxParent(rxParent),
64cdf0e10cSrcweir       mnPageNumber(nPageNumber),
65cdf0e10cSrcweir       mrSlideSorter(rSlideSorter),
66cdf0e10cSrcweir       mnClientId(0)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
~AccessibleSlideSorterObject(void)73cdf0e10cSrcweir AccessibleSlideSorterObject::~AccessibleSlideSorterObject (void)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir     if ( ! IsDisposed())
76cdf0e10cSrcweir         dispose();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 
GetPageNumber(void) const82cdf0e10cSrcweir sal_uInt16 AccessibleSlideSorterObject::GetPageNumber (void) const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     return mnPageNumber;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
FireAccessibleEvent(short nEventId,const uno::Any & rOldValue,const uno::Any & rNewValue)90cdf0e10cSrcweir void AccessibleSlideSorterObject::FireAccessibleEvent (
91cdf0e10cSrcweir     short nEventId,
92cdf0e10cSrcweir     const uno::Any& rOldValue,
93cdf0e10cSrcweir     const uno::Any& rNewValue)
94cdf0e10cSrcweir {
95cdf0e10cSrcweir     if (mnClientId != 0)
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         AccessibleEventObject aEventObject;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         aEventObject.Source = Reference<XWeak>(this);
100cdf0e10cSrcweir         aEventObject.EventId = nEventId;
101cdf0e10cSrcweir         aEventObject.NewValue = rNewValue;
102cdf0e10cSrcweir         aEventObject.OldValue = rOldValue;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 		comphelper::AccessibleEventNotifier::addEvent(mnClientId, aEventObject);
105cdf0e10cSrcweir     }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
disposing(void)111cdf0e10cSrcweir void SAL_CALL AccessibleSlideSorterObject::disposing (void)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     const vos::OGuard aSolarGuard (Application::GetSolarMutex());
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     // Send a disposing to all listeners.
116cdf0e10cSrcweir 	if (mnClientId != 0)
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(mnClientId, *this);
119cdf0e10cSrcweir 		mnClientId =  0;
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir //===== XAccessible ===========================================================
126cdf0e10cSrcweir 
127cdf0e10cSrcweir Reference<XAccessibleContext> SAL_CALL
getAccessibleContext(void)128cdf0e10cSrcweir     AccessibleSlideSorterObject::getAccessibleContext (void)
129cdf0e10cSrcweir     throw (uno::RuntimeException)
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     ThrowIfDisposed();
132cdf0e10cSrcweir     return this;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 
137cdf0e10cSrcweir //===== XAccessibleContext ====================================================
138cdf0e10cSrcweir 
getAccessibleChildCount(void)139cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleSlideSorterObject::getAccessibleChildCount (void)
140cdf0e10cSrcweir     throw (uno::RuntimeException)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     ThrowIfDisposed();
143cdf0e10cSrcweir     return 0;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
getAccessibleChild(sal_Int32)149cdf0e10cSrcweir Reference<XAccessible> SAL_CALL AccessibleSlideSorterObject::getAccessibleChild (sal_Int32 )
150cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, RuntimeException)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir     ThrowIfDisposed();
153cdf0e10cSrcweir     throw lang::IndexOutOfBoundsException();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
getAccessibleParent(void)159cdf0e10cSrcweir Reference<XAccessible> SAL_CALL AccessibleSlideSorterObject::getAccessibleParent (void)
160cdf0e10cSrcweir     throw (uno::RuntimeException)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     ThrowIfDisposed();
163cdf0e10cSrcweir     return mxParent;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
getAccessibleIndexInParent()169cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleSlideSorterObject::getAccessibleIndexInParent()
170cdf0e10cSrcweir     throw (uno::RuntimeException)
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     ThrowIfDisposed();
173cdf0e10cSrcweir     const vos::OGuard aSolarGuard (Application::GetSolarMutex());
174cdf0e10cSrcweir     sal_Int32 nIndexInParent(-1);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     if (mxParent.is())
177cdf0e10cSrcweir     {
178cdf0e10cSrcweir         Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
179cdf0e10cSrcweir         if (xParentContext.is())
180cdf0e10cSrcweir         {
181cdf0e10cSrcweir             sal_Int32 nChildCount (xParentContext->getAccessibleChildCount());
182cdf0e10cSrcweir             for (sal_Int32 i=0; i<nChildCount; ++i)
183cdf0e10cSrcweir                 if (xParentContext->getAccessibleChild(i).get()
184cdf0e10cSrcweir                     == static_cast<XAccessible*>(this))
185cdf0e10cSrcweir                 {
186cdf0e10cSrcweir                     nIndexInParent = i;
187cdf0e10cSrcweir                     break;
188cdf0e10cSrcweir                 }
189cdf0e10cSrcweir         }
190cdf0e10cSrcweir     }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     return nIndexInParent;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
getAccessibleRole(void)198cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleSlideSorterObject::getAccessibleRole (void)
199cdf0e10cSrcweir     throw (uno::RuntimeException)
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     ThrowIfDisposed();
202*0deba7fbSSteve Yin     //set Role = Shape
203*0deba7fbSSteve Yin     static sal_Int16 nRole = AccessibleRole::SHAPE;
204cdf0e10cSrcweir     return nRole;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 
getAccessibleDescription(void)210cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleSlideSorterObject::getAccessibleDescription (void)
211cdf0e10cSrcweir     throw (uno::RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir     ThrowIfDisposed();
214cdf0e10cSrcweir     return String(SdResId(STR_PAGE));
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
getAccessibleName(void)220cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleSlideSorterObject::getAccessibleName (void)
221cdf0e10cSrcweir     throw (uno::RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     ThrowIfDisposed();
224cdf0e10cSrcweir     const vos::OGuard aSolarGuard (Application::GetSolarMutex());
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     SdPage* pPage = GetPage();
227cdf0e10cSrcweir     if (pPage != NULL)
228cdf0e10cSrcweir         return pPage->GetName();
229cdf0e10cSrcweir     else
230cdf0e10cSrcweir         return String();
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 
236cdf0e10cSrcweir Reference<XAccessibleRelationSet> SAL_CALL
getAccessibleRelationSet(void)237cdf0e10cSrcweir     AccessibleSlideSorterObject::getAccessibleRelationSet (void)
238cdf0e10cSrcweir     throw (uno::RuntimeException)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir     ThrowIfDisposed();
241cdf0e10cSrcweir     return Reference<XAccessibleRelationSet>();
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 
247cdf0e10cSrcweir Reference<XAccessibleStateSet> SAL_CALL
getAccessibleStateSet(void)248cdf0e10cSrcweir     AccessibleSlideSorterObject::getAccessibleStateSet (void)
249cdf0e10cSrcweir     throw (uno::RuntimeException)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir     ThrowIfDisposed();
252cdf0e10cSrcweir     const vos::OGuard aSolarGuard (Application::GetSolarMutex());
253cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     if (mxParent.is())
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir 	    // Unconditional states.
258cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::SELECTABLE);
259cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::FOCUSABLE);
260cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::ENABLED);
261cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::VISIBLE);
262cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::SHOWING);
263cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::ACTIVE);
264cdf0e10cSrcweir 	    pStateSet->AddState(AccessibleStateType::SENSITIVE);
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	    // Conditional states.
267cdf0e10cSrcweir         if (mrSlideSorter.GetController().GetPageSelector().IsPageSelected(mnPageNumber))
268cdf0e10cSrcweir             pStateSet->AddState(AccessibleStateType::SELECTED);
269cdf0e10cSrcweir         if (mrSlideSorter.GetController().GetFocusManager().GetFocusedPageIndex() == mnPageNumber)
270cdf0e10cSrcweir             if (mrSlideSorter.GetController().GetFocusManager().IsFocusShowing())
271cdf0e10cSrcweir                 pStateSet->AddState(AccessibleStateType::FOCUSED);
272cdf0e10cSrcweir     }
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     return pStateSet;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 
getLocale(void)280cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleSlideSorterObject::getLocale (void)
281cdf0e10cSrcweir     throw (IllegalAccessibleComponentStateException,
282cdf0e10cSrcweir         RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir     ThrowIfDisposed();
285cdf0e10cSrcweir     // Delegate request to parent.
286cdf0e10cSrcweir 	if (mxParent.is())
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir     	Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
289cdf0e10cSrcweir         if (xParentContext.is())
290cdf0e10cSrcweir 	    	return xParentContext->getLocale ();
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     //	No locale and no parent.  Therefore throw exception to indicate this
294cdf0e10cSrcweir     //	cluelessness.
295cdf0e10cSrcweir     throw IllegalAccessibleComponentStateException();
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 
302cdf0e10cSrcweir //===== XAccessibleEventBroadcaster ===========================================
303cdf0e10cSrcweir 
addEventListener(const Reference<XAccessibleEventListener> & rxListener)304cdf0e10cSrcweir void SAL_CALL AccessibleSlideSorterObject::addEventListener(
305cdf0e10cSrcweir     const Reference<XAccessibleEventListener>& rxListener)
306cdf0e10cSrcweir     throw (RuntimeException)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	if (rxListener.is())
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         const osl::MutexGuard aGuard(maMutex);
311cdf0e10cSrcweir 
312cdf0e10cSrcweir         if (IsDisposed())
313cdf0e10cSrcweir         {
314cdf0e10cSrcweir             uno::Reference<uno::XInterface> x ((lang::XComponent *)this, uno::UNO_QUERY);
315cdf0e10cSrcweir 		    rxListener->disposing (lang::EventObject (x));
316cdf0e10cSrcweir 	    }
317cdf0e10cSrcweir         else
318cdf0e10cSrcweir         {
319cdf0e10cSrcweir             if (mnClientId == 0)
320cdf0e10cSrcweir                 mnClientId = comphelper::AccessibleEventNotifier::registerClient();
321cdf0e10cSrcweir             comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener);
322cdf0e10cSrcweir         }
323cdf0e10cSrcweir     }
324cdf0e10cSrcweir }
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 
removeEventListener(const Reference<XAccessibleEventListener> & rxListener)329cdf0e10cSrcweir void SAL_CALL AccessibleSlideSorterObject::removeEventListener(
330cdf0e10cSrcweir     const Reference<XAccessibleEventListener>& rxListener)
331cdf0e10cSrcweir     throw (uno::RuntimeException)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     ThrowIfDisposed();
334cdf0e10cSrcweir 	if (rxListener.is())
335cdf0e10cSrcweir 	{
336cdf0e10cSrcweir         const osl::MutexGuard aGuard(maMutex);
337cdf0e10cSrcweir 
338cdf0e10cSrcweir         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
339cdf0e10cSrcweir 		if ( !nListenerCount )
340cdf0e10cSrcweir 		{
341cdf0e10cSrcweir 			// no listeners anymore
342cdf0e10cSrcweir 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
343cdf0e10cSrcweir 			// and at least to us not firing any events anymore, in case somebody calls
344cdf0e10cSrcweir 			// NotifyAccessibleEvent, again
345cdf0e10cSrcweir 			comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
346cdf0e10cSrcweir 			mnClientId = 0;
347cdf0e10cSrcweir 		}
348cdf0e10cSrcweir 	}
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 
354cdf0e10cSrcweir //===== XAccessibleComponent ==================================================
355cdf0e10cSrcweir 
containsPoint(const awt::Point & aPoint)356cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleSlideSorterObject::containsPoint(const awt::Point& aPoint)
357cdf0e10cSrcweir     throw (uno::RuntimeException)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir     ThrowIfDisposed();
360cdf0e10cSrcweir     const awt::Size aSize (getSize());
361cdf0e10cSrcweir     return (aPoint.X >= 0)
362cdf0e10cSrcweir         && (aPoint.X < aSize.Width)
363cdf0e10cSrcweir         && (aPoint.Y >= 0)
364cdf0e10cSrcweir         && (aPoint.Y < aSize.Height);
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 
370cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
getAccessibleAtPoint(const awt::Point &)371cdf0e10cSrcweir     AccessibleSlideSorterObject::getAccessibleAtPoint(const awt::Point& )
372cdf0e10cSrcweir     throw (uno::RuntimeException)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir     return NULL;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 
getBounds(void)380cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleSlideSorterObject::getBounds (void)
381cdf0e10cSrcweir     throw (RuntimeException)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     ThrowIfDisposed ();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     Rectangle aBBox (
388cdf0e10cSrcweir         mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
389cdf0e10cSrcweir             mrSlideSorter.GetModel().GetPageDescriptor(mnPageNumber),
390cdf0e10cSrcweir             ::sd::slidesorter::view::PageObjectLayouter::PageObject,
391cdf0e10cSrcweir             ::sd::slidesorter::view::PageObjectLayouter::WindowCoordinateSystem));
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     if (mxParent.is())
394cdf0e10cSrcweir     {
395cdf0e10cSrcweir         Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(), UNO_QUERY);
396cdf0e10cSrcweir         if (xParentComponent.is())
397cdf0e10cSrcweir         {
398cdf0e10cSrcweir             awt::Rectangle aParentBBox (xParentComponent->getBounds());
399cdf0e10cSrcweir             aBBox.Intersection(Rectangle(
400cdf0e10cSrcweir                 aParentBBox.X,
401cdf0e10cSrcweir                 aParentBBox.Y,
402cdf0e10cSrcweir                 aParentBBox.Width,
403cdf0e10cSrcweir                 aParentBBox.Height));
404cdf0e10cSrcweir         }
405cdf0e10cSrcweir     }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     return awt::Rectangle(
408cdf0e10cSrcweir         aBBox.Left(),
409cdf0e10cSrcweir         aBBox.Top(),
410cdf0e10cSrcweir         aBBox.GetWidth(),
411cdf0e10cSrcweir         aBBox.GetHeight());
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 
getLocation()417cdf0e10cSrcweir awt::Point SAL_CALL AccessibleSlideSorterObject::getLocation ()
418cdf0e10cSrcweir     throw (RuntimeException)
419cdf0e10cSrcweir {
420cdf0e10cSrcweir     ThrowIfDisposed ();
421cdf0e10cSrcweir     const awt::Rectangle aBBox (getBounds());
422cdf0e10cSrcweir     return awt::Point(aBBox.X, aBBox.Y);
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 
getLocationOnScreen(void)428cdf0e10cSrcweir awt::Point SAL_CALL AccessibleSlideSorterObject::getLocationOnScreen (void)
429cdf0e10cSrcweir     throw (RuntimeException)
430cdf0e10cSrcweir {
431cdf0e10cSrcweir     ThrowIfDisposed ();
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
434cdf0e10cSrcweir 
435cdf0e10cSrcweir     awt::Point aLocation (getLocation());
436cdf0e10cSrcweir 
437cdf0e10cSrcweir     if (mxParent.is())
438cdf0e10cSrcweir     {
439cdf0e10cSrcweir         Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(),UNO_QUERY);
440cdf0e10cSrcweir         if (xParentComponent.is())
441cdf0e10cSrcweir         {
442cdf0e10cSrcweir             const awt::Point aParentLocationOnScreen(xParentComponent->getLocationOnScreen());
443cdf0e10cSrcweir             aLocation.X += aParentLocationOnScreen.X;
444cdf0e10cSrcweir             aLocation.Y += aParentLocationOnScreen.Y;
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir     }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     return aLocation;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 
getSize(void)454cdf0e10cSrcweir awt::Size SAL_CALL AccessibleSlideSorterObject::getSize (void)
455cdf0e10cSrcweir     throw (RuntimeException)
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     ThrowIfDisposed ();
458cdf0e10cSrcweir     const awt::Rectangle aBBox (getBounds());
459cdf0e10cSrcweir     return awt::Size(aBBox.Width,aBBox.Height);
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 
grabFocus(void)465cdf0e10cSrcweir void SAL_CALL AccessibleSlideSorterObject::grabFocus (void)
466cdf0e10cSrcweir     throw (RuntimeException)
467cdf0e10cSrcweir {
468cdf0e10cSrcweir     // nothing to do
469cdf0e10cSrcweir }
470cdf0e10cSrcweir 
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 
getForeground(void)474cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleSlideSorterObject::getForeground (void)
475cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     ThrowIfDisposed ();
478cdf0e10cSrcweir 	svtools::ColorConfig aColorConfig;
479cdf0e10cSrcweir     sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
480cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 
getBackground(void)486cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleSlideSorterObject::getBackground (void)
487cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir     ThrowIfDisposed ();
490cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
491cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 
498cdf0e10cSrcweir //=====  XServiceInfo  ========================================================
499cdf0e10cSrcweir 
500cdf0e10cSrcweir ::rtl::OUString SAL_CALL
getImplementationName(void)501cdf0e10cSrcweir    	AccessibleSlideSorterObject::getImplementationName (void)
502cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleSlideSorterObject"));
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 
510cdf0e10cSrcweir sal_Bool SAL_CALL
supportsService(const OUString & sServiceName)511cdf0e10cSrcweir  	AccessibleSlideSorterObject::supportsService (const OUString& sServiceName)
512cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
513cdf0e10cSrcweir {
514cdf0e10cSrcweir     ThrowIfDisposed ();
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     //  Iterate over all supported service names and return true if on of them
517cdf0e10cSrcweir     //  matches the given name.
518cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString> aSupportedServices (
519cdf0e10cSrcweir         getSupportedServiceNames ());
520cdf0e10cSrcweir     for (int i=0; i<aSupportedServices.getLength(); i++)
521cdf0e10cSrcweir         if (sServiceName == aSupportedServices[i])
522cdf0e10cSrcweir             return sal_True;
523cdf0e10cSrcweir     return sal_False;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 
529cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL
getSupportedServiceNames(void)530cdf0e10cSrcweir    	AccessibleSlideSorterObject::getSupportedServiceNames (void)
531cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     ThrowIfDisposed ();
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	static const OUString sServiceNames[2] = {
536cdf0e10cSrcweir         OUString(RTL_CONSTASCII_USTRINGPARAM(
537cdf0e10cSrcweir             "com.sun.star.accessibility.Accessible")),
538cdf0e10cSrcweir         OUString(RTL_CONSTASCII_USTRINGPARAM(
539cdf0e10cSrcweir             "com.sun.star.accessibility.AccessibleContext"))
540cdf0e10cSrcweir     };
541cdf0e10cSrcweir 	return uno::Sequence<OUString> (sServiceNames, 2);
542cdf0e10cSrcweir }
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 
ThrowIfDisposed(void)547cdf0e10cSrcweir void AccessibleSlideSorterObject::ThrowIfDisposed (void)
548cdf0e10cSrcweir     throw (lang::DisposedException)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
551cdf0e10cSrcweir 	{
552cdf0e10cSrcweir         OSL_TRACE ("Calling disposed object. Throwing exception:");
553cdf0e10cSrcweir         throw lang::DisposedException (
554cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")),
555cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
556cdf0e10cSrcweir     }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 
IsDisposed(void)561cdf0e10cSrcweir sal_Bool AccessibleSlideSorterObject::IsDisposed (void)
562cdf0e10cSrcweir {
563cdf0e10cSrcweir 	return (rBHelper.bDisposed || rBHelper.bInDispose);
564cdf0e10cSrcweir }
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 
GetPage(void) const569cdf0e10cSrcweir SdPage* AccessibleSlideSorterObject::GetPage (void) const
570cdf0e10cSrcweir {
571cdf0e10cSrcweir     ::sd::slidesorter::model::SharedPageDescriptor pDescriptor(
572cdf0e10cSrcweir         mrSlideSorter.GetModel().GetPageDescriptor(mnPageNumber));
573cdf0e10cSrcweir     if (pDescriptor.get() != NULL)
574cdf0e10cSrcweir         return pDescriptor->GetPage();
575cdf0e10cSrcweir     else
576cdf0e10cSrcweir         return NULL;
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 
580cdf0e10cSrcweir } // end of namespace ::accessibility
581