LibreOffice Module sw (master)  1
acccontext.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 
20 #include <vcl/window.hxx>
21 #include <swtypes.hxx>
22 
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
25 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28 #include <sal/log.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/settings.hxx>
34 #include <viewsh.hxx>
35 #include <crsrsh.hxx>
36 #include <fesh.hxx>
37 #include <wrtsh.hxx>
38 #include <txtfrm.hxx>
39 #include <ndtxt.hxx>
40 #include <pagefrm.hxx>
41 #include <flyfrm.hxx>
42 #include <dflyobj.hxx>
43 #include <pam.hxx>
44 #include <accmap.hxx>
45 #include "accfrmobjslist.hxx"
46 #include "acccontext.hxx"
47 #include <svx/AccessibleShape.hxx>
50 #include <PostItMgr.hxx>
51 
52 using namespace sw::access;
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::accessibility;
55 
57 {
58  m_isShowingState = GetMap() && IsShowing( *(GetMap()) );
59 
60  SwViewShell *pVSh = GetMap()->GetShell();
61  m_isEditableState = pVSh && IsEditable( pVSh );
62  m_isOpaqueState = pVSh && IsOpaque( pVSh );
63  m_isDefuncState = false;
64 }
65 
67 {
68  std::scoped_lock aGuard( m_Mutex );
69 
70  uno::Reference < XAccessible > xParent( pParent );
71  m_xWeakParent = xParent;
72 }
73 
74 uno::Reference< XAccessible > SwAccessibleContext::GetWeakParent() const
75 {
76  std::scoped_lock aGuard( m_Mutex );
77 
78  uno::Reference< XAccessible > xParent( m_xWeakParent );
79  return xParent;
80 }
81 
83 {
84  vcl::Window *pWin = nullptr;
85 
86  if( GetMap() )
87  {
88  const SwViewShell *pVSh = GetMap()->GetShell();
89  OSL_ENSURE( pVSh, "no view shell" );
90  if( pVSh )
91  pWin = pVSh->GetWin();
92 
93  OSL_ENSURE( pWin, "no window" );
94  }
95 
96  return pWin;
97 }
98 
99 // get SwViewShell from accessibility map, and cast to cursor shell
101 {
102  SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : nullptr;
103  OSL_ENSURE( pViewShell, "no view shell" );
104  return dynamic_cast<SwCursorShell*>( pViewShell);
105 }
106 
108 {
109  // just like non-const GetCursorShell
110  const SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : nullptr;
111  OSL_ENSURE( pViewShell, "no view shell" );
112  return dynamic_cast<const SwCursorShell*>( pViewShell);
113 }
114 
115 namespace {
116 
117 enum class Action { NONE, SCROLLED, SCROLLED_WITHIN,
118  SCROLLED_IN, SCROLLED_OUT };
119 
120 }
121 
123  const SwRect& rOldVisArea )
124 {
125  const SwRect& rNewVisArea = GetVisArea();
126  const bool bVisibleChildrenOnly = SwAccessibleChild( pFrame ).IsVisibleChildrenOnly();
127 
128  const SwAccessibleChildSList aList( *pFrame, *(GetMap()) );
130  while( aIter != aList.end() )
131  {
132  const SwAccessibleChild& rLower = *aIter;
133  const SwRect aBox( rLower.GetBox( *(GetMap()) ) );
134  if( rLower.IsAccessible( GetShell()->IsPreview() ) )
135  {
136  Action eAction = Action::NONE;
137  if( aBox.Overlaps( rNewVisArea ) )
138  {
139  if( aBox.Overlaps( rOldVisArea ) )
140  {
141  eAction = Action::SCROLLED_WITHIN;
142  }
143  else
144  {
145  if ( bVisibleChildrenOnly &&
146  !rLower.AlwaysIncludeAsChild() )
147  {
148  eAction = Action::SCROLLED_IN;
149  }
150  else
151  {
152  eAction = Action::SCROLLED;
153  }
154  }
155  }
156  else if( aBox.Overlaps( rOldVisArea ) )
157  {
158  if ( bVisibleChildrenOnly &&
159  !rLower.AlwaysIncludeAsChild() )
160  {
161  eAction = Action::SCROLLED_OUT;
162  }
163  else
164  {
165  eAction = Action::SCROLLED;
166  }
167  }
168  else if( !bVisibleChildrenOnly ||
169  rLower.AlwaysIncludeAsChild() )
170  {
171  // This wouldn't be required if the SwAccessibleFrame,
172  // wouldn't know about the visible area.
173  eAction = Action::SCROLLED;
174  }
175  if( Action::NONE != eAction )
176  {
177  if ( rLower.GetSwFrame() )
178  {
179  OSL_ENSURE( !rLower.AlwaysIncludeAsChild(),
180  "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
181  const SwFrame* pLower( rLower.GetSwFrame() );
183  GetMap()->GetContextImpl( pLower );
184  if( xAccImpl.is() )
185  {
186  switch( eAction )
187  {
188  case Action::SCROLLED:
189  xAccImpl->Scrolled( rOldVisArea );
190  break;
191  case Action::SCROLLED_WITHIN:
192  xAccImpl->ScrolledWithin( rOldVisArea );
193  break;
194  case Action::SCROLLED_IN:
195  xAccImpl->ScrolledIn();
196  break;
197  case Action::SCROLLED_OUT:
198  xAccImpl->ScrolledOut( rOldVisArea );
199  break;
200  case Action::NONE:
201  break;
202  }
203  }
204  else
205  {
206  ChildrenScrolled( pLower, rOldVisArea );
207  }
208  }
209  else if ( rLower.GetDrawObject() )
210  {
211  OSL_ENSURE( !rLower.AlwaysIncludeAsChild(),
212  "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
214  GetMap()->GetContextImpl( rLower.GetDrawObject(),
215  this );
216  if( xAccImpl.is() )
217  {
218  switch( eAction )
219  {
220  case Action::SCROLLED:
221  case Action::SCROLLED_WITHIN:
222  xAccImpl->ViewForwarderChanged();
223  break;
224  case Action::SCROLLED_IN:
225  ScrolledInShape( xAccImpl.get() );
226  break;
227  case Action::SCROLLED_OUT:
228  {
229  xAccImpl->ViewForwarderChanged();
230  // this DisposeShape call was removed by
231  // IAccessibility2 implementation
232  // without giving any reason why
233  DisposeShape( rLower.GetDrawObject(),
234  xAccImpl.get() );
235  }
236  break;
237  // coverity[dead_error_begin] - following conditions exist to avoid compiler warning
238  case Action::NONE:
239  break;
240  }
241  }
242  }
243  else if ( rLower.GetWindow() )
244  {
245  // nothing to do - as such children are always included as children.
246  OSL_ENSURE( rLower.AlwaysIncludeAsChild(),
247  "<SwAccessibleContext::ChildrenScrolled(..)> - not always included child not considered!" );
248  }
249  }
250  }
251  else if ( rLower.GetSwFrame() &&
252  ( !bVisibleChildrenOnly ||
253  aBox.Overlaps( rOldVisArea ) ||
254  aBox.Overlaps( rNewVisArea ) ) )
255  {
256  // There are no unaccessible SdrObjects that need to be notified
257  ChildrenScrolled( rLower.GetSwFrame(), rOldVisArea );
258  }
259  ++aIter;
260  }
261 }
262 
263 void SwAccessibleContext::Scrolled( const SwRect& rOldVisArea )
264 {
265  SetVisArea( GetMap()->GetVisArea() );
266 
267  ChildrenScrolled( GetFrame(), rOldVisArea );
268 
269  bool bIsOldShowingState;
270  bool bIsNewShowingState = IsShowing( *(GetMap()) );
271  {
272  std::scoped_lock aGuard( m_Mutex );
273  bIsOldShowingState = m_isShowingState;
274  m_isShowingState = bIsNewShowingState;
275  }
276 
277  if( bIsOldShowingState != bIsNewShowingState )
278  FireStateChangedEvent( AccessibleStateType::SHOWING,
279  bIsNewShowingState );
280 }
281 
282 void SwAccessibleContext::ScrolledWithin( const SwRect& rOldVisArea )
283 {
284  SetVisArea( GetMap()->GetVisArea() );
285 
286  ChildrenScrolled( GetFrame(), rOldVisArea );
287 
288  FireVisibleDataEvent();
289 }
290 
292 {
293  // This accessible should be freshly created, because it
294  // was not visible before. Therefore, its visible area must already
295  // reflect the scrolling.
296  OSL_ENSURE( GetVisArea() == GetMap()->GetVisArea(),
297  "Visible area of child is wrong. Did it exist already?" );
298 
299  // Send child event at parent. That's all we have to do here.
300  const SwFrame* pParent = GetParent();
302  GetMap()->GetContextImpl( pParent, false ) );
303  uno::Reference < XAccessibleContext > xThis( this );
304  if( !xParentImpl.is() )
305  return;
306 
307  SetParent( xParentImpl.get() );
308 
309  AccessibleEventObject aEvent;
310  aEvent.EventId = AccessibleEventId::CHILD;
311  aEvent.NewValue <<= xThis;
312 
313  xParentImpl->FireAccessibleEvent( aEvent );
314 
315  if( HasCursor() )
316  {
317  vcl::Window *pWin = GetWindow();
318  if( pWin && pWin->HasFocus() )
319  {
320  FireStateChangedEvent( AccessibleStateType::FOCUSED, true );
321  }
322  }
323 }
324 
325 void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea )
326 {
327  SetVisArea( GetMap()->GetVisArea() );
328 
329  // First of all, update the children. That's required to dispose
330  // all children that are existing only if they are visible. They
331  // are not disposed by the recursive Dispose call that follows later on,
332  // because this call will only dispose children that are in the
333  // new visible area. The children we want to dispose however are in the
334  // old visible area all.
335  ChildrenScrolled( GetFrame(), rOldVisArea );
336 
337  // Broadcast a state changed event for the showing state.
338  // It might be that the child is freshly created just to send
339  // the child event. In this case no listener will exist.
340  FireStateChangedEvent( AccessibleStateType::SHOWING, false );
341 
342  // this Dispose call was removed by IAccessibility2 implementation
343  // without giving any reason why - without it we get stale
344  // entries in SwAccessibleMap::mpFrameMap.
345  Dispose(true);
346 }
347 
348 // #i27301# - use new type definition for <_nStates>
350  AccessibleStates _nStates )
351 {
352  const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrame, *(GetMap()) );
353 
354  SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
355  while( aIter != aVisList.end() )
356  {
357  const SwAccessibleChild& rLower = *aIter;
358  const SwFrame* pLower = rLower.GetSwFrame();
359  if( pLower )
360  {
362  if( rLower.IsAccessible( GetShell()->IsPreview() ) )
363  xAccImpl = GetMap()->GetContextImpl( pLower, false );
364  if( xAccImpl.is() )
365  xAccImpl->InvalidateStates( _nStates );
366  else
367  InvalidateChildrenStates( pLower, _nStates );
368  }
369  else if ( rLower.GetDrawObject() )
370  {
371  // TODO: SdrObjects
372  }
373  else if ( rLower.GetWindow() )
374  {
375  // nothing to do ?
376  }
377 
378  ++aIter;
379  }
380 }
381 
383  bool bRecursive,
384  bool bCanSkipInvisible)
385 {
386  const SwAccessibleChildSList aVisList( GetVisArea(), *pFrame, *(GetMap()) );
387  SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
388  while( aIter != aVisList.end() )
389  {
390  const SwAccessibleChild& rLower = *aIter;
391  const SwFrame* pLower = rLower.GetSwFrame();
392  if( pLower )
393  {
394  // tdf#117601 dispose the darn thing if it ever was accessible
395  ::rtl::Reference<SwAccessibleContext> xAccImpl = GetMap()->GetContextImpl(pLower, false);
396  if( xAccImpl.is() )
397  xAccImpl->Dispose( bRecursive );
398  else
399  {
400  // it's possible that the xAccImpl *does* exist with a
401  // ref-count of 0 and blocked in its dtor in another thread -
402  // this call here could be from SwAccessibleMap dtor so
403  // remove it from any maps now!
404  GetMap()->RemoveContext(pLower);
405  // in this case the context will check with a weak_ptr
406  // that the map is still alive so it's not necessary
407  // to clear its m_pMap here.
408  if (bRecursive)
409  {
410  DisposeChildren(pLower, bRecursive, bCanSkipInvisible);
411  }
412  }
413  }
414  else if ( rLower.GetDrawObject() )
415  {
417  GetMap()->GetContextImpl( rLower.GetDrawObject(),
418  this, false ) );
419  if( xAccImpl.is() )
420  DisposeShape( rLower.GetDrawObject(), xAccImpl.get() );
421  }
422  else if ( rLower.GetWindow() )
423  {
424  DisposeChild(rLower, false, bCanSkipInvisible);
425  }
426  ++aIter;
427  }
428 }
429 
431 {
432 }
433 
435 {
436 }
437 
439 {
440 }
441 
442 void SwAccessibleContext::FireAccessibleEvent( AccessibleEventObject& rEvent )
443 {
444  OSL_ENSURE( GetFrame(), "fire event for disposed frame?" );
445  if( !GetFrame() )
446  return;
447 
448  if( !rEvent.Source.is() )
449  {
450  uno::Reference < XAccessibleContext > xThis( this );
451  rEvent.Source = xThis;
452  }
453 
454  if (m_nClientId)
455  comphelper::AccessibleEventNotifier::addEvent( m_nClientId, rEvent );
456 }
457 
459 {
460  AccessibleEventObject aEvent;
461  aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
462 
463  FireAccessibleEvent( aEvent );
464 }
465 
467  bool bNewState )
468 {
469  AccessibleEventObject aEvent;
470 
471  aEvent.EventId = AccessibleEventId::STATE_CHANGED;
472  if( bNewState )
473  aEvent.NewValue <<= nState;
474  else
475  aEvent.OldValue <<= nState;
476 
477  FireAccessibleEvent( aEvent );
478 }
479 
481  ::utl::AccessibleStateSetHelper& rStateSet )
482 {
483  SolarMutexGuard aGuard;
484 
485  // SHOWING
486  if (m_isShowingState)
487  rStateSet.AddState( AccessibleStateType::SHOWING );
488 
489  // EDITABLE
490  if (m_isEditableState)
491  //Set editable state to graphic and other object when the document is editable
492  {
493  rStateSet.AddState( AccessibleStateType::EDITABLE );
494  rStateSet.AddState( AccessibleStateType::RESIZABLE );
495  rStateSet.AddState( AccessibleStateType::MOVEABLE );
496  }
497  // ENABLED
498  rStateSet.AddState( AccessibleStateType::ENABLED );
499 
500  // OPAQUE
501  if (m_isOpaqueState)
502  rStateSet.AddState( AccessibleStateType::OPAQUE );
503 
504  // VISIBLE
506 
507  if (m_isDefuncState)
508  rStateSet.AddState( AccessibleStateType::DEFUNC );
509 }
510 
512 {
513  bool bRet;
514  {
515  std::scoped_lock aGuard( m_Mutex );
516  bRet = m_isEditableState;
517  }
518 
519  return bRet;
520 }
521 
523 {
524  if (!(GetFrame() && GetMap()))
525  {
526  throw lang::DisposedException("object is nonfunctional",
527  static_cast<cppu::OWeakObject*>(this));
528  }
529 }
530 
531 SwAccessibleContext::SwAccessibleContext(std::shared_ptr<SwAccessibleMap> const& pMap,
532  sal_Int16 const nRole,
533  const SwFrame *pF )
534  : SwAccessibleFrame( pMap->GetVisArea(), pF,
535  pMap->GetShell()->IsPreview() )
536  , m_pMap(pMap.get())
537  , m_wMap(pMap)
538  , m_nClientId(0)
539  , m_nRole(nRole)
540  , m_isDisposing( false )
541  , m_isRegisteredAtAccessibleMap( true )
542  , m_isSelectedInDoc(false)
543 {
544  InitStates();
545 }
546 
548 {
549  // must have for 2 reasons: 2. as long as this thread has SolarMutex
550  // another thread cannot destroy the SwAccessibleMap so our temporary
551  // taking a hard ref to SwAccessibleMap won't delay its destruction
552  SolarMutexGuard aGuard;
553  // must check with weak_ptr that m_pMap is still alive
554  std::shared_ptr<SwAccessibleMap> pMap(m_wMap.lock());
555  if (m_isRegisteredAtAccessibleMap && GetFrame() && pMap)
556  {
557  pMap->RemoveContext( GetFrame() );
558  }
559 }
560 
561 uno::Reference< XAccessibleContext > SAL_CALL
563 {
564  uno::Reference < XAccessibleContext > xRet( this );
565  return xRet;
566 }
567 
569 {
570  SolarMutexGuard aGuard;
571 
572  ThrowIfDisposed();
573 
574  return m_isDisposing ? 0 : GetChildCount( *(GetMap()) );
575 }
576 
577 uno::Reference< XAccessible> SAL_CALL
579 {
580  SolarMutexGuard aGuard;
581 
582  ThrowIfDisposed();
583 
584  const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) );
585  if( !aChild.IsValid() )
586  {
587  uno::Reference < XAccessibleContext > xThis( this );
588  lang::IndexOutOfBoundsException aExcept(
589  "index out of bounds",
590  xThis );
591  throw aExcept;
592  }
593 
594  uno::Reference< XAccessible > xChild;
595  if( aChild.GetSwFrame() )
596  {
598  GetMap()->GetContextImpl( aChild.GetSwFrame(), !m_isDisposing ) );
599  if( xChildImpl.is() )
600  {
601  xChildImpl->SetParent( this );
602  xChild = xChildImpl.get();
603  }
604  }
605  else if ( aChild.GetDrawObject() )
606  {
608  GetMap()->GetContextImpl( aChild.GetDrawObject(),
609  this, !m_isDisposing) );
610  if( xChildImpl.is() )
611  xChild = xChildImpl.get();
612  }
613  else if ( aChild.GetWindow() )
614  {
615  xChild = aChild.GetWindow()->GetAccessible();
616  }
617 
618  return xChild;
619 }
620 
621 css::uno::Sequence<uno::Reference<XAccessible>> SAL_CALL
623 {
624  SolarMutexGuard aGuard;
625 
626  ThrowIfDisposed();
627 
628  std::list< sw::access::SwAccessibleChild > aChildren;
629  GetChildren( *GetMap(), aChildren );
630 
631  std::vector<uno::Reference<XAccessible>> aRet;
632  aRet.reserve(aChildren.size());
633  for (const auto & rSwChild : aChildren)
634  {
635  uno::Reference< XAccessible > xChild;
636  if( rSwChild.GetSwFrame() )
637  {
639  GetMap()->GetContextImpl( rSwChild.GetSwFrame(), !m_isDisposing ) );
640  if( xChildImpl.is() )
641  {
642  xChildImpl->SetParent( this );
643  xChild = xChildImpl.get();
644  }
645  }
646  else if ( rSwChild.GetDrawObject() )
647  {
649  GetMap()->GetContextImpl( rSwChild.GetDrawObject(),
650  this, !m_isDisposing) );
651  if( xChildImpl.is() )
652  xChild = xChildImpl.get();
653  }
654  else if ( rSwChild.GetWindow() )
655  {
656  xChild = rSwChild.GetWindow()->GetAccessible();
657  }
658  aRet.push_back(xChild);
659  }
660  return comphelper::containerToSequence(aRet);
661 }
662 
663 uno::Reference< XAccessible> SwAccessibleContext::getAccessibleParentImpl()
664 {
665  SolarMutexGuard aGuard;
666 
667  const SwFrame *pUpper = GetParent();
668  OSL_ENSURE( pUpper != nullptr || m_isDisposing, "no upper found" );
669 
670  uno::Reference< XAccessible > xAcc;
671  if( pUpper )
672  xAcc = GetMap()->GetContext( pUpper, !m_isDisposing );
673 
674  OSL_ENSURE( xAcc.is() || m_isDisposing, "no parent found" );
675 
676  // Remember the parent as weak ref.
677  {
678  std::scoped_lock aWeakParentGuard( m_Mutex );
679  m_xWeakParent = xAcc;
680  }
681 
682  return xAcc;
683 }
684 
685 uno::Reference< XAccessible> SAL_CALL SwAccessibleContext::getAccessibleParent()
686 {
687  SolarMutexGuard aGuard;
688 
689  ThrowIfDisposed();
690 
691  return getAccessibleParentImpl();
692 }
693 
695 {
696  SolarMutexGuard aGuard;
697 
698  ThrowIfDisposed();
699 
700  const SwFrame *pUpper = GetParent();
701  OSL_ENSURE( pUpper != nullptr || m_isDisposing, "no upper found" );
702 
703  sal_Int32 nIndex = -1;
704  if( pUpper )
705  {
707  GetMap()->GetContextImpl(pUpper, !m_isDisposing) );
708  OSL_ENSURE( xAccImpl.is() || m_isDisposing, "no parent found" );
709  if( xAccImpl.is() )
710  nIndex = xAccImpl->GetChildIndex( *(GetMap()), SwAccessibleChild(GetFrame()) );
711  }
712 
713  return nIndex;
714 }
715 
717 {
718  return m_nRole;
719 }
720 
722 {
723  return m_sName;
724 }
725 
726 uno::Reference< XAccessibleRelationSet> SAL_CALL
728 {
729  // by default there are no relations
730  uno::Reference< XAccessibleRelationSet> xRet( new utl::AccessibleRelationSetHelper() );
731  return xRet;
732 }
733 
734 uno::Reference<XAccessibleStateSet> SAL_CALL
736 {
737  SolarMutexGuard aGuard;
738 
739  ThrowIfDisposed();
740 
742  new ::utl::AccessibleStateSetHelper;
743 
744  if (m_isSelectedInDoc)
745  pStateSet->AddState( AccessibleStateType::SELECTED );
746 
747  GetStates( *pStateSet );
748 
749  return pStateSet;
750 }
751 
752 lang::Locale SAL_CALL SwAccessibleContext::getLocale()
753 {
754  SolarMutexGuard aGuard;
755 
756  lang::Locale aLoc( Application::GetSettings().GetLanguageTag().getLocale() );
757  return aLoc;
758 }
759 
761  const uno::Reference< XAccessibleEventListener >& xListener )
762 {
763  if (xListener.is())
764  {
765  SolarMutexGuard aGuard;
766  if (!m_nClientId)
769  }
770 }
771 
773  const uno::Reference< XAccessibleEventListener >& xListener )
774 {
775  if (!(xListener.is() && m_nClientId))
776  return;
777 
778  SolarMutexGuard aGuard;
779  sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
780  if ( !nListenerCount )
781  {
782  // no listeners anymore
783  // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
784  // and at least to us not firing any events anymore, in case somebody calls
785  // NotifyAccessibleEvent, again
787  m_nClientId = 0;
788  }
789 }
790 
791 static bool lcl_PointInRectangle(const awt::Point & aPoint,
792  const awt::Rectangle & aRect)
793 {
794  tools::Long nDiffX = aPoint.X - aRect.X;
795  tools::Long nDiffY = aPoint.Y - aRect.Y;
796 
797  return
798  nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 &&
799  nDiffY < aRect.Height;
800 
801 }
802 
804  const awt::Point& aPoint )
805 {
806  awt::Rectangle aPixBounds = getBoundsImpl(true);
807  aPixBounds.X = 0;
808  aPixBounds.Y = 0;
809 
810  return lcl_PointInRectangle(aPoint, aPixBounds);
811 }
812 
813 uno::Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAtPoint(
814  const awt::Point& aPoint )
815 {
816  SolarMutexGuard aGuard;
817 
818  ThrowIfDisposed();
819 
820  uno::Reference< XAccessible > xAcc;
821 
822  vcl::Window *pWin = GetWindow();
823  if (!pWin)
824  {
825  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
826  }
827 
828  Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to parent
829  if( !GetFrame()->IsRootFrame() )
830  {
831  SwRect aLogBounds( GetBounds( *(GetMap()), GetFrame() ) ); // twip rel to doc root
832  Point aPixPos( GetMap()->CoreToPixel( aLogBounds ).TopLeft() );
833  aPixPoint.setX(aPixPoint.getX() + aPixPos.getX());
834  aPixPoint.setY(aPixPoint.getY() + aPixPos.getY());
835  }
836 
837  const SwAccessibleChild aChild( GetChildAtPixel( aPixPoint, *(GetMap()) ) );
838  if( aChild.GetSwFrame() )
839  {
840  xAcc = GetMap()->GetContext( aChild.GetSwFrame() );
841  }
842  else if( aChild.GetDrawObject() )
843  {
844  xAcc = GetMap()->GetContext( aChild.GetDrawObject(), this );
845  }
846  else if ( aChild.GetWindow() )
847  {
848  xAcc = aChild.GetWindow()->GetAccessible();
849  }
850 
851  return xAcc;
852 }
853 
872 awt::Rectangle SwAccessibleContext::getBoundsImpl(bool bRelative)
873 {
874  SolarMutexGuard aGuard;
875 
876  ThrowIfDisposed();
877 
878  const SwFrame *pParent = GetParent();
879  OSL_ENSURE( pParent, "no Parent found" );
880  vcl::Window *pWin = GetWindow();
881 
882  if (!pParent)
883  {
884  throw uno::RuntimeException("no Parent", static_cast<cppu::OWeakObject*>(this));
885  }
886  if (!pWin)
887  {
888  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
889  }
890 
891  SwRect aLogBounds( GetBounds( *(GetMap()), GetFrame() ) ); // twip relative to document root
892  tools::Rectangle aPixBounds( 0, 0, 0, 0 );
893  if( GetFrame()->IsPageFrame() &&
894  static_cast < const SwPageFrame * >( GetFrame() )->IsEmptyPage() )
895  {
896  OSL_ENSURE( GetShell()->IsPreview(), "empty page accessible?" );
897  if( GetShell()->IsPreview() )
898  {
899  // adjust method call <GetMap()->GetPreviewPageSize()>
900  sal_uInt16 nPageNum =
901  static_cast < const SwPageFrame * >( GetFrame() )->GetPhyPageNum();
902  aLogBounds.SSize( GetMap()->GetPreviewPageSize( nPageNum ) );
903  }
904  }
905  if( !aLogBounds.IsEmpty() )
906  {
907  aPixBounds = GetMap()->CoreToPixel( aLogBounds );
908  if( !pParent->IsRootFrame() && bRelative)
909  {
910  SwRect aParentLogBounds( GetBounds( *(GetMap()), pParent ) ); // twip rel to doc root
911  Point aParentPixPos( GetMap()->CoreToPixel( aParentLogBounds ).TopLeft() );
912  aPixBounds.Move( -aParentPixPos.getX(), -aParentPixPos.getY() );
913  }
914  }
915 
916  awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
917  aPixBounds.GetWidth(), aPixBounds.GetHeight() );
918 
919  return aBox;
920 }
921 
922 awt::Rectangle SAL_CALL SwAccessibleContext::getBounds()
923 {
924  return getBoundsImpl(true);
925 }
926 
927 awt::Point SAL_CALL SwAccessibleContext::getLocation()
928 {
929  awt::Rectangle aRect = getBoundsImpl(true);
930  awt::Point aPoint(aRect.X, aRect.Y);
931 
932  return aPoint;
933 }
934 
936 {
937  awt::Rectangle aRect = getBoundsImpl(false);
938 
939  Point aPixPos(aRect.X, aRect.Y);
940 
941  vcl::Window *pWin = GetWindow();
942  if (!pWin)
943  {
944  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
945  }
946 
947  aPixPos = pWin->OutputToAbsoluteScreenPixel(aPixPos);
948  awt::Point aPoint(aPixPos.getX(), aPixPos.getY());
949 
950  return aPoint;
951 }
952 
953 awt::Size SAL_CALL SwAccessibleContext::getSize()
954 {
955  awt::Rectangle aRect = getBoundsImpl(false);
956  awt::Size aSize( aRect.Width, aRect.Height );
957 
958  return aSize;
959 }
960 
962 {
963  SolarMutexGuard aGuard;
964 
965  ThrowIfDisposed();
966 
967  if( GetFrame()->IsFlyFrame() )
968  {
969  const SdrObject *pObj =
970  static_cast < const SwFlyFrame * >( GetFrame() )->GetVirtDrawObj();
971  if( pObj )
972  Select( const_cast < SdrObject * >( pObj ), false );
973  }
974  else
975  {
976  const SwContentFrame *pCFrame = nullptr;
977  if( GetFrame()->IsContentFrame() )
978  pCFrame = static_cast< const SwContentFrame * >( GetFrame() );
979  else if( GetFrame()->IsLayoutFrame() )
980  pCFrame = static_cast< const SwLayoutFrame * >( GetFrame() )->ContainsContent();
981 
982  if( pCFrame && pCFrame->IsTextFrame() )
983  {
984  const SwTextFrame *pTextFrame = static_cast< const SwTextFrame * >( pCFrame );
985  const SwTextNode *pTextNd = pTextFrame->GetTextNodeFirst();
986  assert(pTextNd); // can it actually be null? probably not=>simplify
987  if( pTextNd )
988  {
989  // create pam for selection
990  SwPosition const aStartPos(pTextFrame->MapViewToModelPos(pTextFrame->GetOffset()));
991  SwPaM aPaM( aStartPos );
992 
993  // set PaM at cursor shell
994  Select( aPaM );
995  }
996  }
997  }
998 }
999 
1001 {
1002  return sal_Int32(COL_BLACK);
1003 }
1004 
1006 {
1007  return sal_Int32(COL_WHITE);
1008 }
1009 
1010 sal_Bool SAL_CALL SwAccessibleContext::supportsService (const OUString& ServiceName)
1011 {
1012  return cppu::supportsService(this, ServiceName);
1013 }
1014 
1016  ::accessibility::AccessibleShape *pAccImpl )
1017 {
1019  if( !xAccImpl.is() )
1020  xAccImpl = GetMap()->GetContextImpl( pObj, this );
1021 
1022  AccessibleEventObject aEvent;
1023  aEvent.EventId = AccessibleEventId::CHILD;
1024  uno::Reference< XAccessible > xAcc( xAccImpl );
1025  aEvent.OldValue <<= xAcc;
1026  FireAccessibleEvent( aEvent );
1027 
1028  GetMap()->RemoveContext( pObj );
1029  xAccImpl->dispose();
1030 }
1031 
1033 {
1034  if(nullptr == pAccImpl)
1035  {
1036  return ;
1037  }
1038  AccessibleEventObject aEvent;
1039  aEvent.EventId = AccessibleEventId::CHILD;
1040  uno::Reference< XAccessible > xAcc( pAccImpl );
1041  aEvent.NewValue <<= xAcc;
1042  FireAccessibleEvent( aEvent );
1043 
1044  if( !pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
1045  return;
1046 
1047  vcl::Window *pWin = GetWindow();
1048  if( pWin && pWin->HasFocus() )
1049  {
1050  AccessibleEventObject aStateChangedEvent;
1051  aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
1052  aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
1053  aStateChangedEvent.Source = xAcc;
1054 
1055  FireAccessibleEvent( aStateChangedEvent );
1056  }
1057 }
1058 
1059 void SwAccessibleContext::Dispose(bool bRecursive, bool bCanSkipInvisible)
1060 {
1061  SolarMutexGuard aGuard;
1062 
1063  OSL_ENSURE( GetFrame() && GetMap(), "already disposed" );
1064  OSL_ENSURE( GetMap()->GetVisArea() == GetVisArea(),
1065  "invalid visible area for dispose" );
1066 
1067  m_isDisposing = true;
1068 
1069  // dispose children
1070  if( bRecursive )
1071  DisposeChildren(GetFrame(), bRecursive, bCanSkipInvisible);
1072 
1073  // get parent
1074  uno::Reference< XAccessible > xParent( GetWeakParent() );
1075  uno::Reference < XAccessibleContext > xThis( this );
1076 
1077  // send child event at parent
1078  if( xParent.is() )
1079  {
1080  SwAccessibleContext *pAcc = static_cast<SwAccessibleContext *>(xParent.get());
1081 
1082  AccessibleEventObject aEvent;
1083  aEvent.EventId = AccessibleEventId::CHILD;
1084  aEvent.OldValue <<= xThis;
1085  pAcc->FireAccessibleEvent( aEvent );
1086  }
1087 
1088  // set defunc state (it's not required to broadcast a state changed
1089  // event if the object is disposed afterwards)
1090  {
1091  std::scoped_lock aDefuncStateGuard( m_Mutex );
1092  m_isDefuncState = true;
1093  }
1094 
1095  // broadcast dispose event
1096  if (m_nClientId)
1097  {
1099  m_nClientId = 0;
1100  }
1101 
1103  ClearFrame();
1104  m_pMap = nullptr;
1105  m_wMap.reset();
1106 
1107  m_isDisposing = false;
1108 }
1109 
1111  bool bRecursive, bool bCanSkipInvisible )
1112 {
1113  SolarMutexGuard aGuard;
1114 
1115  if ( !bCanSkipInvisible ||
1116  rChildFrameOrObj.AlwaysIncludeAsChild() ||
1117  IsShowing( *(GetMap()), rChildFrameOrObj ) ||
1119  {
1120  // If the object could have existed before, then there is nothing to do,
1121  // because no wrapper exists now and therefore no one is interested to
1122  // get notified of the movement.
1123  if( rChildFrameOrObj.GetSwFrame() )
1124  {
1126  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame(), false );
1127  if (xAccImpl)
1128  xAccImpl->Dispose( bRecursive );
1129  }
1130  else if ( rChildFrameOrObj.GetDrawObject() )
1131  {
1133  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1134  this, false );
1135  if (xAccImpl)
1136  DisposeShape( rChildFrameOrObj.GetDrawObject(),
1137  xAccImpl.get() );
1138  }
1139  else if ( rChildFrameOrObj.GetWindow() )
1140  {
1141  AccessibleEventObject aEvent;
1142  aEvent.EventId = AccessibleEventId::CHILD;
1143  uno::Reference< XAccessible > xAcc =
1144  rChildFrameOrObj.GetWindow()->GetAccessible();
1145  aEvent.OldValue <<= xAcc;
1146  FireAccessibleEvent( aEvent );
1147  }
1148  }
1149  else if( bRecursive && rChildFrameOrObj.GetSwFrame() )
1150  DisposeChildren(rChildFrameOrObj.GetSwFrame(), bRecursive, bCanSkipInvisible);
1151 }
1152 
1154 {
1155  SolarMutexGuard aGuard;
1156 
1157  OSL_ENSURE( GetFrame() && !GetFrame()->getFrameArea().IsEmpty(), "context should have a size" );
1158 
1159  bool bIsOldShowingState;
1160  bool bIsNewShowingState = IsShowing( *(GetMap()) );
1161  {
1162  std::scoped_lock aShowingStateGuard( m_Mutex );
1163  bIsOldShowingState = m_isShowingState;
1164  m_isShowingState = bIsNewShowingState;
1165  }
1166 
1167  if( bIsOldShowingState != bIsNewShowingState )
1168  {
1169  FireStateChangedEvent( AccessibleStateType::SHOWING,
1170  bIsNewShowingState );
1171  }
1172  else if( bIsNewShowingState )
1173  {
1174  // The frame stays visible -> broadcast event
1176  }
1177 
1178  // note: InvalidatePosOrSize must call InvalidateContent_ so that
1179  // SwAccessibleParagraph updates its portions, or dispose it
1180  // (see accmap.cxx: INVALID_CONTENT is contained in POS_CHANGED)
1181  if( !bIsNewShowingState &&
1182  SwAccessibleChild( GetParent() ).IsVisibleChildrenOnly() )
1183  {
1184  // this Dispose call was removed by IAccessibility2 implementation
1185  // without giving any reason why - without it we get stale
1186  // entries in SwAccessibleMap::mpFrameMap.
1187  Dispose(true);
1188  }
1189  else
1190  {
1191  InvalidateContent_( true );
1192  }
1193 }
1194 
1196  const SwAccessibleChild& rChildFrameOrObj,
1197  const SwRect& rOldFrame )
1198 {
1199  SolarMutexGuard aGuard;
1200 
1201  // this happens during layout, e.g. when a page is deleted and next page's
1202  // header/footer moves backward such an event is generated
1203  SAL_INFO_IF(rChildFrameOrObj.GetSwFrame() &&
1204  rChildFrameOrObj.GetSwFrame()->getFrameArea().IsEmpty(),
1205  "sw.a11y", "child context should have a size");
1206 
1207  if ( rChildFrameOrObj.AlwaysIncludeAsChild() )
1208  {
1209  // nothing to do;
1210  return;
1211  }
1212 
1213  const bool bVisibleChildrenOnly = SwAccessibleChild( GetFrame() ).IsVisibleChildrenOnly();
1214  const bool bNew = rOldFrame.IsEmpty() ||
1215  ( rOldFrame.Left() == 0 && rOldFrame.Top() == 0 );
1216  if( IsShowing( *(GetMap()), rChildFrameOrObj ) )
1217  {
1218  // If the object could have existed before, then there is nothing to do,
1219  // because no wrapper exists now and therefore no one is interested to
1220  // get notified of the movement.
1221  if( bNew || (bVisibleChildrenOnly && !IsShowing( rOldFrame )) )
1222  {
1223  if( rChildFrameOrObj.GetSwFrame() )
1224  {
1225  // The frame becomes visible. A child event must be send.
1227  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame() );
1228  xAccImpl->ScrolledIn();
1229  }
1230  else if ( rChildFrameOrObj.GetDrawObject() )
1231  {
1233  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1234  this );
1235  // #i37790#
1236  if ( xAccImpl.is() )
1237  {
1238  ScrolledInShape( xAccImpl.get() );
1239  }
1240  else
1241  {
1242  OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - no accessible shape found." );
1243  }
1244  }
1245  else if ( rChildFrameOrObj.GetWindow() )
1246  {
1247  AccessibleEventObject aEvent;
1248  aEvent.EventId = AccessibleEventId::CHILD;
1249  aEvent.NewValue <<= rChildFrameOrObj.GetWindow()->GetAccessible();
1250  FireAccessibleEvent( aEvent );
1251  }
1252  }
1253  }
1254  else
1255  {
1256  // If the frame was visible before, then a child event for the parent
1257  // needs to be send. However, there is no wrapper existing, and so
1258  // no notifications for grandchildren are required. If the are
1259  // grandgrandchildren, they would be notified by the layout.
1260  if( bVisibleChildrenOnly &&
1261  !bNew && IsShowing( rOldFrame ) )
1262  {
1263  if( rChildFrameOrObj.GetSwFrame() )
1264  {
1266  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame() );
1267  xAccImpl->SetParent( this );
1268  xAccImpl->Dispose( true );
1269  }
1270  else if ( rChildFrameOrObj.GetDrawObject() )
1271  {
1273  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1274  this );
1275  DisposeShape( rChildFrameOrObj.GetDrawObject(),
1276  xAccImpl.get() );
1277  }
1278  else if ( rChildFrameOrObj.GetWindow() )
1279  {
1280  OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - not expected to handle dispose of child of type <vcl::Window>." );
1281  }
1282  }
1283  }
1284 }
1285 
1287 {
1288  SolarMutexGuard aGuard;
1289 
1290  InvalidateContent_( false );
1291 }
1292 
1294 {
1295  SolarMutexGuard aGuard;
1296 
1298 }
1299 
1301 {
1302  SolarMutexGuard aGuard;
1303 
1304  InvalidateFocus_();
1305 }
1306 
1307 // #i27301# - use new type definition for <_nStates>
1309 {
1310  if( !GetMap() )
1311  return;
1312 
1313  SwViewShell *pVSh = GetMap()->GetShell();
1314  if( pVSh )
1315  {
1316  if( _nStates & AccessibleStates::EDITABLE )
1317  {
1318  bool bIsOldEditableState;
1319  bool bIsNewEditableState = IsEditable( pVSh );
1320  {
1321  std::scoped_lock aGuard( m_Mutex );
1322  bIsOldEditableState = m_isEditableState;
1323  m_isEditableState = bIsNewEditableState;
1324  }
1325 
1326  if( bIsOldEditableState != bIsNewEditableState )
1327  FireStateChangedEvent( AccessibleStateType::EDITABLE,
1328  bIsNewEditableState );
1329  }
1330  if( _nStates & AccessibleStates::OPAQUE )
1331  {
1332  bool bIsOldOpaqueState;
1333  bool bIsNewOpaqueState = IsOpaque( pVSh );
1334  {
1335  std::scoped_lock aGuard( m_Mutex );
1336  bIsOldOpaqueState = m_isOpaqueState;
1337  m_isOpaqueState = bIsNewOpaqueState;
1338  }
1339 
1340  if( bIsOldOpaqueState != bIsNewOpaqueState )
1341  FireStateChangedEvent( AccessibleStateType::OPAQUE,
1342  bIsNewOpaqueState );
1343  }
1344  }
1345 
1346  InvalidateChildrenStates( GetFrame(), _nStates );
1347 }
1348 
1350 {
1351  AccessibleEventObject aEvent;
1352  aEvent.EventId = nType;
1353 
1354  FireAccessibleEvent( aEvent );
1355 }
1356 
1359 {
1360  AccessibleEventObject aEvent;
1361  aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
1362 
1363  FireAccessibleEvent( aEvent );
1364 }
1365 
1368 {
1369  AccessibleEventObject aEvent;
1370  aEvent.EventId = AccessibleEventId::TEXT_ATTRIBUTE_CHANGED;
1371 
1372  FireAccessibleEvent( aEvent );
1373 }
1374 
1376 {
1377  return false;
1378 }
1379 
1381  bool bAdd )
1382 {
1383  SwCursorShell* pCursorShell = GetCursorShell();
1384  if( !pCursorShell )
1385  return false;
1386 
1387  SwFEShell* pFEShell = dynamic_cast<SwFEShell*>(pCursorShell);
1388  // Get rid of activated OLE object
1389  if( pFEShell )
1390  pFEShell->FinishOLEObj();
1391 
1392  SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell*>(pCursorShell);
1393 
1394  bool bRet = false;
1395  if( pObj )
1396  {
1397  if( pFEShell )
1398  {
1399  sal_uInt8 nFlags = bAdd ? SW_ADD_SELECT : 0;
1400  pFEShell->SelectObj( Point(), nFlags, pObj );
1401  bRet = true;
1402  }
1403  }
1404  else if( pPaM )
1405  {
1406  // Get rid of frame selection. If there is one, make text cursor
1407  // visible again.
1408  bool bCallShowCursor = false;
1409  if( pFEShell && (pFEShell->IsFrameSelected() ||
1410  pFEShell->IsObjSelected()) )
1411  {
1412  Point aPt( LONG_MIN, LONG_MIN );
1413  pFEShell->SelectObj( aPt );
1414  bCallShowCursor = true;
1415  }
1416  pCursorShell->KillPams();
1417  if( pWrtShell && pPaM->HasMark() )
1418  // We have to do this or SwWrtShell can't figure out that it needs
1419  // to kill the selection later, when the user moves the cursor.
1420  pWrtShell->SttSelect();
1421  pCursorShell->SetSelection( *pPaM );
1422  if( pPaM->HasMark() && *pPaM->GetPoint() == *pPaM->GetMark())
1423  // Setting a "Selection" that starts and ends at the same spot
1424  // should remove the selection rather than create an empty one, so
1425  // that we get defined behavior if accessibility sets the cursor
1426  // later.
1427  pCursorShell->ClearMark();
1428  if( bCallShowCursor )
1429  pCursorShell->ShowCursor();
1430  bRet = true;
1431  }
1432 
1433  return bRet;
1434 }
1435 
1437  const OUString *pArg1,
1438  const OUString *pArg2)
1439 {
1440  OUString sStr = SwResId(pResId);
1441 
1442  if( pArg1 )
1443  {
1444  sStr = sStr.replaceFirst( "$(ARG1)", *pArg1 );
1445  }
1446  if( pArg2 )
1447  {
1448  sStr = sStr.replaceFirst( "$(ARG2)", *pArg2 );
1449  }
1450 
1451  return sStr;
1452 }
1453 
1455 {
1456  assert(m_refCount > 0); // must be alive to do this without using m_wMap
1458  GetMap()->RemoveContext( GetFrame() );
1459 }
1460 
1462 {
1463  bool bRet( false );
1464 
1465  if ( GetFrame()->IsTextFrame() )
1466  {
1467  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1468  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1469  {
1470  bRet = pPostItMgr->HasFrameConnectedSidebarWins( *(GetFrame()) );
1471  }
1472  }
1473 
1474  return bRet;
1475 }
1476 
1479 {
1480  vcl::Window* pAdditionalAccessibleChild( nullptr );
1481 
1482  if ( GetFrame()->IsTextFrame() )
1483  {
1484  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1485  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1486  {
1487  pAdditionalAccessibleChild =
1488  pPostItMgr->GetSidebarWinForFrameByIndex( *(GetFrame()), nIndex );
1489  }
1490  }
1491 
1492  return pAdditionalAccessibleChild;
1493 }
1494 
1496 void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< vcl::Window* >* pChildren )
1497 {
1498  if ( GetFrame()->IsTextFrame() )
1499  {
1500  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1501  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1502  {
1503  pPostItMgr->GetAllSidebarWinForFrame( *(GetFrame()), pChildren );
1504  }
1505  }
1506 }
1507 
1508 bool SwAccessibleContext::SetSelectedState(bool const bSelected)
1509 {
1510  if (m_isSelectedInDoc != bSelected)
1511  {
1512  m_isSelectedInDoc = bSelected;
1513  FireStateChangedEvent( AccessibleStateType::SELECTED, bSelected );
1514  return true;
1515  }
1516  return false;
1517 };
1518 
1519 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
void ScrolledOut(const SwRect &rOldVisArea)
Definition: acccontext.cxx:325
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParentImpl()
Definition: acccontext.cxx:663
std::weak_ptr< SwAccessibleMap > m_wMap
note: the m_pMap is guaranteed to be valid until we hit the dtor ~SwAccessibleContext, then m_wMap must be checked if it's still alive, after locking SolarMutex (alternatively, Dispose clears m_pMap)
Definition: acccontext.hxx:81
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:162
virtual css::awt::Point SAL_CALL getLocation() override
Definition: acccontext.cxx:927
void KillPams()
Definition: crsrsh.cxx:1022
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
Definition: acccontext.cxx:935
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
Definition: acccontext.cxx:803
virtual css::awt::Size SAL_CALL getSize() override
Definition: acccontext.cxx:953
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:442
sal_Int32 nIndex
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2081
Marks a position in the document model.
Definition: pam.hxx:36
vcl::Window * GetSidebarWinForFrameByIndex(const SwFrame &rFrame, const sal_Int32 nIndex)
Definition: PostItMgr.cxx:2462
virtual void InvalidateCursorPos_()
Definition: acccontext.cxx:434
bool IsRootFrame() const
Definition: frame.hxx:1174
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame)
void ChildrenScrolled(const SwFrame *pFrame, const SwRect &rOldVisArea)
Definition: acccontext.cxx:122
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Definition: acccontext.cxx:568
void SetParent(SwAccessibleContext *pParent)
Definition: acccontext.cxx:66
constexpr tools::Long Left() const
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
ULONG m_refCount
virtual sal_Int32 SAL_CALL getForeground() override
#define SAL_INFO_IF(condition, area, stream)
long Long
void DisposeChildren(const SwFrame *pFrame, bool bRecursive, bool bCanSkipInvisible)
Definition: acccontext.cxx:382
vcl::Window * GetWindow()
Definition: acccontext.cxx:82
static bool lcl_PointInRectangle(const awt::Point &aPoint, const awt::Rectangle &aRect)
Definition: acccontext.cxx:791
static const AllSettings & GetSettings()
const SwPosition * GetMark() const
Definition: pam.hxx:210
void Scrolled(const SwRect &rOldVisArea)
Definition: acccontext.cxx:263
virtual void SAL_CALL grabFocus() override
Definition: acccontext.cxx:961
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:119
virtual bool HasCursor()
virtual css::lang::Locale SAL_CALL getLocale() override
Return the parents locale or throw exception if this object has no parent yet/anymore.
Definition: acccontext.cxx:752
vcl::Window * GetAdditionalAccessibleChild(const sal_Int32 nIndex)
#i88070# - get additional accessible child by index
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwAccessibleContext(std::shared_ptr< SwAccessibleMap > const &pMap, sal_Int16 nRole, const SwFrame *pFrame)
Definition: acccontext.cxx:531
static sal_Int32 GetChildCount(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame *pFrame, bool bInPagePreviewr)
Definition: accframe.cxx:41
bool GetState(sal_Int16 aState)
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
SwCursorShell * GetCursorShell()
convenience method to get SwCursorShell through accessibility map
Definition: acccontext.cxx:100
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
SwViewShell * GetShell() const
Definition: accmap.hxx:174
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1912
static sw::access::SwAccessibleChild GetChild(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, sal_Int32 &rPos, bool bInPagePreview)
Definition: accframe.cxx:71
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Definition: acccontext.cxx:727
NONE
const SdrObject * GetDrawObject() const
Definition: accfrmobj.hxx:59
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
const SwRect & getFrameArea() const
Definition: frame.hxx:179
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool IsTextFrame() const
Definition: frame.hxx:1234
void GetAdditionalAccessibleChildren(std::vector< vcl::Window * > *pChildren)
#i88070# - get all additional accessible children
constexpr tools::Long GetWidth() const
virtual void InvalidateContent_(bool bVisibleDataFired)
Definition: acccontext.cxx:430
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible)
bool IsVisibleChildrenOnly() const
Definition: accfrmobj.cxx:202
bool IsEmpty() const
Definition: swrect.hxx:304
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: acccontext.cxx:760
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:442
void GetAllSidebarWinForFrame(const SwFrame &rFrame, std::vector< vcl::Window * > *pChildren)
Definition: PostItMgr.cxx:2475
bool Select(SwPaM *pPaM, SdrObject *pObj, bool bAdd)
bool IsOpaque(SwViewShell const *pVSh) const
Definition: accframe.cxx:356
void FireStateChangedEvent(sal_Int16 nState, bool bNewState)
Definition: acccontext.cxx:466
const SwFrame * GetSwFrame() const
Definition: accfrmobj.hxx:58
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:461
static void GetChildren(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, std::list< sw::access::SwAccessibleChild > &rChildren, bool bInPagePreview)
Definition: accframe.cxx:277
Shell * GetShell()
SwAccessibleMap * m_pMap
Definition: acccontext.hxx:77
const SwPosition * GetPoint() const
Definition: pam.hxx:208
const_iterator begin() const
bool FinishOLEObj()
Shutdown server.
Definition: feflyole.cxx:88
static OUString GetResource(TranslateId pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
static sal_Int32 removeEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
bool HasAdditionalAccessibleChildren()
void InvalidateChildrenStates(const SwFrame *_pFrame, AccessibleStates _nStates)
Definition: acccontext.cxx:349
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
void InvalidateStates(AccessibleStates _nStates)
void InvalidateAttr()
#i88069# - attributes has changed
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3547
unsigned char sal_Bool
bool m_isRegisteredAtAccessibleMap
Definition: acccontext.hxx:97
constexpr tools::Long Top() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: acccontext.cxx:685
#define SW_ADD_SELECT
Definition: fesh.hxx:166
bool AlwaysIncludeAsChild() const
indicating, if accessible child is included even, if the corresponding object is not visible...
Definition: accfrmobj.cxx:299
void InvalidateRelation(sal_uInt16 nType)
void SttSelect()
Definition: select.cxx:385
virtual void InvalidatePosOrSize(const SwRect &rFrame)
void SSize(const Size &rNew)
Definition: swrect.hxx:180
const_iterator end() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Definition: acccontext.cxx:578
css::uno::WeakReference< css::accessibility::XAccessible > m_xWeakParent
Definition: acccontext.hxx:75
SwRect GetBounds(const SwAccessibleMap &rAccMap, const SwFrame *pFrame=nullptr)
Definition: accframe.cxx:328
A page of the document layout.
Definition: pagefrm.hxx:57
static void revokeClientNotifyDisposing(const TClientId _nClient, const css::uno::Reference< css::uno::XInterface > &_rxEventSource)
static void SetParent(std::shared_ptr< const SfxItemSet > &rpAttrSet, const SwContentNode &rNode, const SwFormat *pParentFormat, const SwFormat *pConditionalFormat)
Definition: node.cxx:105
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
virtual css::awt::Rectangle SAL_CALL getBounds() override
Definition: acccontext.cxx:922
void ScrolledWithin(const SwRect &rOldVisArea)
Definition: acccontext.cxx:282
bool HasFrameConnectedSidebarWins(const SwFrame &rFrame)
Definition: PostItMgr.cxx:2450
void ScrolledInShape(::accessibility::AccessibleShape *pAccImpl)
void DisposeShape(const SdrObject *pObj,::accessibility::AccessibleShape *pAccImpl)
css::awt::Rectangle getBoundsImpl(bool bRelative)
Get bounding box.
Definition: acccontext.cxx:872
bool IsLayoutFrame() const
Definition: frame.hxx:1170
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
Definition: acccontext.cxx:694
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool IsEditable(SwViewShell const *pVSh) const
Definition: accframe.cxx:339
virtual sal_Int32 SAL_CALL getBackground() override
void RemoveFrameFromAccessibleMap()
virtual OUString SAL_CALL getAccessibleName() override
Definition: acccontext.cxx:721
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
Definition: acccontext.cxx:735
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
std::mutex m_Mutex
Definition: acccontext.hxx:67
static void revokeClient(const TClientId _nClient)
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true)
unsigned char sal_uInt8
vcl::Window * GetWin() const
Definition: viewsh.hxx:338
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet)
Definition: acccontext.cxx:480
bool IsAccessible(bool bPagePreview) const
Definition: accfrmobj.cxx:122
sal_uInt32 m_nClientId
Definition: acccontext.hxx:83
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
tools::Rectangle CoreToPixel(const SwRect &rRect) const
Definition: accmap.cxx:3191
const SwFrame * GetParent() const
Definition: accframe.hxx:155
void ShowCursor()
Definition: crsrsh.cxx:2398
size_t IsObjSelected() const
Definition: feshview.cxx:1246
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1784
bool HasNotes() const
Definition: PostItMgr.cxx:2110
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:177
void InvalidateTextSelection()
#i27301# - text selection has changed
css::uno::Reference< css::accessibility::XAccessible > GetWeakParent() const
Definition: acccontext.cxx:74
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:115
vcl::Window * GetWindow() const
Definition: accfrmobj.hxx:60
virtual void InvalidateFocus_()
Definition: acccontext.cxx:438
void ClearMark()
Definition: crsrsh.cxx:939
const SwPostItMgr * GetPostItMgr() const
Definition: viewsh.hxx:561
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: acccontext.cxx:772
SwRect GetBox(const SwAccessibleMap &rAccMap) const
Definition: accfrmobj.cxx:222
static void addEvent(const TClientId _nClient, const css::accessibility::AccessibleEventObject &_rEvent)
void Dispose(const T &xInterface)
const SwRect & GetVisArea() const
Definition: accframe.hxx:136
bool ShowNotes() const
Definition: PostItMgr.cxx:2104
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: acccontext.cxx:813
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: acccontext.cxx:716
bool HasFocus() const
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
Definition: acccontext.cxx:562
void AddState(sal_Int16 aState)
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1249
AccessibleStates
Definition: accmap.hxx:70
virtual css::uno::Sequence< css::uno::Reference< css::accessibility::XAccessible > > SAL_CALL getAccessibleChildren() override
Definition: acccontext.cxx:622
bool IsFrameSelected() const
Definition: feshview.cxx:1254
virtual ~SwAccessibleContext() override
Definition: acccontext.cxx:547
AnyEventRef aEvent
virtual bool SetSelectedState(bool bSelected)
static sal_Int32 addEventListener(const TClientId _nClient, const css::uno::Reference< css::accessibility::XAccessibleEventListener > &_rxListener)
bool m_bDetectedRangeSegmentation false
constexpr tools::Long GetHeight() const
static sw::access::SwAccessibleChild GetChildAtPixel(const SwRect &rVisArea, const SwFrame &rFrame, const Point &rPos, bool bInPagePreview, SwAccessibleMap &rAccMap)
Definition: accframe.cxx:204
bool IsShowing(const SwAccessibleMap &rAccMap, const sw::access::SwAccessibleChild &rFrameOrObj) const
Definition: accframe.cxx:473