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