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