LibreOffice Module sw (master)  1
accdoc.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <vcl/window.hxx>
21 #include <rootfrm.hxx>
22 
23 #include <com/sun/star/accessibility/AccessibleRole.hpp>
24 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
25 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29 #include <vcl/svapp.hxx>
31 #include <viewsh.hxx>
32 #include <doc.hxx>
33 #include <accmap.hxx>
34 #include "accdoc.hxx"
35 #include <strings.hrc>
36 #include <pagefrm.hxx>
37 
38 #include <swatrset.hxx>
39 #include <docsh.hxx>
40 #include <crsrsh.hxx>
41 #include <fesh.hxx>
42 #include <fmtclds.hxx>
43 #include <flyfrm.hxx>
44 #include <txtfrm.hxx>
45 #include <sectfrm.hxx>
46 #include <section.hxx>
47 #include <svx/unoapi.hxx>
48 #include <swmodule.hxx>
49 #include <svtools/colorcfg.hxx>
50 
51 #include <fmtanchr.hxx>
52 #include <viewimp.hxx>
53 #include <dview.hxx>
54 #include <dcontact.hxx>
55 #include <svx/svdmark.hxx>
56 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentView";
57 const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleDocumentView";
58 
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::accessibility;
61 
62 using lang::IndexOutOfBoundsException;
63 
64 // SwAccessibleDocumentBase: base class for SwAccessibleDocument and
65 // SwAccessiblePreview
66 
68  std::shared_ptr<SwAccessibleMap> const& pMap)
69  : SwAccessibleContext(pMap, AccessibleRole::DOCUMENT_TEXT,
70  pMap->GetShell()->GetLayout())
71  , mxParent(pMap->GetShell()->GetWin()->GetAccessibleParentWindow()->GetAccessible())
72  , mpChildWin(nullptr)
73 {
74 }
75 
77 {
78 }
79 
81 {
82  SolarMutexGuard aGuard;
83 
84  SwRect aOldVisArea( GetVisArea() );
85  const SwRect& rNewVisArea = GetMap()->GetVisArea();
86  if( aOldVisArea != rNewVisArea )
87  {
89  // #i58139# - showing state of document view needs also be updated.
90  // Thus, call method <Scrolled(..)> instead of <ChildrenScrolled(..)>
91  // ChildrenScrolled( GetFrame(), aOldVisArea );
92  Scrolled( aOldVisArea );
93  }
94 }
95 
96 void SwAccessibleDocumentBase::AddChild( vcl::Window *pWin, bool bFireEvent )
97 {
98  SolarMutexGuard aGuard;
99 
100  OSL_ENSURE( !mpChildWin, "only one child window is supported" );
101  if( !mpChildWin )
102  {
103  mpChildWin = pWin;
104 
105  if( bFireEvent )
106  {
107  AccessibleEventObject aEvent;
108  aEvent.EventId = AccessibleEventId::CHILD;
109  aEvent.NewValue <<= mpChildWin->GetAccessible();
110  FireAccessibleEvent( aEvent );
111  }
112  }
113 }
114 
116 {
117  SolarMutexGuard aGuard;
118 
119  OSL_ENSURE( !mpChildWin || pWin == mpChildWin, "invalid child window to remove" );
120  if( mpChildWin && pWin == mpChildWin )
121  {
122  AccessibleEventObject aEvent;
123  aEvent.EventId = AccessibleEventId::CHILD;
124  aEvent.OldValue <<= mpChildWin->GetAccessible();
125  FireAccessibleEvent( aEvent );
126 
127  mpChildWin = nullptr;
128  }
129 }
130 
132 {
133  SolarMutexGuard aGuard;
134 
135  // ThrowIfDisposed is called by parent
136 
137  sal_Int32 nChildren = SwAccessibleContext::getAccessibleChildCount();
138  if( !IsDisposing() && mpChildWin )
139  nChildren++;
140 
141  return nChildren;
142 }
143 
144 uno::Reference< XAccessible> SAL_CALL
146 {
147  SolarMutexGuard aGuard;
148 
149  if( mpChildWin )
150  {
151  ThrowIfDisposed();
152 
153  if ( nIndex == GetChildCount( *(GetMap()) ) )
154  {
155  return mpChildWin->GetAccessible();
156  }
157  }
158 
160 }
161 
162 uno::Reference< XAccessible> SAL_CALL SwAccessibleDocumentBase::getAccessibleParent()
163 {
164  return mxParent;
165 }
166 
168 {
169  SolarMutexGuard aGuard;
170 
171  uno::Reference < XAccessibleContext > xAcc( mxParent->getAccessibleContext() );
172  uno::Reference < XAccessible > xThis( this );
173  sal_Int32 nCount = xAcc->getAccessibleChildCount();
174 
175  for( sal_Int32 i=0; i < nCount; i++ )
176  {
177  try
178  {
179  if( xAcc->getAccessibleChild( i ) == xThis )
180  return i;
181  }
182  catch(const css::lang::IndexOutOfBoundsException &)
183  {
184  return -1;
185  }
186  }
187  return -1;
188 }
189 
191 {
192  return GetResource( STR_ACCESS_DOC_DESC );
193 }
194 
196 {
197  SolarMutexGuard g;
198 
199  OUString sAccName = GetResource( STR_ACCESS_DOC_WORDPROCESSING );
200  SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr;
201  if ( pDoc )
202  {
203  OUString sFileName = pDoc->getDocAccTitle();
204  if ( sFileName.isEmpty() )
205  {
206  SwDocShell* pDocSh = pDoc->GetDocShell();
207  if ( pDocSh )
208  {
209  sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME );
210  }
211  }
212 
213  if ( !sFileName.isEmpty() )
214  {
215  sAccName = sFileName + " - " + sAccName;
216  }
217  }
218 
219  return sAccName;
220 }
221 
222 awt::Rectangle SAL_CALL SwAccessibleDocumentBase::getBounds()
223 {
224  try
225  {
226  SolarMutexGuard aGuard;
227 
228  vcl::Window *pWin = GetWindow();
229  if (!pWin)
230  {
231  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
232  }
233 
235  awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
236  aPixBounds.GetWidth(), aPixBounds.GetHeight() );
237 
238  return aBox;
239  }
240  catch(const css::lang::IndexOutOfBoundsException &)
241  {
242  return awt::Rectangle();
243  }
244 }
245 
247 {
248  SolarMutexGuard aGuard;
249 
250  vcl::Window *pWin = GetWindow();
251  if (!pWin)
252  {
253  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
254  }
255 
256  Point aPixPos( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ).TopLeft() );
257  awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
258 
259  return aLoc;
260 }
261 
263 {
264  SolarMutexGuard aGuard;
265 
266  vcl::Window *pWin = GetWindow();
267  if (!pWin)
268  {
269  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
270  }
271 
272  Point aPixPos( pWin->GetWindowExtentsRelative( nullptr ).TopLeft() );
273  awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
274 
275  return aLoc;
276 }
277 
278 css::awt::Size SAL_CALL SwAccessibleDocumentBase::getSize()
279 {
280  SolarMutexGuard aGuard;
281 
282  vcl::Window *pWin = GetWindow();
283  if (!pWin)
284  {
285  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
286  }
287 
288  Size aPixSize( pWin->GetWindowExtentsRelative( nullptr ).GetSize() );
289  awt::Size aSize( aPixSize.Width(), aPixSize.Height() );
290 
291  return aSize;
292 }
293 
295  const awt::Point& aPoint )
296 {
297  SolarMutexGuard aGuard;
298 
299  vcl::Window *pWin = GetWindow();
300  if (!pWin)
301  {
302  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
303  }
304 
305  tools::Rectangle aPixBounds( pWin->GetWindowExtentsRelative( nullptr ) );
306  aPixBounds.Move(-aPixBounds.Left(), -aPixBounds.Top());
307 
308  Point aPixPoint( aPoint.X, aPoint.Y );
309  return aPixBounds.IsInside( aPixPoint );
310 }
311 
312 uno::Reference< XAccessible > SAL_CALL SwAccessibleDocumentBase::getAccessibleAtPoint(
313  const awt::Point& aPoint )
314 {
315  SolarMutexGuard aGuard;
316 
317  if( mpChildWin )
318  {
319  ThrowIfDisposed();
320 
321  vcl::Window *pWin = GetWindow();
322  if (!pWin)
323  {
324  throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
325  }
326 
327  Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to window
328  if( mpChildWin->GetWindowExtentsRelative( pWin ).IsInside( aPixPoint ) )
329  return mpChildWin->GetAccessible();
330  }
331 
333 }
334 
335 // SwAccessibleDocument
336 
338  ::utl::AccessibleStateSetHelper& rStateSet )
339 {
340  SwAccessibleContext::GetStates( rStateSet );
341 
342  // MULTISELECTABLE
343  rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
344  rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
345 }
346 
348  std::shared_ptr<SwAccessibleMap> const& pInitMap)
349  : SwAccessibleDocumentBase(pInitMap)
350  , maSelectionHelper(*this)
351 {
352  SetName(pInitMap->GetDocName());
353  vcl::Window *pWin = pInitMap->GetShell()->GetWin();
354  if( pWin )
355  {
356  pWin->AddChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
357  sal_uInt16 nCount = pWin->GetChildCount();
358  for( sal_uInt16 i=0; i < nCount; i++ )
359  {
360  vcl::Window* pChildWin = pWin->GetChild( i );
361  if( pChildWin &&
362  AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
363  AddChild( pChildWin, false );
364  }
365  }
366 }
367 
369 {
370  vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr;
371  if( pWin )
372  pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
373 }
374 
375 void SwAccessibleDocument::Dispose(bool bRecursive, bool bCanSkipInvisible)
376 {
377  OSL_ENSURE( GetFrame() && GetMap(), "already disposed" );
378 
379  vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr;
380  if( pWin )
381  pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
382  SwAccessibleContext::Dispose(bRecursive, bCanSkipInvisible);
383 }
384 
385 IMPL_LINK( SwAccessibleDocument, WindowChildEventListener, VclWindowEvent&, rEvent, void )
386 {
387  OSL_ENSURE( rEvent.GetWindow(), "Window???" );
388  switch ( rEvent.GetId() )
389  {
390  case VclEventId::WindowShow: // send create on show for direct accessible children
391  {
392  vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
393  if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
394  {
395  AddChild( pChildWin );
396  }
397  }
398  break;
399  case VclEventId::WindowHide: // send destroy on hide for direct accessible children
400  {
401  vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
402  if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
403  {
404  RemoveChild( pChildWin );
405  }
406  }
407  break;
408  case VclEventId::ObjectDying: // send destroy on hide for direct accessible children
409  {
410  vcl::Window* pChildWin = rEvent.GetWindow();
411  if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
412  {
413  RemoveChild( pChildWin );
414  }
415  }
416  break;
417  default: break;
418  }
419 }
420 
422 {
423  return sImplementationName;
424 }
425 
426 sal_Bool SAL_CALL SwAccessibleDocument::supportsService(const OUString& sTestServiceName)
427 {
428  return cppu::supportsService(this, sTestServiceName);
429 }
430 
431 uno::Sequence< OUString > SAL_CALL SwAccessibleDocument::getSupportedServiceNames()
432 {
434 }
435 
436 // XInterface
437 
439  const uno::Type& rType )
440 {
441  uno::Any aRet;
443  {
444  uno::Reference<XAccessibleSelection> aSelect = this;
445  aRet <<= aSelect;
446  }
448  {
449  uno::Reference<XAccessibleExtendedAttributes> aAttribute = this;
450  aRet <<= aAttribute;
451  }
453  {
454  uno::Reference<XAccessibleGetAccFlowTo> AccFlowTo = this;
455  aRet <<= AccFlowTo;
456  }
457  else
458  aRet = SwAccessibleContext::queryInterface( rType );
459  return aRet;
460 }
461 
462 // XTypeProvider
463 uno::Sequence< uno::Type > SAL_CALL SwAccessibleDocument::getTypes()
464 {
465  return cppu::OTypeCollection(
467  SwAccessibleDocumentBase::getTypes() ).getTypes();
468 }
469 
470 uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleDocument::getImplementationId()
471 {
472  return css::uno::Sequence<sal_Int8>();
473 }
474 
475 // XAccessibleSelection
476 
478  sal_Int32 nChildIndex )
479 {
481 }
482 
484  sal_Int32 nChildIndex )
485 {
486  return maSelectionHelper.isAccessibleChildSelected(nChildIndex);
487 }
488 
490 {
491 }
492 
494 {
496 }
497 
499 {
501 }
502 
504  sal_Int32 nSelectedChildIndex )
505 {
506  return maSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex);
507 }
508 
509 // index has to be treated as global child index.
511  sal_Int32 nChildIndex )
512 {
514 }
515 
517 {
518  SolarMutexGuard g;
519 
520  uno::Any anyAtrribute;
521  SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr;
522 
523  if (!pDoc)
524  return anyAtrribute;
525  SwCursorShell* pCursorShell = GetCursorShell();
526  if( !pCursorShell )
527  return anyAtrribute;
528 
529  SwFEShell* pFEShell = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr
530  ? static_cast<SwFEShell*>( pCursorShell )
531  : nullptr;
532  OUString sAttrName;
533  OUString sValue;
534  sal_uInt16 nPage, nLogPage;
535  OUString sDisplay;
536 
537  if( pFEShell )
538  {
539  pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay);
540  sAttrName = "page-name:";
541 
542  sValue = sAttrName + sDisplay ;
543  sAttrName = ";page-number:";
544  sValue += sAttrName;
545  sValue += OUString::number( nPage ) ;
546  sAttrName = ";total-pages:";
547  sValue += sAttrName;
548  sValue += OUString::number( pCursorShell->GetPageCnt() ) ;
549  sValue += ";";
550 
551  sAttrName = "line-number:";
552 
553  SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame();
554  SwPageFrame* pCurrPage=static_cast<SwFrame*>(pCurrFrame)->FindPageFrame();
555  sal_uLong nLineNum = 0;
556  SwTextFrame* pTextFrame = nullptr;
557  SwTextFrame* pCurrTextFrame = nullptr;
558  pTextFrame = static_cast< SwTextFrame* >(pCurrPage->ContainsContent());
559  if (pCurrFrame->IsInFly())//such as, graphic,chart
560  {
561  SwFlyFrame *pFlyFrame = pCurrFrame->FindFlyFrame();
562  const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor();
563  RndStdIds eAnchorId = rAnchor.GetAnchorId();
564  if(eAnchorId == RndStdIds::FLY_AS_CHAR)
565  {
566  const SwFrame *pSwFrame = pFlyFrame->GetAnchorFrame();
567  if(pSwFrame->IsTextFrame())
568  pCurrTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pSwFrame));
569  }
570  }
571  else
572  {
573  assert(dynamic_cast<SwTextFrame*>(pCurrFrame));
574  pCurrTextFrame = static_cast<SwTextFrame* >(pCurrFrame);
575  }
576  //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer
577  SwFrame* pFrame = pCurrTextFrame;
578  while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() )
579  pFrame = pFrame->GetUpper();
580  if ( pFrame )
581  pCurrTextFrame = nullptr;
582  //check shape
583  if(pCursorShell->Imp()->GetDrawView())
584  {
585  const SdrMarkList &rMrkList = pCursorShell->Imp()->GetDrawView()->GetMarkedObjectList();
586  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
587  {
588  SdrObject *pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
589  SwFrameFormat* pFormat = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat();
590  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
591  if( RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId() )
592  pCurrTextFrame = nullptr;
593  }
594  }
595  //calculate line number
596  if (pCurrTextFrame && pTextFrame)
597  {
598  if (!(pCurrTextFrame->IsInTab() || pCurrTextFrame->IsInFootnote()))
599  {
600  while( pTextFrame != pCurrTextFrame )
601  {
602  //check header/footer
603  pFrame = pTextFrame;
604  while ( pFrame && !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() )
605  pFrame = pFrame->GetUpper();
606  if ( pFrame )
607  {
608  pTextFrame = static_cast< SwTextFrame*>(pTextFrame->GetNextContentFrame());
609  continue;
610  }
611  if (!(pTextFrame->IsInTab() || pTextFrame->IsInFootnote() || pTextFrame->IsInFly()))
612  nLineNum += pTextFrame->GetThisLines();
613  pTextFrame = static_cast< SwTextFrame* >(pTextFrame ->GetNextContentFrame());
614  }
615  SwPaM* pCaret = pCursorShell->GetCursor();
616  if (!pCurrTextFrame->IsEmpty() && pCaret)
617  {
618  assert(pCurrTextFrame->IsTextFrame());
619  const SwPosition* pPoint = nullptr;
620  if (pCurrTextFrame->IsInFly())
621  {
622  SwFlyFrame *pFlyFrame = pCurrTextFrame->FindFlyFrame();
623  const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor();
624  pPoint = rAnchor.GetContentAnchor();
625  SwContentNode *const pNode(pPoint->nNode.GetNode().GetContentNode());
626  pCurrTextFrame = pNode
627  ? static_cast<SwTextFrame*>(pNode->getLayoutFrame(
628  pCurrTextFrame->getRootFrame(), pPoint))
629  : nullptr;
630  }
631  else
632  pPoint = pCaret->GetPoint();
633  if (pCurrTextFrame)
634  {
635  TextFrameIndex const nActPos(pCurrTextFrame->MapModelToViewPos(*pPoint));
636  nLineNum += pCurrTextFrame->GetLineCount( nActPos );
637  }
638  }
639  else
640  ++nLineNum;
641  }
642  }
643 
644  sValue += sAttrName;
645  sValue += OUString::number( nLineNum ) ;
646 
647  sValue += ";";
648 
649  SwFrame* pCurrCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame();
650 
651  sAttrName = "column-number:";
652  sValue += sAttrName;
653 
654  int nCurrCol = 1;
655  if(pCurrCol!=nullptr)
656  {
657  //SwLayoutFrame* pParent = pCurrCol->GetUpper();
658  SwFrame* pCurrPageCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame();
659  while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrame())
660  {
661  pCurrPageCol = pCurrPageCol->GetUpper();
662  }
663 
664  SwLayoutFrame* pParent = pCurrPageCol->GetUpper();
665 
666  if(pParent!=nullptr)
667  {
668  SwFrame* pCol = pParent->Lower();
669  while(pCol&&(pCol!=pCurrPageCol))
670  {
671  pCol = pCol->GetNext();
672  ++nCurrCol;
673  }
674  }
675  }
676  sValue += OUString::number( nCurrCol ) ;
677  sValue += ";";
678 
679  sAttrName = "total-columns:";
680 
681  const SwFormatCol &rFormatCol=pCurrPage->GetAttrSet()->GetCol();
682  sal_uInt16 nColCount=rFormatCol.GetNumCols();
683  nColCount = nColCount>0?nColCount:1;
684  sValue += sAttrName;
685  sValue += OUString::number( nColCount ) ;
686 
687  sValue += ";";
688 
689  SwSectionFrame* pCurrSctFrame=static_cast<SwFrame*>(pCurrFrame)->FindSctFrame();
690  if(pCurrSctFrame!=nullptr && pCurrSctFrame->GetSection()!=nullptr )
691  {
692  sAttrName = "section-name:";
693 
694  sValue += sAttrName;
695  OUString sectionName = pCurrSctFrame->GetSection()->GetSectionName();
696 
697  sectionName = sectionName.replaceFirst( "\\" , "\\\\" );
698  sectionName = sectionName.replaceFirst( "=" , "\\=" );
699  sectionName = sectionName.replaceFirst( ";" , "\\;" );
700  sectionName = sectionName.replaceFirst( "," , "\\," );
701  sectionName = sectionName.replaceFirst( ":" , "\\:" );
702 
703  sValue += sectionName;
704 
705  sValue += ";";
706 
707  //section-columns-number
708  sAttrName = "section-columns-number:";
709 
710  nCurrCol = 1;
711 
712  if(pCurrCol!=nullptr)
713  {
714  SwLayoutFrame* pParent = pCurrCol->GetUpper();
715  if(pParent!=nullptr)
716  {
717  SwFrame* pCol = pParent->Lower();
718  while(pCol&&(pCol!=pCurrCol))
719  {
720  pCol = pCol->GetNext();
721  nCurrCol +=1;
722  }
723  }
724  }
725  sValue += sAttrName;
726  sValue += OUString::number( nCurrCol ) ;
727  sValue += ";";
728 
729  //section-total-columns
730  sAttrName = "section-total-columns:";
731  const SwFormatCol &rFormatSctCol=pCurrSctFrame->GetAttrSet()->GetCol();
732  sal_uInt16 nSctColCount=rFormatSctCol.GetNumCols();
733  nSctColCount = nSctColCount>0?nSctColCount:1;
734  sValue += sAttrName;
735  sValue += OUString::number( nSctColCount ) ;
736 
737  sValue += ";";
738  }
739 
740  anyAtrribute <<= sValue;
741  }
742  return anyAtrribute;
743 }
744 
746 {
747  SolarMutexGuard aGuard;
748  return sal_Int32(SW_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor);
749 }
750 
751 css::uno::Sequence< css::uno::Any >
752  SAL_CALL SwAccessibleDocument::getAccFlowTo(const css::uno::Any& rAny, sal_Int32 nType)
753 {
754  SolarMutexGuard g;
755 
756  const sal_Int32 FORSPELLCHECKFLOWTO = 1;
757  const sal_Int32 FORFINDREPLACEFLOWTO = 2;
758  SwAccessibleMap* pAccMap = GetMap();
759  if ( !pAccMap )
760  {
761  return uno::Sequence< uno::Any >();
762  }
763 
764  if ( nType == FORSPELLCHECKFLOWTO )
765  {
766  uno::Reference< css::drawing::XShape > xShape;
767  rAny >>= xShape;
768  if( xShape.is() )
769  {
770  SdrObject* pObj = GetSdrObjectFromXShape(xShape);
771  if( pObj )
772  {
773  uno::Reference<XAccessible> xAcc = pAccMap->GetContext(pObj, this, false);
774  uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY );
775  if ( xAccSelection.is() )
776  {
777  try
778  {
779  if ( xAccSelection->getSelectedAccessibleChildCount() )
780  {
781  uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 );
782  if ( xSel.is() )
783  {
784  uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
785  if ( xSelContext.is() )
786  {
787  //if in sw we find the selected paragraph here
788  if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
789  {
790  uno::Sequence<uno::Any> aRet( 1 );
791  aRet[0] <<= xSel;
792  return aRet;
793  }
794  }
795  }
796  }
797  }
798  catch ( const css::lang::IndexOutOfBoundsException& )
799  {
800  return uno::Sequence< uno::Any >();
801  }
802  //end of try...catch
803  }
804  }
805  }
806  else
807  {
808  uno::Reference< XAccessible > xAcc = pAccMap->GetCursorContext();
809  SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
810  if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH )
811  {
812  uno::Sequence< uno::Any > aRet(1);
813  aRet[0] <<= xAcc;
814  return aRet;
815  }
816  }
817  }
818  else if ( nType == FORFINDREPLACEFLOWTO )
819  {
820  SwCursorShell* pCursorShell = GetCursorShell();
821  if ( pCursorShell )
822  {
823  SwPaM *_pStartCursor = pCursorShell->GetCursor(), *_pStartCursor2 = _pStartCursor;
824  std::set<SwFrame*> vFrameList;
825  do
826  {
827  if ( _pStartCursor && _pStartCursor->HasMark() )
828  {
829  SwContentNode* pContentNode = _pStartCursor->GetContentNode();
830  SwFrame *const pFrame = pContentNode
831  ? pContentNode->getLayoutFrame(pCursorShell->GetLayout(), _pStartCursor->GetPoint())
832  : nullptr;
833  if ( pFrame )
834  {
835  vFrameList.insert( pFrame );
836  }
837  }
838  }
839 
840  while( _pStartCursor && ( (_pStartCursor = _pStartCursor->GetNext()) != _pStartCursor2) );
841 
842  if ( !vFrameList.empty() )
843  {
844  uno::Sequence< uno::Any > aRet(vFrameList.size());
845  sal_Int32 nIndex = 0;
846  for ( const auto& rpFrame : vFrameList )
847  {
848  uno::Reference< XAccessible > xAcc = pAccMap->GetContext(rpFrame, false);
849  if ( xAcc.is() )
850  {
851  SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
852  if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH )
853  {
854  aRet[nIndex] <<= xAcc;
855  }
856  }
857  nIndex++;
858  }
859 
860  return aRet;
861  }
862  }
863  }
864 
865  return uno::Sequence< uno::Any >();
866 }
867 
868 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_Char sImplementationName[]
Definition: accdoc.cxx:57
Point TopLeft() const
const int nColCount
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
Definition: accdoc.cxx:294
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: accdoc.cxx:498
long GetWidth() const
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:440
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2816
size_t GetMarkCount() const
long GetHeight() const
Marks a position in the document model.
Definition: pam.hxx:35
SwAccessibleDocumentBase(std::shared_ptr< SwAccessibleMap > const &pInitMap)
Definition: accdoc.cxx:67
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
Definition: accdoc.cxx:262
SwContentFrame * GetNextContentFrame() const
Definition: cntfrm.hxx:98
static OUString GetResource(const char *pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
bool IsInFly() const
Definition: frame.hxx:937
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:184
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: accdoc.cxx:510
OUString GetTitle(sal_uInt16 nMaxLen=0) const
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
SwDocShell * GetDocShell()
Definition: doc.hxx:1341
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Definition: acccontext.cxx:566
const sal_Char sAccessibleServiceName[]
Definition: acccontext.hxx:43
bool IsInFootnote() const
Definition: frame.hxx:925
vcl::Window * GetAccessibleParentWindow() const
SwAccessibleSelectionHelper maSelectionHelper
Definition: accdoc.hxx:99
sal_uIntPtr sal_uLong
vcl::Window * GetWindow()
Definition: acccontext.cxx:83
void AddChild(vcl::Window *pWin, bool bFireEvent=true)
Definition: accdoc.cxx:96
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
void Scrolled(const SwRect &rOldVisArea)
Definition: acccontext.cxx:260
Definition: doc.hxx:185
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:116
void RemoveChildEventListener(const Link< VclWindowEvent &, void > &rEventListener)
SdrMark * GetMark(size_t nNum) const
virtual void SAL_CALL clearAccessibleSelection() override
Definition: accdoc.cxx:489
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: accdoc.cxx:483
static sal_Int32 GetChildCount(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame *pFrame, bool bInPagePreviewr)
Definition: accframe.cxx:41
virtual css::awt::Point SAL_CALL getLocation() override
Definition: accdoc.cxx:246
void Move(long nHorzMoveDelta, long nVertMoveDelta)
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
virtual OUString SAL_CALL getAccessibleDescription() override
Definition: accdoc.cxx:190
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: accdoc.cxx:463
SwCursorShell * GetCursorShell()
convenience method to get SwCursorShell through accessibility map
Definition: acccontext.cxx:101
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: accdoc.cxx:477
SwViewShell * GetShell() const
Definition: accmap.hxx:169
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
bool isAccessibleChildSelected(sal_Int32 nChildIndex)
sal_uLong GetThisLines() const
Definition: txtfrm.hxx:657
bool IsInTab() const
Definition: frame.hxx:931
char sal_Char
sal_Int32 SAL_CALL getBackground() override
Definition: accdoc.cxx:745
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool IsTextFrame() const
Definition: frame.hxx:1210
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
long Top() const
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
SwPaM * GetNext()
Definition: pam.hxx:264
const SwAttrSet * GetAttrSet() const
WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for SwTextFrame, use GetBreakItem()/GetPageDescItem() instead.
Definition: findfrm.cxx:674
virtual ~SwAccessibleDocumentBase() override
Definition: accdoc.cxx:76
css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)
SdrObject * GetMarkedSdrObj() const
bool IsEmpty() const
Definition: txtfrm.hxx:509
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: accdoc.cxx:426
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Definition: accdoc.cxx:131
#define SFX_TITLE_APINAME
const OUString & getDocAccTitle() const
Definition: doc.hxx:549
Style of a layout element.
Definition: frmfmt.hxx:57
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:165
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1266
#define SW_MOD()
Definition: swmodule.hxx:256
virtual css::awt::Rectangle SAL_CALL getBounds() override
Definition: accdoc.cxx:222
virtual css::awt::Size SAL_CALL getSize() override
Definition: accdoc.cxx:278
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
sal_uInt16 GetPageCnt()
Definition: crsrsh.cxx:1278
const OUString & GetSectionName() const
Definition: section.hxx:169
const SwPosition * GetPoint() const
Definition: pam.hxx:207
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
const SwFrame * Lower() const
Definition: layfrm.hxx:100
int i
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: accdoc.cxx:493
SwSection * GetSection()
Definition: sectfrm.hxx:84
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
SwAccessibleDocument(std::shared_ptr< SwAccessibleMap > const &pInitMap)
Definition: accdoc.cxx:347
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
const css::uno::WeakReference< css::accessibility::XAccessible > & GetCursorContext() const
Definition: accmap.hxx:307
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
unsigned char sal_Bool
const SwRect & GetVisArea() const
Definition: accmap.cxx:3500
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: accdoc.cxx:162
bool IsInside(const Point &rPOINT) const
void SetVisArea(const SwRect &rNewVisArea)
Definition: accframe.hxx:131
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: accdoc.cxx:312
css::uno::Sequence< css::uno::Any > SAL_CALL getAccFlowTo(const css::uno::Any &rAny, sal_Int32 nType) override
Definition: accdoc.cxx:752
access to an accessible Writer document
Definition: accdoc.hxx:93
virtual ~SwAccessibleDocument() override
Definition: accdoc.cxx:368
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Definition: acccontext.cxx:576
virtual css::uno::Any SAL_CALL getExtendedAttributes() override
Definition: accdoc.cxx:516
A page of the document layout.
Definition: pagefrm.hxx:40
virtual OUString SAL_CALL getImplementationName() override
Definition: accdoc.cxx:421
bool IsDisposing() const
Definition: acccontext.hxx:109
IMPL_LINK(SwAccessibleDocument, WindowChildEventListener, VclWindowEvent &, rEvent, void)
Definition: accdoc.cxx:385
Size GetSize() const
SVX_DLLPUBLIC SdrObject * GetSdrObjectFromXShape(const css::uno::Reference< css::drawing::XShape > &xShape)
sal_uInt16 GetLineCount(TextFrameIndex nPos)
Determines the line count.
Definition: txtfrm.cxx:3740
SwDrawView * GetDrawView()
Definition: viewimp.hxx:156
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2426
void RemoveChild(vcl::Window *pWin)
Definition: accdoc.cxx:115
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true)
vcl::Window * GetWin() const
Definition: viewsh.hxx:340
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet)
Definition: acccontext.cxx:478
void selectAccessibleChild(sal_Int32 nChildIndex)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: accdoc.cxx:470
bool IsPageFrame() const
Definition: frame.hxx:1154
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1848
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:112
long Left() const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: accdoc.cxx:438
virtual OUString SAL_CALL getAccessibleName() override
Definition: accdoc.cxx:195
void deselectAccessibleChild(sal_Int32 nChildIndex)
VclPtr< vcl::Window > mpChildWin
Definition: accdoc.hxx:35
sal_uInt16 GetNumCols() const
Definition: fmtclds.hxx:114
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: accdoc.cxx:337
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
Definition: accdoc.cxx:167
RndStdIds
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:186
const SwFrame * GetAnchorFrame() const
sal_uInt16 GetAccessibleRole() const
const SwRect & GetVisArea() const
Definition: accframe.hxx:136
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: accdoc.cxx:431
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
Definition: acccontext.cxx:770
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: acccontext.cxx:672
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
Definition: findfrm.cxx:66
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2071
void AddState(sal_Int16 aState)
css::uno::Reference< css::accessibility::XAccessible > mxParent
Definition: accdoc.hxx:33
SdrObjUserCall * GetUserCall() const
void SetName(const OUString &rName)
Definition: acccontext.hxx:99
bool IsFooterFrame() const
Definition: frame.hxx:1170
tools::Rectangle GetWindowExtentsRelative(vcl::Window *pRelativeWindow) const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
Definition: accdoc.cxx:503
const sal_Char sServiceName[]
Definition: accdoc.cxx:56
bool IsHeaderFrame() const
Definition: frame.hxx:1166
SwFrame * GetNext()
Definition: frame.hxx:654
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Definition: accdoc.cxx:145
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: accdoc.cxx:375