LibreOffice Module sw (master)  1
accmap.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 <rtl/ref.hxx>
21 #include <cppuhelper/weakref.hxx>
22 #include <vcl/window.hxx>
23 #include <svx/svdmodel.hxx>
24 #include <svx/unomod.hxx>
25 #include <algorithm>
26 #include <map>
27 #include <list>
28 #include <vector>
29 #include <accmap.hxx>
30 #include "acccontext.hxx"
31 #include "accdoc.hxx"
32 #include <strings.hrc>
33 #include "accpreview.hxx"
34 #include "accpage.hxx"
35 #include "accpara.hxx"
36 #include "accheaderfooter.hxx"
37 #include "accfootnote.hxx"
38 #include "acctextframe.hxx"
39 #include "accgraphic.hxx"
40 #include "accembedded.hxx"
41 #include "acccell.hxx"
42 #include "acctable.hxx"
43 #include <fesh.hxx>
44 #include <rootfrm.hxx>
45 #include <txtfrm.hxx>
46 #include <hffrm.hxx>
47 #include <ftnfrm.hxx>
48 #include <cellfrm.hxx>
49 #include <tabfrm.hxx>
50 #include <pagefrm.hxx>
51 #include <flyfrm.hxx>
52 #include <ndtyp.hxx>
55 #include <svx/ShapeTypeHandler.hxx>
56 #include <svx/SvxShapeTypes.hxx>
57 #include <svx/svdpage.hxx>
58 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
59 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
60 #include <com/sun/star/accessibility/AccessibleRole.hpp>
61 #include <com/sun/star/beans/XPropertySet.hpp>
62 #include <com/sun/star/document/XShapeEventBroadcaster.hpp>
63 #include <cppuhelper/implbase.hxx>
65 #include <pagepreviewlayout.hxx>
66 #include <dcontact.hxx>
67 #include <svx/unoapi.hxx>
68 #include <svx/svdmark.hxx>
69 #include <doc.hxx>
70 #include <drawdoc.hxx>
71 #include <pam.hxx>
72 #include <ndtxt.hxx>
73 #include <dflyobj.hxx>
74 #include <prevwpage.hxx>
75 #include <calbck.hxx>
76 #include <undobj.hxx>
77 #include <tools/diagnose_ex.h>
78 #include <tools/debug.hxx>
79 
80 using namespace ::com::sun::star;
81 using namespace ::com::sun::star::accessibility;
82 using namespace ::sw::access;
83 
84 namespace {
85 
86 struct SwFrameFunc
87 {
88  bool operator()( const SwFrame * p1, const SwFrame * p2) const
89  {
90  return p1 < p2;
91  }
92 };
93 
94 }
95 
97 {
98 public:
99  typedef const SwFrame * key_type;
100  typedef uno::WeakReference < XAccessible > mapped_type;
101  typedef std::pair<const key_type,mapped_type> value_type;
102  typedef SwFrameFunc key_compare;
103  typedef std::map<key_type,mapped_type,key_compare>::iterator iterator;
104  typedef std::map<key_type,mapped_type,key_compare>::const_iterator const_iterator;
105 private:
106  std::map <key_type,mapped_type,key_compare> maMap;
107 public:
108 
109 #if OSL_DEBUG_LEVEL > 0
110  bool mbLocked;
111 #endif
112 
114 #if OSL_DEBUG_LEVEL > 0
115  : mbLocked( false )
116 #endif
117  {}
118 
119  iterator begin() { return maMap.begin(); }
120  iterator end() { return maMap.end(); }
121  bool empty() const { return maMap.empty(); }
122  void clear() { maMap.clear(); }
123  iterator find(const key_type& key) { return maMap.find(key); }
124  template<class... Args>
125  std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); }
126  iterator erase(const_iterator const & pos) { return maMap.erase(pos); }
127 };
128 
129 namespace {
130 
131 class SwDrawModellListener_Impl : public SfxListener,
132  public ::cppu::WeakImplHelper< document::XShapeEventBroadcaster >
133 {
134  mutable ::osl::Mutex maListenerMutex;
136  std::unordered_map<css::uno::Reference< css::drawing::XShape >, css::uno::Reference< css::document::XShapeEventListener >> maShapeListeners;
137  SdrModel *mpDrawModel;
138 protected:
139  virtual ~SwDrawModellListener_Impl() override;
140 
141 public:
142  explicit SwDrawModellListener_Impl( SdrModel *pDrawModel );
143 
144  // css::document::XEventBroadcaster
145  virtual void SAL_CALL addEventListener( const uno::Reference< document::XEventListener >& xListener ) override;
146  virtual void SAL_CALL removeEventListener( const uno::Reference< document::XEventListener >& xListener ) override;
147  // css::document::XShapeEventBroadcaster
148  virtual void SAL_CALL addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override;
149  virtual void SAL_CALL removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::document::XShapeEventListener >& xListener ) override;
150 
151  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
152  void Dispose();
153 };
154 
155 }
156 
157 SwDrawModellListener_Impl::SwDrawModellListener_Impl( SdrModel *pDrawModel ) :
158  maEventListeners( maListenerMutex ),
159  mpDrawModel( pDrawModel )
160 {
161  StartListening( *mpDrawModel );
162 }
163 
164 SwDrawModellListener_Impl::~SwDrawModellListener_Impl()
165 {
166  Dispose();
167 }
168 
169 void SAL_CALL SwDrawModellListener_Impl::addEventListener( const uno::Reference< document::XEventListener >& xListener )
170 {
171  maEventListeners.addInterface( xListener );
172 }
173 
174 void SAL_CALL SwDrawModellListener_Impl::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
175 {
176  maEventListeners.removeInterface( xListener );
177 }
178 
179 void SAL_CALL SwDrawModellListener_Impl::addShapeEventListener(
180  const css::uno::Reference< css::drawing::XShape >& xShape,
181  const uno::Reference< document::XShapeEventListener >& xListener )
182 {
183  assert(xShape.is() && "no shape?");
184  osl::MutexGuard aGuard(maListenerMutex);
185  auto rv = maShapeListeners.emplace(xShape, xListener);
186  assert(rv.second && "duplicate listener?");
187  (void)rv;
188 }
189 
190 void SAL_CALL SwDrawModellListener_Impl::removeShapeEventListener(
191  const css::uno::Reference< css::drawing::XShape >& xShape,
192  const uno::Reference< document::XShapeEventListener >& xListener )
193 {
194  osl::MutexGuard aGuard(maListenerMutex);
195  auto it = maShapeListeners.find(xShape);
196  if (it != maShapeListeners.end())
197  {
198  assert(it->second == xListener);
199  (void)xListener;
200  maShapeListeners.erase(it);
201  }
202 }
203 
205  const SfxHint& rHint )
206 {
207  // do not broadcast notifications for writer fly frames, because there
208  // are no shapes that need to know about them.
209  if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
210  return;
211  const SdrHint *pSdrHint = static_cast<const SdrHint*>( &rHint );
212  if (pSdrHint->GetObject() &&
213  ( dynamic_cast< const SwFlyDrawObj* >(pSdrHint->GetObject()) != nullptr ||
214  dynamic_cast< const SwVirtFlyDrawObj* >(pSdrHint->GetObject()) != nullptr ||
215  typeid(SdrObject) == typeid(pSdrHint->GetObject()) ) )
216  {
217  return;
218  }
219 
220  OSL_ENSURE( mpDrawModel, "draw model listener is disposed" );
221  if( !mpDrawModel )
222  return;
223 
224  document::EventObject aEvent;
225  if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel, pSdrHint, aEvent ) )
226  return;
227 
228  ::comphelper::OInterfaceIteratorHelper2 aIter( maEventListeners );
229  while( aIter.hasMoreElements() )
230  {
231  uno::Reference < document::XEventListener > xListener( aIter.next(),
232  uno::UNO_QUERY );
233  try
234  {
235  xListener->notifyEvent( aEvent );
236  }
237  catch( uno::RuntimeException const & )
238  {
239  TOOLS_WARN_EXCEPTION("sw.a11y", "Runtime exception caught while notifying shape");
240  }
241  }
242 
243  // right now, we're only handling the specific event necessary to fix this performance problem
244  if (pSdrHint->GetKind() == SdrHintKind::ObjectChange)
245  {
246  auto pSdrObject = const_cast<SdrObject*>(pSdrHint->GetObject());
247  uno::Reference<drawing::XShape> xShape(pSdrObject->getUnoShape(), uno::UNO_QUERY);
248  osl::MutexGuard aGuard(maListenerMutex);
249  auto it = maShapeListeners.find(xShape);
250  if (it != maShapeListeners.end())
251  it->second->notifyShapeEvent(aEvent);
252  }
253 }
254 
255 void SwDrawModellListener_Impl::Dispose()
256 {
257  if (mpDrawModel != nullptr) {
258  EndListening( *mpDrawModel );
259  }
260  mpDrawModel = nullptr;
261 }
262 
263 namespace {
264 
265 struct SwShapeFunc
266 {
267  bool operator()( const SdrObject * p1, const SdrObject * p2) const
268  {
269  return p1 < p2;
270  }
271 };
272 
273 }
274 
275 typedef std::pair < const SdrObject *, ::rtl::Reference < ::accessibility::AccessibleShape > > SwAccessibleObjShape_Impl;
276 
278 {
279 public:
280 
281  typedef const SdrObject * key_type;
282  typedef uno::WeakReference<XAccessible> mapped_type;
283  typedef std::pair<const key_type,mapped_type> value_type;
284  typedef SwShapeFunc key_compare;
285  typedef std::map<key_type,mapped_type,key_compare>::iterator iterator;
286  typedef std::map<key_type,mapped_type,key_compare>::const_iterator const_iterator;
287 
288 private:
289 
291  std::map<key_type,mapped_type,SwShapeFunc> maMap;
292 
293 public:
294 
296  : maMap()
297  {
298  maInfo.SetSdrView( pMap->GetShell()->GetDrawView() );
299  maInfo.SetDevice( pMap->GetShell()->GetWin() );
300  maInfo.SetViewForwarder( pMap );
301  uno::Reference < document::XShapeEventBroadcaster > xModelBroadcaster =
302  new SwDrawModellListener_Impl(
304  maInfo.SetModelBroadcaster( xModelBroadcaster );
305  }
306 
308 
309  const ::accessibility::AccessibleShapeTreeInfo& GetInfo() const { return maInfo; }
310 
311  std::unique_ptr<SwAccessibleObjShape_Impl[]> Copy( size_t& rSize,
312  const SwFEShell *pFESh,
313  SwAccessibleObjShape_Impl **pSelShape ) const;
314 
315  iterator end() { return maMap.end(); }
316  const_iterator cbegin() const { return maMap.cbegin(); }
317  const_iterator cend() const { return maMap.cend(); }
318  bool empty() const { return maMap.empty(); }
319  iterator find(const key_type& key) { return maMap.find(key); }
320  template<class... Args>
321  std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); }
322  iterator erase(const_iterator const & pos) { return maMap.erase(pos); }
323 };
324 
326 {
327  uno::Reference < document::XEventBroadcaster > xBrd( maInfo.GetModelBroadcaster() );
328  if( xBrd.is() )
329  static_cast < SwDrawModellListener_Impl * >( xBrd.get() )->Dispose();
330 }
331 
332 std::unique_ptr<SwAccessibleObjShape_Impl[]>
334  size_t& rSize, const SwFEShell *pFESh,
335  SwAccessibleObjShape_Impl **pSelStart ) const
336 {
337  std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
338  SwAccessibleObjShape_Impl *pSelShape = nullptr;
339 
340  size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
341  rSize = maMap.size();
342 
343  if( rSize > 0 )
344  {
345  pShapes.reset(new SwAccessibleObjShape_Impl[rSize]);
346 
347  SwAccessibleObjShape_Impl *pShape = pShapes.get();
348  pSelShape = &(pShapes[rSize]);
349  for( const auto& rEntry : maMap )
350  {
351  const SdrObject *pObj = rEntry.first;
352  uno::Reference < XAccessible > xAcc( rEntry.second );
353  if( nSelShapes && pFESh && pFESh->IsObjSelected( *pObj ) )
354  {
355  // selected objects are inserted from the back
356  --pSelShape;
357  pSelShape->first = pObj;
358  pSelShape->second =
359  static_cast < ::accessibility::AccessibleShape* >(
360  xAcc.get() );
361  --nSelShapes;
362  }
363  else
364  {
365  pShape->first = pObj;
366  pShape->second =
367  static_cast < ::accessibility::AccessibleShape* >(
368  xAcc.get() );
369  ++pShape;
370  }
371  }
372  assert(pSelShape == pShape);
373  }
374 
375  if( pSelStart )
376  *pSelStart = pSelShape;
377 
378  return pShapes;
379 }
380 
382 {
383 public:
391 
392 private:
393  SwRect maOldBox; // the old bounds for CHILD_POS_CHANGED
394  // and POS_CHANGED
395  uno::WeakReference < XAccessible > mxAcc; // The object that fires the event
396  SwAccessibleChild const maFrameOrObj; // the child for CHILD_POS_CHANGED and
397  // the same as xAcc for any other
398  // event type
399  EventType meType; // The event type
400  AccessibleStates mnStates; // check states or update caret pos
401 
402 public:
403  const SwFrame* mpParentFrame; // The object that fires the event
404  bool IsNoXaccParentFrame() const
405  {
406  return CHILD_POS_CHANGED == meType && mpParentFrame != nullptr;
407  }
408 
409 public:
412  const SwAccessibleChild& rFrameOrObj )
413  : mxAcc( pA ),
414  maFrameOrObj( rFrameOrObj ),
415  meType( eT ),
416  mnStates( AccessibleStates::NONE ),
417  mpParentFrame( nullptr )
418  {}
419 
421  const SwAccessibleChild& rFrameOrObj )
422  : maFrameOrObj( rFrameOrObj ),
423  meType( eT ),
424  mnStates( AccessibleStates::NONE ),
425  mpParentFrame( nullptr )
426  {
427  assert(SwAccessibleEvent_Impl::DISPOSE == meType &&
428  "wrong event constructor, DISPOSE only");
429  }
430 
432  : meType( eT ),
433  mnStates( AccessibleStates::NONE ),
434  mpParentFrame( nullptr )
435  {
436  assert(SwAccessibleEvent_Impl::SHAPE_SELECTION == meType &&
437  "wrong event constructor, SHAPE_SELECTION only" );
438  }
439 
442  const SwAccessibleChild& rFrameOrObj,
443  const SwRect& rR )
444  : maOldBox( rR ),
445  mxAcc( pA ),
446  maFrameOrObj( rFrameOrObj ),
447  meType( eT ),
448  mnStates( AccessibleStates::NONE ),
449  mpParentFrame( nullptr )
450  {
451  assert((SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType ||
453  "wrong event constructor, (CHILD_)POS_CHANGED only" );
454  }
455 
458  const SwAccessibleChild& rFrameOrObj,
459  const AccessibleStates _nStates )
460  : mxAcc( pA ),
461  maFrameOrObj( rFrameOrObj ),
462  meType( eT ),
463  mnStates( _nStates ),
464  mpParentFrame( nullptr )
465  {
466  assert( SwAccessibleEvent_Impl::CARET_OR_STATES == meType &&
467  "wrong event constructor, CARET_OR_STATES only" );
468  }
469 
470  SwAccessibleEvent_Impl( EventType eT, const SwFrame *pParentFrame,
471  const SwAccessibleChild& rFrameOrObj, const SwRect& rR ) :
472  maOldBox( rR ),
473  maFrameOrObj( rFrameOrObj ),
474  meType( eT ),
475  mnStates( AccessibleStates::NONE ),
476  mpParentFrame( pParentFrame )
477  {
478  assert( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType &&
479  "wrong event constructor, CHILD_POS_CHANGED only" );
480  }
481 
482  // <SetType(..)> only used in method <SwAccessibleMap::AppendEvent(..)>
483  void SetType( EventType eT )
484  {
485  meType = eT;
486  }
488  {
489  return meType;
490  }
491 
493  {
494  uno::Reference < XAccessible > xTmp( mxAcc );
496  static_cast<SwAccessibleContext*>( xTmp.get() ) );
497 
498  return xAccImpl;
499  }
500 
501  const SwRect& GetOldBox() const
502  {
503  return maOldBox;
504  }
505  // <SetOldBox(..)> only used in method <SwAccessibleMap::AppendEvent(..)>
506  void SetOldBox( const SwRect& rOldBox )
507  {
508  maOldBox = rOldBox;
509  }
510 
511  const SwAccessibleChild& GetFrameOrObj() const
512  {
513  return maFrameOrObj;
514  }
515 
516  // <SetStates(..)> only used in method <SwAccessibleMap::AppendEvent(..)>
517  void SetStates( AccessibleStates _nStates )
518  {
519  mnStates |= _nStates;
520  }
521 
522  bool IsUpdateCursorPos() const
523  {
524  return bool(mnStates & AccessibleStates::CARET);
525  }
526  bool IsInvalidateStates() const
527  {
528  return bool(mnStates & (AccessibleStates::EDITABLE | AccessibleStates::OPAQUE));
529  }
530  bool IsInvalidateRelation() const
531  {
533  }
535  {
536  return bool( mnStates & AccessibleStates::TEXT_SELECTION_CHANGED );
537  }
538 
540  {
541  return bool( mnStates & AccessibleStates::TEXT_ATTRIBUTE_CHANGED );
542  }
543 
545  {
546  return mnStates;
547  }
548 
550  {
551  return mnStates;
552  }
553 };
554 
556 {
557  std::list<SwAccessibleEvent_Impl> maEvents;
558  bool mbFiring;
559 
560 public:
562  : mbFiring( false )
563  {}
564 
565  void SetFiring()
566  {
567  mbFiring = true;
568  }
569  bool IsFiring() const
570  {
571  return mbFiring;
572  }
573 
574  void MoveMissingXAccToEnd();
575 
576  size_t size() const { return maEvents.size(); }
577  std::list<SwAccessibleEvent_Impl>::iterator begin() { return maEvents.begin(); }
578  std::list<SwAccessibleEvent_Impl>::iterator end() { return maEvents.end(); }
579  std::list<SwAccessibleEvent_Impl>::iterator insert( const std::list<SwAccessibleEvent_Impl>::iterator& aIter,
580  const SwAccessibleEvent_Impl& rEvent )
581  {
582  return maEvents.insert( aIter, rEvent );
583  }
584  std::list<SwAccessibleEvent_Impl>::iterator erase( const std::list<SwAccessibleEvent_Impl>::iterator& aPos )
585  {
586  return maEvents.erase( aPos );
587  }
588 };
589 
590 // see comment in SwAccessibleMap::InvalidatePosOrSize()
591 // last case "else if(pParent)" for why this surprising hack exists
593 {
594  size_t nSize = size();
595  if (nSize < 2 )
596  {
597  return;
598  }
600  for (auto li = begin(); li != end(); )
601  {
602  if (li->IsNoXaccParentFrame())
603  {
604  lstEvent.insert(lstEvent.end(), *li);
605  li = erase(li);
606  }
607  else
608  ++li;
609  }
610  assert(size() + lstEvent.size() == nSize);
611  maEvents.insert(end(),lstEvent.begin(),lstEvent.end());
612  assert(size() == nSize);
613 }
614 
615 namespace {
616 
617 struct SwAccessibleChildFunc
618 {
619  bool operator()( const SwAccessibleChild& r1,
620  const SwAccessibleChild& r2 ) const
621  {
622  const void *p1 = r1.GetSwFrame()
623  ? static_cast < const void * >( r1.GetSwFrame())
624  : ( r1.GetDrawObject()
625  ? static_cast < const void * >( r1.GetDrawObject() )
626  : static_cast < const void * >( r1.GetWindow() ) );
627  const void *p2 = r2.GetSwFrame()
628  ? static_cast < const void * >( r2.GetSwFrame())
629  : ( r2.GetDrawObject()
630  ? static_cast < const void * >( r2.GetDrawObject() )
631  : static_cast < const void * >( r2.GetWindow() ) );
632  return p1 < p2;
633  }
634 };
635 
636 }
637 
639 {
640 public:
641  typedef SwAccessibleChild key_type;
642  typedef std::list<SwAccessibleEvent_Impl>::iterator mapped_type;
643  typedef std::pair<const key_type,mapped_type> value_type;
644  typedef SwAccessibleChildFunc key_compare;
645  typedef std::map<key_type,mapped_type,key_compare>::iterator iterator;
646  typedef std::map<key_type,mapped_type,key_compare>::const_iterator const_iterator;
647 private:
648  std::map <key_type,mapped_type,key_compare> maMap;
649 public:
650  iterator end() { return maMap.end(); }
651  iterator find(const key_type& key) { return maMap.find(key); }
652  template<class... Args>
653  std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); }
654  iterator erase(const_iterator const & pos) { return maMap.erase(pos); }
655 };
656 
657 namespace {
658 
659 struct SwAccessibleParaSelection
660 {
661  TextFrameIndex const nStartOfSelection;
662  TextFrameIndex const nEndOfSelection;
663 
664  SwAccessibleParaSelection(const TextFrameIndex nStartOfSelection_,
665  const TextFrameIndex nEndOfSelection_)
666  : nStartOfSelection(nStartOfSelection_)
667  , nEndOfSelection(nEndOfSelection_)
668  {}
669 };
670 
671 struct SwXAccWeakRefComp
672 {
673  bool operator()( const uno::WeakReference<XAccessible>& _rXAccWeakRef1,
674  const uno::WeakReference<XAccessible>& _rXAccWeakRef2 ) const
675  {
676  return _rXAccWeakRef1.get() < _rXAccWeakRef2.get();
677  }
678 };
679 
680 }
681 
683 {
684 public:
685  typedef uno::WeakReference < XAccessible > key_type;
686  typedef SwAccessibleParaSelection mapped_type;
687  typedef std::pair<const key_type,mapped_type> value_type;
688  typedef SwXAccWeakRefComp key_compare;
689  typedef std::map<key_type,mapped_type,key_compare>::iterator iterator;
690  typedef std::map<key_type,mapped_type,key_compare>::const_iterator const_iterator;
691 private:
692  std::map<key_type,mapped_type,key_compare> maMap;
693 public:
694  iterator begin() { return maMap.begin(); }
695  iterator end() { return maMap.end(); }
696  iterator find(const key_type& key) { return maMap.find(key); }
697  template<class... Args>
698  std::pair<iterator,bool> emplace(Args&&... args) { return maMap.emplace(std::forward<Args>(args)...); }
699  iterator erase(const_iterator const & pos) { return maMap.erase(pos); }
700 };
701 
702 // helper class that stores preview data
704 {
705  typedef std::vector<tools::Rectangle> Rectangles;
706  Rectangles maPreviewRects;
707  Rectangles maLogicRects;
708 
711 
713 
728  static void AdjustLogicPgRectToVisibleArea( SwRect& _iorLogicPgSwRect,
729  const SwRect& _rPreviewPgSwRect,
730  const Size& _rPreviewWinSize );
731 
732 public:
734 
735  void Update( const SwAccessibleMap& rAccMap,
736  const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
737  const Fraction& _rScale,
738  const SwPageFrame* _pSelectedPageFrame,
739  const Size& _rPreviewWinSize );
740 
741  void InvalidateSelection( const SwPageFrame* _pSelectedPageFrame );
742 
743  const SwRect& GetVisArea() const { return maVisArea;}
744 
749  void AdjustMapMode( MapMode& rMapMode,
750  const Point& rPoint ) const;
751 
752  const SwPageFrame *GetSelPage() const { return mpSelPage; }
753 
754  void DisposePage(const SwPageFrame *pPageFrame );
755 };
756 
758  mpSelPage( nullptr )
759 {
760 }
761 
763  const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
764  const Fraction& _rScale,
765  const SwPageFrame* _pSelectedPageFrame,
766  const Size& _rPreviewWinSize )
767 {
768  // store preview scaling, maximal preview page size and selected page
769  maScale = _rScale;
770  mpSelPage = _pSelectedPageFrame;
771 
772  // prepare loop on preview pages
773  maPreviewRects.clear();
774  maLogicRects.clear();
775  SwAccessibleChild aPage;
776  maVisArea.Clear();
777 
778  // loop on preview pages to calculate <maPreviewRects>, <maLogicRects> and
779  // <maVisArea>
780  for ( auto & rpPreviewPage : _rPreviewPages )
781  {
782  aPage = rpPreviewPage->pPage;
783 
784  // add preview page rectangle to <maPreviewRects>
785  tools::Rectangle aPreviewPgRect( rpPreviewPage->aPreviewWinPos, rpPreviewPage->aPageSize );
786  maPreviewRects.push_back( aPreviewPgRect );
787 
788  // add logic page rectangle to <maLogicRects>
789  SwRect aLogicPgSwRect( aPage.GetBox( rAccMap ) );
790  tools::Rectangle aLogicPgRect( aLogicPgSwRect.SVRect() );
791  maLogicRects.push_back( aLogicPgRect );
792  // union visible area with visible part of logic page rectangle
793  if ( rpPreviewPage->bVisible )
794  {
795  if ( !rpPreviewPage->pPage->IsEmptyPage() )
796  {
797  AdjustLogicPgRectToVisibleArea( aLogicPgSwRect,
798  SwRect( aPreviewPgRect ),
799  _rPreviewWinSize );
800  }
801  if ( maVisArea.IsEmpty() )
802  maVisArea = aLogicPgSwRect;
803  else
804  maVisArea.Union( aLogicPgSwRect );
805  }
806  }
807 }
808 
809 void SwAccPreviewData::InvalidateSelection( const SwPageFrame* _pSelectedPageFrame )
810 {
811  mpSelPage = _pSelectedPageFrame;
812  assert(mpSelPage);
813 }
814 
815 namespace {
816 
817 struct ContainsPredicate
818 {
819  const Point& mrPoint;
820  explicit ContainsPredicate( const Point& rPoint ) : mrPoint(rPoint) {}
821  bool operator() ( const tools::Rectangle& rRect ) const
822  {
823  return rRect.IsInside( mrPoint );
824  }
825 };
826 
827 }
828 
830  const Point& rPoint ) const
831 {
832  // adjust scale
833  rMapMode.SetScaleX( maScale );
834  rMapMode.SetScaleY( maScale );
835 
836  // find proper rectangle
837  Rectangles::const_iterator aBegin = maLogicRects.begin();
838  Rectangles::const_iterator aEnd = maLogicRects.end();
839  Rectangles::const_iterator aFound = std::find_if( aBegin, aEnd,
840  ContainsPredicate( rPoint ) );
841 
842  if( aFound != aEnd )
843  {
844  // found! set new origin
845  Point aPoint = (maPreviewRects.begin() + (aFound - aBegin))->TopLeft();
846  aPoint -= (maLogicRects.begin() + (aFound-aBegin))->TopLeft();
847  rMapMode.SetOrigin( aPoint );
848  }
849  // else: don't adjust MapMode
850 }
851 
853 {
854  if( mpSelPage == pPageFrame )
855  mpSelPage = nullptr;
856 }
857 
858 // adjust logic page rectangle to its visible part
860  SwRect& _iorLogicPgSwRect,
861  const SwRect& _rPreviewPgSwRect,
862  const Size& _rPreviewWinSize )
863 {
864  // determine preview window rectangle
865  const SwRect aPreviewWinSwRect( Point( 0, 0 ), _rPreviewWinSize );
866  // calculate visible preview page rectangle
867  SwRect aVisPreviewPgSwRect( _rPreviewPgSwRect );
868  aVisPreviewPgSwRect.Intersection( aPreviewWinSwRect );
869  // adjust logic page rectangle
870  SwTwips nTmpDiff;
871  // left
872  nTmpDiff = aVisPreviewPgSwRect.Left() - _rPreviewPgSwRect.Left();
873  if ( nTmpDiff > 0 )
874  _iorLogicPgSwRect.Left( _iorLogicPgSwRect.Left() + nTmpDiff );
875  // top
876  nTmpDiff = aVisPreviewPgSwRect.Top() - _rPreviewPgSwRect.Top();
877  if ( nTmpDiff > 0 )
878  _iorLogicPgSwRect.Top( _iorLogicPgSwRect.Top() + nTmpDiff );
879  // right
880  nTmpDiff = _rPreviewPgSwRect.Right() - aVisPreviewPgSwRect.Right();
881  if ( nTmpDiff > 0 )
882  _iorLogicPgSwRect.Right( _iorLogicPgSwRect.Right() - nTmpDiff );
883  // bottom
884  nTmpDiff = _rPreviewPgSwRect.Bottom() - aVisPreviewPgSwRect.Bottom();
885  if ( nTmpDiff > 0 )
886  _iorLogicPgSwRect.Bottom( _iorLogicPgSwRect.Bottom() - nTmpDiff );
887 }
888 
889 static bool AreInSameTable( const uno::Reference< XAccessible >& rAcc,
890  const SwFrame *pFrame )
891 {
892  bool bRet = false;
893 
894  if( pFrame && pFrame->IsCellFrame() && rAcc.is() )
895  {
896  // Is it in the same table? We check that
897  // by comparing the last table frame in the
898  // follow chain, because that's cheaper than
899  // searching the first one.
900  SwAccessibleContext *pAccImpl =
901  static_cast< SwAccessibleContext *>( rAcc.get() );
902  if( pAccImpl->GetFrame()->IsCellFrame() )
903  {
904  const SwTabFrame *pTabFrame1 = pAccImpl->GetFrame()->FindTabFrame();
905  if (pTabFrame1)
906  {
907  while (pTabFrame1->GetFollow())
908  pTabFrame1 = pTabFrame1->GetFollow();
909  }
910 
911  const SwTabFrame *pTabFrame2 = pFrame->FindTabFrame();
912  if (pTabFrame2)
913  {
914  while (pTabFrame2->GetFollow())
915  pTabFrame2 = pTabFrame2->GetFollow();
916  }
917 
918  bRet = (pTabFrame1 == pTabFrame2);
919  }
920  }
921 
922  return bRet;
923 }
924 
926 {
928  if (!xAccImpl.is() && rEvent.mpParentFrame != nullptr)
929  {
931  mpFrameMap->find( rEvent.mpParentFrame );
932  if( aIter != mpFrameMap->end() )
933  {
934  uno::Reference < XAccessible > xAcc( (*aIter).second );
935  if (xAcc.is())
936  {
937  uno::Reference < XAccessibleContext > xContext(xAcc,uno::UNO_QUERY);
938  if (xContext.is() && xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
939  {
940  xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
941  }
942  }
943  }
944  }
946  {
948  }
949  else if( xAccImpl.is() && xAccImpl->GetFrame() )
950  {
951  if ( rEvent.GetType() != SwAccessibleEvent_Impl::DISPOSE &&
952  rEvent.IsInvalidateTextAttrs() )
953  {
954  xAccImpl->InvalidateAttr();
955  }
956  switch( rEvent.GetType() )
957  {
959  xAccImpl->InvalidateContent();
960  break;
962  xAccImpl->InvalidatePosOrSize( rEvent.GetOldBox() );
963  break;
965  xAccImpl->InvalidateChildPosOrSize( rEvent.GetFrameOrObj(),
966  rEvent.GetOldBox() );
967  break;
969  assert(!"dispose event has been stored");
970  break;
972  // nothing to do here - handled above
973  break;
974  default:
975  break;
976  }
977  if( SwAccessibleEvent_Impl::DISPOSE != rEvent.GetType() )
978  {
979  if( rEvent.IsUpdateCursorPos() )
980  xAccImpl->InvalidateCursorPos();
981  if( rEvent.IsInvalidateStates() )
982  xAccImpl->InvalidateStates( rEvent.GetStates() );
983  if( rEvent.IsInvalidateRelation() )
984  {
985  // both events CONTENT_FLOWS_FROM_RELATION_CHANGED and
986  // CONTENT_FLOWS_TO_RELATION_CHANGED are possible
988  {
989  xAccImpl->InvalidateRelation(
990  AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED );
991  }
993  {
994  xAccImpl->InvalidateRelation(
995  AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED );
996  }
997  }
998 
999  if ( rEvent.IsInvalidateTextSelection() )
1000  {
1001  xAccImpl->InvalidateTextSelection();
1002  }
1003  }
1004  }
1005 }
1006 
1008 {
1009  osl::MutexGuard aGuard( maEventMutex );
1010 
1011  if( !mpEvents )
1013  if( !mpEventMap )
1015 
1016  if( mpEvents->IsFiring() )
1017  {
1018  // While events are fired new ones are generated. They have to be fired
1019  // now. This does not work for DISPOSE events!
1020  OSL_ENSURE( rEvent.GetType() != SwAccessibleEvent_Impl::DISPOSE,
1021  "dispose event while firing events" );
1022  FireEvent( rEvent );
1023  }
1024  else
1025  {
1026 
1028  mpEventMap->find( rEvent.GetFrameOrObj() );
1029  if( aIter != mpEventMap->end() )
1030  {
1031  SwAccessibleEvent_Impl aEvent( *(*aIter).second );
1032  assert( aEvent.GetType() != SwAccessibleEvent_Impl::DISPOSE &&
1033  "dispose events should not be stored" );
1034  bool bAppendEvent = true;
1035  switch( rEvent.GetType() )
1036  {
1038  // A CARET_OR_STATES event is added to any other
1039  // event only. It is broadcasted after any other event, so the
1040  // event should be put to the back.
1041  OSL_ENSURE( aEvent.GetType() != SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
1042  "invalid event combination" );
1043  aEvent.SetStates( rEvent.GetAllStates() );
1044  break;
1046  // An INVALID_CONTENT event overwrites a CARET_OR_STATES
1047  // event (but keeps its flags) and it is contained in a
1048  // POS_CHANGED event.
1049  // Therefore, the event's type has to be adapted and the event
1050  // has to be put at the end.
1051  //
1052  // fdo#56031 An INVALID_CONTENT event overwrites a INVALID_ATTR
1053  // event and overwrites its flags
1054  OSL_ENSURE( aEvent.GetType() != SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
1055  "invalid event combination" );
1058  else if ( aEvent.GetType() == SwAccessibleEvent_Impl::INVALID_ATTR )
1059  {
1061  aEvent.SetStates( rEvent.GetAllStates() );
1062  }
1063 
1064  break;
1066  // A pos changed event overwrites CARET_STATES (keeping its
1067  // flags) as well as INVALID_CONTENT. The old box position
1068  // has to be stored however if the old event is not a
1069  // POS_CHANGED itself.
1070  OSL_ENSURE( aEvent.GetType() != SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
1071  "invalid event combination" );
1073  aEvent.SetOldBox( rEvent.GetOldBox() );
1075  break;
1077  // CHILD_POS_CHANGED events can only follow CHILD_POS_CHANGED
1078  // events. The only action that needs to be done again is
1079  // to put the old event to the back. The new one cannot be used,
1080  // because we are interested in the old frame bounds.
1081  OSL_ENSURE( aEvent.GetType() == SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
1082  "invalid event combination" );
1083  break;
1085  OSL_ENSURE( aEvent.GetType() == SwAccessibleEvent_Impl::SHAPE_SELECTION,
1086  "invalid event combination" );
1087  break;
1089  // DISPOSE events overwrite all others. They are not stored
1090  // but executed immediately to avoid broadcasting of
1091  // nonfunctional objects. So what needs to be done here is to
1092  // remove all events for the frame in question.
1093  bAppendEvent = false;
1094  break;
1096  OSL_ENSURE( aEvent.GetType() == SwAccessibleEvent_Impl::INVALID_ATTR,
1097  "invalid event combination" );
1098  break;
1099  }
1100  if( bAppendEvent )
1101  {
1102  mpEvents->erase( (*aIter).second );
1103  (*aIter).second = mpEvents->insert( mpEvents->end(), aEvent );
1104  }
1105  else
1106  {
1107  mpEvents->erase( (*aIter).second );
1108  mpEventMap->erase( aIter );
1109  }
1110  }
1111  else if( SwAccessibleEvent_Impl::DISPOSE != rEvent.GetType() )
1112  {
1113  mpEventMap->emplace( rEvent.GetFrameOrObj(),
1114  mpEvents->insert( mpEvents->end(), rEvent ) );
1115  }
1116  }
1117 }
1118 
1120  const uno::Reference< XAccessible >& rAcc )
1121 {
1122  SwAccessibleContext *pAccImpl =
1123  static_cast< SwAccessibleContext *>( rAcc.get() );
1124  assert(pAccImpl);
1125  assert(pAccImpl->GetFrame());
1126  if( GetShell()->ActionPend() )
1127  {
1129  pAccImpl,
1130  SwAccessibleChild(pAccImpl->GetFrame()),
1132  AppendEvent( aEvent );
1133  }
1134  else
1135  {
1136  FireEvents();
1137  // While firing events the current frame might have
1138  // been disposed because it moved out of the visible area.
1139  // Setting the cursor for such frames is useless and even
1140  // causes asserts.
1141  if( pAccImpl->GetFrame() )
1142  pAccImpl->InvalidateCursorPos();
1143  }
1144 }
1145 
1147 {
1148  if( GetShell()->ActionPend() )
1149  {
1150  SwAccessibleEvent_Impl aEvent(
1152  AppendEvent( aEvent );
1153  }
1154  else
1155  {
1156  FireEvents();
1158  }
1159 }
1160 
1161 //This method should implement the following functions:
1162 //1.find the shape objects and set the selected state.
1163 //2.find the Swframe objects and set the selected state.
1164 //3.find the paragraph objects and set the selected state.
1166 {
1167  std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
1168  SwAccessibleObjShape_Impl *pSelShape = nullptr;
1169  size_t nShapes = 0;
1170 
1171  const SwViewShell *pVSh = GetShell();
1172  const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>( pVSh) != nullptr ?
1173  static_cast< const SwFEShell * >( pVSh ) : nullptr;
1174  SwPaM* pCursor = pFESh ? pFESh->GetCursor( false /* ??? */ ) : nullptr;
1175 
1176  //const size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
1177 
1178  {
1179  osl::MutexGuard aGuard( maMutex );
1180  if( mpShapeMap )
1181  pShapes = mpShapeMap->Copy( nShapes, pFESh, &pSelShape );
1182  }
1183 
1184  bool bIsSelAll =IsDocumentSelAll();
1185 
1186  if( mpShapeMap )
1187  {
1188  //Checked for shapes.
1192 
1193  if( bIsSelAll)
1194  {
1195  while( aIter != aEndIter )
1196  {
1197  uno::Reference < XAccessible > xAcc( (*aIter).second );
1198  if( xAcc.is() )
1199  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->SetState( AccessibleStateType::SELECTED );
1200 
1201  ++aIter;
1202  }
1203  }
1204  else
1205  {
1206  while( aIter != aEndIter )
1207  {
1208  SwAccessibleChild aFrame( (*aIter).first );
1209 
1210  const SwFrameFormat *pFrameFormat = (*aIter).first ? ::FindFrameFormat( (*aIter).first ) : nullptr;
1211  if( !pFrameFormat )
1212  {
1213  ++aIter;
1214  continue;
1215  }
1216  const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
1217  const SwPosition *pPos = rAnchor.GetContentAnchor();
1218 
1219  if(rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
1220  {
1221  uno::Reference < XAccessible > xAcc( (*aIter).second );
1222  if(xAcc.is())
1223  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
1224 
1225  ++aIter;
1226  continue;
1227  }
1228 
1229  if( !pPos )
1230  {
1231  ++aIter;
1232  continue;
1233  }
1234  if( pPos->nNode.GetNode().GetTextNode() )
1235  {
1236  int nIndex = pPos->nContent.GetIndex();
1237  bool bMarked = false;
1238  if( pCursor != nullptr )
1239  {
1240  const SwTextNode* pNode = pPos->nNode.GetNode().GetTextNode();
1241  SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pVSh->GetLayout())));
1242  sal_uLong nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
1243  sal_uLong nLastNode;
1244  if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
1245  {
1246  nLastNode = pMerged->pLastNode->GetIndex();
1247  }
1248  else
1249  {
1250  nLastNode = nFirstNode;
1251  }
1252 
1253  sal_uLong nHere = pNode->GetIndex();
1254 
1255  for(SwPaM& rTmpCursor : pCursor->GetRingContainer())
1256  {
1257  // ignore, if no mark
1258  if( rTmpCursor.HasMark() )
1259  {
1260  bMarked = true;
1261  // check whether nHere is 'inside' pCursor
1262  SwPosition* pStart = rTmpCursor.Start();
1263  sal_uLong nStartIndex = pStart->nNode.GetIndex();
1264  SwPosition* pEnd = rTmpCursor.End();
1265  sal_uLong nEndIndex = pEnd->nNode.GetIndex();
1266  if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
1267  {
1268  if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1269  {
1270  if( ( ((nHere == nStartIndex) && (nIndex >= pStart->nContent.GetIndex())) || (nHere > nStartIndex) )
1271  &&( ((nHere == nEndIndex) && (nIndex < pEnd->nContent.GetIndex())) || (nHere < nEndIndex) ) )
1272  {
1273  uno::Reference < XAccessible > xAcc( (*aIter).second );
1274  if( xAcc.is() )
1275  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->SetState( AccessibleStateType::SELECTED );
1276  }
1277  else
1278  {
1279  uno::Reference < XAccessible > xAcc( (*aIter).second );
1280  if( xAcc.is() )
1281  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
1282  }
1283  }
1284  else if( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA )
1285  {
1286  uno::Reference<XAccessible> const xAcc((*aIter).second);
1287  if (xAcc.is())
1288  {
1289  if (IsSelectFrameAnchoredAtPara(*pPos, *pStart, *pEnd))
1290  {
1291  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->SetState( AccessibleStateType::SELECTED );
1292  }
1293  else
1294  {
1295  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
1296  }
1297  }
1298  }
1299  else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
1300  {
1301  uno::Reference<XAccessible> const xAcc((*aIter).second);
1302  if (xAcc.is())
1303  {
1304  if (IsDestroyFrameAnchoredAtChar(*pPos, *pStart, *pEnd))
1305  {
1306  static_cast<::accessibility::AccessibleShape*>(xAcc.get())->SetState( AccessibleStateType::SELECTED );
1307  }
1308  else
1309  {
1310  static_cast<::accessibility::AccessibleShape*>(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
1311  }
1312  }
1313  }
1314  }
1315  }
1316  }
1317  }
1318  if( !bMarked )
1319  {
1320  SwAccessibleObjShape_Impl *pShape = pShapes.get();
1321  size_t nNumShapes = nShapes;
1322  while( nNumShapes )
1323  {
1324  if( pShape < pSelShape && (pShape->first==(*aIter).first) )
1325  {
1326  uno::Reference < XAccessible > xAcc( (*aIter).second );
1327  if(xAcc.is())
1328  static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->ResetState( AccessibleStateType::SELECTED );
1329  }
1330  --nNumShapes;
1331  ++pShape;
1332  }
1333  }
1334  }
1335 
1336  ++aIter;
1337  }//while( aIter != aEndIter )
1338  }//else
1339  }
1340 
1341  pShapes.reset();
1342 
1343  //Checked for FlyFrame
1344  if (mpFrameMap)
1345  {
1347  while( aIter != mpFrameMap->end() )
1348  {
1349  const SwFrame *pFrame = (*aIter).first;
1350  if(pFrame->IsFlyFrame())
1351  {
1352  uno::Reference < XAccessible > xAcc = (*aIter).second;
1353 
1354  if(xAcc.is())
1355  {
1356  SwAccessibleFrameBase *pAccFrame = static_cast< SwAccessibleFrameBase * >(xAcc.get());
1357  bool bFrameChanged = pAccFrame->SetSelectedState( true );
1358  if (bFrameChanged)
1359  {
1360  const SwFlyFrame *pFlyFrame = static_cast< const SwFlyFrame * >( pFrame );
1361  const SwFrameFormat *pFrameFormat = pFlyFrame->GetFormat();
1362  if (pFrameFormat)
1363  {
1364  const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
1365  if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1366  {
1367  uno::Reference< XAccessible > xAccParent = pAccFrame->getAccessibleParent();
1368  if (xAccParent.is())
1369  {
1370  uno::Reference< XAccessibleContext > xAccContext = xAccParent->getAccessibleContext();
1371  if(xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
1372  {
1373  SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xAccContext.get());
1374  if(pAccFrame->IsSeletedInDoc())
1375  {
1376  m_setParaAdd.insert(pAccPara);
1377  }
1378  else if(m_setParaAdd.count(pAccPara) == 0)
1379  {
1380  m_setParaRemove.insert(pAccPara);
1381  }
1382  }
1383  }
1384  }
1385  }
1386  }
1387  }
1388  }
1389  ++aIter;
1390  }
1391  }
1392 
1393  typedef std::vector< SwAccessibleContext* > VEC_PARA;
1394  VEC_PARA vecAdd;
1395  VEC_PARA vecRemove;
1396  //Checked for Paras.
1397  bool bMarkChanged = false;
1399  if( pCursor != nullptr )
1400  {
1401  for(SwPaM& rTmpCursor : pCursor->GetRingContainer())
1402  {
1403  if( rTmpCursor.HasMark() )
1404  {
1405  SwNodeIndex nStartIndex( rTmpCursor.Start()->nNode );
1406  SwNodeIndex nEndIndex( rTmpCursor.End()->nNode );
1407  for (; nStartIndex <= nEndIndex; ++nStartIndex)
1408  {
1409  SwFrame *pFrame = nullptr;
1410  if(nStartIndex.GetNode().IsContentNode())
1411  {
1412  SwContentNode* pCNd = static_cast<SwContentNode*>(&(nStartIndex.GetNode()));
1414  if (mapTemp.find(pFrame) != mapTemp.end())
1415  {
1416  continue; // sw_redlinehide: once is enough
1417  }
1418  }
1419  else if( nStartIndex.GetNode().IsTableNode() )
1420  {
1421  SwTableNode * pTable = static_cast<SwTableNode *>(&(nStartIndex.GetNode()));
1422  SwTableFormat* pFormat = pTable->GetTable().GetFrameFormat();
1423  pFrame = SwIterator<SwFrame, SwTableFormat>(*pFormat).First();
1424  }
1425 
1426  if( pFrame && mpFrameMap)
1427  {
1428  SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pFrame );
1429  if( aIter != mpFrameMap->end() )
1430  {
1431  uno::Reference < XAccessible > xAcc = (*aIter).second;
1432  bool isChanged = false;
1433  if( xAcc.is() )
1434  {
1435  isChanged = static_cast< SwAccessibleContext * >(xAcc.get())->SetSelectedState( true );
1436  }
1437  if(!isChanged)
1438  {
1439  SwAccessibleContextMap_Impl::iterator aEraseIter = mpSeletedFrameMap->find( pFrame );
1440  if(aEraseIter != mpSeletedFrameMap->end())
1441  mpSeletedFrameMap->erase(aEraseIter);
1442  }
1443  else
1444  {
1445  bMarkChanged = true;
1446  vecAdd.push_back(static_cast< SwAccessibleContext * >(xAcc.get()));
1447  }
1448 
1449  mapTemp.emplace( pFrame, xAcc );
1450  }
1451  }
1452  }
1453  }
1454  }
1455  }
1456  if( !mpSeletedFrameMap )
1458  if( !mpSeletedFrameMap->empty() )
1459  {
1461  while( aIter != mpSeletedFrameMap->end() )
1462  {
1463  uno::Reference < XAccessible > xAcc = (*aIter).second;
1464  if(xAcc.is())
1465  static_cast< SwAccessibleContext * >(xAcc.get())->SetSelectedState( false );
1466  ++aIter;
1467  vecRemove.push_back(static_cast< SwAccessibleContext * >(xAcc.get()));
1468  }
1469  bMarkChanged = true;
1470  mpSeletedFrameMap->clear();
1471  }
1472 
1473  SwAccessibleContextMap_Impl::iterator aIter = mapTemp.begin();
1474  while( aIter != mapTemp.end() )
1475  {
1476  mpSeletedFrameMap->emplace( (*aIter).first, (*aIter).second );
1477  ++aIter;
1478  }
1479  mapTemp.clear();
1480 
1481  if( bMarkChanged && mpFrameMap)
1482  {
1483  for (SwAccessibleContext* pAccPara : vecAdd)
1484  {
1485  AccessibleEventObject aEvent;
1486  aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
1487  if (pAccPara)
1488  {
1489  pAccPara->FireAccessibleEvent( aEvent );
1490  }
1491  }
1492  for (SwAccessibleContext* pAccPara : vecRemove)
1493  {
1494  AccessibleEventObject aEvent;
1495  aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
1496  if (pAccPara)
1497  {
1498  pAccPara->FireAccessibleEvent( aEvent );
1499  }
1500  }
1501  }
1502 }
1503 
1504 //Merge with DoInvalidateShapeFocus
1505 void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=false*/)
1506 {
1507  std::unique_ptr<SwAccessibleObjShape_Impl[]> pShapes;
1508  SwAccessibleObjShape_Impl *pSelShape = nullptr;
1509  size_t nShapes = 0;
1510 
1511  const SwViewShell *pVSh = GetShell();
1512  const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>( pVSh) != nullptr ?
1513  static_cast< const SwFEShell * >( pVSh ) : nullptr;
1514  const size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
1515 
1516  //when InvalidateFocus Call this function ,and the current selected shape count is not 1 ,
1517  //return
1518  if (bInvalidateFocusMode && nSelShapes != 1)
1519  {
1520  return;
1521  }
1522  {
1523  osl::MutexGuard aGuard( maMutex );
1524  if( mpShapeMap )
1525  pShapes = mpShapeMap->Copy( nShapes, pFESh, &pSelShape );
1526  }
1527 
1528  if( !pShapes )
1529  return;
1530 
1531  typedef std::vector< ::rtl::Reference < ::accessibility::AccessibleShape > > VEC_SHAPE;
1532  VEC_SHAPE vecxShapeAdd;
1533  VEC_SHAPE vecxShapeRemove;
1534  int nCountSelectedShape=0;
1535 
1536  vcl::Window *pWin = GetShell()->GetWin();
1537  bool bFocused = pWin && pWin->HasFocus();
1538  SwAccessibleObjShape_Impl *pShape = pShapes.get();
1539  int nShapeCount = nShapes;
1540  while( nShapeCount )
1541  {
1542  if (pShape->second.is() && IsInSameLevel(pShape->first, pFESh))
1543  {
1544  if( pShape < pSelShape )
1545  {
1546  if(pShape->second->ResetState( AccessibleStateType::SELECTED ))
1547  {
1548  vecxShapeRemove.push_back(pShape->second);
1549  }
1550  pShape->second->ResetState( AccessibleStateType::FOCUSED );
1551  }
1552  }
1553  --nShapeCount;
1554  ++pShape;
1555  }
1556 
1557  for (const auto& rpShape : vecxShapeRemove)
1558  {
1559  ::accessibility::AccessibleShape *pAccShape = rpShape.get();
1560  if (pAccShape)
1561  {
1562  pAccShape->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), uno::Any());
1563  }
1564  }
1565 
1566  pShape = pShapes.get();
1567 
1568  while( nShapes )
1569  {
1570  if (pShape->second.is() && IsInSameLevel(pShape->first, pFESh))
1571  {
1572  if( pShape >= pSelShape )
1573  {
1574  //first fire focus event
1575  if( bFocused && 1 == nSelShapes )
1576  pShape->second->SetState( AccessibleStateType::FOCUSED );
1577  else
1578  pShape->second->ResetState( AccessibleStateType::FOCUSED );
1579 
1580  if(pShape->second->SetState( AccessibleStateType::SELECTED ))
1581  {
1582  vecxShapeAdd.push_back(pShape->second);
1583  }
1584  ++nCountSelectedShape;
1585  }
1586  }
1587 
1588  --nShapes;
1589  ++pShape;
1590  }
1591 
1592  const unsigned int SELECTION_WITH_NUM = 10;
1593  if (vecxShapeAdd.size() > SELECTION_WITH_NUM )
1594  {
1595  uno::Reference< XAccessible > xDoc = GetDocumentView( );
1596  SwAccessibleContext * pCont = static_cast<SwAccessibleContext *>(xDoc.get());
1597  if (pCont)
1598  {
1599  AccessibleEventObject aEvent;
1600  aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN;
1601  pCont->FireAccessibleEvent(aEvent);
1602  }
1603  }
1604  else
1605  {
1606  short nEventID = AccessibleEventId::SELECTION_CHANGED_ADD;
1607  if (nCountSelectedShape <= 1 && vecxShapeAdd.size() == 1 )
1608  {
1609  nEventID = AccessibleEventId::SELECTION_CHANGED;
1610  }
1611  for (const auto& rpShape : vecxShapeAdd)
1612  {
1613  ::accessibility::AccessibleShape *pAccShape = rpShape.get();
1614  if (pAccShape)
1615  {
1616  pAccShape->CommitChange(nEventID, uno::Any(), uno::Any());
1617  }
1618  }
1619  }
1620 
1621  for (const auto& rpShape : vecxShapeAdd)
1622  {
1623  ::accessibility::AccessibleShape *pAccShape = rpShape.get();
1624  if (pAccShape)
1625  {
1626  SdrObject *pObj = GetSdrObjectFromXShape(pAccShape->GetXShape());
1627  SwFrameFormat *pFrameFormat = pObj ? FindFrameFormat( pObj ) : nullptr;
1628  if (pFrameFormat)
1629  {
1630  const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
1631  if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR )
1632  {
1633  uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent();
1634  if (xPara.is())
1635  {
1636  uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext();
1637  if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
1638  {
1639  SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get());
1640  if (pAccPara)
1641  {
1642  m_setParaAdd.insert(pAccPara);
1643  }
1644  }
1645  }
1646  }
1647  }
1648  }
1649  }
1650  for (const auto& rpShape : vecxShapeRemove)
1651  {
1652  ::accessibility::AccessibleShape *pAccShape = rpShape.get();
1653  if (pAccShape)
1654  {
1655  uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent();
1656  uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext();
1657  if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
1658  {
1659  SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get());
1660  if (m_setParaAdd.count(pAccPara) == 0 )
1661  {
1662  m_setParaRemove.insert(pAccPara);
1663  }
1664  }
1665  }
1666  }
1667 }
1668 
1669 //Merge with DoInvalidateShapeSelection
1670 /*
1671 void SwAccessibleMap::DoInvalidateShapeFocus()
1672 {
1673  const SwViewShell *pVSh = GetShell();
1674  const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>( pVSh) != nullptr ?
1675  static_cast< const SwFEShell * >( pVSh ) : nullptr;
1676  const size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
1677 
1678  if( nSelShapes != 1 )
1679  return;
1680 
1681  SwAccessibleObjShape_Impl *pShapes = nullptr;
1682  SwAccessibleObjShape_Impl *pSelShape = nullptr;
1683  size_t nShapes = 0;
1684 
1685  {
1686  osl::MutexGuard aGuard( maMutex );
1687  if( mpShapeMap )
1688  pShapes = mpShapeMap->Copy( nShapes, pFESh, &pSelShape );
1689  }
1690 
1691  if( pShapes )
1692  {
1693  vcl::Window *pWin = GetShell()->GetWin();
1694  bool bFocused = pWin && pWin->HasFocus();
1695  SwAccessibleObjShape_Impl *pShape = pShapes;
1696  while( nShapes )
1697  {
1698  if( pShape->second.is() )
1699  {
1700  if( bFocused && pShape >= pSelShape )
1701  pShape->second->SetState( AccessibleStateType::FOCUSED );
1702  else
1703  pShape->second->ResetState( AccessibleStateType::FOCUSED );
1704  }
1705 
1706  --nShapes;
1707  ++pShape;
1708  }
1709 
1710  delete[] pShapes;
1711  }
1712 }
1713 
1714 */
1715 
1717  mpVSh( pSh ),
1718  mbShapeSelected( false ),
1719  maDocName(SwAccessibleContext::GetResource(STR_ACCESS_DOC_NAME))
1720 {
1721  pSh->GetLayout()->AddAccessibleShell();
1722 }
1723 
1725 {
1727  uno::Reference < XAccessible > xAcc;
1728  {
1729  osl::MutexGuard aGuard( maMutex );
1730  if( mpFrameMap )
1731  {
1732  const SwRootFrame *pRootFrame = GetShell()->GetLayout();
1733  SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pRootFrame );
1734  if( aIter != mpFrameMap->end() )
1735  xAcc = (*aIter).second;
1736  if( !xAcc.is() )
1737  assert(false); // let's hope this can't happen? the vcl::Window apparently owns the top-level
1738  //xAcc = new SwAccessibleDocument(shared_from_this());
1739  }
1740  }
1741 
1742  if(xAcc.is())
1743  {
1744  SwAccessibleDocumentBase *const pAcc =
1745  static_cast<SwAccessibleDocumentBase *>(xAcc.get());
1746  pAcc->Dispose( true );
1747  }
1748 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
1749  if( mpFrameMap )
1750  {
1752  while( aIter != mpFrameMap->end() )
1753  {
1754  uno::Reference < XAccessible > xTmp = (*aIter).second;
1755  if( xTmp.is() )
1756  {
1757  SwAccessibleContext *pTmp = static_cast< SwAccessibleContext * >( xTmp.get() );
1758  assert(pTmp->GetMap() == nullptr); // must be disposed
1759  }
1760  ++aIter;
1761  }
1762  }
1763 #endif
1764  {
1765  osl::MutexGuard aGuard( maMutex );
1766  assert((!mpFrameMap || mpFrameMap->empty()) &&
1767  "Frame map should be empty after disposing the root frame");
1768  assert((!mpShapeMap || mpShapeMap->empty()) &&
1769  "Object map should be empty after disposing the root frame");
1770  mpFrameMap.reset();
1771  mpShapeMap.reset();
1772  mvShapes.clear();
1773  mpSelectedParas.reset();
1774  }
1775 
1776  mpPreview.reset();
1777 
1778  {
1779  osl::MutexGuard aGuard( maEventMutex );
1780  assert(!mpEvents);
1781  assert(!mpEventMap);
1782  mpEventMap.reset();
1783  mpEvents.reset();
1784  }
1786 }
1787 
1788 uno::Reference< XAccessible > SwAccessibleMap::GetDocumentView_(
1789  bool bPagePreview )
1790 {
1791  uno::Reference < XAccessible > xAcc;
1792  bool bSetVisArea = false;
1793 
1794  {
1795  osl::MutexGuard aGuard( maMutex );
1796 
1797  if( !mpFrameMap )
1798  {
1800 #if OSL_DEBUG_LEVEL > 0
1801  mpFrameMap->mbLocked = false;
1802 #endif
1803  }
1804 
1805 #if OSL_DEBUG_LEVEL > 0
1806  assert(!mpFrameMap->mbLocked);
1807  mpFrameMap->mbLocked = true;
1808 #endif
1809 
1810  const SwRootFrame *pRootFrame = GetShell()->GetLayout();
1811  SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pRootFrame );
1812  if( aIter != mpFrameMap->end() )
1813  xAcc = (*aIter).second;
1814  if( xAcc.is() )
1815  {
1816  bSetVisArea = true; // Set VisArea when map mutex is not locked
1817  }
1818  else
1819  {
1820  if( bPagePreview )
1821  xAcc = new SwAccessiblePreview(shared_from_this());
1822  else
1823  xAcc = new SwAccessibleDocument(shared_from_this());
1824 
1825  if( aIter != mpFrameMap->end() )
1826  {
1827  (*aIter).second = xAcc;
1828  }
1829  else
1830  {
1831  mpFrameMap->emplace( pRootFrame, xAcc );
1832  }
1833  }
1834 
1835 #if OSL_DEBUG_LEVEL > 0
1836  mpFrameMap->mbLocked = false;
1837 #endif
1838  }
1839 
1840  if( bSetVisArea )
1841  {
1842  SwAccessibleDocumentBase *pAcc =
1843  static_cast< SwAccessibleDocumentBase * >( xAcc.get() );
1844  pAcc->SetVisArea();
1845  }
1846 
1847  return xAcc;
1848 }
1849 
1850 uno::Reference< XAccessible > SwAccessibleMap::GetDocumentView( )
1851 {
1852  return GetDocumentView_( false );
1853 }
1854 
1855 uno::Reference<XAccessible> SwAccessibleMap::GetDocumentPreview(
1856  const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
1857  const Fraction& _rScale,
1858  const SwPageFrame* _pSelectedPageFrame,
1859  const Size& _rPreviewWinSize )
1860 {
1861  // create & update preview data object
1862  if( mpPreview == nullptr )
1863  mpPreview.reset( new SwAccPreviewData() );
1864  mpPreview->Update( *this, _rPreviewPages, _rScale, _pSelectedPageFrame, _rPreviewWinSize );
1865 
1866  uno::Reference<XAccessible> xAcc = GetDocumentView_( true );
1867  return xAcc;
1868 }
1869 
1870 uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrame *pFrame,
1871  bool bCreate )
1872 {
1874  uno::Reference < XAccessible > xAcc;
1875  uno::Reference < XAccessible > xOldCursorAcc;
1876  bool bOldShapeSelected = false;
1877 
1878  {
1879  osl::MutexGuard aGuard( maMutex );
1880 
1881  if( !mpFrameMap && bCreate )
1883  if( mpFrameMap )
1884  {
1885  SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pFrame );
1886  if( aIter != mpFrameMap->end() )
1887  xAcc = (*aIter).second;
1888 
1889  if( !xAcc.is() && bCreate )
1890  {
1891  SwAccessibleContext *pAcc = nullptr;
1892  switch( pFrame->GetType() )
1893  {
1894  case SwFrameType::Txt:
1895  pAcc = new SwAccessibleParagraph(shared_from_this(),
1896  static_cast< const SwTextFrame& >( *pFrame ) );
1897  break;
1898  case SwFrameType::Header:
1899  pAcc = new SwAccessibleHeaderFooter(shared_from_this(),
1900  static_cast< const SwHeaderFrame *>( pFrame ) );
1901  break;
1902  case SwFrameType::Footer:
1903  pAcc = new SwAccessibleHeaderFooter(shared_from_this(),
1904  static_cast< const SwFooterFrame *>( pFrame ) );
1905  break;
1906  case SwFrameType::Ftn:
1907  {
1908  const SwFootnoteFrame *pFootnoteFrame =
1909  static_cast < const SwFootnoteFrame * >( pFrame );
1910  bool bIsEndnote =
1911  SwAccessibleFootnote::IsEndnote( pFootnoteFrame );
1912  pAcc = new SwAccessibleFootnote(shared_from_this(), bIsEndnote,
1913  /*(bIsEndnote ? mnEndnote++ : mnFootnote++),*/
1914  pFootnoteFrame );
1915  }
1916  break;
1917  case SwFrameType::Fly:
1918  {
1919  const SwFlyFrame *pFlyFrame =
1920  static_cast < const SwFlyFrame * >( pFrame );
1921  switch( SwAccessibleFrameBase::GetNodeType( pFlyFrame ) )
1922  {
1923  case SwNodeType::Grf:
1924  pAcc = new SwAccessibleGraphic(shared_from_this(), pFlyFrame );
1925  break;
1926  case SwNodeType::Ole:
1927  pAcc = new SwAccessibleEmbeddedObject(shared_from_this(), pFlyFrame );
1928  break;
1929  default:
1930  pAcc = new SwAccessibleTextFrame(shared_from_this(), *pFlyFrame );
1931  break;
1932  }
1933  }
1934  break;
1935  case SwFrameType::Cell:
1936  pAcc = new SwAccessibleCell(shared_from_this(),
1937  static_cast< const SwCellFrame *>( pFrame ) );
1938  break;
1939  case SwFrameType::Tab:
1940  pAcc = new SwAccessibleTable(shared_from_this(),
1941  static_cast< const SwTabFrame *>( pFrame ) );
1942  break;
1943  case SwFrameType::Page:
1944  OSL_ENSURE( GetShell()->IsPreview(),
1945  "accessible page frames only in PagePreview" );
1946  pAcc = new SwAccessiblePage(shared_from_this(), pFrame);
1947  break;
1948  default: break;
1949  }
1950  xAcc = pAcc;
1951  assert(xAcc.is());
1952 
1953  if( aIter != mpFrameMap->end() )
1954  {
1955  (*aIter).second = xAcc;
1956  }
1957  else
1958  {
1959  mpFrameMap->emplace( pFrame, xAcc );
1960  }
1961 
1962  if( pAcc->HasCursor() &&
1963  !AreInSameTable( mxCursorContext, pFrame ) )
1964  {
1965  // If the new context has the focus, and if we know
1966  // another context that had the focus, then the focus
1967  // just moves from the old context to the new one. We
1968  // then have to send a focus event and a caret event for
1969  // the old context. We have to do that now,
1970  // because after we have left this method, anyone might
1971  // call getStates for the new context and will get a
1972  // focused state then. Sending the focus changes event
1973  // after that seems to be strange. However, we cannot
1974  // send a focus event for the new context now, because
1975  // no one except us knows it. In any case, we remember
1976  // the new context as the one that has the focus
1977  // currently.
1978 
1979  xOldCursorAcc = mxCursorContext;
1980  mxCursorContext = xAcc;
1981 
1982  bOldShapeSelected = mbShapeSelected;
1983  mbShapeSelected = false;
1984  }
1985  }
1986  }
1987  }
1988 
1989  // Invalidate focus for old object when map is not locked
1990  if( xOldCursorAcc.is() )
1991  InvalidateCursorPosition( xOldCursorAcc );
1992  if( bOldShapeSelected )
1994 
1995  return xAcc;
1996 }
1997 
1999  const SwFrame *pFrame,
2000  bool bCreate )
2001 {
2002  uno::Reference < XAccessible > xAcc( GetContext( pFrame, bCreate ) );
2003 
2005  static_cast< SwAccessibleContext * >( xAcc.get() ) );
2006 
2007  return xAccImpl;
2008 }
2009 
2010 uno::Reference< XAccessible> SwAccessibleMap::GetContext(
2011  const SdrObject *pObj,
2012  SwAccessibleContext *pParentImpl,
2013  bool bCreate )
2014 {
2015  uno::Reference < XAccessible > xAcc;
2016  uno::Reference < XAccessible > xOldCursorAcc;
2017 
2018  {
2019  osl::MutexGuard aGuard( maMutex );
2020 
2021  if( !mpShapeMap && bCreate )
2022  mpShapeMap.reset(new SwAccessibleShapeMap_Impl( this ));
2023  if( mpShapeMap )
2024  {
2025  SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
2026  if( aIter != mpShapeMap->end() )
2027  xAcc = (*aIter).second;
2028 
2029  if( !xAcc.is() && bCreate )
2030  {
2032  uno::Reference < drawing::XShape > xShape(
2033  const_cast< SdrObject * >( pObj )->getUnoShape(),
2034  uno::UNO_QUERY );
2035  if( xShape.is() )
2036  {
2037  ::accessibility::ShapeTypeHandler& rShapeTypeHandler =
2039  uno::Reference < XAccessible > xParent( pParentImpl );
2041  xShape, xParent, this );
2042 
2043  pAcc = rShapeTypeHandler.CreateAccessibleObject(
2044  aShapeInfo, mpShapeMap->GetInfo() );
2045  }
2046  xAcc = pAcc.get();
2047  assert(xAcc.is());
2048  pAcc->Init();
2049  if( aIter != mpShapeMap->end() )
2050  {
2051  (*aIter).second = xAcc;
2052  }
2053  else
2054  {
2055  mpShapeMap->emplace( pObj, xAcc );
2056  }
2057  // TODO: focus!!!
2058  AddGroupContext(pObj, xAcc);
2059  }
2060  }
2061  }
2062 
2063  // Invalidate focus for old object when map is not locked
2064  if( xOldCursorAcc.is() )
2065  InvalidateCursorPosition( xOldCursorAcc );
2066 
2067  return xAcc;
2068 }
2069 
2070 bool SwAccessibleMap::IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh)
2071 {
2072  if (pFESh)
2073  return pFESh->IsObjSameLevelWithMarked(pObj);
2074  return false;
2075 }
2076 
2077 void SwAccessibleMap::AddShapeContext(const SdrObject *pObj, uno::Reference < XAccessible > const & xAccShape)
2078 {
2079  osl::MutexGuard aGuard( maMutex );
2080 
2081  if( mpShapeMap )
2082  {
2083  mpShapeMap->emplace( pObj, xAccShape );
2084  }
2085 
2086 }
2087 
2088 //Added by yanjun for sym2_6407
2090 {
2091  osl::MutexGuard aGuard( maMutex );
2092  // TODO: Why are sub-shapes of group shapes even added to our map?
2093  // Doesn't the AccessibleShape of the top-level shape create them
2094  // on demand anyway? Why does SwAccessibleMap need to know them?
2095  // We cannot rely on getAccessibleChild here to remove the sub-shapes
2096  // from mpShapes because the top-level shape may not only be disposed here
2097  // but also by visibility checks in svx, then it doesn't return children.
2098  if (mpShapeMap && pParentObj && pParentObj->IsGroupObject())
2099  {
2100  SdrObjList *const pChildren(pParentObj->GetSubList());
2101  for (size_t i = 0; pChildren && i < pChildren->GetObjCount(); ++i)
2102  {
2103  SdrObject *const pChild(pChildren->GetObj(i));
2104  assert(pChild);
2105  RemoveContext(pChild);
2106  }
2107  }
2108 }
2109 //End
2110 
2111 void SwAccessibleMap::AddGroupContext(const SdrObject *pParentObj, uno::Reference < XAccessible > const & xAccParent)
2112 {
2113  osl::MutexGuard aGuard( maMutex );
2114  if( mpShapeMap )
2115  {
2116  //here get all the sub list.
2117  if (pParentObj->IsGroupObject())
2118  {
2119  if (xAccParent.is())
2120  {
2121  uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext();
2122  if (xContext.is())
2123  {
2124  sal_Int32 nChildren = xContext->getAccessibleChildCount();
2125  for(sal_Int32 i = 0; i<nChildren; i++)
2126  {
2127  uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i);
2128  if (xChild.is())
2129  {
2130  uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext();
2131  if (xChildContext.is())
2132  {
2133  short nRole = xChildContext->getAccessibleRole();
2134  if (nRole == AccessibleRole::SHAPE)
2135  {
2136  ::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get());
2137  uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape();
2138  if (xShape.is())
2139  {
2140  SdrObject* pObj = GetSdrObjectFromXShape(xShape);
2141  AddShapeContext(pObj, xChild);
2142  AddGroupContext(pObj,xChild);
2143  }
2144  }
2145  }
2146  }
2147  }
2148  }
2149  }
2150  }
2151  }
2152 }
2153 
2155  const SdrObject *pObj,
2156  SwAccessibleContext *pParentImpl,
2157  bool bCreate )
2158 {
2159  uno::Reference < XAccessible > xAcc( GetContext( pObj, pParentImpl, bCreate ) );
2160 
2162  static_cast< ::accessibility::AccessibleShape* >( xAcc.get() ) );
2163 
2164  return xAccImpl;
2165 }
2166 
2168 {
2169  osl::MutexGuard aGuard( maMutex );
2170 
2171  if( mpFrameMap )
2172  {
2174  mpFrameMap->find( pFrame );
2175  if( aIter != mpFrameMap->end() )
2176  {
2177  mpFrameMap->erase( aIter );
2178 
2179  // Remove reference to old caret object. Though mxCursorContext
2180  // is a weak reference and cleared automatically, clearing it
2181  // directly makes sure to not keep a non-functional object.
2182  uno::Reference < XAccessible > xOldAcc( mxCursorContext );
2183  if( xOldAcc.is() )
2184  {
2185  SwAccessibleContext *pOldAccImpl =
2186  static_cast< SwAccessibleContext *>( xOldAcc.get() );
2187  OSL_ENSURE( pOldAccImpl->GetFrame(), "old caret context is disposed" );
2188  if( pOldAccImpl->GetFrame() == pFrame )
2189  {
2190  xOldAcc.clear(); // get an empty ref
2191  mxCursorContext = xOldAcc;
2192  }
2193  }
2194 
2195  if( mpFrameMap->empty() )
2196  {
2197  mpFrameMap.reset();
2198  }
2199  }
2200  }
2201 }
2202 
2204 {
2205  osl::MutexGuard aGuard( maMutex );
2206 
2207  if( mpShapeMap )
2208  {
2209  SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
2210  if( aIter != mpShapeMap->end() )
2211  {
2212  uno::Reference < XAccessible > xAcc( (*aIter).second );
2213  mpShapeMap->erase( aIter );
2214  RemoveGroupContext(pObj);
2215  // The shape selection flag is not cleared, but one might do
2216  // so but has to make sure that the removed context is the one
2217  // that is selected.
2218 
2219  if( mpShapeMap && mpShapeMap->empty() )
2220  {
2221  mpShapeMap.reset();
2222  }
2223  }
2224  }
2225 }
2226 
2227 bool SwAccessibleMap::Contains(const SwFrame *pFrame) const
2228 {
2229  return (pFrame && mpFrameMap && mpFrameMap->find(pFrame) != mpFrameMap->end());
2230 }
2231 
2233  const SdrObject *pObj,
2234  vcl::Window* pWindow,
2235  bool bRecursive,
2236  bool bCanSkipInvisible )
2237 {
2238  SwAccessibleChild aFrameOrObj( pFrame, pObj, pWindow );
2239 
2240  // Indeed, the following assert checks the frame's accessible flag,
2241  // because that's the one that is evaluated in the layout. The frame
2242  // might not be accessible anyway. That's the case for cell frames that
2243  // contain further cells.
2244  OSL_ENSURE( !aFrameOrObj.GetSwFrame() || aFrameOrObj.GetSwFrame()->IsAccessibleFrame(),
2245  "non accessible frame should be disposed" );
2246 
2247  if (aFrameOrObj.IsAccessible(GetShell()->IsPreview())
2248  // fdo#87199 dispose the darn thing if it ever was accessible
2249  || Contains(pFrame))
2250  {
2254  // get accessible context for frame
2255  {
2256  osl::MutexGuard aGuard( maMutex );
2257 
2258  // First of all look for an accessible context for a frame
2259  if( aFrameOrObj.GetSwFrame() && mpFrameMap )
2260  {
2262  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2263  if( aIter != mpFrameMap->end() )
2264  {
2265  uno::Reference < XAccessible > xAcc( (*aIter).second );
2266  xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
2267  }
2268  }
2269  if( !xAccImpl.is() && mpFrameMap )
2270  {
2271  // If there is none, look if the parent is accessible.
2272  const SwFrame *pParent =
2273  SwAccessibleFrame::GetParent( aFrameOrObj,
2274  GetShell()->IsPreview());
2275 
2276  if( pParent )
2277  {
2279  mpFrameMap->find( pParent );
2280  if( aIter != mpFrameMap->end() )
2281  {
2282  uno::Reference < XAccessible > xAcc( (*aIter).second );
2283  xParentAccImpl =
2284  static_cast< SwAccessibleContext *>( xAcc.get() );
2285  }
2286  }
2287  }
2288  if( !xParentAccImpl.is() && !aFrameOrObj.GetSwFrame() && mpShapeMap )
2289  {
2291  mpShapeMap->find( aFrameOrObj.GetDrawObject() );
2292  if( aIter != mpShapeMap->end() )
2293  {
2294  uno::Reference < XAccessible > xAcc( (*aIter).second );
2295  xShapeAccImpl =
2296  static_cast< ::accessibility::AccessibleShape *>( xAcc.get() );
2297  }
2298  }
2299  if( pObj && GetShell()->ActionPend() &&
2300  (xParentAccImpl.is() || xShapeAccImpl.is()) )
2301  {
2302  // Keep a reference to the XShape to avoid that it
2303  // is deleted with a SwFrameFormat::Modify.
2304  uno::Reference < drawing::XShape > xShape(
2305  const_cast< SdrObject * >( pObj )->getUnoShape(),
2306  uno::UNO_QUERY );
2307  if( xShape.is() )
2308  {
2309  mvShapes.push_back( xShape );
2310  }
2311  }
2312  }
2313 
2314  // remove events stored for the frame
2315  {
2316  osl::MutexGuard aGuard( maEventMutex );
2317  if( mpEvents )
2318  {
2320  mpEventMap->find( aFrameOrObj );
2321  if( aIter != mpEventMap->end() )
2322  {
2323  SwAccessibleEvent_Impl aEvent(
2324  SwAccessibleEvent_Impl::DISPOSE, aFrameOrObj );
2325  AppendEvent( aEvent );
2326  }
2327  }
2328  }
2329 
2330  // If the frame is accessible and there is a context for it, dispose
2331  // the frame. If the frame is no context for it but disposing should
2332  // take place recursive, the frame's children have to be disposed
2333  // anyway, so we have to create the context then.
2334  if( xAccImpl.is() )
2335  {
2336  xAccImpl->Dispose( bRecursive );
2337  }
2338  else if( xParentAccImpl.is() )
2339  {
2340  // If the frame is a cell frame, the table must be notified.
2341  // If we are in an action, a table model change event will
2342  // be broadcasted at the end of the action to give the table
2343  // a chance to generate a single table change event.
2344 
2345  xParentAccImpl->DisposeChild( aFrameOrObj, bRecursive, bCanSkipInvisible );
2346  }
2347  else if( xShapeAccImpl.is() )
2348  {
2349  RemoveContext( aFrameOrObj.GetDrawObject() );
2350  xShapeAccImpl->dispose();
2351  }
2352 
2353  if( mpPreview && pFrame && pFrame->IsPageFrame() )
2354  mpPreview->DisposePage( static_cast< const SwPageFrame *>( pFrame ) );
2355  }
2356 }
2357 
2359  const SdrObject *pObj,
2360  vcl::Window* pWindow,
2361  const SwRect& rOldBox )
2362 {
2363  SwAccessibleChild aFrameOrObj( pFrame, pObj, pWindow );
2364  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2365  {
2368  const SwFrame *pParent =nullptr;
2369  {
2370  osl::MutexGuard aGuard( maMutex );
2371 
2372  if( mpFrameMap )
2373  {
2374  if( aFrameOrObj.GetSwFrame() )
2375  {
2377  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2378  if( aIter != mpFrameMap->end() )
2379  {
2380  // If there is an accessible object already it is
2381  // notified directly.
2382  uno::Reference < XAccessible > xAcc( (*aIter).second );
2383  xAccImpl =
2384  static_cast< SwAccessibleContext *>( xAcc.get() );
2385  }
2386  }
2387  if( !xAccImpl.is() )
2388  {
2389  // Otherwise we look if the parent is accessible.
2390  // If not, there is nothing to do.
2391  pParent =
2392  SwAccessibleFrame::GetParent( aFrameOrObj,
2393  GetShell()->IsPreview());
2394 
2395  if( pParent )
2396  {
2398  mpFrameMap->find( pParent );
2399  if( aIter != mpFrameMap->end() )
2400  {
2401  uno::Reference < XAccessible > xAcc( (*aIter).second );
2402  xParentAccImpl =
2403  static_cast< SwAccessibleContext *>( xAcc.get() );
2404  }
2405  }
2406  }
2407  }
2408  }
2409 
2410  if( xAccImpl.is() )
2411  {
2412  if( GetShell()->ActionPend() )
2413  {
2414  SwAccessibleEvent_Impl aEvent(
2415  SwAccessibleEvent_Impl::POS_CHANGED, xAccImpl.get(),
2416  aFrameOrObj, rOldBox );
2417  AppendEvent( aEvent );
2418  }
2419  else
2420  {
2421  FireEvents();
2422  if (xAccImpl->GetFrame()) // not if disposed by FireEvents()
2423  {
2424  xAccImpl->InvalidatePosOrSize(rOldBox);
2425  }
2426  }
2427  }
2428  else if( xParentAccImpl.is() )
2429  {
2430  if( GetShell()->ActionPend() )
2431  {
2432  assert(pParent);
2433  // tdf#99722 faster not to buffer events that won't be sent
2434  if (!SwAccessibleChild(pParent).IsVisibleChildrenOnly()
2435  || xParentAccImpl->IsShowing(rOldBox)
2436  || xParentAccImpl->IsShowing(*this, aFrameOrObj))
2437  {
2438  SwAccessibleEvent_Impl aEvent(
2440  xParentAccImpl.get(), aFrameOrObj, rOldBox );
2441  AppendEvent( aEvent );
2442  }
2443  }
2444  else
2445  {
2446  FireEvents();
2447  xParentAccImpl->InvalidateChildPosOrSize( aFrameOrObj,
2448  rOldBox );
2449  }
2450  }
2451  else if(pParent)
2452  {
2453 /*
2454 For child graphic and its parent paragraph,if split 2 graphic to 2 paragraph,
2455 will delete one graphic swfrm and new create 1 graphic swfrm ,
2456 then the new paragraph and the new graphic SwFrame will add .
2457 but when add graphic SwFrame ,the accessible of the new Paragraph is not created yet.
2458 so the new graphic accessible 'parent is NULL,
2459 so run here: save the parent's SwFrame not the accessible object parent,
2460 */
2461  bool bIsValidFrame = false;
2462  bool bIsTextParent = false;
2463  if (aFrameOrObj.GetSwFrame())
2464  {
2465  if (SwFrameType::Fly == pFrame->GetType())
2466  {
2467  bIsValidFrame =true;
2468  }
2469  }
2470  else if(pObj)
2471  {
2472  if (SwFrameType::Txt == pParent->GetType())
2473  {
2474  bIsTextParent =true;
2475  }
2476  }
2477  if( bIsValidFrame || bIsTextParent )
2478  {
2479  if( GetShell()->ActionPend() )
2480  {
2481  SwAccessibleEvent_Impl aEvent(
2483  pParent, aFrameOrObj, rOldBox );
2484  AppendEvent( aEvent );
2485  }
2486  else
2487  {
2488  OSL_ENSURE(false,"");
2489  }
2490  }
2491  }
2492  }
2493 }
2494 
2496 {
2497  SwAccessibleChild aFrameOrObj( pFrame );
2498  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2499  {
2500  uno::Reference < XAccessible > xAcc;
2501  {
2502  osl::MutexGuard aGuard( maMutex );
2503 
2504  if( mpFrameMap )
2505  {
2507  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2508  if( aIter != mpFrameMap->end() )
2509  xAcc = (*aIter).second;
2510  }
2511  }
2512 
2513  if( xAcc.is() )
2514  {
2515  SwAccessibleContext *pAccImpl =
2516  static_cast< SwAccessibleContext *>( xAcc.get() );
2517  if( GetShell()->ActionPend() )
2518  {
2519  SwAccessibleEvent_Impl aEvent(
2521  aFrameOrObj );
2522  AppendEvent( aEvent );
2523  }
2524  else
2525  {
2526  FireEvents();
2527  pAccImpl->InvalidateContent();
2528  }
2529  }
2530  }
2531 }
2532 
2534 {
2535  SwAccessibleChild aFrameOrObj( &rTextFrame );
2536  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2537  {
2538  uno::Reference < XAccessible > xAcc;
2539  {
2540  osl::MutexGuard aGuard( maMutex );
2541 
2542  if( mpFrameMap )
2543  {
2545  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2546  if( aIter != mpFrameMap->end() )
2547  xAcc = (*aIter).second;
2548  }
2549  }
2550 
2551  if( xAcc.is() )
2552  {
2553  SwAccessibleContext *pAccImpl =
2554  static_cast< SwAccessibleContext *>( xAcc.get() );
2555  if( GetShell()->ActionPend() )
2556  {
2558  pAccImpl, aFrameOrObj );
2560  AppendEvent( aEvent );
2561  }
2562  else
2563  {
2564  FireEvents();
2565  pAccImpl->InvalidateAttr();
2566  }
2567  }
2568  }
2569 }
2570 
2572 {
2573  SwAccessibleChild aFrameOrObj( pFrame );
2574  bool bShapeSelected = false;
2575  const SwViewShell *pVSh = GetShell();
2576  if( auto pCSh = dynamic_cast<const SwCursorShell*>(pVSh) )
2577  {
2578  if( pCSh->IsTableMode() )
2579  {
2580  while( aFrameOrObj.GetSwFrame() && !aFrameOrObj.GetSwFrame()->IsCellFrame() )
2581  aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper();
2582  }
2583  else if( auto pFESh = dynamic_cast<const SwFEShell*>(pVSh) )
2584  {
2585  const SwFrame *pFlyFrame = pFESh->GetSelectedFlyFrame();
2586  if( pFlyFrame )
2587  {
2588  OSL_ENSURE( !pFrame || pFrame->FindFlyFrame() == pFlyFrame,
2589  "cursor is not contained in fly frame" );
2590  aFrameOrObj = pFlyFrame;
2591  }
2592  else if( pFESh->IsObjSelected() > 0 )
2593  {
2594  bShapeSelected = true;
2595  aFrameOrObj = static_cast<const SwFrame *>( nullptr );
2596  }
2597  }
2598  }
2599 
2600  OSL_ENSURE( bShapeSelected || aFrameOrObj.IsAccessible(GetShell()->IsPreview()),
2601  "frame is not accessible" );
2602 
2603  uno::Reference < XAccessible > xOldAcc;
2604  uno::Reference < XAccessible > xAcc;
2605  bool bOldShapeSelected = false;
2606 
2607  {
2608  osl::MutexGuard aGuard( maMutex );
2609 
2610  xOldAcc = mxCursorContext;
2611  mxCursorContext = xAcc; // clear reference
2612 
2613  bOldShapeSelected = mbShapeSelected;
2614  mbShapeSelected = bShapeSelected;
2615 
2616  if( aFrameOrObj.GetSwFrame() && mpFrameMap )
2617  {
2619  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2620  if( aIter != mpFrameMap->end() )
2621  xAcc = (*aIter).second;
2622  else
2623  {
2624  SwRect rcEmpty;
2625  const SwTabFrame* pTabFrame = aFrameOrObj.GetSwFrame()->FindTabFrame();
2626  if (pTabFrame)
2627  {
2628  InvalidatePosOrSize(pTabFrame, nullptr, nullptr, rcEmpty);
2629  }
2630  else
2631  {
2632  InvalidatePosOrSize(aFrameOrObj.GetSwFrame(), nullptr, nullptr, rcEmpty);
2633  }
2634 
2635  aIter = mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2636  if( aIter != mpFrameMap->end() )
2637  {
2638  xAcc = (*aIter).second;
2639  }
2640  }
2641 
2642  // For cells, some extra thoughts are necessary,
2643  // because invalidating the cursor for one cell
2644  // invalidates the cursor for all cells of the same
2645  // table. For this reason, we don't want to
2646  // invalidate the cursor for the old cursor object
2647  // and the new one if they are within the same table,
2648  // because this would result in doing the work twice.
2649  // Moreover, we have to make sure to invalidate the
2650  // cursor even if the current cell has no accessible object.
2651  // If the old cursor objects exists and is in the same
2652  // table, it's the best choice, because using it avoids
2653  // an unnecessary cursor invalidation cycle when creating
2654  // a new object for the current cell.
2655  if( aFrameOrObj.GetSwFrame()->IsCellFrame() )
2656  {
2657  if( xOldAcc.is() &&
2658  AreInSameTable( xOldAcc, aFrameOrObj.GetSwFrame() ) )
2659  {
2660  if( xAcc.is() )
2661  xOldAcc = xAcc; // avoid extra invalidation
2662  else
2663  xAcc = xOldAcc; // make sure at least one
2664  }
2665  if( !xAcc.is() )
2666  xAcc = GetContext( aFrameOrObj.GetSwFrame() );
2667  }
2668  }
2669  else if (bShapeSelected)
2670  {
2671  const SwFEShell *pFESh = static_cast< const SwFEShell * >( pVSh );
2672  const SdrMarkList *pMarkList = pFESh->GetMarkList();
2673  if (pMarkList != nullptr && pMarkList->GetMarkCount() == 1)
2674  {
2675  SdrObject *pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
2676  ::rtl::Reference < ::accessibility::AccessibleShape > pAccShapeImpl = GetContextImpl(pObj,nullptr,false);
2677  if (!pAccShapeImpl.is())
2678  {
2679  while (pObj && pObj->getParentSdrObjectFromSdrObject())
2680  {
2681  pObj = pObj->getParentSdrObjectFromSdrObject();
2682  }
2683  if (pObj != nullptr)
2684  {
2685  const SwFrame *pParent = SwAccessibleFrame::GetParent( SwAccessibleChild(pObj), GetShell()->IsPreview() );
2686  if( pParent )
2687  {
2688  ::rtl::Reference< SwAccessibleContext > xParentAccImpl = GetContextImpl(pParent,false);
2689  if (!xParentAccImpl.is())
2690  {
2691  const SwTabFrame* pTabFrame = pParent->FindTabFrame();
2692  if (pTabFrame)
2693  {
2694  //The Table should not add in acc.because the "pParent" is not add to acc .
2695  uno::Reference< XAccessible> xAccParentTab = GetContext(pTabFrame);//Should Create.
2696 
2697  const SwFrame *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pTabFrame), GetShell()->IsPreview() );
2698  if (pParentRoot)
2699  {
2700  ::rtl::Reference< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,false);
2701  if(xParentAccImplRoot.is())
2702  {
2703  AccessibleEventObject aEvent;
2704  aEvent.EventId = AccessibleEventId::CHILD;
2705  aEvent.NewValue <<= xAccParentTab;
2706  xParentAccImplRoot->FireAccessibleEvent( aEvent );
2707  }
2708  }
2709 
2710  //Get "pParent" acc again.
2711  xParentAccImpl = GetContextImpl(pParent,false);
2712  }
2713  else
2714  {
2715  //directly create this acc para .
2716  xParentAccImpl = GetContextImpl(pParent);//Should Create.
2717 
2718  const SwFrame *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pParent), GetShell()->IsPreview() );
2719 
2720  ::rtl::Reference< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,false);
2721  if(xParentAccImplRoot.is())
2722  {
2723  AccessibleEventObject aEvent;
2724  aEvent.EventId = AccessibleEventId::CHILD;
2725  aEvent.NewValue <<= uno::Reference< XAccessible>(xParentAccImpl.get());
2726  xParentAccImplRoot->FireAccessibleEvent( aEvent );
2727  }
2728  }
2729  }
2730  if (xParentAccImpl.is())
2731  {
2732  uno::Reference< XAccessible> xAccShape =
2733  GetContext(pObj,xParentAccImpl.get());
2734 
2735  AccessibleEventObject aEvent;
2736  aEvent.EventId = AccessibleEventId::CHILD;
2737  aEvent.NewValue <<= xAccShape;
2738  xParentAccImpl->FireAccessibleEvent( aEvent );
2739  }
2740  }
2741  }
2742  }
2743  }
2744  }
2745  }
2746 
2747  m_setParaAdd.clear();
2748  m_setParaRemove.clear();
2749  if( xOldAcc.is() && xOldAcc != xAcc )
2750  InvalidateCursorPosition( xOldAcc );
2751  if( bOldShapeSelected || bShapeSelected )
2752  InvalidateShapeSelection();
2753  if( xAcc.is() )
2754  InvalidateCursorPosition( xAcc );
2755 
2756  InvalidateShapeInParaSelection();
2757 
2758  for (SwAccessibleParagraph* pAccPara : m_setParaRemove)
2759  {
2760  if(pAccPara && pAccPara->getSelectedAccessibleChildCount() == 0 && pAccPara->getSelectedText().getLength() == 0)
2761  {
2762  if(pAccPara->SetSelectedState(false))
2763  {
2764  AccessibleEventObject aEvent;
2765  aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
2766  pAccPara->FireAccessibleEvent( aEvent );
2767  }
2768  }
2769  }
2770  for (SwAccessibleParagraph* pAccPara : m_setParaAdd)
2771  {
2772  if(pAccPara && pAccPara->SetSelectedState(true))
2773  {
2774  AccessibleEventObject aEvent;
2775  aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
2776  pAccPara->FireAccessibleEvent( aEvent );
2777  }
2778  }
2779 }
2780 
2782 {
2783  if(GetShell()->IsPreview())
2784  {
2785  uno::Reference<XAccessible> xAcc = GetDocumentView_( true );
2786  if (xAcc.get())
2787  {
2788  SwAccessiblePreview *pAccPreview = static_cast<SwAccessiblePreview *>(xAcc.get());
2789  if (pAccPreview)
2790  {
2791  pAccPreview->InvalidateFocus();
2792  return ;
2793  }
2794  }
2795  }
2796  uno::Reference < XAccessible > xAcc;
2797  {
2798  osl::MutexGuard aGuard( maMutex );
2799 
2800  xAcc = mxCursorContext;
2801  }
2802 
2803  if( xAcc.is() )
2804  {
2805  SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
2806  pAccImpl->InvalidateFocus();
2807  }
2808  else
2809  {
2811  }
2812 }
2813 
2815  const ::rtl::Reference < SwAccessibleContext >& rCursorContext )
2816 {
2817  osl::MutexGuard aGuard( maMutex );
2818  uno::Reference < XAccessible > xAcc( rCursorContext.get() );
2819  mxCursorContext = xAcc;
2820 }
2821 
2823 {
2824  // Start with the frame or the first upper that is accessible
2825  SwAccessibleChild aFrameOrObj( _pFrame );
2826  while( aFrameOrObj.GetSwFrame() &&
2827  !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2828  aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper();
2829  if( !aFrameOrObj.GetSwFrame() )
2830  aFrameOrObj = GetShell()->GetLayout();
2831 
2832  uno::Reference< XAccessible > xAcc( GetContext( aFrameOrObj.GetSwFrame() ) );
2833  SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
2834  if( GetShell()->ActionPend() )
2835  {
2837  pAccImpl,
2838  SwAccessibleChild(pAccImpl->GetFrame()),
2840  AppendEvent( aEvent );
2841  }
2842  else
2843  {
2844  FireEvents();
2846  }
2847 }
2848 
2850  bool bFrom )
2851 {
2852  // first, see if this frame is accessible, and if so, get the respective
2853  SwAccessibleChild aFrameOrObj( pFrame );
2854  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2855  {
2856  uno::Reference < XAccessible > xAcc;
2857  {
2858  osl::MutexGuard aGuard( maMutex );
2859 
2860  if( mpFrameMap )
2861  {
2863  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2864  if( aIter != mpFrameMap->end() )
2865  {
2866  xAcc = (*aIter).second;
2867  }
2868  }
2869  }
2870 
2871  // deliver event directly, or queue event
2872  if( xAcc.is() )
2873  {
2874  SwAccessibleContext *pAccImpl =
2875  static_cast< SwAccessibleContext *>( xAcc.get() );
2876  if( GetShell()->ActionPend() )
2877  {
2879  pAccImpl, SwAccessibleChild(pFrame),
2880  ( bFrom
2883  AppendEvent( aEvent );
2884  }
2885  else
2886  {
2887  FireEvents();
2888  pAccImpl->InvalidateRelation( bFrom
2889  ? AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED
2890  : AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED );
2891  }
2892  }
2893  }
2894 }
2895 
2897  const SwFrame* pFollow )
2898 {
2899  InvalidateRelationSet_( pMaster, false );
2900  InvalidateRelationSet_( pFollow, true );
2901 }
2902 
2903 // invalidation of CONTENT_FLOW_FROM/_TO relation of a paragraph
2905  const bool _bFrom )
2906 {
2907  InvalidateRelationSet_( &_rTextFrame, _bFrom );
2908 }
2909 
2910 // invalidation of text selection of a paragraph
2912 {
2913  // first, see if this frame is accessible, and if so, get the respective
2914  SwAccessibleChild aFrameOrObj( &_rTextFrame );
2915  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2916  {
2917  uno::Reference < XAccessible > xAcc;
2918  {
2919  osl::MutexGuard aGuard( maMutex );
2920 
2921  if( mpFrameMap )
2922  {
2924  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2925  if( aIter != mpFrameMap->end() )
2926  {
2927  xAcc = (*aIter).second;
2928  }
2929  }
2930  }
2931 
2932  // deliver event directly, or queue event
2933  if( xAcc.is() )
2934  {
2935  SwAccessibleContext *pAccImpl =
2936  static_cast< SwAccessibleContext *>( xAcc.get() );
2937  if( GetShell()->ActionPend() )
2938  {
2939  SwAccessibleEvent_Impl aEvent(
2941  pAccImpl,
2942  SwAccessibleChild( &_rTextFrame ),
2944  AppendEvent( aEvent );
2945  }
2946  else
2947  {
2948  FireEvents();
2949  pAccImpl->InvalidateTextSelection();
2950  }
2951  }
2952  }
2953 }
2954 
2955 sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrame& rParentFrame,
2956  vcl::Window& rChild ) const
2957 {
2958  sal_Int32 nIndex( -1 );
2959 
2960  SwAccessibleChild aFrameOrObj( &rParentFrame );
2961  if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) )
2962  {
2963  uno::Reference < XAccessible > xAcc;
2964  {
2965  osl::MutexGuard aGuard( maMutex );
2966 
2967  if( mpFrameMap )
2968  {
2970  mpFrameMap->find( aFrameOrObj.GetSwFrame() );
2971  if( aIter != mpFrameMap->end() )
2972  {
2973  xAcc = (*aIter).second;
2974  }
2975  }
2976  }
2977 
2978  if( xAcc.is() )
2979  {
2980  SwAccessibleContext *pAccImpl =
2981  static_cast< SwAccessibleContext *>( xAcc.get() );
2982 
2983  nIndex = pAccImpl->GetChildIndex( const_cast<SwAccessibleMap&>(*this),
2984  SwAccessibleChild( &rChild ) );
2985  }
2986  }
2987 
2988  return nIndex;
2989 }
2990 
2991 void SwAccessibleMap::UpdatePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
2992  const Fraction& _rScale,
2993  const SwPageFrame* _pSelectedPageFrame,
2994  const Size& _rPreviewWinSize )
2995 {
2996  assert(GetShell()->IsPreview() && "no preview?");
2997  assert(mpPreview != nullptr && "no preview data?");
2998 
2999  mpPreview->Update( *this, _rPreviewPages, _rScale, _pSelectedPageFrame, _rPreviewWinSize );
3000 
3001  // propagate change of VisArea through the document's
3002  // accessibility tree; this will also send appropriate scroll
3003  // events
3004  SwAccessibleContext* pDoc =
3005  GetContextImpl( GetShell()->GetLayout() ).get();
3006  static_cast<SwAccessibleDocumentBase*>( pDoc )->SetVisArea();
3007 
3008  uno::Reference < XAccessible > xOldAcc;
3009  uno::Reference < XAccessible > xAcc;
3010  {
3011  osl::MutexGuard aGuard( maMutex );
3012 
3013  xOldAcc = mxCursorContext;
3014 
3015  const SwPageFrame *pSelPage = mpPreview->GetSelPage();
3016  if( pSelPage && mpFrameMap )
3017  {
3019  mpFrameMap->find( pSelPage );
3020  if( aIter != mpFrameMap->end() )
3021  xAcc = (*aIter).second;
3022  }
3023  }
3024 
3025  if( xOldAcc.is() && xOldAcc != xAcc )
3026  InvalidateCursorPosition( xOldAcc );
3027  if( xAcc.is() )
3028  InvalidateCursorPosition( xAcc );
3029 }
3030 
3032 {
3033  assert(GetShell()->IsPreview());
3034  assert(mpPreview != nullptr);
3035 
3036  mpPreview->InvalidateSelection( GetShell()->GetLayout()->GetPageByPageNum( nSelPage ) );
3037 
3038  uno::Reference < XAccessible > xOldAcc;
3039  uno::Reference < XAccessible > xAcc;
3040  {
3041  osl::MutexGuard aGuard( maMutex );
3042 
3043  xOldAcc = mxCursorContext;
3044 
3045  const SwPageFrame *pSelPage = mpPreview->GetSelPage();
3046  if( pSelPage && mpFrameMap )
3047  {
3048  SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pSelPage );
3049  if( aIter != mpFrameMap->end() )
3050  xAcc = (*aIter).second;
3051  }
3052  }
3053 
3054  if( xOldAcc.is() && xOldAcc != xAcc )
3055  InvalidateCursorPosition( xOldAcc );
3056  if( xAcc.is() )
3057  InvalidateCursorPosition( xAcc );
3058 }
3059 
3060 bool SwAccessibleMap::IsPageSelected( const SwPageFrame *pPageFrame ) const
3061 {
3062  return mpPreview && mpPreview->GetSelPage() == pPageFrame;
3063 }
3064 
3066 {
3067  {
3068  osl::MutexGuard aGuard( maEventMutex );
3069  if( mpEvents )
3070  {
3071  if (mpEvents->IsFiring())
3072  {
3073  return; // prevent recursive FireEvents()
3074  }
3075 
3076  mpEvents->SetFiring();
3077  mpEvents->MoveMissingXAccToEnd();
3078  for( auto const& aEvent : *mpEvents )
3079  FireEvent(aEvent);
3080 
3081  mpEventMap.reset();
3082  mpEvents.reset();
3083  }
3084  }
3085  {
3086  osl::MutexGuard aGuard( maMutex );
3087  mvShapes.clear();
3088  }
3089 
3090 }
3091 
3093 {
3094  MapMode aSrc( MapUnit::MapTwip );
3095  MapMode aDest( MapUnit::Map100thMM );
3096  return OutputDevice::LogicToLogic( GetVisArea().SVRect(), aSrc, aDest );
3097 }
3098 
3099 // Convert a MM100 value relative to the document root into a pixel value
3100 // relative to the screen!
3102 {
3103  MapMode aSrc( MapUnit::Map100thMM );
3104  MapMode aDest( MapUnit::MapTwip );
3105 
3106  Point aPoint = OutputDevice::LogicToLogic( rPoint, aSrc, aDest );
3107  vcl::Window *pWin = GetShell()->GetWin();
3108  if( pWin )
3109  {
3110  MapMode aMapMode;
3111  GetMapMode( aPoint, aMapMode );
3112  aPoint = pWin->LogicToPixel( aPoint, aMapMode );
3113  aPoint = pWin->OutputToAbsoluteScreenPixel( aPoint );
3114  }
3115 
3116  return aPoint;
3117 }
3118 
3120 {
3121  MapMode aSrc( MapUnit::Map100thMM );
3122  MapMode aDest( MapUnit::MapTwip );
3123  Size aSize( OutputDevice::LogicToLogic( rSize, aSrc, aDest ) );
3124  if( GetShell()->GetWin() )
3125  {
3126  MapMode aMapMode;
3127  GetMapMode( Point(0,0), aMapMode );
3128  aSize = GetShell()->GetWin()->LogicToPixel( aSize, aMapMode );
3129  }
3130 
3131  return aSize;
3132 }
3133 
3135  ::accessibility::AccessibleShape* pCurrentChild,
3136  const uno::Reference< drawing::XShape >& _rxShape,
3137  const long /*_nIndex*/,
3138  const ::accessibility::AccessibleShapeTreeInfo& /*_rShapeTreeInfo*/
3139  )
3140 {
3141  const SdrObject *pObj = nullptr;
3142  {
3143  osl::MutexGuard aGuard( maMutex );
3144  if( mpShapeMap )
3145  {
3148  while( aIter != aEndIter && !pObj )
3149  {
3150  uno::Reference < XAccessible > xAcc( (*aIter).second );
3152  static_cast < ::accessibility::AccessibleShape* >( xAcc.get() );
3153  if( pAccShape == pCurrentChild )
3154  {
3155  pObj = (*aIter).first;
3156  }
3157  ++aIter;
3158  }
3159  }
3160  }
3161  if( !pObj )
3162  return false;
3163 
3164  uno::Reference < drawing::XShape > xShape( _rxShape ); // keep reference to shape, because
3165  // we might be the only one that
3166  // holds it.
3167  // Also get keep parent.
3168  uno::Reference < XAccessible > xParent( pCurrentChild->getAccessibleParent() );
3169  pCurrentChild = nullptr; // will be released by dispose
3170  A11yDispose( nullptr, pObj, nullptr );
3171 
3172  {
3173  osl::MutexGuard aGuard( maMutex );
3174 
3175  if( !mpShapeMap )
3176  mpShapeMap.reset(new SwAccessibleShapeMap_Impl( this ));
3177 
3178  // create the new child
3179  ::accessibility::ShapeTypeHandler& rShapeTypeHandler =
3182  xShape, xParent, this );
3184  rShapeTypeHandler.CreateAccessibleObject (
3185  aShapeInfo, mpShapeMap->GetInfo() ));
3186 
3187  uno::Reference < XAccessible > xAcc( pReplacement.get() );
3188  if( xAcc.is() )
3189  {
3190  pReplacement->Init();
3191 
3192  SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->find( pObj );
3193  if( aIter != mpShapeMap->end() )
3194  {
3195  (*aIter).second = xAcc;
3196  }
3197  else
3198  {
3199  mpShapeMap->emplace( pObj, xAcc );
3200  }
3201  }
3202  }
3203 
3204  SwRect aEmptyRect;
3205  InvalidatePosOrSize( nullptr, pObj, nullptr, aEmptyRect );
3206 
3207  return true;
3208 }
3209 
3210 //Get the accessible control shape from the model object, here model object is with XPropertySet type
3212 {
3213  if( mpShapeMap )
3214  {
3217  while( aIter != aEndIter)
3218  {
3219  uno::Reference < XAccessible > xAcc( (*aIter).second );
3221  static_cast < ::accessibility::AccessibleShape* >( xAcc.get() );
3223  {
3224  ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
3225  if (pCtlAccShape->GetControlModel() == pSet)
3226  return pCtlAccShape;
3227  }
3228  ++aIter;
3229  }
3230  }
3231  return nullptr;
3232 }
3233 
3234 css::uno::Reference< XAccessible >
3235  SwAccessibleMap::GetAccessibleCaption (const css::uno::Reference< css::drawing::XShape >&)
3236 {
3237  return nullptr;
3238 }
3239 
3241 {
3242  Point aPoint;
3243  if( GetShell()->GetWin() )
3244  {
3245  MapMode aMapMode;
3246  GetMapMode( rPoint, aMapMode );
3247  aPoint = GetShell()->GetWin()->PixelToLogic( rPoint, aMapMode );
3248  }
3249  return aPoint;
3250 }
3251 
3252 static long lcl_CorrectCoarseValue(long aCoarseValue, long aFineValue,
3253  long aRefValue, bool bToLower)
3254 {
3255  long aResult = aCoarseValue;
3256 
3257  if (bToLower)
3258  {
3259  if (aFineValue < aRefValue)
3260  aResult -= 1;
3261  }
3262  else
3263  {
3264  if (aFineValue > aRefValue)
3265  aResult += 1;
3266  }
3267 
3268  return aResult;
3269 }
3270 
3272  const tools::Rectangle & rSource,
3273  const tools::Rectangle & rInGrid)
3274 {
3275  rRect.SetLeft( lcl_CorrectCoarseValue(rRect.Left(), rSource.Left(),
3276  rInGrid.Left(), false) );
3277  rRect.SetTop( lcl_CorrectCoarseValue(rRect.Top(), rSource.Top(),
3278  rInGrid.Top(), false) );
3279  rRect.SetRight( lcl_CorrectCoarseValue(rRect.Right(), rSource.Right(),
3280  rInGrid.Right(), true) );
3281  rRect.SetBottom( lcl_CorrectCoarseValue(rRect.Bottom(), rSource.Bottom(),
3282  rInGrid.Bottom(), true) );
3283 }
3284 
3286 {
3287  tools::Rectangle aRect;
3288  if( GetShell()->GetWin() )
3289  {
3290  MapMode aMapMode;
3291  GetMapMode( rRect.TopLeft(), aMapMode );
3292  aRect = GetShell()->GetWin()->LogicToPixel( rRect, aMapMode );
3293 
3294  tools::Rectangle aTmpRect = GetShell()->GetWin()->PixelToLogic( aRect, aMapMode );
3295  lcl_CorrectRectangle(aRect, rRect, aTmpRect);
3296  }
3297 
3298  return aRect;
3299 }
3300 
3309 void SwAccessibleMap::GetMapMode( const Point& _rPoint,
3310  MapMode& _orMapMode ) const
3311 {
3312  MapMode aMapMode = GetShell()->GetWin()->GetMapMode();
3313  if( GetShell()->IsPreview() )
3314  {
3315  assert(mpPreview != nullptr);
3316  mpPreview->AdjustMapMode( aMapMode, _rPoint );
3317  }
3318  _orMapMode = aMapMode;
3319 }
3320 
3321 Size SwAccessibleMap::GetPreviewPageSize(sal_uInt16 const nPreviewPageNum) const
3322 {
3323  assert(mpVSh->IsPreview());
3324  assert(mpPreview != nullptr);
3325  return mpVSh->PagePreviewLayout()->GetPreviewPageSizeByPageNum(nPreviewPageNum);
3326 }
3327 
3332 std::unique_ptr<SwAccessibleSelectedParas_Impl> SwAccessibleMap::BuildSelectedParas()
3333 {
3334  // no accessible contexts, no selection
3335  if ( !mpFrameMap )
3336  {
3337  return nullptr;
3338  }
3339 
3340  // get cursor as an instance of its base class <SwPaM>
3341  SwPaM* pCursor( nullptr );
3342  {
3343  SwCursorShell* pCursorShell = dynamic_cast<SwCursorShell*>(GetShell());
3344  if ( pCursorShell )
3345  {
3346  SwFEShell* pFEShell = dynamic_cast<SwFEShell*>(pCursorShell);
3347  if ( !pFEShell ||
3348  ( !pFEShell->IsFrameSelected() &&
3349  pFEShell->IsObjSelected() == 0 ) )
3350  {
3351  // get cursor without updating an existing table cursor.
3352  pCursor = pCursorShell->GetCursor( false );
3353  }
3354  }
3355  }
3356  // no cursor, no selection
3357  if ( !pCursor )
3358  {
3359  return nullptr;
3360  }
3361 
3362  std::unique_ptr<SwAccessibleSelectedParas_Impl> pRetSelectedParas;
3363 
3364  // loop on all cursors
3365  SwPaM* pRingStart = pCursor;
3366  do {
3367 
3368  // for a selection the cursor has to have a mark.
3369  // for safety reasons assure that point and mark are in text nodes
3370  if ( pCursor->HasMark() &&
3371  pCursor->GetPoint()->nNode.GetNode().IsTextNode() &&
3372  pCursor->GetMark()->nNode.GetNode().IsTextNode() )
3373  {
3374  SwPosition* pStartPos = pCursor->Start();
3375  SwPosition* pEndPos = pCursor->End();
3376  // loop on all text nodes inside the selection
3377  SwNodeIndex aIdx( pStartPos->nNode );
3378  for ( ; aIdx.GetIndex() <= pEndPos->nNode.GetIndex(); ++aIdx )
3379  {
3380  SwTextNode* pTextNode( aIdx.GetNode().GetTextNode() );
3381  if ( pTextNode )
3382  {
3383  // loop on all text frames registered at the text node.
3385  for( SwTextFrame* pTextFrame = aIter.First(); pTextFrame; pTextFrame = aIter.Next() )
3386  {
3387  uno::WeakReference < XAccessible > xWeakAcc;
3389  mpFrameMap->find( pTextFrame );
3390  if( aMapIter != mpFrameMap->end() )
3391  {
3392  xWeakAcc = (*aMapIter).second;
3393  SwAccessibleParaSelection aDataEntry(
3394  sw::FrameContainsNode(*pTextFrame, pStartPos->nNode.GetIndex())
3395  ? pTextFrame->MapModelToViewPos(*pStartPos)
3396  : TextFrameIndex(0),
3397 
3398  sw::FrameContainsNode(*pTextFrame, pEndPos->nNode.GetIndex())
3399  ? pTextFrame->MapModelToViewPos(*pEndPos)
3401  if ( !pRetSelectedParas )
3402  {
3403  pRetSelectedParas.reset(
3405  }
3406  // sw_redlinehide: should be idempotent for multiple nodes in a merged para
3407  pRetSelectedParas->emplace( xWeakAcc, aDataEntry );
3408  }
3409  }
3410  }
3411  }
3412  }
3413 
3414  // prepare next turn: get next cursor in ring
3415  pCursor = pCursor->GetNext();
3416  } while ( pCursor != pRingStart );
3417 
3418  return pRetSelectedParas;
3419 }
3420 
3422 {
3423  osl::MutexGuard aGuard( maMutex );
3424 
3425  // keep previously known selected paragraphs
3426  std::unique_ptr<SwAccessibleSelectedParas_Impl> pPrevSelectedParas( std::move(mpSelectedParas) );
3427 
3428  // determine currently selected paragraphs
3430 
3431  // compare currently selected paragraphs with the previously selected
3432  // paragraphs and submit corresponding TEXT_SELECTION_CHANGED events.
3433  // first, search for new and changed selections.
3434  // on the run remove selections from previously known ones, if they are
3435  // also in the current ones.
3436  if ( mpSelectedParas )
3437  {
3439  for ( ; aIter != mpSelectedParas->end(); ++aIter )
3440  {
3441  bool bSubmitEvent( false );
3442  if ( !pPrevSelectedParas )
3443  {
3444  // new selection
3445  bSubmitEvent = true;
3446  }
3447  else
3448  {
3450  pPrevSelectedParas->find( (*aIter).first );
3451  if ( aPrevSelected != pPrevSelectedParas->end() )
3452  {
3453  // check, if selection has changed
3454  if ( (*aIter).second.nStartOfSelection !=
3455  (*aPrevSelected).second.nStartOfSelection ||
3456  (*aIter).second.nEndOfSelection !=
3457  (*aPrevSelected).second.nEndOfSelection )
3458  {
3459  // changed selection
3460  bSubmitEvent = true;
3461  }
3462  pPrevSelectedParas->erase( aPrevSelected );
3463  }
3464  else
3465  {
3466  // new selection
3467  bSubmitEvent = true;
3468  }
3469  }
3470 
3471  if ( bSubmitEvent )
3472  {
3473  uno::Reference < XAccessible > xAcc( (*aIter).first );
3474  if ( xAcc.is() )
3475  {
3477  static_cast<SwAccessibleContext*>( xAcc.get() ) );
3478  if ( xAccImpl.is() && xAccImpl->GetFrame() )
3479  {
3480  const SwTextFrame* pTextFrame(
3481  dynamic_cast<const SwTextFrame*>(xAccImpl->GetFrame()) );
3482  OSL_ENSURE( pTextFrame,
3483  "<SwAccessibleMap::_SubmitTextSelectionChangedEvents()> - unexpected type of frame" );
3484  if ( pTextFrame )
3485  {
3486  InvalidateParaTextSelection( *pTextFrame );
3487  }
3488  }
3489  }
3490  }
3491  }
3492  }
3493 
3494  // second, handle previous selections - after the first step the data
3495  // structure of the previously known only contains the 'old' selections
3496  if ( pPrevSelectedParas )
3497  {
3498  SwAccessibleSelectedParas_Impl::iterator aIter = pPrevSelectedParas->begin();
3499  for ( ; aIter != pPrevSelectedParas->end(); ++aIter )
3500  {
3501  uno::Reference < XAccessible > xAcc( (*aIter).first );
3502  if ( xAcc.is() )
3503  {
3505  static_cast<SwAccessibleContext*>( xAcc.get() ) );
3506  if ( xAccImpl.is() && xAccImpl->GetFrame() )
3507  {
3508  const SwTextFrame* pTextFrame(
3509  dynamic_cast<const SwTextFrame*>(xAccImpl->GetFrame()) );
3510  OSL_ENSURE( pTextFrame,
3511  "<SwAccessibleMap::_SubmitTextSelectionChangedEvents()> - unexpected type of frame" );
3512  if ( pTextFrame )
3513  {
3514  InvalidateParaTextSelection( *pTextFrame );
3515  }
3516  }
3517  }
3518  }
3519  }
3520 }
3521 
3523 {
3524  assert(!GetShell()->IsPreview() || (mpPreview != nullptr));
3525 
3526  return GetShell()->IsPreview()
3527  ? mpPreview->GetVisArea()
3528  : GetShell()->VisArea();
3529 }
3530 
3532 {
3533  return GetShell()->GetDoc()->IsPrepareSelAll();
3534 }
3535 
3536 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AdjustMapMode(MapMode &rMapMode, const Point &rPoint) const
Adjust the MapMode so that the preview page appears at the proper position.
Definition: accmap.cxx:829
Point TopLeft() const
bool IsInvalidateTextSelection() const
Definition: accmap.cxx:534
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
void SetStates(AccessibleStates _nStates)
Definition: accmap.cxx:517
void InvalidateRelationSet(const SwFrame *pMaster, const SwFrame *pFollow)
Definition: accmap.cxx:2896
std::unique_ptr< SwAccessibleContextMap_Impl > mpFrameMap
Definition: accmap.hxx:94
void DisposePage(const SwPageFrame *pPageFrame)
Definition: accmap.cxx:852
void InvalidateContent(const SwFrame *pFrame)
Definition: accmap.cxx:2495
sal_uLong GetIndex() const
Definition: node.hxx:282
virtual tools::Rectangle GetVisibleArea() const override
Definition: accmap.cxx:3092
virtual bool IsDocumentSelAll() override
Definition: accmap.cxx:3531
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:444
sal_Int32 nIndex
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2810
const SwFrame * mpParentFrame
Definition: accmap.cxx:403
static bool createEvent(const SdrModel *pDoc, const SdrHint *pSdrHint, css::document::EventObject &aEvent)
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2167
SdrHintKind GetKind() const
size_t GetMarkCount() const
bool IsInvalidateRelation() const
Definition: accmap.cxx:530
Marks a position in the document model.
Definition: pam.hxx:35
std::pair< const SdrObject *,::rtl::Reference< ::accessibility::AccessibleShape > > SwAccessibleObjShape_Impl
Definition: accmap.cxx:275
iterator erase(const_iterator const &pos)
Definition: accmap.cxx:699
SdrView * GetDrawView()
Definition: vnew.cxx:375
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:39
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:188
std::map< key_type, mapped_type, SwShapeFunc > maMap
Definition: accmap.cxx:291
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3003
SwAccessibleEvent_Impl(EventType eT, SwAccessibleContext *pA, const SwAccessibleChild &rFrameOrObj, const SwRect &rR)
Definition: accmap.cxx:440
sal_Int32 GetChildIndex(const SwFrame &rParentFrame, vcl::Window &rChild) const
Definition: accmap.cxx:2955
size_t size() const
Definition: accmap.cxx:576
const_iterator cend() const
Definition: accmap.cxx:317
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
std::pair< iterator, bool > emplace(Args &&...args)
Definition: accmap.cxx:321
SwAccessibleParaSelection mapped_type
Definition: accmap.cxx:686
SwNodeIndex nNode
Definition: pam.hxx:37
SwFrameType GetType() const
Definition: frame.hxx:498
std::unique_ptr< SwAccessibleEventList_Impl > mpEvents
Definition: accmap.hxx:97
std::map< key_type, mapped_type, key_compare >::const_iterator const_iterator
Definition: accmap.cxx:646
sal_uIntPtr sal_uLong
SET_PARA m_setParaAdd
Definition: accmap.hxx:308
void InvalidateShapeSelection()
Definition: accmap.cxx:1146
const SwPageFrame * mpSelPage
Definition: accmap.cxx:712
const css::uno::Reference< css::drawing::XShape > & GetXShape() const
static bool IsEndnote(const SwFootnoteFrame *pFrame)
virtual ::accessibility::AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
Definition: accmap.cxx:3211
const SwPosition * GetMark() const
Definition: pam.hxx:209
SwRect maVisArea
Definition: accmap.cxx:709
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1147
std::pair< iterator, bool > emplace(Args &&...args)
Definition: accmap.cxx:698
TElementType * Next()
Definition: calbck.hxx:373
const SwAccessibleChild & GetFrameOrObj() const
Definition: accmap.cxx:511
std::map< key_type, mapped_type, key_compare >::iterator iterator
Definition: accmap.cxx:645
const SwRect & GetVisArea() const
Definition: accmap.cxx:743
tuple args
const SdrMarkList * GetMarkList() const
Definition: fesh.hxx:518
const MapMode & GetMapMode() const
virtual bool HasCursor()
SwNode & GetNode() const
Definition: ndindex.hxx:119
SwViewShell * mpVSh
Definition: accmap.hxx:102
long SwTwips
Definition: swtypes.hxx:49
iterator erase(const_iterator const &pos)
Definition: accmap.cxx:654
bool IsSelectFrameAnchoredAtPara(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
is a fly anchored at paragraph at rAnchorPos selected?
Definition: undobj.cxx:1583
SdrMark * GetMark(size_t nNum) const
uno::WeakReference< XAccessible > mapped_type
Definition: accmap.cxx:282
rtl::Reference< AccessibleShape > CreateAccessibleObject(const AccessibleShapeInfo &rShapeInfo, const AccessibleShapeTreeInfo &rShapeTreeInfo) const
::osl::Mutex maEventMutex
Definition: accmap.hxx:93
void FireEvents()
Definition: accmap.cxx:3065
bool IsCellFrame() const
Definition: frame.hxx:1202
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
bool IsDestroyFrameAnchoredAtChar(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
will DelContentIndex destroy a frame anchored at character at rAnchorPos?
Definition: undobj.cxx:1546
AccessibleStates GetAllStates() const
Definition: accmap.cxx:549
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
std::pair< iterator, bool > emplace(Args &&...args)
Definition: accmap.cxx:125
void InvalidatePreviewSelection(sal_uInt16 nSelPage)
Definition: accmap.cxx:3031
std::unique_ptr< SwAccessibleObjShape_Impl[]> Copy(size_t &rSize, const SwFEShell *pFESh, SwAccessibleObjShape_Impl **pSelShape) const
Definition: accmap.cxx:333
virtual SdrObjList * GetSubList() const
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
SfxHintId GetId() const
const unsigned int SELECTION_WITH_NUM
Definition: acctable.cxx:60
mutable::osl::Mutex maMutex
Definition: accmap.hxx:92
void InvalidatePosOrSize(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, const SwRect &rOldFrame)
Definition: accmap.cxx:2358
std::list< SwAccessibleEvent_Impl > maEvents
Definition: accmap.cxx:557
bool IsFlyFrame() const
Definition: frame.hxx:1186
SwViewShell * GetShell() const
Definition: accmap.hxx:169
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1998
long Right() const
void Top(const long nTop)
Definition: swrect.hxx:202
NONE
SwIndex nContent
Definition: pam.hxx:38
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
AccessibleStates GetStates() const
Definition: accmap.cxx:544
void SetModelBroadcaster(const css::uno::Reference< css::document::XShapeEventBroadcaster > &rxModelBroadcaster)
static bool IsInSameLevel(const SdrObject *pObj, const SwFEShell *pFESh)
Definition: accmap.cxx:2070
css::uno::Reference< css::accessibility::XAccessible > GetDocumentPreview(const std::vector< std::unique_ptr< PreviewPage >> &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:1855
::accessibility::AccessibleShapeTreeInfo maInfo
Definition: accmap.cxx:290
Size GetPreviewPageSizeByPageNum(sal_uInt16 _nPageNum) const
get size of a preview page by its physical page number
std::vector< tools::Rectangle > Rectangles
Definition: accmap.cxx:705
std::map< key_type, mapped_type, key_compare > maMap
Definition: accmap.cxx:648
SwRect & Intersection(const SwRect &rRect)
Definition: swrect.cxx:54
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
Point PixelToCore(const Point &rPoint) const
Definition: accmap.cxx:3240
const SwRect & GetOldBox() const
Definition: accmap.cxx:501
const SwTable & GetTable() const
Definition: node.hxx:497
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
void AddShapeContext(const SdrObject *pObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccShape)
Definition: accmap.cxx:2077
long Top() const
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:958
std::pair< iterator, bool > emplace(Args &&...args)
Definition: accmap.cxx:653
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:119
void Right(const long nRight)
Definition: swrect.hxx:198
bool IsUpdateCursorPos() const
Definition: accmap.cxx:522
static void lcl_CorrectRectangle(tools::Rectangle &rRect, const tools::Rectangle &rSource, const tools::Rectangle &rInGrid)
Definition: accmap.cxx:3271
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: viewsh.cxx:2584
SwPagePreviewLayout * PagePreviewLayout()
Definition: viewpg.cxx:32
const SwPageFrame * GetSelPage() const
Definition: accmap.cxx:752
static void AdjustLogicPgRectToVisibleArea(SwRect &_iorLogicPgSwRect, const SwRect &_rPreviewPgSwRect, const Size &_rPreviewWinSize)
adjust logic page rectangle to its visible part
Definition: accmap.cxx:859
bool IsEmpty() const
Definition: swrect.hxx:294
SwPaM * GetNext()
Definition: pam.hxx:264
void InvalidateParaTextSelection(const SwTextFrame &_rTextFrame)
invalidation of text selection of a paragraph
Definition: accmap.cxx:2911
std::pair< const key_type, mapped_type > value_type
Definition: accmap.cxx:283
void FireEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:925
std::pair< const key_type, mapped_type > value_type
Definition: accmap.cxx:643
std::unique_ptr< SwAccessibleEventMap_Impl > mpEventMap
Definition: accmap.hxx:98
SdrObject * GetMarkedSdrObj() const
EventType GetType() const
Definition: accmap.cxx:487
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool FrameContainsNode(SwContentFrame const &rFrame, sal_uLong nNodeIndex)
Definition: txtfrm.cxx:284
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: accmap.cxx:3235
UNDERLYING_TYPE get() const
Style of a layout element.
Definition: frmfmt.hxx:57
iterator erase(const_iterator const &pos)
Definition: accmap.cxx:126
void SetScaleX(const Fraction &rScaleX)
#define TOOLS_WARN_EXCEPTION(area, stream)
bool IsPrepareSelAll() const
Definition: doc.hxx:560
void SetTop(long v)
const_iterator cbegin() const
Definition: accmap.cxx:316
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView()
Definition: accmap.cxx:1850
Size GetPreviewPageSize(sal_uInt16 _nPreviewPageNum) const
get size of a dedicated preview page
Definition: accmap.cxx:3321
iterator find(const key_type &key)
Definition: accmap.cxx:696
const SdrObject * key_type
Definition: accmap.cxx:281
iterator find(const key_type &key)
Definition: accmap.cxx:123
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwRect & VisArea() const
Definition: viewsh.cxx:558
void InvalidateCursorPosition(const css::uno::Reference< css::accessibility::XAccessible > &rAcc)
const SwPosition * GetPoint() const
Definition: pam.hxx:207
const SwFrame * key_type
Definition: accmap.cxx:99
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwAccessibleEvent_Impl(EventType eT)
Definition: accmap.cxx:431
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView_(bool bPagePreview)
Definition: accmap.cxx:1788
bool ActionPend() const
Definition: viewsh.hxx:199
TElementType * First()
Definition: calbck.hxx:342
int i
accessibility implementation for the page (SwPageFrame) The page is only visible in the page preview...
Definition: accpage.hxx:32
bool IsPreview() const
Definition: viewsh.hxx:491
FlyAnchors.
Definition: fmtanchr.hxx:34
void SetOrigin(const Point &rOrigin)
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
void SetRight(long v)
uno::WeakReference< XAccessible > key_type
Definition: accmap.cxx:685
std::map< key_type, mapped_type, key_compare >::iterator iterator
Definition: accmap.cxx:689
static bool GetChildIndex(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, const sw::access::SwAccessibleChild &rChild, sal_Int32 &rPos, bool bInPagePreview)
Definition: accframe.cxx:138
tools::Rectangle CoreToPixel(const tools::Rectangle &rRect) const
Definition: accmap.cxx:3285
void InvalidateStates(AccessibleStates _nStates)
void InvalidateAttr()
#i88069# - attributes has changed
void GetMapMode(const Point &_rPoint, MapMode &_orMapMode) const
get mapping mode for LogicToPixel and PixelToLogic conversions
Definition: accmap.cxx:3309
const css::uno::Reference< css::beans::XPropertySet > & GetControlModel() const
SwAccessibleChildFunc key_compare
Definition: accmap.cxx:644
static ShapeTypeHandler & Instance()
long Bottom() const
const SwRect & GetVisArea() const
Definition: accmap.cxx:3522
void SetScaleY(const Fraction &rScaleY)
dgm::Point & mrPoint
std::pair< const key_type, mapped_type > value_type
Definition: accmap.cxx:101
bool IsGroupObject() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: acccontext.cxx:687
bool IsInside(const Point &rPOINT) const
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual ~SwAccessibleMap() override
Definition: accmap.cxx:1724
Fraction maScale
Definition: accmap.cxx:710
void InvalidateRelation(sal_uInt16 nType)
ring_container GetRingContainer()
Definition: ring.hxx:240
bool IsInvalidateStates() const
Definition: accmap.cxx:526
iterator find(const key_type &key)
Definition: accmap.cxx:319
access to an accessible Writer document
Definition: accdoc.hxx:93
A page of the document layout.
Definition: pagefrm.hxx:40
static SwNodeType GetNodeType(const SwFlyFrame *pFlyFrame)
void AddAccessibleShell()
Definition: rootfrm.hxx:385
Point OutputToAbsoluteScreenPixel(const Point &rPos) const
const SwPosition * Start() const
Definition: pam.hxx:212
AccessibleStates mnStates
Definition: accmap.cxx:400
SwAccessibleChild const maFrameOrObj
Definition: accmap.cxx:396
std::list< SwAccessibleEvent_Impl >::iterator begin()
Definition: accmap.cxx:577
void SetOldBox(const SwRect &rOldBox)
Definition: accmap.cxx:506
void InvalidateFocus()
Definition: accmap.cxx:2781
void SetViewForwarder(const IAccessibleViewForwarder *pViewForwarder)
Point PixelToLogic(const Point &rDevicePt) const
Point LogicToPixel(const Point &rLogicPt) const
std::unique_ptr< SwAccessibleShapeMap_Impl > mpShapeMap
Definition: accmap.hxx:95
bool empty() const
Definition: accmap.cxx:318
uno::WeakReference< XAccessible > mxAcc
Definition: accmap.cxx:395
void RemoveAccessibleShell()
Definition: rootfrm.hxx:386
SVX_DLLPUBLIC SdrObject * GetSdrObjectFromXShape(const css::uno::Reference< css::drawing::XShape > &xShape)
std::pair< const key_type, mapped_type > value_type
Definition: accmap.cxx:687
void A11yDispose(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, bool bRecursive=false, bool bCanSkipInvisible=true)
Definition: accmap.cxx:2232
std::map< key_type, mapped_type, key_compare > maMap
Definition: accmap.cxx:692
void AddGroupContext(const SdrObject *pParentObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccParent)
Definition: accmap.cxx:2111
void Left(const long nLeft)
Definition: swrect.hxx:193
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void Bottom(const long nBottom)
Definition: swrect.hxx:207
void InvalidateRelationSet_(const SwFrame *pFrame, bool bFrom)
Definition: accmap.cxx:2849
void InvalidateShapeInParaSelection()
Definition: accmap.cxx:1165
std::map< key_type, mapped_type, key_compare >::const_iterator const_iterator
Definition: accmap.cxx:286
bool IsSeletedInDoc() const
Definition: acccontext.hxx:354
const css::uno::Reference< css::document::XShapeEventBroadcaster > & GetModelBroadcaster() const
iterator erase(const_iterator const &pos)
Definition: accmap.cxx:322
const ::accessibility::AccessibleShapeTreeInfo & GetInfo() const
Definition: accmap.cxx:309
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
std::map< key_type, mapped_type, key_compare >::const_iterator const_iterator
Definition: accmap.cxx:690
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true)
::rtl::Reference< SwAccessibleContext > GetContext() const
Definition: accmap.cxx:492
vcl::Window * GetWin() const
Definition: viewsh.hxx:340
void InvalidateAttr(const SwTextFrame &rTextFrame)
Definition: accmap.cxx:2533
Rectangles maPreviewRects
Definition: accmap.cxx:706
ShapeTypeId GetTypeId(const OUString &aServiceName) const
sal_Int32 GetIndex() const
Definition: index.hxx:95
std::map< key_type, mapped_type, key_compare > maMap
Definition: accmap.cxx:106
virtual bool ReplaceChild(::accessibility::AccessibleShape *pCurrentChild, const css::uno::Reference< css::drawing::XShape > &_rxShape, const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo &_rShapeTreeInfo) override
Definition: accmap.cxx:3134
virtual SwDrawModel * GetOrCreateDrawModel()=0
void InvalidateEditableStates(const SwFrame *_pFrame)
Definition: accmap.cxx:2822
void UpdatePreview(const std::vector< std::unique_ptr< PreviewPage >> &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:2991
std::unique_ptr< SwAccessibleSelectedParas_Impl > BuildSelectedParas()
method to build up a new data structure of the accessible paragraphs, which have a selection ...
Definition: accmap.cxx:3332
SwAccessibleEvent_Impl(EventType eT, SwAccessibleContext *pA, const SwAccessibleChild &rFrameOrObj)
Definition: accmap.cxx:410
const SwPosition * End() const
Definition: pam.hxx:217
void SetBottom(long v)
bool Contains(const SwFrame *pFrame) const
Definition: accmap.cxx:2227
const SwFrame * GetParent() const
Definition: accframe.hxx:155
size_t IsObjSelected() const
Definition: feshview.cxx:1158
bool IsPageFrame() const
Definition: frame.hxx:1154
virtual Point LogicToPixel(const Point &rPoint) const override
Definition: accmap.cxx:3101
void InvalidateParaFlowRelation(const SwTextFrame &_rTextFrame, const bool _bFrom)
invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
Definition: accmap.cxx:2904
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1870
void InvalidateTextSelection()
#i27301# - text selection has changed
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:114
long Left() const
SwAccessibleChild key_type
Definition: accmap.cxx:641
SdrObject * getParentSdrObjectFromSdrObject() const
void Update(const SwAccessibleMap &rAccMap, const std::vector< std::unique_ptr< PreviewPage >> &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:762
const SwTabFrame * GetFollow() const
Definition: tabfrm.hxx:243
std::map< key_type, mapped_type, key_compare >::const_iterator const_iterator
Definition: accmap.cxx:104
bool IsFiring() const
Definition: accmap.cxx:569
virtual bool SetSelectedState(bool bSeleted) override
SwAccessibleShapeMap_Impl(SwAccessibleMap const *pMap)
Definition: accmap.cxx:295
std::map< key_type, mapped_type, key_compare >::iterator iterator
Definition: accmap.cxx:103
virtual bool SetState(sal_Int16 aState) override
accessibility implementation for the page preview.
Definition: accpreview.hxx:33
SET_PARA m_setParaRemove
Definition: accmap.hxx:309
void SetLeft(long v)
bool IsObjSameLevelWithMarked(const SdrObject *pObj) const
Definition: feshview.cxx:1206
void Clear()
Definition: swrect.hxx:298
#define DBG_TESTSOLARMUTEX()
SwShapeFunc key_compare
Definition: accmap.cxx:284
void SetCursorContext(const ::rtl::Reference< SwAccessibleContext > &rCursorContext)
Definition: accmap.cxx:2814
void Dispose(const T &xInterface)
bool IsPageSelected(const SwPageFrame *pPageFrame) const
Definition: accmap.cxx:3060
std::unique_ptr< SwAccPreviewData > mpPreview
for page preview: store preview data, VisArea, and mapping of preview-to-display coordinates ...
Definition: accmap.hxx:105
std::list< SwAccessibleEvent_Impl >::iterator erase(const std::list< SwAccessibleEvent_Impl >::iterator &aPos)
Definition: accmap.cxx:584
SwShapeList_Impl mvShapes
Definition: accmap.hxx:96
static bool AreInSameTable(const uno::Reference< XAccessible > &rAcc, const SwFrame *pFrame)
Definition: accmap.cxx:889
SwAccessibleEvent_Impl(EventType eT, SwAccessibleContext *pA, const SwAccessibleChild &rFrameOrObj, const AccessibleStates _nStates)
Definition: accmap.cxx:456
void SetDevice(OutputDevice *pWindow)
void InvalidateTextSelectionOfAllParas()
invalidation of text selection of all paragraphs
Definition: accmap.cxx:3421
std::list< SwAccessibleEvent_Impl >::iterator mapped_type
Definition: accmap.cxx:642
uno::WeakReference< XAccessible > mapped_type
Definition: accmap.cxx:100
SwXAccWeakRefComp key_compare
Definition: accmap.cxx:688
void SetType(EventType eT)
Definition: accmap.cxx:483
std::unique_ptr< SwAccessibleContextMap_Impl > mpSeletedFrameMap
Definition: accmap.hxx:121
std::list< SwAccessibleEvent_Impl >::iterator insert(const std::list< SwAccessibleEvent_Impl >::iterator &aIter, const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:579
void RemoveGroupContext(const SdrObject *pParentObj)
Definition: accmap.cxx:2089
bool HasFocus() const
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
iterator find(const key_type &key)
Definition: accmap.cxx:651
bool IsTextNode() const
Definition: node.hxx:636
SwAccessibleEvent_Impl(EventType eT, const SwAccessibleChild &rFrameOrObj)
Definition: accmap.cxx:420
void DoInvalidateShapeSelection(bool bInvalidateFocusMode=false)
Definition: accmap.cxx:1505
AccessibleStates
Definition: accmap.hxx:70
SwAccessibleEvent_Impl(EventType eT, const SwFrame *pParentFrame, const SwAccessibleChild &rFrameOrObj, const SwRect &rR)
Definition: accmap.cxx:470
void InvalidateSelection(const SwPageFrame *_pSelectedPageFrame)
Definition: accmap.cxx:809
bool IsFrameSelected() const
Definition: feshview.cxx:1166
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61
static long lcl_CorrectCoarseValue(long aCoarseValue, long aFineValue, long aRefValue, bool bToLower)
Definition: accmap.cxx:3252
bool mbShapeSelected
Definition: accmap.hxx:109
AnyEventRef aEvent
std::list< SwAccessibleEvent_Impl >::iterator end()
Definition: accmap.cxx:578
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
void AppendEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:1007
Rectangles maLogicRects
Definition: accmap.cxx:707
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1075
bool IsInvalidateTextAttrs() const
Definition: accmap.cxx:539
css::uno::WeakReference< css::accessibility::XAccessible > mxCursorContext
Definition: accmap.hxx:107
std::unique_ptr< SwAccessibleSelectedParas_Impl > mpSelectedParas
Definition: accmap.hxx:101
bool IsNoXaccParentFrame() const
Definition: accmap.cxx:404
SwAccessibleMap(SwViewShell *pSh)
Definition: accmap.cxx:1716
const SdrObject * GetObject() const
std::map< key_type, mapped_type, key_compare >::iterator iterator
Definition: accmap.cxx:285
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo