LibreOffice Module sd (master) 1
AccessibleSlideSorterObject.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21
22#include <SlideSorter.hxx>
29#include <view/SlsLayouter.hxx>
31#include <com/sun/star/accessibility/AccessibleRole.hpp>
32#include <com/sun/star/accessibility/AccessibleStateType.hpp>
33#include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
34#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37#include <sal/log.hxx>
38
39#include <sdpage.hxx>
40#include <sdresid.hxx>
41#include <vcl/svapp.hxx>
42#include <vcl/settings.hxx>
43
44#include <strings.hrc>
45
46using namespace ::com::sun::star;
47using namespace ::com::sun::star::uno;
48using namespace ::com::sun::star::accessibility;
49
50namespace accessibility {
51
53 const Reference<XAccessible>& rxParent,
55 sal_uInt16 nPageNumber)
56 : mxParent(rxParent),
57 mnPageNumber(nPageNumber),
58 mrSlideSorter(rSlideSorter),
59 mnClientId(0)
60{
61}
62
64{
65 if ( ! IsDisposed())
66 dispose();
67}
68
70 short nEventId,
71 const uno::Any& rOldValue,
72 const uno::Any& rNewValue)
73{
74 if (mnClientId != 0)
75 {
76 AccessibleEventObject aEventObject;
77
78 aEventObject.Source = Reference<XWeak>(this);
79 aEventObject.EventId = nEventId;
80 aEventObject.NewValue = rNewValue;
81 aEventObject.OldValue = rOldValue;
82
84 }
85}
86
87void AccessibleSlideSorterObject::disposing(std::unique_lock<std::mutex>&)
88{
89 // Send a disposing to all listeners.
90 if (mnClientId != 0)
91 {
93 mnClientId = 0;
94 }
95}
96
97//===== XAccessible ===========================================================
98
99Reference<XAccessibleContext> SAL_CALL
101{
103 return this;
104}
105
106//===== XAccessibleContext ====================================================
107
109{
111 return 0;
112}
113
114Reference<XAccessible> SAL_CALL AccessibleSlideSorterObject::getAccessibleChild (sal_Int64 )
115{
117 throw lang::IndexOutOfBoundsException();
118}
119
121{
123 return mxParent;
124}
125
127{
129 const SolarMutexGuard aSolarGuard;
130 sal_Int64 nIndexInParent(-1);
131
132 if (mxParent.is())
133 {
134 Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
135 if (xParentContext.is())
136 {
137 sal_Int64 nChildCount (xParentContext->getAccessibleChildCount());
138 for (sal_Int64 i=0; i<nChildCount; ++i)
139 if (xParentContext->getAccessibleChild(i).get()
140 == static_cast<XAccessible*>(this))
141 {
142 nIndexInParent = i;
143 break;
144 }
145 }
146 }
147
148 return nIndexInParent;
149}
150
152{
154 return AccessibleRole::SHAPE;
155}
156
158{
160 return SdResId(STR_PAGE);
161}
162
164{
166 const SolarMutexGuard aSolarGuard;
167
168 SdPage* pPage = GetPage();
169 if (pPage != nullptr)
170 return pPage->GetName();
171 else
172 return OUString();
173}
174
175Reference<XAccessibleRelationSet> SAL_CALL
177{
179 return Reference<XAccessibleRelationSet>();
180}
181
182sal_Int64 SAL_CALL
184{
186 const SolarMutexGuard aSolarGuard;
187 sal_Int64 nStateSet = 0;
188
189 if (mxParent.is())
190 {
191 // Unconditional states.
192 nStateSet |= AccessibleStateType::SELECTABLE;
193 nStateSet |= AccessibleStateType::FOCUSABLE;
194 nStateSet |= AccessibleStateType::ENABLED;
195 nStateSet |= AccessibleStateType::VISIBLE;
196 nStateSet |= AccessibleStateType::SHOWING;
197 nStateSet |= AccessibleStateType::ACTIVE;
198 nStateSet |= AccessibleStateType::SENSITIVE;
199
200 // Conditional states.
202 nStateSet |= AccessibleStateType::SELECTED;
205 nStateSet |= AccessibleStateType::FOCUSED;
206 }
207
208 return nStateSet;
209}
210
212{
214 // Delegate request to parent.
215 if (mxParent.is())
216 {
217 Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
218 if (xParentContext.is())
219 return xParentContext->getLocale ();
220 }
221
222 // No locale and no parent. Therefore throw exception to indicate this
223 // cluelessness.
224 throw IllegalAccessibleComponentStateException();
225}
226
227//===== XAccessibleEventBroadcaster ===========================================
228
230 const Reference<XAccessibleEventListener>& rxListener)
231{
232 if (!rxListener.is())
233 return;
234
235 const std::unique_lock aGuard(m_aMutex);
236
237 if (IsDisposed())
238 {
239 uno::Reference<uno::XInterface> x (static_cast<lang::XComponent *>(this), uno::UNO_QUERY);
240 rxListener->disposing (lang::EventObject (x));
241 }
242 else
243 {
244 if (mnClientId == 0)
247 }
248}
249
251 const Reference<XAccessibleEventListener>& rxListener)
252{
254 if (!(rxListener.is() && mnClientId))
255 return;
256
257 const std::unique_lock aGuard(m_aMutex);
258
259 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
260 if ( !nListenerCount )
261 {
262 // no listeners anymore
263 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
264 // and at least to us not firing any events anymore, in case somebody calls
265 // NotifyAccessibleEvent, again
267 mnClientId = 0;
268 }
269}
270
271//===== XAccessibleComponent ==================================================
272
273sal_Bool SAL_CALL AccessibleSlideSorterObject::containsPoint(const awt::Point& aPoint)
274{
276 const awt::Size aSize (getSize());
277 return (aPoint.X >= 0)
278 && (aPoint.X < aSize.Width)
279 && (aPoint.Y >= 0)
280 && (aPoint.Y < aSize.Height);
281}
282
283Reference<XAccessible> SAL_CALL
285{
286 return nullptr;
287}
288
290{
292
293 const SolarMutexGuard aSolarGuard;
294
295 ::tools::Rectangle aBBox (
300
301 if (mxParent.is())
302 {
303 Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(), UNO_QUERY);
304 if (xParentComponent.is())
305 {
306 awt::Rectangle aParentBBox (xParentComponent->getBounds());
308 aParentBBox.X,
309 aParentBBox.Y,
310 aParentBBox.Width,
311 aParentBBox.Height));
312 }
313 }
314
315 return awt::Rectangle(
316 aBBox.Left(),
317 aBBox.Top(),
318 aBBox.GetWidth(),
319 aBBox.GetHeight());
320}
321
323{
325 const awt::Rectangle aBBox (getBounds());
326 return awt::Point(aBBox.X, aBBox.Y);
327}
328
330{
332
333 const SolarMutexGuard aSolarGuard;
334
335 awt::Point aLocation (getLocation());
336
337 if (mxParent.is())
338 {
339 Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(),UNO_QUERY);
340 if (xParentComponent.is())
341 {
342 const awt::Point aParentLocationOnScreen(xParentComponent->getLocationOnScreen());
343 aLocation.X += aParentLocationOnScreen.X;
344 aLocation.Y += aParentLocationOnScreen.Y;
345 }
346 }
347
348 return aLocation;
349}
350
352{
354 const awt::Rectangle aBBox (getBounds());
355 return awt::Size(aBBox.Width,aBBox.Height);
356}
357
359{
360 // nothing to do
361}
362
364{
366 svtools::ColorConfig aColorConfig;
367 Color nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
368 return static_cast<sal_Int32>(nColor);
369}
370
372{
375 return sal_Int32(nColor);
376}
377
378// XServiceInfo
379OUString SAL_CALL
381{
382 return "AccessibleSlideSorterObject";
383}
384
385sal_Bool SAL_CALL AccessibleSlideSorterObject::supportsService (const OUString& sServiceName)
386{
388}
389
390uno::Sequence< OUString> SAL_CALL
392{
394
395 return uno::Sequence<OUString> {
396 OUString("com.sun.star.accessibility.Accessible"),
397 OUString("com.sun.star.accessibility.AccessibleContext")
398 };
399}
400
402{
403 if (m_bDisposed)
404 {
405 SAL_WARN("sd", "Calling disposed object. Throwing exception:");
406 throw lang::DisposedException ("object has been already disposed",
407 static_cast<uno::XWeak*>(this));
408 }
409}
410
412{
413 return m_bDisposed;
414}
415
417{
420 if (pDescriptor)
421 return pDescriptor->GetPage();
422 else
423 return nullptr;
424}
425
426} // end of namespace ::accessibility
427
428/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SlideSorter & mrSlideSorter
constexpr OUStringLiteral sServiceName
unotools::WeakReference< AnimationNode > mxParent
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const OUString & GetName() const
Definition: sdpage.cxx:2505
const Color & GetWindowColor() const
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
AccessibleSlideSorterObject(const css::uno::Reference< css::accessibility::XAccessible > &rxParent, ::sd::slidesorter::SlideSorter &rSlideSorter, sal_uInt16 nPageNumber)
Create a new object that represents a page object in the slide sorter.
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &rxListener) override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
SdPage * GetPage() const
Return the page that is made accessible by the called object.
void FireAccessibleEvent(short nEventId, const css::uno::Any &rOldValue, const css::uno::Any &rNewValue)
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::awt::Size SAL_CALL getSize() override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
virtual css::lang::Locale SAL_CALL getLocale() override
bool IsDisposed() const
Check whether or not the object has been disposed (or is in the state of being disposed).
virtual void disposing(std::unique_lock< std::mutex > &) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &rxListener) override
virtual css::awt::Point SAL_CALL getLocation() override
void ThrowIfDisposed()
Check whether or not the object has been disposed (or is in the state of being disposed).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
css::uno::Reference< css::accessibility::XAccessible > mxParent
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
virtual OUString SAL_CALL getAccessibleName() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
static void revokeClient(const TClientId _nClient)
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
virtual void SAL_CALL dispose() noexcept final override
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
SD_DLLPUBLIC controller::SlideSorterController & GetController() const
model::SlideSorterModel & GetModel() const
view::SlideSorterView & GetView() const
bool IsFocusShowing() const
Return <TRUE> when the focus indicator is currently shown.
sal_Int32 GetFocusedPageIndex() const
Return the index of the page that currently has the focus as it is accepted by the slide sorter model...
SD_DLLPUBLIC bool IsPageSelected(int nPageIndex)
Return whether the specified page is selected.
SharedPageDescriptor GetPageDescriptor(const sal_Int32 nPageIndex, const bool bCreate=true) const
Return a page descriptor for the page with the specified index.
std::shared_ptr< PageObjectLayouter > const & GetPageObjectLayouter() const
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr tools::Long GetHeight() const
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
constexpr tools::Long Left() const
float x
#define SAL_WARN(area, stream)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
std::shared_ptr< PageDescriptor > SharedPageDescriptor
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
unsigned char sal_Bool
@ VISIBLE
Definition: unolayer.hxx:37