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  {
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 }
326 
327 void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea )
328 {
329  SetVisArea( GetMap()->GetVisArea() );
330 
331  // First of all, update the children. That's required to dispose
332  // all children that are existing only if they are visible. They
333  // are not disposed by the recursive Dispose call that follows later on,
334  // because this call will only dispose children that are in the
335  // new visible area. The children we want to dispose however are in the
336  // old visible area all.
337  ChildrenScrolled( GetFrame(), rOldVisArea );
338 
339  // Broadcast a state changed event for the showing state.
340  // It might be that the child is freshly created just to send
341  // the child event. In this case no listener will exist.
342  FireStateChangedEvent( AccessibleStateType::SHOWING, false );
343 
344  // this Dispose call was removed by IAccessibility2 implementation
345  // without giving any reason why - without it we get stale
346  // entries in SwAccessibleMap::mpFrameMap.
347  Dispose(true);
348 }
349 
350 // #i27301# - use new type definition for <_nStates>
352  AccessibleStates _nStates )
353 {
354  const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrame, *(GetMap()) );
355 
356  SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
357  while( aIter != aVisList.end() )
358  {
359  const SwAccessibleChild& rLower = *aIter;
360  const SwFrame* pLower = rLower.GetSwFrame();
361  if( pLower )
362  {
364  if( rLower.IsAccessible( GetShell()->IsPreview() ) )
365  xAccImpl = GetMap()->GetContextImpl( pLower, false );
366  if( xAccImpl.is() )
367  xAccImpl->InvalidateStates( _nStates );
368  else
369  InvalidateChildrenStates( pLower, _nStates );
370  }
371  else if ( rLower.GetDrawObject() )
372  {
373  // TODO: SdrObjects
374  }
375  else if ( rLower.GetWindow() )
376  {
377  // nothing to do ?
378  }
379 
380  ++aIter;
381  }
382 }
383 
385  bool bRecursive,
386  bool bCanSkipInvisible)
387 {
388  const SwAccessibleChildSList aVisList( GetVisArea(), *pFrame, *(GetMap()) );
389  SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
390  while( aIter != aVisList.end() )
391  {
392  const SwAccessibleChild& rLower = *aIter;
393  const SwFrame* pLower = rLower.GetSwFrame();
394  if( pLower )
395  {
396  // tdf#117601 dispose the darn thing if it ever was accessible
397  ::rtl::Reference<SwAccessibleContext> xAccImpl = GetMap()->GetContextImpl(pLower, false);
398  if( xAccImpl.is() )
399  xAccImpl->Dispose( bRecursive );
400  else
401  {
402  // it's possible that the xAccImpl *does* exist with a
403  // ref-count of 0 and blocked in its dtor in another thread -
404  // this call here could be from SwAccessibleMap dtor so
405  // remove it from any maps now!
406  GetMap()->RemoveContext(pLower);
407  // in this case the context will check with a weak_ptr
408  // that the map is still alive so it's not necessary
409  // to clear its m_pMap here.
410  if (bRecursive)
411  {
412  DisposeChildren(pLower, bRecursive, bCanSkipInvisible);
413  }
414  }
415  }
416  else if ( rLower.GetDrawObject() )
417  {
419  GetMap()->GetContextImpl( rLower.GetDrawObject(),
420  this, false ) );
421  if( xAccImpl.is() )
422  DisposeShape( rLower.GetDrawObject(), xAccImpl.get() );
423  }
424  else if ( rLower.GetWindow() )
425  {
426  DisposeChild(rLower, false, bCanSkipInvisible);
427  }
428  ++aIter;
429  }
430 }
431 
433 {
434 }
435 
437 {
438 }
439 
441 {
442 }
443 
444 void SwAccessibleContext::FireAccessibleEvent( AccessibleEventObject& rEvent )
445 {
446  OSL_ENSURE( GetFrame(), "fire event for disposed frame?" );
447  if( !GetFrame() )
448  return;
449 
450  if( !rEvent.Source.is() )
451  {
452  uno::Reference < XAccessibleContext > xThis( this );
453  rEvent.Source = xThis;
454  }
455 
456  if (m_nClientId)
457  comphelper::AccessibleEventNotifier::addEvent( m_nClientId, rEvent );
458 }
459 
461 {
462  AccessibleEventObject aEvent;
463  aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
464 
465  FireAccessibleEvent( aEvent );
466 }
467 
469  bool bNewState )
470 {
471  AccessibleEventObject aEvent;
472 
473  aEvent.EventId = AccessibleEventId::STATE_CHANGED;
474  if( bNewState )
475  aEvent.NewValue <<= nState;
476  else
477  aEvent.OldValue <<= nState;
478 
479  FireAccessibleEvent( aEvent );
480 }
481 
483  ::utl::AccessibleStateSetHelper& rStateSet )
484 {
485  SolarMutexGuard aGuard;
486 
487  // SHOWING
488  if (m_isShowingState)
489  rStateSet.AddState( AccessibleStateType::SHOWING );
490 
491  // EDITABLE
492  if (m_isEditableState)
493  //Set editable state to graphic and other object when the document is editable
494  {
495  rStateSet.AddState( AccessibleStateType::EDITABLE );
496  rStateSet.AddState( AccessibleStateType::RESIZABLE );
497  rStateSet.AddState( AccessibleStateType::MOVEABLE );
498  }
499  // ENABLED
500  rStateSet.AddState( AccessibleStateType::ENABLED );
501 
502  // OPAQUE
503  if (m_isOpaqueState)
504  rStateSet.AddState( AccessibleStateType::OPAQUE );
505 
506  // VISIBLE
508 
509  if (m_isDefuncState)
510  rStateSet.AddState( AccessibleStateType::DEFUNC );
511 }
512 
514 {
515  bool bRet;
516  {
517  osl::MutexGuard aGuard( m_Mutex );
518  bRet = m_isEditableState;
519  }
520 
521  return bRet;
522 }
523 
525 {
526  if (!(GetFrame() && GetMap()))
527  {
528  throw lang::DisposedException("object is nonfunctional",
529  static_cast<cppu::OWeakObject*>(this));
530  }
531 }
532 
533 SwAccessibleContext::SwAccessibleContext(std::shared_ptr<SwAccessibleMap> const& pMap,
534  sal_Int16 const nRole,
535  const SwFrame *pF )
536  : SwAccessibleFrame( pMap->GetVisArea().SVRect(), pF,
537  pMap->GetShell()->IsPreview() )
538  , m_pMap(pMap.get())
539  , m_wMap(pMap)
540  , m_nClientId(0)
541  , m_nRole(nRole)
542  , m_isDisposing( false )
543  , m_isRegisteredAtAccessibleMap( true )
544  , m_isSelectedInDoc(false)
545 {
546  InitStates();
547 }
548 
550 {
551  // must have for 2 reasons: 2. as long as this thread has SolarMutex
552  // another thread cannot destroy the SwAccessibleMap so our temporary
553  // taking a hard ref to SwAccessibleMap won't delay its destruction
554  SolarMutexGuard aGuard;
555  // must check with weak_ptr that m_pMap is still alive
556  std::shared_ptr<SwAccessibleMap> pMap(m_wMap.lock());
557  if (m_isRegisteredAtAccessibleMap && GetFrame() && pMap)
558  {
559  pMap->RemoveContext( GetFrame() );
560  }
561 }
562 
563 uno::Reference< XAccessibleContext > SAL_CALL
565 {
566  uno::Reference < XAccessibleContext > xRet( this );
567  return xRet;
568 }
569 
571 {
572  SolarMutexGuard aGuard;
573 
574  ThrowIfDisposed();
575 
576  return m_isDisposing ? 0 : GetChildCount( *(GetMap()) );
577 }
578 
579 uno::Reference< XAccessible> SAL_CALL
581 {
582  SolarMutexGuard aGuard;
583 
584  ThrowIfDisposed();
585 
586  const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) );
587  if( !aChild.IsValid() )
588  {
589  uno::Reference < XAccessibleContext > xThis( this );
590  lang::IndexOutOfBoundsException aExcept(
591  "index out of bounds",
592  xThis );
593  throw aExcept;
594  }
595 
596  uno::Reference< XAccessible > xChild;
597  if( aChild.GetSwFrame() )
598  {
600  GetMap()->GetContextImpl( aChild.GetSwFrame(), !m_isDisposing ) );
601  if( xChildImpl.is() )
602  {
603  xChildImpl->SetParent( this );
604  xChild = xChildImpl.get();
605  }
606  }
607  else if ( aChild.GetDrawObject() )
608  {
610  GetMap()->GetContextImpl( aChild.GetDrawObject(),
611  this, !m_isDisposing) );
612  if( xChildImpl.is() )
613  xChild = xChildImpl.get();
614  }
615  else if ( aChild.GetWindow() )
616  {
617  xChild = aChild.GetWindow()->GetAccessible();
618  }
619 
620  return xChild;
621 }
622 
623 css::uno::Sequence<uno::Reference<XAccessible>> SAL_CALL
625 {
626  SolarMutexGuard aGuard;
627 
628  ThrowIfDisposed();
629 
630  std::list< sw::access::SwAccessibleChild > aChildren;
631  GetChildren( *GetMap(), aChildren );
632 
633  std::vector<uno::Reference<XAccessible>> aRet;
634  aRet.reserve(aChildren.size());
635  for (const auto & rSwChild : aChildren)
636  {
637  uno::Reference< XAccessible > xChild;
638  if( rSwChild.GetSwFrame() )
639  {
641  GetMap()->GetContextImpl( rSwChild.GetSwFrame(), !m_isDisposing ) );
642  if( xChildImpl.is() )
643  {
644  xChildImpl->SetParent( this );
645  xChild = xChildImpl.get();
646  }
647  }
648  else if ( rSwChild.GetDrawObject() )
649  {
651  GetMap()->GetContextImpl( rSwChild.GetDrawObject(),
652  this, !m_isDisposing) );
653  if( xChildImpl.is() )
654  xChild = xChildImpl.get();
655  }
656  else if ( rSwChild.GetWindow() )
657  {
658  xChild = rSwChild.GetWindow()->GetAccessible();
659  }
660  aRet.push_back(xChild);
661  }
662  return comphelper::containerToSequence(aRet);
663 }
664 
665 uno::Reference< XAccessible> SwAccessibleContext::getAccessibleParentImpl()
666 {
667  SolarMutexGuard aGuard;
668 
669  const SwFrame *pUpper = GetParent();
670  OSL_ENSURE( pUpper != nullptr || m_isDisposing, "no upper found" );
671 
672  uno::Reference< XAccessible > xAcc;
673  if( pUpper )
674  xAcc = GetMap()->GetContext( pUpper, !m_isDisposing );
675 
676  OSL_ENSURE( xAcc.is() || m_isDisposing, "no parent found" );
677 
678  // Remember the parent as weak ref.
679  {
680  osl::MutexGuard aWeakParentGuard( m_Mutex );
681  m_xWeakParent = xAcc;
682  }
683 
684  return xAcc;
685 }
686 
687 uno::Reference< XAccessible> SAL_CALL SwAccessibleContext::getAccessibleParent()
688 {
689  SolarMutexGuard aGuard;
690 
691  ThrowIfDisposed();
692 
693  return getAccessibleParentImpl();
694 }
695 
697 {
698  SolarMutexGuard aGuard;
699 
700  ThrowIfDisposed();
701 
702  const SwFrame *pUpper = GetParent();
703  OSL_ENSURE( pUpper != nullptr || m_isDisposing, "no upper found" );
704 
705  sal_Int32 nIndex = -1;
706  if( pUpper )
707  {
709  GetMap()->GetContextImpl(pUpper, !m_isDisposing) );
710  OSL_ENSURE( xAccImpl.is() || m_isDisposing, "no parent found" );
711  if( xAccImpl.is() )
712  nIndex = xAccImpl->GetChildIndex( *(GetMap()), SwAccessibleChild(GetFrame()) );
713  }
714 
715  return nIndex;
716 }
717 
719 {
720  return m_nRole;
721 }
722 
724 {
725  return m_sName;
726 }
727 
728 uno::Reference< XAccessibleRelationSet> SAL_CALL
730 {
731  // by default there are no relations
732  uno::Reference< XAccessibleRelationSet> xRet( new utl::AccessibleRelationSetHelper() );
733  return xRet;
734 }
735 
736 uno::Reference<XAccessibleStateSet> SAL_CALL
738 {
739  SolarMutexGuard aGuard;
740 
741  ThrowIfDisposed();
742 
744  new ::utl::AccessibleStateSetHelper;
745 
746  if (m_isSelectedInDoc)
747  pStateSet->AddState( AccessibleStateType::SELECTED );
748 
749  uno::Reference<XAccessibleStateSet> xStateSet( pStateSet );
750  GetStates( *pStateSet );
751 
752  return xStateSet;
753 }
754 
755 lang::Locale SAL_CALL SwAccessibleContext::getLocale()
756 {
757  SolarMutexGuard aGuard;
758 
759  lang::Locale aLoc( Application::GetSettings().GetLanguageTag().getLocale() );
760  return aLoc;
761 }
762 
764  const uno::Reference< XAccessibleEventListener >& xListener )
765 {
766  if (xListener.is())
767  {
768  SolarMutexGuard aGuard;
769  if (!m_nClientId)
772  }
773 }
774 
776  const uno::Reference< XAccessibleEventListener >& xListener )
777 {
778  if (xListener.is() && m_nClientId)
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 
794 static bool lcl_PointInRectangle(const awt::Point & aPoint,
795  const awt::Rectangle & aRect)
796 {
797  long nDiffX = aPoint.X - aRect.X;
798  long nDiffY = aPoint.Y - aRect.Y;
799 
800  return
801  nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 &&
802  nDiffY < aRect.Height;
803 
804 }
805 
807  const awt::Point& aPoint )
808 {
809  awt::Rectangle aPixBounds = getBoundsImpl(true);
810  aPixBounds.X = 0;
811  aPixBounds.Y = 0;
812 
813  return lcl_PointInRectangle(aPoint, aPixBounds);
814 }
815 
816 uno::Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAtPoint(
817  const awt::Point& aPoint )
818 {
819  SolarMutexGuard aGuard;
820 
821  ThrowIfDisposed();
822 
823  uno::Reference< XAccessible > xAcc;
824 
825  vcl::Window *pWin = GetWindow();
826  if (!pWin)
827  {
828  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
829  }
830 
831  Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to parent
832  if( !GetFrame()->IsRootFrame() )
833  {
834  SwRect aLogBounds( GetBounds( *(GetMap()), GetFrame() ) ); // twip rel to doc root
835  Point aPixPos( GetMap()->CoreToPixel( aLogBounds.SVRect() ).TopLeft() );
836  aPixPoint.setX(aPixPoint.getX() + aPixPos.getX());
837  aPixPoint.setY(aPixPoint.getY() + aPixPos.getY());
838  }
839 
840  const SwAccessibleChild aChild( GetChildAtPixel( aPixPoint, *(GetMap()) ) );
841  if( aChild.GetSwFrame() )
842  {
843  xAcc = GetMap()->GetContext( aChild.GetSwFrame() );
844  }
845  else if( aChild.GetDrawObject() )
846  {
847  xAcc = GetMap()->GetContext( aChild.GetDrawObject(), this );
848  }
849  else if ( aChild.GetWindow() )
850  {
851  xAcc = aChild.GetWindow()->GetAccessible();
852  }
853 
854  return xAcc;
855 }
856 
875 awt::Rectangle SwAccessibleContext::getBoundsImpl(bool bRelative)
876 {
877  SolarMutexGuard aGuard;
878 
879  ThrowIfDisposed();
880 
881  const SwFrame *pParent = GetParent();
882  OSL_ENSURE( pParent, "no Parent found" );
883  vcl::Window *pWin = GetWindow();
884 
885  if (!pParent)
886  {
887  throw uno::RuntimeException("no Parent", static_cast<cppu::OWeakObject*>(this));
888  }
889  if (!pWin)
890  {
891  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
892  }
893 
894  SwRect aLogBounds( GetBounds( *(GetMap()), GetFrame() ) ); // twip relative to document root
895  tools::Rectangle aPixBounds( 0, 0, 0, 0 );
896  if( GetFrame()->IsPageFrame() &&
897  static_cast < const SwPageFrame * >( GetFrame() )->IsEmptyPage() )
898  {
899  OSL_ENSURE( GetShell()->IsPreview(), "empty page accessible?" );
900  if( GetShell()->IsPreview() )
901  {
902  // adjust method call <GetMap()->GetPreviewPageSize()>
903  sal_uInt16 nPageNum =
904  static_cast < const SwPageFrame * >( GetFrame() )->GetPhyPageNum();
905  aLogBounds.SSize( GetMap()->GetPreviewPageSize( nPageNum ) );
906  }
907  }
908  if( !aLogBounds.IsEmpty() )
909  {
910  aPixBounds = GetMap()->CoreToPixel( aLogBounds.SVRect() );
911  if( !pParent->IsRootFrame() && bRelative)
912  {
913  SwRect aParentLogBounds( GetBounds( *(GetMap()), pParent ) ); // twip rel to doc root
914  Point aParentPixPos( GetMap()->CoreToPixel( aParentLogBounds.SVRect() ).TopLeft() );
915  aPixBounds.Move( -aParentPixPos.getX(), -aParentPixPos.getY() );
916  }
917  }
918 
919  awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
920  aPixBounds.GetWidth(), aPixBounds.GetHeight() );
921 
922  return aBox;
923 }
924 
925 awt::Rectangle SAL_CALL SwAccessibleContext::getBounds()
926 {
927  return getBoundsImpl(true);
928 }
929 
930 awt::Point SAL_CALL SwAccessibleContext::getLocation()
931 {
932  awt::Rectangle aRect = getBoundsImpl(true);
933  awt::Point aPoint(aRect.X, aRect.Y);
934 
935  return aPoint;
936 }
937 
939 {
940  awt::Rectangle aRect = getBoundsImpl(false);
941 
942  Point aPixPos(aRect.X, aRect.Y);
943 
944  vcl::Window *pWin = GetWindow();
945  if (!pWin)
946  {
947  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
948  }
949 
950  aPixPos = pWin->OutputToAbsoluteScreenPixel(aPixPos);
951  awt::Point aPoint(aPixPos.getX(), aPixPos.getY());
952 
953  return aPoint;
954 }
955 
956 awt::Size SAL_CALL SwAccessibleContext::getSize()
957 {
958  awt::Rectangle aRect = getBoundsImpl(false);
959  awt::Size aSize( aRect.Width, aRect.Height );
960 
961  return aSize;
962 }
963 
965 {
966  SolarMutexGuard aGuard;
967 
968  ThrowIfDisposed();
969 
970  if( GetFrame()->IsFlyFrame() )
971  {
972  const SdrObject *pObj =
973  static_cast < const SwFlyFrame * >( GetFrame() )->GetVirtDrawObj();
974  if( pObj )
975  Select( const_cast < SdrObject * >( pObj ), false );
976  }
977  else
978  {
979  const SwContentFrame *pCFrame = nullptr;
980  if( GetFrame()->IsContentFrame() )
981  pCFrame = static_cast< const SwContentFrame * >( GetFrame() );
982  else if( GetFrame()->IsLayoutFrame() )
983  pCFrame = static_cast< const SwLayoutFrame * >( GetFrame() )->ContainsContent();
984 
985  if( pCFrame && pCFrame->IsTextFrame() )
986  {
987  const SwTextFrame *pTextFrame = static_cast< const SwTextFrame * >( pCFrame );
988  const SwTextNode *pTextNd = pTextFrame->GetTextNodeFirst();
989  assert(pTextNd); // can it actually be null? probably not=>simplify
990  if( pTextNd )
991  {
992  // create pam for selection
993  SwPosition const aStartPos(pTextFrame->MapViewToModelPos(pTextFrame->GetOfst()));
994  SwPaM aPaM( aStartPos );
995 
996  // set PaM at cursor shell
997  Select( aPaM );
998  }
999  }
1000  }
1001 }
1002 
1004 {
1005  return sal_Int32(COL_BLACK);
1006 }
1007 
1009 {
1010  return sal_Int32(COL_WHITE);
1011 }
1012 
1013 sal_Bool SAL_CALL SwAccessibleContext::supportsService (const OUString& ServiceName)
1014 {
1015  return cppu::supportsService(this, ServiceName);
1016 }
1017 
1019  ::accessibility::AccessibleShape *pAccImpl )
1020 {
1022  if( !xAccImpl.is() )
1023  xAccImpl = GetMap()->GetContextImpl( pObj, this );
1024 
1025  AccessibleEventObject aEvent;
1026  aEvent.EventId = AccessibleEventId::CHILD;
1027  uno::Reference< XAccessible > xAcc( xAccImpl.get() );
1028  aEvent.OldValue <<= xAcc;
1029  FireAccessibleEvent( aEvent );
1030 
1031  GetMap()->RemoveContext( pObj );
1032  xAccImpl->dispose();
1033 }
1034 
1036 {
1037  if(nullptr == pAccImpl)
1038  {
1039  return ;
1040  }
1041  AccessibleEventObject aEvent;
1042  aEvent.EventId = AccessibleEventId::CHILD;
1043  uno::Reference< XAccessible > xAcc( pAccImpl );
1044  aEvent.NewValue <<= xAcc;
1045  FireAccessibleEvent( aEvent );
1046 
1047  if( pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
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 
1062 void SwAccessibleContext::Dispose(bool bRecursive, bool bCanSkipInvisible)
1063 {
1064  SolarMutexGuard aGuard;
1065 
1066  OSL_ENSURE( GetFrame() && GetMap(), "already disposed" );
1067  OSL_ENSURE( GetMap()->GetVisArea() == GetVisArea(),
1068  "invalid visible area for dispose" );
1069 
1070  m_isDisposing = true;
1071 
1072  // dispose children
1073  if( bRecursive )
1074  DisposeChildren(GetFrame(), bRecursive, bCanSkipInvisible);
1075 
1076  // get parent
1077  uno::Reference< XAccessible > xParent( GetWeakParent() );
1078  uno::Reference < XAccessibleContext > xThis( this );
1079 
1080  // send child event at parent
1081  if( xParent.is() )
1082  {
1083  SwAccessibleContext *pAcc = static_cast<SwAccessibleContext *>(xParent.get());
1084 
1085  AccessibleEventObject aEvent;
1086  aEvent.EventId = AccessibleEventId::CHILD;
1087  aEvent.OldValue <<= xThis;
1088  pAcc->FireAccessibleEvent( aEvent );
1089  }
1090 
1091  // set defunc state (it's not required to broadcast a state changed
1092  // event if the object is disposed afterwards)
1093  {
1094  osl::MutexGuard aDefuncStateGuard( m_Mutex );
1095  m_isDefuncState = true;
1096  }
1097 
1098  // broadcast dispose event
1099  if (m_nClientId)
1100  {
1102  m_nClientId = 0;
1103  }
1104 
1106  ClearFrame();
1107  m_pMap = nullptr;
1108  m_wMap.reset();
1109 
1110  m_isDisposing = false;
1111 }
1112 
1114  bool bRecursive, bool bCanSkipInvisible )
1115 {
1116  SolarMutexGuard aGuard;
1117 
1118  if ( !bCanSkipInvisible ||
1119  rChildFrameOrObj.AlwaysIncludeAsChild() ||
1120  IsShowing( *(GetMap()), rChildFrameOrObj ) ||
1122  {
1123  // If the object could have existed before, then there is nothing to do,
1124  // because no wrapper exists now and therefore no one is interested to
1125  // get notified of the movement.
1126  if( rChildFrameOrObj.GetSwFrame() )
1127  {
1129  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame(), false );
1130  if (xAccImpl)
1131  xAccImpl->Dispose( bRecursive );
1132  }
1133  else if ( rChildFrameOrObj.GetDrawObject() )
1134  {
1136  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1137  this, false );
1138  if (xAccImpl)
1139  DisposeShape( rChildFrameOrObj.GetDrawObject(),
1140  xAccImpl.get() );
1141  }
1142  else if ( rChildFrameOrObj.GetWindow() )
1143  {
1144  AccessibleEventObject aEvent;
1145  aEvent.EventId = AccessibleEventId::CHILD;
1146  uno::Reference< XAccessible > xAcc =
1147  rChildFrameOrObj.GetWindow()->GetAccessible();
1148  aEvent.OldValue <<= xAcc;
1149  FireAccessibleEvent( aEvent );
1150  }
1151  }
1152  else if( bRecursive && rChildFrameOrObj.GetSwFrame() )
1153  DisposeChildren(rChildFrameOrObj.GetSwFrame(), bRecursive, bCanSkipInvisible);
1154 }
1155 
1157 {
1158  SolarMutexGuard aGuard;
1159 
1160  OSL_ENSURE( GetFrame() && !GetFrame()->getFrameArea().IsEmpty(), "context should have a size" );
1161 
1162  bool bIsOldShowingState;
1163  bool bIsNewShowingState = IsShowing( *(GetMap()) );
1164  {
1165  osl::MutexGuard aShowingStateGuard( m_Mutex );
1166  bIsOldShowingState = m_isShowingState;
1167  m_isShowingState = bIsNewShowingState;
1168  }
1169 
1170  if( bIsOldShowingState != bIsNewShowingState )
1171  {
1172  FireStateChangedEvent( AccessibleStateType::SHOWING,
1173  bIsNewShowingState );
1174  }
1175  else if( bIsNewShowingState )
1176  {
1177  // The frame stays visible -> broadcast event
1179  }
1180 
1181  // note: InvalidatePosOrSize must call InvalidateContent_ so that
1182  // SwAccessibleParagraph updates its portions, or dispose it
1183  // (see accmap.cxx: INVALID_CONTENT is contained in POS_CHANGED)
1184  if( !bIsNewShowingState &&
1185  SwAccessibleChild( GetParent() ).IsVisibleChildrenOnly() )
1186  {
1187  // this Dispose call was removed by IAccessibility2 implementation
1188  // without giving any reason why - without it we get stale
1189  // entries in SwAccessibleMap::mpFrameMap.
1190  Dispose(true);
1191  }
1192  else
1193  {
1194  InvalidateContent_( true );
1195  }
1196 }
1197 
1199  const SwAccessibleChild& rChildFrameOrObj,
1200  const SwRect& rOldFrame )
1201 {
1202  SolarMutexGuard aGuard;
1203 
1204  // this happens during layout, e.g. when a page is deleted and next page's
1205  // header/footer moves backward such an event is generated
1206  SAL_INFO_IF(rChildFrameOrObj.GetSwFrame() &&
1207  rChildFrameOrObj.GetSwFrame()->getFrameArea().IsEmpty(),
1208  "sw.a11y", "child context should have a size");
1209 
1210  if ( rChildFrameOrObj.AlwaysIncludeAsChild() )
1211  {
1212  // nothing to do;
1213  return;
1214  }
1215 
1216  const bool bVisibleChildrenOnly = SwAccessibleChild( GetFrame() ).IsVisibleChildrenOnly();
1217  const bool bNew = rOldFrame.IsEmpty() ||
1218  ( rOldFrame.Left() == 0 && rOldFrame.Top() == 0 );
1219  if( IsShowing( *(GetMap()), rChildFrameOrObj ) )
1220  {
1221  // If the object could have existed before, then there is nothing to do,
1222  // because no wrapper exists now and therefore no one is interested to
1223  // get notified of the movement.
1224  if( bNew || (bVisibleChildrenOnly && !IsShowing( rOldFrame )) )
1225  {
1226  if( rChildFrameOrObj.GetSwFrame() )
1227  {
1228  // The frame becomes visible. A child event must be send.
1230  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame() );
1231  xAccImpl->ScrolledIn();
1232  }
1233  else if ( rChildFrameOrObj.GetDrawObject() )
1234  {
1236  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1237  this );
1238  // #i37790#
1239  if ( xAccImpl.is() )
1240  {
1241  ScrolledInShape( xAccImpl.get() );
1242  }
1243  else
1244  {
1245  OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - no accessible shape found." );
1246  }
1247  }
1248  else if ( rChildFrameOrObj.GetWindow() )
1249  {
1250  AccessibleEventObject aEvent;
1251  aEvent.EventId = AccessibleEventId::CHILD;
1252  aEvent.NewValue <<= rChildFrameOrObj.GetWindow()->GetAccessible();
1253  FireAccessibleEvent( aEvent );
1254  }
1255  }
1256  }
1257  else
1258  {
1259  // If the frame was visible before, then a child event for the parent
1260  // needs to be send. However, there is no wrapper existing, and so
1261  // no notifications for grandchildren are required. If the are
1262  // grandgrandchildren, they would be notified by the layout.
1263  if( bVisibleChildrenOnly &&
1264  !bNew && IsShowing( rOldFrame ) )
1265  {
1266  if( rChildFrameOrObj.GetSwFrame() )
1267  {
1269  GetMap()->GetContextImpl( rChildFrameOrObj.GetSwFrame() );
1270  xAccImpl->SetParent( this );
1271  xAccImpl->Dispose( true );
1272  }
1273  else if ( rChildFrameOrObj.GetDrawObject() )
1274  {
1276  GetMap()->GetContextImpl( rChildFrameOrObj.GetDrawObject(),
1277  this );
1278  DisposeShape( rChildFrameOrObj.GetDrawObject(),
1279  xAccImpl.get() );
1280  }
1281  else if ( rChildFrameOrObj.GetWindow() )
1282  {
1283  OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - not expected to handle dispose of child of type <vcl::Window>." );
1284  }
1285  }
1286  }
1287 }
1288 
1290 {
1291  SolarMutexGuard aGuard;
1292 
1293  InvalidateContent_( false );
1294 }
1295 
1297 {
1298  SolarMutexGuard aGuard;
1299 
1301 }
1302 
1304 {
1305  SolarMutexGuard aGuard;
1306 
1307  InvalidateFocus_();
1308 }
1309 
1310 // #i27301# - use new type definition for <_nStates>
1312 {
1313  if( GetMap() )
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 }
1351 
1353 {
1354  AccessibleEventObject aEvent;
1355  aEvent.EventId = nType;
1356 
1357  FireAccessibleEvent( aEvent );
1358 }
1359 
1362 {
1363  AccessibleEventObject aEvent;
1364  aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
1365 
1366  FireAccessibleEvent( aEvent );
1367 }
1368 
1371 {
1372  AccessibleEventObject aEvent;
1373  aEvent.EventId = AccessibleEventId::TEXT_ATTRIBUTE_CHANGED;
1374 
1375  FireAccessibleEvent( aEvent );
1376 }
1377 
1379 {
1380  return false;
1381 }
1382 
1384  bool bAdd )
1385 {
1386  SwCursorShell* pCursorShell = GetCursorShell();
1387  if( !pCursorShell )
1388  return false;
1389 
1390  SwFEShell* pFEShell = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr
1391  ? static_cast<SwFEShell*>( pCursorShell )
1392  : nullptr;
1393  // Get rid of activated OLE object
1394  if( pFEShell )
1395  pFEShell->FinishOLEObj();
1396 
1397  SwWrtShell* pWrtShell = dynamic_cast<const SwWrtShell*>( pCursorShell) != nullptr
1398  ? static_cast<SwWrtShell*>( pCursorShell )
1399  : nullptr;
1400 
1401  bool bRet = false;
1402  if( pObj )
1403  {
1404  if( pFEShell )
1405  {
1406  sal_uInt8 nFlags = bAdd ? SW_ADD_SELECT : 0;
1407  pFEShell->SelectObj( Point(), nFlags, pObj );
1408  bRet = true;
1409  }
1410  }
1411  else if( pPaM )
1412  {
1413  // Get rid of frame selection. If there is one, make text cursor
1414  // visible again.
1415  bool bCallShowCursor = false;
1416  if( pFEShell && (pFEShell->IsFrameSelected() ||
1417  pFEShell->IsObjSelected()) )
1418  {
1419  Point aPt( LONG_MIN, LONG_MIN );
1420  pFEShell->SelectObj( aPt );
1421  bCallShowCursor = true;
1422  }
1423  pCursorShell->KillPams();
1424  if( pWrtShell && pPaM->HasMark() )
1425  // We have to do this or SwWrtShell can't figure out that it needs
1426  // to kill the selection later, when the user moves the cursor.
1427  pWrtShell->SttSelect();
1428  pCursorShell->SetSelection( *pPaM );
1429  if( pPaM->HasMark() && *pPaM->GetPoint() == *pPaM->GetMark())
1430  // Setting a "Selection" that starts and ends at the same spot
1431  // should remove the selection rather than create an empty one, so
1432  // that we get defined behavior if accessibility sets the cursor
1433  // later.
1434  pCursorShell->ClearMark();
1435  if( bCallShowCursor )
1436  pCursorShell->ShowCursor();
1437  bRet = true;
1438  }
1439 
1440  return bRet;
1441 }
1442 
1443 OUString SwAccessibleContext::GetResource(const char* pResId,
1444  const OUString *pArg1,
1445  const OUString *pArg2)
1446 {
1447  OUString sStr = SwResId(pResId);
1448 
1449  if( pArg1 )
1450  {
1451  sStr = sStr.replaceFirst( "$(ARG1)", *pArg1 );
1452  }
1453  if( pArg2 )
1454  {
1455  sStr = sStr.replaceFirst( "$(ARG2)", *pArg2 );
1456  }
1457 
1458  return sStr;
1459 }
1460 
1462 {
1463  assert(m_refCount > 0); // must be alive to do this without using m_wMap
1465  GetMap()->RemoveContext( GetFrame() );
1466 }
1467 
1469 {
1470  bool bRet( false );
1471 
1472  if ( GetFrame()->IsTextFrame() )
1473  {
1474  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1475  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1476  {
1477  bRet = pPostItMgr->HasFrameConnectedSidebarWins( *(GetFrame()) );
1478  }
1479  }
1480 
1481  return bRet;
1482 }
1483 
1486 {
1487  vcl::Window* pAdditionalAccessibleChild( nullptr );
1488 
1489  if ( GetFrame()->IsTextFrame() )
1490  {
1491  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1492  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1493  {
1494  pAdditionalAccessibleChild =
1495  pPostItMgr->GetSidebarWinForFrameByIndex( *(GetFrame()), nIndex );
1496  }
1497  }
1498 
1499  return pAdditionalAccessibleChild;
1500 }
1501 
1503 void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< vcl::Window* >* pChildren )
1504 {
1505  if ( GetFrame()->IsTextFrame() )
1506  {
1507  SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1508  if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1509  {
1510  pPostItMgr->GetAllSidebarWinForFrame( *(GetFrame()), pChildren );
1511  }
1512  }
1513 }
1514 
1515 bool SwAccessibleContext::SetSelectedState(bool const bSelected)
1516 {
1517  if (m_isSelectedInDoc != bSelected)
1518  {
1519  m_isSelectedInDoc = bSelected;
1520  FireStateChangedEvent( AccessibleStateType::SELECTED, bSelected );
1521  return true;
1522  }
1523  return false;
1524 };
1525 
1526 /* 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:327
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParentImpl()
Definition: acccontext.cxx:665
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:80
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual css::awt::Point SAL_CALL getLocation() override
Definition: acccontext.cxx:930
long GetWidth() const
void KillPams()
Definition: crsrsh.cxx:1013
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
Definition: acccontext.cxx:938
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
Definition: acccontext.cxx:806
virtual css::awt::Size SAL_CALL getSize() override
Definition: acccontext.cxx:956
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:444
sal_Int32 nIndex
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2167
long GetHeight() const
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
Marks a position in the document model.
Definition: pam.hxx:35
vcl::Window * GetSidebarWinForFrameByIndex(const SwFrame &rFrame, const sal_Int32 nIndex)
Definition: PostItMgr.cxx:2411
static OUString GetResource(const char *pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
virtual void InvalidateCursorPos_()
Definition: acccontext.cxx:436
bool IsRootFrame() const
Definition: frame.hxx:1150
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:570
void SetParent(SwAccessibleContext *pParent)
Definition: acccontext.cxx:67
ULONG m_refCount
virtual sal_Int32 SAL_CALL getForeground() override
#define SAL_INFO_IF(condition, area, stream)
void DisposeChildren(const SwFrame *pFrame, bool bRecursive, bool bCanSkipInvisible)
Definition: acccontext.cxx:384
vcl::Window * GetWindow()
Definition: acccontext.cxx:83
static bool lcl_PointInRectangle(const awt::Point &aPoint, const awt::Rectangle &aRect)
Definition: acccontext.cxx:794
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:964
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:118
TextFrameIndex GetOfst() const
Definition: txtfrm.hxx:428
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:755
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:533
static sal_Int32 GetChildCount(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame *pFrame, bool bInPagePreviewr)
Definition: accframe.cxx:41
bool GetState(sal_Int16 aState)
void Move(long nHorzMoveDelta, long nVertMoveDelta)
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:1998
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:729
void Top(const long nTop)
Definition: swrect.hxx:202
NONE
const SdrObject * GetDrawObject() const
Definition: accfrmobj.hxx:59
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
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:1210
void GetAdditionalAccessibleChildren(std::vector< vcl::Window * > *pChildren)
#i88070# - get all additional accessible children
virtual void InvalidateContent_(bool bVisibleDataFired)
Definition: acccontext.cxx:432
long Top() const
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible)
bool IsVisibleChildrenOnly() const
Definition: accfrmobj.cxx:202
void setY(long nY)
bool IsEmpty() const
Definition: swrect.hxx:294
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: acccontext.cxx:763
void GetAllSidebarWinForFrame(const SwFrame &rFrame, std::vector< vcl::Window * > *pChildren)
Definition: PostItMgr.cxx:2424
bool Select(SwPaM *pPaM, SdrObject *pObj, bool bAdd)
long getY() const
bool IsOpaque(SwViewShell const *pVSh) const
Definition: accframe.cxx:356
void FireStateChangedEvent(sal_Int16 nState, bool bNewState)
Definition: acccontext.cxx:468
long getX() const
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:447
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:76
const SwPosition * GetPoint() const
Definition: pam.hxx:207
const_iterator begin() const
bool FinishOLEObj()
Shutdown server.
Definition: feflyole.cxx:89
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:351
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:3285
void InvalidateAttr()
#i88069# - attributes has changed
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3486
unsigned char sal_Bool
bool m_isRegisteredAtAccessibleMap
Definition: acccontext.hxx:96
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: acccontext.cxx:687
#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:178
sal_Int16 const m_nRole
Definition: acccontext.hxx:83
void SttSelect()
Definition: select.cxx:389
virtual void InvalidatePosOrSize(const SwRect &rFrame)
void SSize(const Size &rNew)
Definition: swrect.hxx:176
const_iterator end() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Definition: acccontext.cxx:580
css::uno::WeakReference< css::accessibility::XAccessible > m_xWeakParent
Definition: acccontext.hxx:74
SwRect GetBounds(const SwAccessibleMap &rAccMap, const SwFrame *pFrame=nullptr)
Definition: accframe.cxx:328
A page of the document layout.
Definition: pagefrm.hxx:40
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:100
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
virtual css::awt::Rectangle SAL_CALL getBounds() override
Definition: acccontext.cxx:925
void ScrolledWithin(const SwRect &rOldVisArea)
Definition: acccontext.cxx:283
bool HasFrameConnectedSidebarWins(const SwFrame &rFrame)
Definition: PostItMgr.cxx:2399
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:875
bool IsLayoutFrame() const
Definition: frame.hxx:1146
void Left(const long nLeft)
Definition: swrect.hxx:193
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
Definition: acccontext.cxx:696
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:723
tools::Rectangle SVRect() const
Definition: swrect.hxx:282
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
Definition: acccontext.cxx:737
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:340
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet)
Definition: acccontext.cxx:482
bool IsAccessible(bool bPagePreview) const
Definition: accfrmobj.cxx:122
sal_uInt32 m_nClientId
Definition: acccontext.hxx:82
virtual bool SetSelectedState(bool bSeleted)
const SwFrame * GetParent() const
Definition: accframe.hxx:155
void ShowCursor()
Definition: crsrsh.cxx:2379
size_t IsObjSelected() const
Definition: feshview.cxx:1158
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1870
bool HasNotes() const
Definition: PostItMgr.cxx:2061
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
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void InvalidateTextSelection()
#i27301# - text selection has changed
css::uno::Reference< css::accessibility::XAccessible > GetWeakParent() const
Definition: acccontext.cxx:75
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:114
long Left() const
vcl::Window * GetWindow() const
Definition: accfrmobj.hxx:60
virtual void InvalidateFocus_()
Definition: acccontext.cxx:440
void ClearMark()
Definition: crsrsh.cxx:930
const SwPostItMgr * GetPostItMgr() const
Definition: viewsh.hxx:559
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
Definition: acccontext.cxx:775
mutable::osl::Mutex m_Mutex
Definition: acccontext.hxx:66
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:2055
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: acccontext.cxx:816
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: acccontext.cxx:718
bool HasFocus() const
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
Definition: acccontext.cxx:564
void AddState(sal_Int16 aState)
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1236
AccessibleStates
Definition: accmap.hxx:70
virtual css::uno::Sequence< css::uno::Reference< css::accessibility::XAccessible > > SAL_CALL getAccessibleChildren() override
Definition: acccontext.cxx:624
bool IsFrameSelected() const
Definition: feshview.cxx:1166
virtual ~SwAccessibleContext() override
Definition: acccontext.cxx:549
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