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