LibreOffice Module sw (master) 1
accpara.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 <memory>
21#include <numeric>
22#include <txtfrm.hxx>
23#include <flyfrm.hxx>
24#include <mdiexp.hxx>
25#include <ndtxt.hxx>
26#include <pam.hxx>
27#include <unotextrange.hxx>
28#include <unocrsrhelper.hxx>
29#include <crstate.hxx>
30#include <accmap.hxx>
31#include <fesh.hxx>
32#include <viewopt.hxx>
33#include <vcl/svapp.hxx>
34#include <vcl/window.hxx>
35#include <sal/log.hxx>
36#include <com/sun/star/accessibility/AccessibleRole.hpp>
37#include <com/sun/star/accessibility/AccessibleScrollType.hpp>
38#include <com/sun/star/accessibility/AccessibleStateType.hpp>
39#include <com/sun/star/accessibility/AccessibleTextType.hpp>
40#include <com/sun/star/accessibility/AccessibleEventId.hpp>
41#include <com/sun/star/i18n/Boundary.hpp>
42#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
43#include <com/sun/star/i18n/WordType.hpp>
44#include <com/sun/star/i18n/XBreakIterator.hpp>
45#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
46#include <com/sun/star/beans/UnknownPropertyException.hpp>
47#include <breakit.hxx>
48#include "accpara.hxx"
49#include "accportions.hxx"
50#include <sfx2/viewsh.hxx>
51#include <sfx2/viewfrm.hxx>
52#include <sfx2/dispatch.hxx>
53#include <unocrsr.hxx>
54#include <unoport.hxx>
55#include <doc.hxx>
57#include "acchyperlink.hxx"
58#include "acchypertextdata.hxx"
60#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
62#include <algorithm>
63#include <docufld.hxx>
64#include <txtfld.hxx>
65#include <fmtfld.hxx>
66#include <modcfg.hxx>
67#include <com/sun/star/beans/XPropertySet.hpp>
68#include <swmodule.hxx>
69#include <redline.hxx>
70#include <com/sun/star/awt/FontWeight.hpp>
71#include <com/sun/star/awt/FontStrikeout.hpp>
72#include <com/sun/star/awt/FontSlant.hpp>
73#include <wrong.hxx>
74#include <editeng/brushitem.hxx>
75#include <editeng/unoprnms.hxx>
76#include <editeng/lrspitem.hxx>
77#include <editeng/ulspitem.hxx>
78#include <swatrset.hxx>
79#include <unosett.hxx>
80#include <unomap.hxx>
81#include <unoprnms.hxx>
82#include <com/sun/star/text/WritingMode2.hpp>
83#include <viewimp.hxx>
84#include "textmarkuphelper.hxx"
86#include <com/sun/star/text/TextMarkupType.hpp>
89#include <svx/colorwindow.hxx>
90#include <o3tl/string_view.hxx>
91#include <editeng/editids.hrc>
92
93#include <reffld.hxx>
94#include <flddat.hxx>
95#include "../../uibase/inc/fldmgr.hxx"
96#include <fldbas.hxx> // SwField
97
98using namespace ::com::sun::star;
99using namespace ::com::sun::star::accessibility;
100using namespace ::com::sun::star::container;
101
102using beans::PropertyValue;
103using beans::XMultiPropertySet;
104using beans::UnknownPropertyException;
105using beans::PropertyState_DIRECT_VALUE;
106
107using std::max;
108using std::min;
109using std::sort;
110
111namespace com::sun::star::text {
112 class XText;
113}
114
115constexpr OUStringLiteral sServiceName = u"com.sun.star.text.AccessibleParagraphView";
116constexpr OUStringLiteral sImplementationName = u"com.sun.star.comp.Writer.SwAccessibleParagraphView";
117
119{
121}
122
124{
125 return OUString(); // provide empty description for paragraphs
126}
127
129{
130 sal_Int32 nRet = -1;
131
132 // get the selection's point, and test whether it's in our node
133 // #i27301# - consider adjusted method signature
134 SwPaM* pCaret = GetCursor( false ); // caret is first PaM in PaM-ring
135
136 if( pCaret != nullptr )
137 {
138 SwTextFrame const*const pTextFrame(static_cast<SwTextFrame const*>(GetFrame()));
139 assert(pTextFrame);
140
141 // check whether the point points into 'our' node
142 SwPosition* pPoint = pCaret->GetPoint();
143 if (sw::FrameContainsNode(*pTextFrame, pPoint->GetNodeIndex()))
144 {
145 // same node? Then check whether it's also within 'our' part
146 // of the paragraph
147 const TextFrameIndex nIndex = pTextFrame->MapModelToViewPos(*pPoint);
148 if(!GetPortionData().IsValidCorePosition( nIndex ) ||
149 (GetPortionData().IsZeroCorePositionData()
150 && nIndex == TextFrameIndex(0)))
151 {
152 bool bFormat = pTextFrame->HasPara();
153 if(bFormat)
154 {
157 }
158 }
159 if( GetPortionData().IsValidCorePosition( nIndex ) )
160 {
161 // Yes, it's us!
162 // consider that cursor/caret is in front of the list label
163 if ( pCaret->IsInFrontOfLabel() )
164 {
165 nRet = 0;
166 }
167 else
168 {
170 }
171
172 OSL_ENSURE( nRet >= 0, "invalid cursor?" );
173 OSL_ENSURE( nRet <= GetPortionData().GetAccessibleString().
174 getLength(), "invalid cursor?" );
175 }
176 // else: in this paragraph, but in different frame
177 }
178 // else: not in this paragraph
179 }
180 // else: no cursor -> no caret
181
182 return nRet;
183}
184
185// #i27301# - new parameter <_bForSelection>
186SwPaM* SwAccessibleParagraph::GetCursor( const bool _bForSelection )
187{
188 // get the cursor shell; if we don't have any, we don't have a
189 // cursor/selection either
190 SwPaM* pCursor = nullptr;
192 // #i27301# - if cursor is retrieved for selection, the cursors for
193 // a table selection has to be returned.
194 if ( pCursorShell != nullptr &&
195 ( _bForSelection || !pCursorShell->IsTableMode() ) )
196 {
197 SwFEShell *pFESh = dynamic_cast<SwFEShell*>(pCursorShell);
198 if( !pFESh ||
199 !(pFESh->IsFrameSelected() || pFESh->IsObjSelected() > 0) )
200 {
201 // get the selection, and test whether it affects our text node
202 pCursor = pCursorShell->GetCursor( false /* ??? */ );
203 }
204 }
205
206 return pCursor;
207}
208
210{
211 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
212 const SwTextNode *pTextNd = pFrame->GetTextNodeForParaProps();
213 return pTextNd->IsOutline();
214}
215
216void SwAccessibleParagraph::GetStates( sal_Int64& rStateSet )
217{
219
220 // MULTILINE
221 rStateSet |= AccessibleStateType::MULTI_LINE;
222
223 if (GetCursorShell())
224 {
225 // MULTISELECTABLE
226 rStateSet |= AccessibleStateType::MULTI_SELECTABLE;
227 // FOCUSABLE
228 rStateSet |= AccessibleStateType::FOCUSABLE;
229 }
230
231 // FOCUSED (simulates node index of cursor)
232 SwPaM* pCaret = GetCursor( false ); // #i27301# - consider adjusted method signature
233 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
234 assert(pFrame);
235 if (pCaret != nullptr &&
236 sw::FrameContainsNode(*pFrame, pCaret->GetPoint()->GetNodeIndex()) &&
237 m_nOldCaretPos != -1)
238 {
239 vcl::Window *pWin = GetWindow();
240 if( pWin && pWin->HasFocus() )
241 rStateSet |= AccessibleStateType::FOCUSED;
243 GetMap()->SetCursorContext( xThis );
244 }
245}
246
247void SwAccessibleParagraph::InvalidateContent_( bool bVisibleDataFired )
248{
249 OUString sOldText( GetString() );
250
252
253 const OUString& rText = GetString();
254
255 if( rText != sOldText )
256 {
257 // The text is changed
258 AccessibleEventObject aEvent;
259 aEvent.EventId = AccessibleEventId::TEXT_CHANGED;
260
261 // determine exact changes between sOldText and rText
263 aEvent.OldValue,
264 aEvent.NewValue);
265
267 uno::Reference< XAccessible > xparent = getAccessibleParent();
268 uno::Reference< XAccessibleContext > xAccContext(xparent,uno::UNO_QUERY);
269 if (xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
270 {
271 SwAccessibleContext* pPara = static_cast< SwAccessibleContext* >(xparent.get());
272 if(pPara)
273 {
274 AccessibleEventObject aParaEvent;
275 aParaEvent.EventId = AccessibleEventId::VALUE_CHANGED;
276 pPara->FireAccessibleEvent(aParaEvent);
277 }
278 }
279 }
280 else if( !bVisibleDataFired )
281 {
283 }
284
285 bool bNewIsHeading = IsHeading();
286 //Get the real heading level, Heading1 ~ Heading10
288 bool bOldIsHeading;
289 {
290 std::scoped_lock aGuard( m_Mutex );
291 bOldIsHeading = m_bIsHeading;
292 if( m_bIsHeading != bNewIsHeading )
293 m_bIsHeading = bNewIsHeading;
294 }
295
296 if( bNewIsHeading != bOldIsHeading )
297 {
298 // The role has changed
299 AccessibleEventObject aEvent;
300 aEvent.EventId = AccessibleEventId::ROLE_CHANGED;
301
303 }
304
305 if( rText == sOldText )
306 return;
307
308 OUString sNewDesc( GetDescription() );
309 OUString sOldDesc;
310 {
311 std::scoped_lock aGuard( m_Mutex );
312 sOldDesc = m_sDesc;
313 if( m_sDesc != sNewDesc )
314 m_sDesc = sNewDesc;
315 }
316
317 if( sNewDesc != sOldDesc )
318 {
319 // The text is changed
320 AccessibleEventObject aEvent;
321 aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
322 aEvent.OldValue <<= sOldDesc;
323 aEvent.NewValue <<= sNewDesc;
324
326 }
327}
328
330{
331 // The text is changed
332 sal_Int32 nNew = GetCaretPos();
333 sal_Int32 nOld;
334 {
335 std::scoped_lock aGuard( m_Mutex );
336 nOld = m_nOldCaretPos;
337 m_nOldCaretPos = nNew;
338 }
339 if( -1 != nNew )
340 {
341 // remember that object as the one that has the caret. This is
342 // necessary to notify that object if the cursor leaves it.
344 GetMap()->SetCursorContext( xThis );
345 }
346
347 vcl::Window *pWin = GetWindow();
348 if( nOld == nNew )
349 return;
350
351 // The cursor's node position is simulated by the focus!
352 if( pWin && pWin->HasFocus() && -1 == nOld )
353 FireStateChangedEvent( AccessibleStateType::FOCUSED, true );
354
355 AccessibleEventObject aEvent;
356 aEvent.EventId = AccessibleEventId::CARET_CHANGED;
357 aEvent.OldValue <<= nOld;
358 aEvent.NewValue <<= nNew;
359
361
362 if( pWin && pWin->HasFocus() && -1 == nNew )
363 FireStateChangedEvent( AccessibleStateType::FOCUSED, false );
364 //To send TEXT_SELECTION_CHANGED event
365 sal_Int32 nStart=0;
366 sal_Int32 nEnd =0;
367 bool bCurSelection = GetSelection(nStart,nEnd);
368 if(m_bLastHasSelection || bCurSelection )
369 {
370 aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
371 aEvent.OldValue.clear();
372 aEvent.NewValue.clear();
374 }
375 m_bLastHasSelection =bCurSelection;
376
377}
378
380{
381 vcl::Window *pWin = GetWindow();
382 if( pWin )
383 {
384 sal_Int32 nPos;
385 {
386 std::scoped_lock aGuard( m_Mutex );
388 }
389 OSL_ENSURE( nPos != -1, "focus object should be selected" );
390
391 FireStateChangedEvent( AccessibleStateType::FOCUSED,
392 pWin->HasFocus() && nPos != -1 );
393 }
394}
395
397 std::shared_ptr<SwAccessibleMap> const& pInitMap,
398 const SwTextFrame& rTextFrame )
399 : SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
400 , m_nOldCaretPos( -1 )
401 , m_bIsHeading( false )
402 //Get the real heading level, Heading1 ~ Heading10
403 , m_nHeadingLevel (-1)
404 , m_aSelectionHelper( *this )
405 , mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTextFrame ) ) // #i108125#
406 , m_bLastHasSelection(false) //To add TEXT_SELECTION_CHANGED event
407{
408 StartListening(const_cast<SwTextFrame&>(rTextFrame));
410 //Get the real heading level, Heading1 ~ Heading10
412 SetName( OUString() ); // set an empty accessibility name for paragraphs
413}
414
416{
417 SolarMutexGuard aGuard;
418
419 m_pPortionData.reset();
420 m_pHyperTextData.reset();
421 mpParaChangeTrackInfo.reset(); // #i108125#
423}
424
426{
427 std::scoped_lock aGuard( m_Mutex );
428 return m_nOldCaretPos != -1;
429}
430
432{
433 // obtain the text frame
434 const SwTextFrame* pFrame = static_cast<const SwTextFrame*>( GetFrame() );
435 OSL_ENSURE( pFrame != nullptr, "The text frame has vanished!" );
436 if (!pFrame)
438 else
439 {
440 OSL_ENSURE( pFrame->IsTextFrame(), "The text frame has mutated!" );
441 // build new portion data
443 pFrame, GetMap()->GetShell()->GetViewOptions()) );
444 pFrame->VisitPortions( *m_pPortionData );
445 }
446 OSL_ENSURE( m_pPortionData != nullptr, "UpdatePortionData() failed" );
447}
448
450{
451 m_pPortionData.reset();
452 m_pHyperTextData.reset();
453}
454
456{
457 OSL_ENSURE( GetMap() != nullptr, "no map?" );
458 SwViewShell* pViewShell = GetMap()->GetShell();
459
460 OSL_ENSURE( pViewShell != nullptr, "View shell expected!" );
461 SfxViewShell* pSfxShell = pViewShell->GetSfxViewShell();
462
463 OSL_ENSURE( pSfxShell != nullptr, "SfxViewShell shell expected!" );
464 if( !pSfxShell )
465 return;
466
467 SfxViewFrame& rFrame = pSfxShell->GetViewFrame();
468 SfxDispatcher *pDispatcher = rFrame.GetDispatcher();
469 OSL_ENSURE( pDispatcher != nullptr, "Dispatcher expected!" );
470 if( !pDispatcher )
471 return;
472
473 pDispatcher->Execute( nSlot );
474}
475
477 sal_Int32 nStartIndex,
478 sal_Int32 nEndIndex )
479{
480 OSL_ENSURE( (IsValidChar(nStartIndex, GetString().getLength()) &&
481 (nEndIndex == -1)) ||
482 IsValidRange(nStartIndex, nEndIndex, GetString().getLength()),
483 "please check parameters before calling this method" );
484
485 const TextFrameIndex nStart = GetPortionData().GetCoreViewPosition(nStartIndex);
486 const TextFrameIndex nEnd = (nEndIndex == -1)
487 ? (nStart + TextFrameIndex(1))
488 : GetPortionData().GetCoreViewPosition(nEndIndex);
489
490 // create UNO cursor
491 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
492 SwPosition aStartPos(pFrame->MapViewToModelPos(nStart));
493 auto pUnoCursor(const_cast<SwDoc&>(pFrame->GetDoc()).CreateUnoCursor(aStartPos));
494 pUnoCursor->SetMark();
495 *pUnoCursor->GetMark() = pFrame->MapViewToModelPos(nEnd);
496
497 // create a (dummy) text portion to be returned
498 uno::Reference<text::XText> aEmpty;
499 return new SwXTextPortion ( pUnoCursor.get(), aEmpty, PORTION_TEXT);
500}
501
502// range checking for parameter
503
505 sal_Int32 nPos, sal_Int32 nLength)
506{
507 return (nPos >= 0) && (nPos < nLength);
508}
509
511 sal_Int32 nPos, sal_Int32 nLength)
512{
513 return (nPos >= 0) && (nPos <= nLength);
514}
515
517 sal_Int32 nBegin, sal_Int32 nEnd, sal_Int32 nLength)
518{
519 return IsValidPosition(nBegin, nLength) && IsValidPosition(nEnd, nLength);
520}
521
522//the function is to check whether the position is in a redline range.
524{
525 const SwRangeRedline* pRedline = nullptr;
526 SwPaM* pCrSr = GetCursor( true );
527 if ( pCrSr )
528 {
529 SwPosition* pStart = pCrSr->Start();
530 pRedline = pStart->GetDoc().getIDocumentRedlineAccess().GetRedline(*pStart, nullptr);
531 }
532
533 return pRedline;
534}
535
536// text boundaries
537
539 i18n::Boundary& rBound,
540 sal_Int32 nPos )
541{
542 if( GetPortionData().FillBoundaryIFDateField( rBound, nPos) )
543 return true;
544
545 rBound.startPos = nPos;
546 rBound.endPos = nPos+1;
547 return true;
548}
549
551 i18n::Boundary& rBound,
552 const OUString& rText,
553 sal_Int32 nPos )
554{
555 // now ask the Break-Iterator for the word
556 assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
557
558 // get locale for this position
559 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
561 lang::Locale aLocale = g_pBreakIt->GetLocale(pFrame->GetLangOfChar(nCorePos, 0, true));
562
563 // which type of word are we interested in?
564 // (DICTIONARY_WORD includes punctuation, ANY_WORD doesn't.)
565 const sal_Int16 nWordType = i18n::WordType::ANY_WORD;
566
567 // get word boundary, as the Break-Iterator sees fit.
568 rBound = g_pBreakIt->GetBreakIter()->getWordBoundary(
569 rText, nPos, aLocale, nWordType, true );
570
571 return true;
572}
573
575 i18n::Boundary& rBound,
576 const OUString& rText,
577 sal_Int32 nPos )
578{
579 const sal_Unicode* pStr = rText.getStr();
580 while( nPos < rText.getLength() && pStr[nPos] == u' ' )
581 nPos++;
582
584 return true;
585}
586
588 i18n::Boundary& rBound,
589 std::u16string_view aText,
590 sal_Int32 nPos )
591{
592 if( sal_Int32(aText.size()) == nPos )
594 else
596 return true;
597}
598
600 i18n::Boundary& rBound,
601 std::u16string_view aText )
602{
603 rBound.startPos = 0;
604 rBound.endPos = aText.size();
605 return true;
606}
607
609 i18n::Boundary& rBound,
610 sal_Int32 nPos )
611{
613 return true;
614}
615
617 i18n::Boundary& rBound,
618 const OUString& rText,
619 sal_Int32 nPos )
620{
621 // ask the Break-Iterator for the glyph by moving one cell
622 // forward, and then one cell back
623 assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
624
625 // get locale for this position
626 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
628 lang::Locale aLocale = g_pBreakIt->GetLocale(pFrame->GetLangOfChar(nCorePos, 0, true));
629
630 // get word boundary, as the Break-Iterator sees fit.
631 const sal_Int16 nIterMode = i18n::CharacterIteratorMode::SKIPCELL;
632 sal_Int32 nDone = 0;
633 rBound.endPos = g_pBreakIt->GetBreakIter()->nextCharacters(
634 rText, nPos, aLocale, nIterMode, 1, nDone );
635 rBound.startPos = g_pBreakIt->GetBreakIter()->previousCharacters(
636 rText, rBound.endPos, aLocale, nIterMode, 1, nDone );
637 bool bRet = ((rBound.startPos <= nPos) && (nPos <= rBound.endPos));
638 OSL_ENSURE( rBound.startPos <= nPos, "start pos too high" );
639 OSL_ENSURE( rBound.endPos >= nPos, "end pos too low" );
640
641 return bRet;
642}
643
645 i18n::Boundary& rBound,
646 const OUString& rText,
647 sal_Int32 nPos,
648 sal_Int16 nTextType )
649{
650 // error checking
651 if( !( AccessibleTextType::LINE == nTextType
652 ? IsValidPosition( nPos, rText.getLength() )
653 : IsValidChar( nPos, rText.getLength() ) ) )
654 throw lang::IndexOutOfBoundsException();
655
656 bool bRet;
657
658 switch( nTextType )
659 {
660 case AccessibleTextType::WORD:
661 bRet = GetWordBoundary(rBound, rText, nPos);
662 break;
663
664 case AccessibleTextType::SENTENCE:
665 bRet = GetSentenceBoundary( rBound, rText, nPos );
666 break;
667
668 case AccessibleTextType::PARAGRAPH:
669 bRet = GetParagraphBoundary( rBound, rText );
670 break;
671
672 case AccessibleTextType::CHARACTER:
673 bRet = GetCharBoundary( rBound, nPos );
674 break;
675
676 case AccessibleTextType::LINE:
677 //Solve the problem of returning wrong LINE and PARAGRAPH
678 if((nPos == rText.getLength()) && nPos > 0)
679 bRet = GetLineBoundary( rBound, rText, nPos - 1);
680 else
681 bRet = GetLineBoundary( rBound, rText, nPos );
682 break;
683
684 case AccessibleTextType::ATTRIBUTE_RUN:
685 bRet = GetAttributeBoundary( rBound, nPos );
686 break;
687
688 case AccessibleTextType::GLYPH:
689 bRet = GetGlyphBoundary( rBound, rText, nPos );
690 break;
691
692 default:
693 throw lang::IllegalArgumentException( );
694 }
695
696 return bRet;
697}
698
700{
701 SolarMutexGuard aGuard;
702
704
705 std::scoped_lock aGuard2( m_Mutex );
706 if( m_sDesc.isEmpty() )
708
709 return m_sDesc;
710}
711
712lang::Locale SAL_CALL SwAccessibleParagraph::getLocale()
713{
714 SolarMutexGuard aGuard;
715
716 const SwTextFrame *pTextFrame = GetFrame()->DynCastTextFrame();
717 if( !pTextFrame )
718 {
719 throw uno::RuntimeException("no SwTextFrame", static_cast<cppu::OWeakObject*>(this));
720 }
721
722 lang::Locale aLoc(g_pBreakIt->GetLocale(pTextFrame->GetLangOfChar(TextFrameIndex(0), 0, true)));
723
724 return aLoc;
725}
726
727// #i27138# - paragraphs are in relation CONTENT_FLOWS_FROM and/or CONTENT_FLOWS_TO
728uno::Reference<XAccessibleRelationSet> SAL_CALL SwAccessibleParagraph::getAccessibleRelationSet()
729{
730 SolarMutexGuard aGuard;
731
733
735
736 const SwTextFrame* pTextFrame = GetFrame()->DynCastTextFrame();
737 OSL_ENSURE( pTextFrame,
738 "<SwAccessibleParagraph::getAccessibleRelationSet()> - missing text frame");
739 if ( pTextFrame )
740 {
741 const SwContentFrame* pPrevContentFrame( pTextFrame->FindPrevCnt() );
742 if ( pPrevContentFrame )
743 {
744 uno::Sequence< uno::Reference<XInterface> > aSequence { GetMap()->GetContext( pPrevContentFrame ) };
745 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
746 aSequence );
747 pHelper->AddRelation( aAccRel );
748 }
749
750 const SwContentFrame* pNextContentFrame( pTextFrame->FindNextCnt( true ) );
751 if ( pNextContentFrame )
752 {
753 uno::Sequence< uno::Reference<XInterface> > aSequence { GetMap()->GetContext( pNextContentFrame ) };
754 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
755 aSequence );
756 pHelper->AddRelation( aAccRel );
757 }
758 }
759
760 return pHelper;
761}
762
764{
765 SolarMutexGuard aGuard;
766
768
769 // get cursor shell
770 SwCursorShell *pCursorSh = GetCursorShell();
771 SwPaM *pCursor = GetCursor( false ); // #i27301# - consider new method signature
772 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() );
773
774 if (pCursorSh != nullptr &&
775 ( pCursor == nullptr ||
776 !sw::FrameContainsNode(*pTextFrame, pCursor->GetPoint()->GetNodeIndex()) ||
777 !pTextFrame->IsInside(pTextFrame->MapModelToViewPos(*pCursor->GetPoint()))))
778 {
779 // create pam for selection
780 SwPosition const aStartPos(pTextFrame->MapViewToModelPos(pTextFrame->GetOffset()));
781 SwPaM aPaM( aStartPos );
782
783 // set PaM at cursor shell
784 Select( aPaM );
785
786 }
787
788 // ->#i13955#
789 vcl::Window * pWindow = GetWindow();
790
791 if (pWindow != nullptr)
792 pWindow->GrabFocus();
793 // <-#i13955#
794}
795
796// #i71385#
797static bool lcl_GetBackgroundColor( Color & rColor,
798 const SwFrame* pFrame,
799 SwCursorShell* pCursorSh )
800{
801 const SvxBrushItem* pBackgroundBrush = nullptr;
802 std::optional<Color> xSectionTOXColor;
803 SwRect aDummyRect;
805
806 if ( pFrame &&
807 pFrame->GetBackgroundBrush( aFillAttributes, pBackgroundBrush, xSectionTOXColor, aDummyRect, false, /*bConsiderTextBox=*/false ) )
808 {
809 if ( xSectionTOXColor )
810 {
811 rColor = *xSectionTOXColor;
812 return true;
813 }
814 else
815 {
816 rColor = pBackgroundBrush->GetColor();
817 return true;
818 }
819 }
820 else if ( pCursorSh )
821 {
822 rColor = pCursorSh->Imp()->GetRetoucheColor();
823 return true;
824 }
825
826 return false;
827}
828
830{
832
833 Color aBackgroundCol;
834
835 if ( lcl_GetBackgroundColor( aBackgroundCol, GetFrame(), GetCursorShell() ) )
836 {
837 if ( aBackgroundCol.IsDark() )
838 {
839 return sal_Int32(COL_WHITE);
840 }
841 else
842 {
843 return sal_Int32(COL_BLACK);
844 }
845 }
846
848}
849
851{
853
854 Color aBackgroundCol;
855
856 if ( lcl_GetBackgroundColor( aBackgroundCol, GetFrame(), GetCursorShell() ) )
857 {
858 return sal_Int32(aBackgroundCol);
859 }
860
862}
863
865{
866 return sImplementationName;
867}
868
870 const OUString& sTestServiceName)
871{
872 return cppu::supportsService(this, sTestServiceName);
873}
874
875uno::Sequence< OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames()
876{
878}
879
880static uno::Sequence< OUString > const & getAttributeNames()
881{
882 static uno::Sequence< OUString > const aNames
883 {
884 // Add the font name to attribute list
885 // sorted list of strings
899 };
900 return aNames;
901}
902
903static uno::Sequence< OUString > const & getSupplementalAttributeNames()
904{
905 static uno::Sequence< OUString > const aNames
906 {
907 // sorted list of strings
917 };
918 return aNames;
919}
920
921// XInterface
922
924{
925 uno::Any aRet;
927 {
928 uno::Reference<XAccessibleText> aAccText = static_cast<XAccessibleText *>(*this); // resolve ambiguity
929 aRet <<= aAccText;
930 }
932 {
933 uno::Reference<XAccessibleEditableText> aAccEditText = this;
934 aRet <<= aAccEditText;
935 }
936 else if ( rType == cppu::UnoType<XAccessibleSelection>::get())
937 {
938 uno::Reference<XAccessibleSelection> aAccSel = this;
939 aRet <<= aAccSel;
940 }
941 else if ( rType == cppu::UnoType<XAccessibleHypertext>::get())
942 {
943 uno::Reference<XAccessibleHypertext> aAccHyp = this;
944 aRet <<= aAccHyp;
945 }
946 // #i63870#
947 // add interface com::sun:star:accessibility::XAccessibleTextAttributes
949 {
950 uno::Reference<XAccessibleTextAttributes> aAccTextAttr = this;
951 aRet <<= aAccTextAttr;
952 }
953 // #i89175#
954 // add interface com::sun:star:accessibility::XAccessibleTextMarkup
956 {
957 uno::Reference<XAccessibleTextMarkup> aAccTextMarkup = this;
958 aRet <<= aAccTextMarkup;
959 }
960 // add interface com::sun:star:accessibility::XAccessibleMultiLineText
962 {
963 uno::Reference<XAccessibleMultiLineText> aAccMultiLineText = this;
964 aRet <<= aAccMultiLineText;
965 }
967 {
968 uno::Reference< css::accessibility::XAccessibleTextSelection > aTextExtension = this;
969 aRet <<= aTextExtension;
970 }
972 {
973 uno::Reference<XAccessibleExtendedAttributes> xAttr = this;
974 aRet <<= xAttr;
975 }
976 else
977 {
978 aRet = SwAccessibleContext::queryInterface(rType);
979 }
980
981 return aRet;
982}
983
984// XTypeProvider
985uno::Sequence< uno::Type > SAL_CALL SwAccessibleParagraph::getTypes()
986{
987 // #i63870# - add type accessibility::XAccessibleTextAttributes
988 // #i89175# - add type accessibility::XAccessibleTextMarkup and
996 SwAccessibleContext::getTypes() ).getTypes();
997}
998
999uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleParagraph::getImplementationId()
1000{
1001 return css::uno::Sequence<sal_Int8>();
1002}
1003
1004// XAccessibleText
1005
1007{
1008 SolarMutexGuard aGuard;
1009
1011
1012 sal_Int32 nRet = GetCaretPos();
1013 {
1014 std::scoped_lock aOldCaretPosGuard( m_Mutex );
1015 OSL_ENSURE( nRet == m_nOldCaretPos, "caret pos out of sync" );
1016 m_nOldCaretPos = nRet;
1017 }
1018 if( -1 != nRet )
1019 {
1021 GetMap()->SetCursorContext( xThis );
1022 }
1023
1024 return nRet;
1025}
1026
1028{
1029 SolarMutexGuard aGuard;
1030
1032
1033 // parameter checking
1034 sal_Int32 nLength = GetString().getLength();
1035 if ( ! IsValidPosition( nIndex, nLength ) )
1036 {
1037 throw lang::IndexOutOfBoundsException();
1038 }
1039
1040 bool bRet = false;
1041
1042 // get cursor shell
1043 SwCursorShell* pCursorShell = GetCursorShell();
1044 if( pCursorShell != nullptr )
1045 {
1046 // create pam for selection
1047 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1048 TextFrameIndex const nFrameIndex(GetPortionData().GetCoreViewPosition(nIndex));
1049 SwPosition aStartPos(pFrame->MapViewToModelPos(nFrameIndex));
1050 SwPaM aPaM( aStartPos );
1051
1052 // set PaM at cursor shell
1053 bRet = Select( aPaM );
1054 }
1055
1056 return bRet;
1057}
1058
1060{
1061 SolarMutexGuard aGuard;
1062
1064
1065 OUString sText( GetString() );
1066
1067 // return character (if valid)
1068 if( !IsValidChar(nIndex, sText.getLength() ) )
1069 throw lang::IndexOutOfBoundsException();
1070
1071 return sText[nIndex];
1072}
1073
1074css::uno::Sequence< css::style::TabStop > SwAccessibleParagraph::GetCurrentTabStop( sal_Int32 nIndex )
1075{
1076 SolarMutexGuard aGuard;
1077
1079
1080 /* #i12332# The position after the string needs special treatment.
1081 IsValidChar -> IsValidPosition
1082 */
1083 if( ! (IsValidPosition( nIndex, GetString().getLength() ) ) )
1084 throw lang::IndexOutOfBoundsException();
1085
1086 /* #i12332# */
1087 bool bBehindText = false;
1088 if ( nIndex == GetString().getLength() )
1089 bBehindText = true;
1090
1091 // get model position & prepare GetCharRect() arguments
1092 SwCursorMoveState aMoveState;
1093 aMoveState.m_bRealHeight = true;
1094 aMoveState.m_bRealWidth = true;
1095 SwSpecialPos aSpecialPos;
1096 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1097
1098 /* #i12332# FillSpecialPos does not accept nIndex ==
1099 GetString().getLength(). In that case nPos is set to the
1100 length of the string in the core. This way GetCharRect
1101 returns the rectangle for a cursor at the end of the
1102 paragraph. */
1103 const TextFrameIndex nPos = bBehindText
1104 ? TextFrameIndex(pFrame->GetText().getLength())
1105 : GetPortionData().FillSpecialPos(nIndex, aSpecialPos, aMoveState.m_pSpecialPos );
1106
1107 // call GetCharRect
1108 SwRect aCoreRect;
1109 SwPosition aPosition(pFrame->MapViewToModelPos(nPos));
1110 GetFrame()->GetCharRect( aCoreRect, aPosition, &aMoveState );
1111
1112 // already get the caret position
1113 css::uno::Sequence< css::style::TabStop > tabs;
1114 const sal_Int32 nStrLen = pFrame->GetText().getLength();
1115 if( nStrLen > 0 )
1116 {
1117 SwFrame* pTFrame = const_cast<SwFrame*>(GetFrame());
1118 tabs = pTFrame->GetTabStopInfo(aCoreRect.Left());
1119 }
1120
1121 if( tabs.hasElements() )
1122 {
1123 // translate core coordinates into accessibility coordinates
1124 vcl::Window *pWin = GetWindow();
1125 if (!pWin)
1126 {
1127 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
1128 }
1129
1130 SwRect aTmpRect(0, 0, tabs[0].Position, 0);
1131
1132 tools::Rectangle aScreenRect( GetMap()->CoreToPixel( aTmpRect ));
1133 SwRect aFrameLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root
1134
1135 Point aFramePixPos( GetMap()->CoreToPixel( aFrameLogBounds ).TopLeft() );
1136 aScreenRect.Move( -aFramePixPos.X(), -aFramePixPos.Y() );
1137
1138 tabs.getArray()[0].Position = aScreenRect.GetWidth();
1139 }
1140
1141 return tabs;
1142}
1143
1144namespace {
1145
1146struct IndexCompare
1147{
1148 const PropertyValue* pValues;
1149 explicit IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {}
1150 bool operator() ( sal_Int32 a, sal_Int32 b ) const
1151 {
1152 return (pValues[a].Name < pValues[b].Name);
1153 }
1154};
1155
1156}
1157
1159{
1160 OUString strTypeName;
1161 SwFieldMgr aMgr;
1162 SwTextField* pTextField = nullptr;
1163 sal_Int32 nFieldIndex = GetPortionData().GetFieldIndex(nIndex);
1164 if (nFieldIndex >= 0)
1165 {
1166 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1167 sw::MergedAttrIter iter(*pFrame);
1168 while (SwTextAttr const*const pHt = iter.NextAttr())
1169 {
1170 if ((pHt->Which() == RES_TXTATR_FIELD
1171 || pHt->Which() == RES_TXTATR_ANNOTATION
1172 || pHt->Which() == RES_TXTATR_INPUTFIELD)
1173 && (nFieldIndex-- == 0))
1174 {
1175 pTextField = const_cast<SwTextField*>(
1176 static_txtattr_cast<SwTextField const*>(pHt));
1177 break;
1178 }
1179 else if (pHt->Which() == RES_TXTATR_REFMARK
1180 && (nFieldIndex-- == 0))
1181 {
1182 strTypeName = "set reference";
1183 }
1184 }
1185 }
1186 if (pTextField)
1187 {
1188 const SwField* pField = pTextField->GetFormatField().GetField();
1189 if (pField)
1190 {
1191 strTypeName = SwFieldType::GetTypeStr(pField->GetTypeId());
1192 const SwFieldIds nWhich = pField->GetTyp()->Which();
1193 OUString sEntry;
1194 sal_uInt32 subType = 0;
1195 switch (nWhich)
1196 {
1198 subType = static_cast<const SwDocStatField*>(pField)->GetSubType();
1199 break;
1200 case SwFieldIds::GetRef:
1201 {
1202 switch( pField->GetSubType() )
1203 {
1204 case REF_BOOKMARK:
1205 {
1206 const SwGetRefField* pRefField = dynamic_cast<const SwGetRefField*>(pField);
1207 if ( pRefField && pRefField->IsRefToHeadingCrossRefBookmark() )
1208 sEntry = "Headings";
1209 else if ( pRefField && pRefField->IsRefToNumItemCrossRefBookmark() )
1210 sEntry = "Numbered Paragraphs";
1211 else
1212 sEntry = "Bookmarks";
1213 }
1214 break;
1215 case REF_FOOTNOTE:
1216 sEntry = "Footnotes";
1217 break;
1218 case REF_ENDNOTE:
1219 sEntry = "Endnotes";
1220 break;
1221 case REF_SETREFATTR:
1222 sEntry = "Insert Reference";
1223 break;
1224 case REF_SEQUENCEFLD:
1225 sEntry = static_cast<const SwGetRefField*>(pField)->GetSetRefName();
1226 break;
1227 }
1228 //Get format string
1229 strTypeName = sEntry;
1230 // <pField->GetFormat() >= 0> is always true as <pField->GetFormat()> is unsigned
1231// if (pField->GetFormat() >= 0)
1232 {
1233 sEntry = aMgr.GetFormatStr( pField->GetTypeId(), pField->GetFormat() );
1234 if (sEntry.getLength() > 0)
1235 {
1236 strTypeName += "-" + sEntry;
1237 }
1238 }
1239 }
1240 break;
1242 subType = static_cast<const SwDateTimeField*>(pField)->GetSubType();
1243 break;
1245 {
1246 const sal_uInt32 nFormat= pField->GetFormat();
1247 const sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false);
1248 if (nFormat < nSize)
1249 {
1250 sEntry = aMgr.GetFormatStr(pField->GetTypeId(), nFormat);
1251 if (sEntry.getLength() > 0)
1252 {
1253 strTypeName += "-" + sEntry;
1254 }
1255 }
1256 }
1257 break;
1259 subType = static_cast<const SwExtUserField*>(pField)->GetSubType();
1260 break;
1262 case SwFieldIds::SetExp:
1263 {
1264 sEntry = pField->GetTyp()->GetName();
1265 if (sEntry.getLength() > 0)
1266 {
1267 strTypeName += "-" + sEntry;
1268 }
1269 }
1270 break;
1272 subType = pField->GetSubType();
1273 subType &= 0x00ff;
1274 break;
1276 {
1277 const SwRefPageSetField* pRPld = static_cast<const SwRefPageSetField*>(pField);
1278 bool bOn = pRPld->IsOn();
1279 strTypeName += "-";
1280 if (bOn)
1281 strTypeName += "on";
1282 else
1283 strTypeName += "off";
1284 }
1285 break;
1286 case SwFieldIds::Author:
1287 {
1288 strTypeName += "-" + aMgr.GetFormatStr(pField->GetTypeId(), pField->GetFormat() & 0xff);
1289 }
1290 break;
1291 default: break;
1292 }
1293 if (subType > 0 || nWhich == SwFieldIds::DocInfo || nWhich == SwFieldIds::ExtUser || nWhich == SwFieldIds::DocStat)
1294 {
1295 std::vector<OUString> aLst;
1296 aMgr.GetSubTypes(pField->GetTypeId(), aLst);
1297 if (subType < aLst.size())
1298 sEntry = aLst[subType];
1299 if (sEntry.getLength() > 0)
1300 {
1301 if (nWhich == SwFieldIds::DocInfo)
1302 {
1303 strTypeName = sEntry;
1304 sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false);
1305 const sal_uInt16 nExSub = pField->GetSubType() & 0xff00;
1306 if (nSize > 0 && nExSub > 0)
1307 {
1308 //Get extra subtype string
1309 strTypeName += "-";
1310 sEntry = aMgr.GetFormatStr(pField->GetTypeId(), nExSub/0x0100-1);
1311 strTypeName += sEntry;
1312 }
1313 }
1314 else
1315 {
1316 strTypeName += "-" + sEntry;
1317 }
1318 }
1319 }
1320 }
1321 }
1322 return strTypeName;
1323}
1324
1325// #i63870# - re-implement method on behalf of methods
1326// <_getDefaultAttributesImpl(..)> and <_getRunAttributesImpl(..)>
1328 sal_Int32 nIndex,
1329 const uno::Sequence< OUString >& aRequestedAttributes )
1330{
1331
1332 SolarMutexGuard aGuard;
1333
1335
1336 const OUString& rText = GetString();
1337
1338 if (!IsValidPosition(nIndex, rText.getLength()))
1339 throw lang::IndexOutOfBoundsException();
1340
1341 bool bSupplementalMode = false;
1342 uno::Sequence< OUString > aNames = aRequestedAttributes;
1343 if (!aNames.hasElements())
1344 {
1345 bSupplementalMode = true;
1346 aNames = getAttributeNames();
1347 }
1348 // retrieve default character attributes
1349 tAccParaPropValMap aDefAttrSeq;
1350 _getDefaultAttributesImpl( aNames, aDefAttrSeq, true );
1351
1352 // retrieved run character attributes
1353 tAccParaPropValMap aRunAttrSeq;
1354 _getRunAttributesImpl( nIndex, aNames, aRunAttrSeq );
1355
1356 // merge default and run attributes
1357 std::vector< PropertyValue > aValues( aDefAttrSeq.size() );
1358 sal_Int32 i = 0;
1359 for ( const auto& rDefEntry : aDefAttrSeq )
1360 {
1361 tAccParaPropValMap::const_iterator aRunIter =
1362 aRunAttrSeq.find( rDefEntry.first );
1363 if ( aRunIter != aRunAttrSeq.end() )
1364 {
1365 aValues[i] = aRunIter->second;
1366 }
1367 else
1368 {
1369 aValues[i] = rDefEntry.second;
1370 }
1371 ++i;
1372 }
1373 if( bSupplementalMode )
1374 {
1375 uno::Sequence< OUString > aSupplementalNames = aRequestedAttributes;
1376 if (!aSupplementalNames.hasElements())
1377 aSupplementalNames = getSupplementalAttributeNames();
1378
1379 tAccParaPropValMap aSupplementalAttrSeq;
1380 _getSupplementalAttributesImpl( aSupplementalNames, aSupplementalAttrSeq );
1381
1382 aValues.resize( aValues.size() + aSupplementalAttrSeq.size() );
1383
1384 for ( const auto& rSupplementalEntry : aSupplementalAttrSeq )
1385 {
1386 aValues[i] = rSupplementalEntry.second;
1387 ++i;
1388 }
1389
1390 _correctValues( nIndex, aValues );
1391
1392 aValues.emplace_back();
1393
1394 OUString strTypeName = GetFieldTypeNameAtIndex(nIndex);
1395 if (!strTypeName.isEmpty())
1396 {
1397 aValues.emplace_back();
1398 PropertyValue& rValueFT = aValues.back();
1399 rValueFT.Name = "FieldType";
1400 rValueFT.Value <<= strTypeName.toAsciiLowerCase();
1401 rValueFT.Handle = -1;
1402 rValueFT.State = PropertyState_DIRECT_VALUE;
1403 }
1404
1405 //sort property values
1406 // build sorted index array
1407 sal_Int32 nLength = aValues.size();
1408 std::vector<sal_Int32> aIndices;
1409 aIndices.reserve(nLength);
1410 for (i = 0; i < nLength; ++i)
1411 aIndices.push_back(i);
1412 std::sort(aIndices.begin(), aIndices.end(), IndexCompare(aValues.data()));
1413 // create sorted sequences according to index array
1414 uno::Sequence<PropertyValue> aNewValues( nLength );
1415 PropertyValue* pNewValues = aNewValues.getArray();
1416 for (i = 0; i < nLength; ++i)
1417 {
1418 pNewValues[i] = aValues[aIndices[i]];
1419 }
1420 return aNewValues;
1421 }
1422
1423 return comphelper::containerToSequence(aValues);
1424}
1425
1426static void SetPutRecursive(SfxItemSet &targetSet, const SfxItemSet &sourceSet)
1427{
1428 const SfxItemSet *const pParentSet = sourceSet.GetParent();
1429 if (pParentSet)
1430 SetPutRecursive(targetSet, *pParentSet);
1431 targetSet.Put(sourceSet);
1432}
1433
1434// #i63870#
1436 const uno::Sequence< OUString >& aRequestedAttributes,
1437 tAccParaPropValMap& rDefAttrSeq,
1438 const bool bOnlyCharAttrs )
1439{
1440 // retrieve default attributes
1441 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1442 const SwTextNode *const pTextNode(pFrame->GetTextNodeForParaProps());
1443 std::optional<SfxItemSet> pSet;
1444 if ( !bOnlyCharAttrs )
1445 {
1446 pSet.emplace( const_cast<SwAttrPool&>(pTextNode->GetDoc().GetAttrPool()),
1450 }
1451 else
1452 {
1453 pSet.emplace( const_cast<SwAttrPool&>(pTextNode->GetDoc().GetAttrPool()),
1454 svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END - 1> );
1455 }
1456 // #i82637# - From the perspective of the a11y API the default character
1457 // attributes are the character attributes, which are set at the paragraph style
1458 // of the paragraph. The character attributes set at the automatic paragraph
1459 // style of the paragraph are treated as run attributes.
1460 // pTextNode->SwContentNode::GetAttr( *pSet );
1461 // get default paragraph attributes, if needed, and merge these into <pSet>
1462 if ( !bOnlyCharAttrs )
1463 {
1466 aParaSet( const_cast<SwAttrPool&>(pTextNode->GetDoc().GetAttrPool()) );
1467 pTextNode->SwContentNode::GetAttr( aParaSet );
1468 pSet->Put( aParaSet );
1469 }
1470 // get default character attributes and merge these into <pSet>
1471 OSL_ENSURE( pTextNode->GetTextColl(),
1472 "<SwAccessibleParagraph::_getDefaultAttributesImpl(..)> - missing paragraph style. Serious defect!" );
1473 if ( pTextNode->GetTextColl() )
1474 {
1476 aCharSet( const_cast<SwAttrPool&>(pTextNode->GetDoc().GetAttrPool()) );
1477 SetPutRecursive( aCharSet, pTextNode->GetTextColl()->GetAttrSet() );
1478 pSet->Put( aCharSet );
1479 }
1480
1481 // build-up sequence containing the run attributes <rDefAttrSeq>
1482 tAccParaPropValMap aDefAttrSeq;
1483 {
1484 const SfxItemPropertyMap& rPropMap =
1486 for ( const auto pEntry : rPropMap.getPropertyEntries() )
1487 {
1488 const SfxPoolItem* pItem = pSet->GetItem( pEntry->nWID );
1489 if ( pItem )
1490 {
1491 uno::Any aVal;
1492 pItem->QueryValue( aVal, pEntry->nMemberId );
1493
1494 PropertyValue rPropVal;
1495 rPropVal.Name = pEntry->aName;
1496 rPropVal.Value = aVal;
1497 rPropVal.Handle = -1;
1498 rPropVal.State = beans::PropertyState_DEFAULT_VALUE;
1499
1500 aDefAttrSeq[rPropVal.Name] = rPropVal;
1501 }
1502 }
1503
1504 // #i72800#
1505 // add property value entry for the paragraph style
1506 if ( !bOnlyCharAttrs && pTextNode->GetTextColl() )
1507 {
1508 if ( aDefAttrSeq.find( UNO_NAME_PARA_STYLE_NAME ) == aDefAttrSeq.end() )
1509 {
1510 PropertyValue rPropVal;
1511 rPropVal.Name = UNO_NAME_PARA_STYLE_NAME;
1512 uno::Any aVal( uno::Any( pTextNode->GetTextColl()->GetName() ) );
1513 rPropVal.Value = aVal;
1514 rPropVal.Handle = -1;
1515 rPropVal.State = beans::PropertyState_DEFAULT_VALUE;
1516
1517 aDefAttrSeq[rPropVal.Name] = rPropVal;
1518 }
1519 }
1520
1521 // #i73371#
1522 // resolve value text::WritingMode2::PAGE of property value entry WritingMode
1523 if ( !bOnlyCharAttrs && GetFrame() )
1524 {
1525 tAccParaPropValMap::iterator aIter = aDefAttrSeq.find( UNO_NAME_WRITING_MODE );
1526 if ( aIter != aDefAttrSeq.end() )
1527 {
1528 PropertyValue rPropVal( aIter->second );
1529 sal_Int16 nVal = rPropVal.Value.get<sal_Int16>();
1530 if ( nVal == text::WritingMode2::PAGE )
1531 {
1532 const SwFrame* pUpperFrame( GetFrame()->GetUpper() );
1533 while ( pUpperFrame )
1534 {
1535 if ( pUpperFrame->GetType() &
1537 {
1538 if ( pUpperFrame->IsVertical() )
1539 {
1540 nVal = text::WritingMode2::TB_RL;
1541 }
1542 else if ( pUpperFrame->IsRightToLeft() )
1543 {
1544 nVal = text::WritingMode2::RL_TB;
1545 }
1546 else
1547 {
1548 nVal = text::WritingMode2::LR_TB;
1549 }
1550 rPropVal.Value <<= nVal;
1551 aDefAttrSeq[rPropVal.Name] = rPropVal;
1552 break;
1553 }
1554
1555 if ( pUpperFrame->IsFlyFrame() )
1556 {
1557 pUpperFrame = static_cast<const SwFlyFrame*>(pUpperFrame)->GetAnchorFrame();
1558 }
1559 else
1560 {
1561 pUpperFrame = pUpperFrame->GetUpper();
1562 }
1563 }
1564 }
1565 }
1566 }
1567 }
1568
1569 if ( !aRequestedAttributes.hasElements() )
1570 {
1571 rDefAttrSeq = aDefAttrSeq;
1572 }
1573 else
1574 {
1575 for( const OUString& rReqAttr : aRequestedAttributes )
1576 {
1577 tAccParaPropValMap::const_iterator const aIter = aDefAttrSeq.find( rReqAttr );
1578 if ( aIter != aDefAttrSeq.end() )
1579 {
1580 rDefAttrSeq[ aIter->first ] = aIter->second;
1581 }
1582 }
1583 }
1584}
1585
1586uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes(
1587 const uno::Sequence< OUString >& aRequestedAttributes )
1588{
1589 SolarMutexGuard aGuard;
1590
1592
1593 tAccParaPropValMap aDefAttrSeq;
1594 _getDefaultAttributesImpl( aRequestedAttributes, aDefAttrSeq );
1595
1596 // #i92233#
1597 constexpr OUStringLiteral sMMToPixelRatio = u"MMToPixelRatio";
1598 bool bProvideMMToPixelRatio( !aRequestedAttributes.hasElements() ||
1599 (comphelper::findValue(aRequestedAttributes, sMMToPixelRatio) != -1) );
1600
1601 uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() +
1602 ( bProvideMMToPixelRatio ? 1 : 0 ) );
1603 auto pValues = aValues.getArray();
1604 std::transform(aDefAttrSeq.begin(), aDefAttrSeq.end(), pValues,
1605 [](const auto& rEntry) -> PropertyValue { return rEntry.second; });
1606
1607 // #i92233#
1608 if ( bProvideMMToPixelRatio )
1609 {
1610 PropertyValue rPropVal;
1611 rPropVal.Name = sMMToPixelRatio;
1612 const Size a100thMMSize( 1000, 1000 );
1613 const Size aPixelSize = GetMap()->LogicToPixel( a100thMMSize );
1614 const float fRatio = (static_cast<float>(a100thMMSize.Width())/100)/aPixelSize.Width();
1615 rPropVal.Value <<= fRatio;
1616 rPropVal.Handle = -1;
1617 rPropVal.State = beans::PropertyState_DEFAULT_VALUE;
1618 pValues[ aValues.getLength() - 1 ] = rPropVal;
1619 }
1620
1621 return aValues;
1622}
1623
1625 const sal_Int32 nIndex,
1626 const uno::Sequence< OUString >& aRequestedAttributes,
1627 tAccParaPropValMap& rRunAttrSeq )
1628{
1629 // create PaM for character at position <nIndex>
1630 std::optional<SwPaM> pPaM;
1631 const TextFrameIndex nCorePos(GetPortionData().GetCoreViewPosition(nIndex));
1632 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1633 SwPosition const aModelPos(pFrame->MapViewToModelPos(nCorePos));
1634 SwTextNode *const pTextNode(aModelPos.GetNode().GetTextNode());
1635 {
1636 SwPosition const aEndPos(*pTextNode,
1637 aModelPos.GetContentIndex() == pTextNode->Len()
1638 ? pTextNode->Len() // ???
1639 : aModelPos.GetContentIndex() + 1);
1640 pPaM.emplace(aModelPos, aEndPos);
1641 }
1642
1643 // retrieve character attributes for the created PaM <pPaM>
1644 SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END -1> aSet( pPaM->GetDoc().GetAttrPool() );
1645 // #i82637#
1646 // From the perspective of the a11y API the character attributes, which
1647 // are set at the automatic paragraph style of the paragraph, are treated
1648 // as run attributes.
1649 // SwXTextCursor::GetCursorAttr( *pPaM, aSet, sal_True, sal_True );
1650 // get character attributes from automatic paragraph style and merge these into <aSet>
1651 {
1652 if ( pTextNode->HasSwAttrSet() )
1653 {
1654 SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END -1> aAutomaticParaStyleCharAttrs( pPaM->GetDoc().GetAttrPool());
1655 aAutomaticParaStyleCharAttrs.Put( *(pTextNode->GetpSwAttrSet()), false );
1656 aSet.Put( aAutomaticParaStyleCharAttrs );
1657 }
1658 }
1659 // get character attributes at <pPaM> and merge these into <aSet>
1660 {
1661 SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END -1> aCharAttrsAtPaM( pPaM->GetDoc().GetAttrPool() );
1662 SwUnoCursorHelper::GetCursorAttr(*pPaM, aCharAttrsAtPaM, true);
1663 aSet.Put( aCharAttrsAtPaM );
1664 }
1665
1666 // build-up sequence containing the run attributes <rRunAttrSeq>
1667 {
1668 tAccParaPropValMap aRunAttrSeq;
1669 {
1670 tAccParaPropValMap aDefAttrSeq;
1671 uno::Sequence< OUString > aDummy;
1672 _getDefaultAttributesImpl( aDummy, aDefAttrSeq, true ); // #i82637#
1673
1674 const SfxItemPropertyMap& rPropMap =
1676 for ( const auto pEntry : rPropMap.getPropertyEntries() )
1677 {
1678 const SfxPoolItem* pItem( nullptr );
1679 // #i82637# - Found character attributes, whose value equals the value of
1680 // the corresponding default character attributes, are excluded.
1681 if ( aSet.GetItemState( pEntry->nWID, true, &pItem ) == SfxItemState::SET )
1682 {
1683 uno::Any aVal;
1684 pItem->QueryValue( aVal, pEntry->nMemberId );
1685
1686 PropertyValue rPropVal;
1687 rPropVal.Name = pEntry->aName;
1688 rPropVal.Value = aVal;
1689 rPropVal.Handle = -1;
1690 rPropVal.State = PropertyState_DIRECT_VALUE;
1691
1692 tAccParaPropValMap::const_iterator aDefIter =
1693 aDefAttrSeq.find( rPropVal.Name );
1694 if ( aDefIter == aDefAttrSeq.end() ||
1695 rPropVal.Value != aDefIter->second.Value )
1696 {
1697 aRunAttrSeq[rPropVal.Name] = rPropVal;
1698 }
1699 }
1700 }
1701 }
1702
1703 if ( !aRequestedAttributes.hasElements() )
1704 {
1705 rRunAttrSeq = aRunAttrSeq;
1706 }
1707 else
1708 {
1709 for( const OUString& rReqAttr : aRequestedAttributes )
1710 {
1711 tAccParaPropValMap::iterator aIter = aRunAttrSeq.find( rReqAttr );
1712 if ( aIter != aRunAttrSeq.end() )
1713 {
1714 rRunAttrSeq[ (*aIter).first ] = (*aIter).second;
1715 }
1716 }
1717 }
1718 }
1719}
1720
1721uno::Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes(
1722 sal_Int32 nIndex,
1723 const uno::Sequence< OUString >& aRequestedAttributes )
1724{
1725 SolarMutexGuard aGuard;
1726
1728
1729 {
1730 const OUString& rText = GetString();
1731 if (!IsValidPosition(nIndex, rText.getLength()))
1732 {
1733 throw lang::IndexOutOfBoundsException();
1734 }
1735 }
1736
1737 tAccParaPropValMap aRunAttrSeq;
1738 _getRunAttributesImpl( nIndex, aRequestedAttributes, aRunAttrSeq );
1739
1740 return comphelper::mapValuesToSequence( aRunAttrSeq );
1741}
1742
1744 const uno::Sequence< OUString >& aRequestedAttributes,
1745 tAccParaPropValMap& rSupplementalAttrSeq )
1746{
1747 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1748 const SwTextNode *const pTextNode(pFrame->GetTextNodeForParaProps());
1756 aSet( const_cast<SwAttrPool&>(pTextNode->GetDoc().GetAttrPool()) );
1757
1758 if ( pTextNode->HasBullet() || pTextNode->HasNumber() )
1759 {
1760 aSet.Put( pTextNode->GetAttr(RES_PARATR_LIST_LEVEL) );
1761 }
1762 aSet.Put( pTextNode->SwContentNode::GetAttr(RES_UL_SPACE) );
1763 aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_FIRSTLINE) );
1764 aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_TEXTLEFT) );
1765 aSet.Put( pTextNode->SwContentNode::GetAttr(RES_MARGIN_RIGHT) );
1766 aSet.Put( pTextNode->SwContentNode::GetAttr(RES_PARATR_ADJUST) );
1767
1768 tAccParaPropValMap aSupplementalAttrSeq;
1769 {
1772 for (const auto & rEntry : pPropMap)
1773 {
1774 const SfxPoolItem* pItem = aSet.GetItem( rEntry.nWID );
1775 if ( pItem )
1776 {
1777 uno::Any aVal;
1778 pItem->QueryValue( aVal, rEntry.nMemberId );
1779
1780 PropertyValue rPropVal;
1781 rPropVal.Name = rEntry.aName;
1782 rPropVal.Value = aVal;
1783 rPropVal.Handle = -1;
1784 rPropVal.State = beans::PropertyState_DEFAULT_VALUE;
1785
1786 aSupplementalAttrSeq[rPropVal.Name] = rPropVal;
1787 }
1788 }
1789 }
1790
1791 for( const OUString& rSupplementalAttr : aRequestedAttributes )
1792 {
1793 tAccParaPropValMap::const_iterator const aIter = aSupplementalAttrSeq.find( rSupplementalAttr );
1794 if ( aIter != aSupplementalAttrSeq.end() )
1795 {
1796 rSupplementalAttrSeq[ aIter->first ] = aIter->second;
1797 }
1798 }
1799}
1800
1801void SwAccessibleParagraph::_correctValues( const sal_Int32 nIndex,
1802 std::vector< PropertyValue >& rValues)
1803{
1804 PropertyValue ChangeAttr, ChangeAttrColor;
1805
1806 const SwRangeRedline* pRedline = GetRedlineAtIndex();
1807 if ( pRedline )
1808 {
1809
1810 const SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
1811 AuthorCharAttr aChangeAttr;
1812 if ( pOpt )
1813 {
1814 switch( pRedline->GetType())
1815 {
1816 case RedlineType::Insert:
1817 aChangeAttr = pOpt->GetInsertAuthorAttr();
1818 break;
1819 case RedlineType::Delete:
1820 aChangeAttr = pOpt->GetDeletedAuthorAttr();
1821 break;
1822 case RedlineType::Format:
1823 aChangeAttr = pOpt->GetFormatAuthorAttr();
1824 break;
1825 default: break;
1826 }
1827 }
1828 switch( aChangeAttr.m_nItemId )
1829 {
1830 case SID_ATTR_CHAR_WEIGHT:
1832 ChangeAttr.Value <<= awt::FontWeight::BOLD;
1833 break;
1834 case SID_ATTR_CHAR_POSTURE:
1836 ChangeAttr.Value <<= awt::FontSlant_ITALIC; //char posture
1837 break;
1838 case SID_ATTR_CHAR_STRIKEOUT:
1840 ChangeAttr.Value <<= awt::FontStrikeout::SINGLE; //char strikeout
1841 break;
1842 case SID_ATTR_CHAR_UNDERLINE:
1844 ChangeAttr.Value <<= aChangeAttr.m_nAttr; //underline line
1845 break;
1846 }
1847 if( aChangeAttr.m_nColor != COL_NONE_COLOR )
1848 {
1849 if( aChangeAttr.m_nItemId == SID_ATTR_BRUSH )
1850 {
1851 ChangeAttrColor.Name = UNO_NAME_CHAR_BACK_COLOR;
1852 if( aChangeAttr.m_nColor == COL_TRANSPARENT )//char backcolor
1853 ChangeAttrColor.Value <<= COL_BLUE;
1854 else
1855 ChangeAttrColor.Value <<= aChangeAttr.m_nColor;
1856 }
1857 else
1858 {
1859 ChangeAttrColor.Name = UNO_NAME_CHAR_COLOR;
1860 if( aChangeAttr.m_nColor == COL_TRANSPARENT )//char color
1861 ChangeAttrColor.Value <<= COL_BLUE;
1862 else
1863 ChangeAttrColor.Value <<= aChangeAttr.m_nColor;
1864 }
1865 }
1866 }
1867
1868 // sw_redlinehide: this function only needs SwWrongList for 1 character,
1869 // and the end is excluded by InWrongWord(),
1870 // so it ought to work to just pick the wrong-list/node that contains
1871 // the character following the given nIndex
1872 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
1873 TextFrameIndex const nCorePos(GetPortionData().GetCoreViewPosition(nIndex));
1874 std::pair<SwTextNode*, sal_Int32> pos(pFrame->MapViewToModel(nCorePos));
1875 if (pos.first->Len() == pos.second
1876 && nCorePos != TextFrameIndex(pFrame->GetText().getLength()))
1877 {
1878 pos = pFrame->MapViewToModel(nCorePos + TextFrameIndex(1)); // try this one instead
1879 assert(pos.first->Len() != pos.second);
1880 }
1881 const SwTextNode *const pTextNode(pos.first);
1882
1883 sal_Int32 nValues = rValues.size();
1884 for (sal_Int32 i = 0; i < nValues; ++i)
1885 {
1886 PropertyValue& rValue = rValues[i];
1887
1888 if (rValue.Name == ChangeAttr.Name )
1889 {
1890 rValue.Value = ChangeAttr.Value;
1891 continue;
1892 }
1893
1894 if (rValue.Name == ChangeAttrColor.Name )
1895 {
1896 rValue.Value = ChangeAttrColor.Value;
1897 continue;
1898 }
1899
1900 //back color
1901 if (rValue.Name == UNO_NAME_CHAR_BACK_COLOR)
1902 {
1903 uno::Any &anyChar = rValue.Value;
1904 sal_uInt32 crBack = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved));
1905 if (COL_AUTO == Color(ColorTransparency, crBack))
1906 {
1907 uno::Reference<XAccessibleComponent> xComponent(this);
1908 if (xComponent.is())
1909 {
1910 crBack = static_cast<sal_uInt32>(xComponent->getBackground());
1911 }
1912 rValue.Value <<= crBack;
1913 }
1914 continue;
1915 }
1916
1917 //char color
1918 if (rValue.Name == UNO_NAME_CHAR_COLOR)
1919 {
1921 rValue.Value <<= GetCursorShell()->GetViewOptions()->GetFieldShadingsColor();
1922 uno::Any &anyChar = rValue.Value;
1923 sal_uInt32 crChar = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved));
1924
1925 if( COL_AUTO == Color(ColorTransparency, crChar) )
1926 {
1927 uno::Reference<XAccessibleComponent> xComponent(this);
1928 if (xComponent.is())
1929 {
1930 Color cr(ColorTransparency, xComponent->getBackground());
1931 crChar = sal_uInt32(cr.IsDark() ? COL_WHITE : COL_BLACK);
1932 rValue.Value <<= crChar;
1933 }
1934 }
1935 continue;
1936 }
1937
1938 // UnderLine
1939 if (rValue.Name == UNO_NAME_CHAR_UNDERLINE)
1940 {
1941 //misspelled word
1942 SwCursorShell* pCursorShell = GetCursorShell();
1943 if( pCursorShell != nullptr && pCursorShell->GetViewOptions() && pCursorShell->GetViewOptions()->IsOnlineSpell())
1944 {
1945 const SwWrongList* pWrongList = pTextNode->GetWrong();
1946 if( nullptr != pWrongList )
1947 {
1948 sal_Int32 nBegin = pos.second;
1949 sal_Int32 nLen = 1;
1950 if (pWrongList->InWrongWord(nBegin, nLen) && !pTextNode->IsSymbolAt(nBegin))
1951 {
1952 rValue.Value <<= sal_uInt16(LINESTYLE_WAVE);
1953 }
1954 }
1955 }
1956 continue;
1957 }
1958
1959 // UnderLineColor
1960 if (rValue.Name == UNO_NAME_CHAR_UNDERLINE_COLOR)
1961 {
1962 //misspelled word
1963 SwCursorShell* pCursorShell = GetCursorShell();
1964 if( pCursorShell != nullptr && pCursorShell->GetViewOptions() && pCursorShell->GetViewOptions()->IsOnlineSpell())
1965 {
1966 const SwWrongList* pWrongList = pTextNode->GetWrong();
1967 if( nullptr != pWrongList )
1968 {
1969 sal_Int32 nBegin = pos.second;
1970 sal_Int32 nLen = 1;
1971 if (pWrongList->InWrongWord(nBegin, nLen) && !pTextNode->IsSymbolAt(nBegin))
1972 {
1973 rValue.Value <<= sal_Int32(0x00ff0000);
1974 continue;
1975 }
1976 }
1977 }
1978
1979 uno::Any &anyChar = rValue.Value;
1980 sal_uInt32 crUnderline = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved));
1981 if ( COL_AUTO == Color(ColorTransparency, crUnderline) )
1982 {
1983 uno::Reference<XAccessibleComponent> xComponent(this);
1984 if (xComponent.is())
1985 {
1986 Color cr(ColorTransparency, xComponent->getBackground());
1987 crUnderline = sal_uInt32(cr.IsDark() ? COL_WHITE : COL_BLACK);
1988 rValue.Value <<= crUnderline;
1989 }
1990 }
1991
1992 continue;
1993 }
1994
1995 //tab stop
1996 if (rValue.Name == UNO_NAME_TABSTOPS)
1997 {
1998 css::uno::Sequence< css::style::TabStop > tabs = GetCurrentTabStop( nIndex );
1999 if( !tabs.hasElements() )
2000 {
2001 css::style::TabStop ts;
2002 css::awt::Rectangle rc0 = getCharacterBounds(0);
2003 css::awt::Rectangle rc1 = getCharacterBounds(nIndex);
2004 if( rc1.X - rc0.X >= 48 )
2005 ts.Position = (rc1.X - rc0.X) - (rc1.X - rc0.X - 48)% 47 + 47;
2006 else
2007 ts.Position = 48;
2008 ts.DecimalChar = ' ';
2009 ts.FillChar = ' ';
2010 ts.Alignment = css::style::TabAlign_LEFT;
2011 tabs = { ts };
2012 }
2013 rValue.Value <<= tabs;
2014 continue;
2015 }
2016
2017 //footnote & endnote
2018 if (rValue.Name == UNO_NAME_CHAR_ESCAPEMENT)
2019 {
2021 {
2022 rValue.Value <<= sal_Int32(101);
2023 }
2024 continue;
2025 }
2026 }
2027}
2028
2030 sal_Int32 nIndex )
2031{
2032 SolarMutexGuard aGuard;
2033
2035
2036 // #i12332# The position after the string needs special treatment.
2037 // IsValidChar -> IsValidPosition
2038 if( ! (IsValidPosition( nIndex, GetString().getLength() ) ) )
2039 throw lang::IndexOutOfBoundsException();
2040
2041 // #i12332#
2042 bool bBehindText = false;
2043 if ( nIndex == GetString().getLength() )
2044 bBehindText = true;
2045
2046 // get model position & prepare GetCharRect() arguments
2047 SwCursorMoveState aMoveState;
2048 aMoveState.m_bRealHeight = true;
2049 aMoveState.m_bRealWidth = true;
2050 SwSpecialPos aSpecialPos;
2051 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
2052
2058 const TextFrameIndex nPos = bBehindText
2059 ? TextFrameIndex(pFrame->GetText().getLength())
2060 : GetPortionData().FillSpecialPos(nIndex, aSpecialPos, aMoveState.m_pSpecialPos );
2061
2062 // call GetCharRect
2063 SwRect aCoreRect;
2064 SwPosition aPosition(pFrame->MapViewToModelPos(nPos));
2065 GetFrame()->GetCharRect( aCoreRect, aPosition, &aMoveState );
2066
2067 // translate core coordinates into accessibility coordinates
2068 vcl::Window *pWin = GetWindow();
2069 if (!pWin)
2070 {
2071 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
2072 }
2073
2074 tools::Rectangle aScreenRect( GetMap()->CoreToPixel( aCoreRect ));
2075 SwRect aFrameLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root
2076
2077 Point aFramePixPos( GetMap()->CoreToPixel( aFrameLogBounds ).TopLeft() );
2078 aScreenRect.Move( -aFramePixPos.getX(), -aFramePixPos.getY() );
2079
2080 // convert into AWT Rectangle
2081 return awt::Rectangle(
2082 aScreenRect.Left(), aScreenRect.Top(),
2083 aScreenRect.GetWidth(), aScreenRect.GetHeight() );
2084}
2085
2087{
2088 SolarMutexGuard aGuard;
2089
2091
2092 return GetString().getLength();
2093}
2094
2095sal_Int32 SwAccessibleParagraph::getIndexAtPoint( const awt::Point& rPoint )
2096{
2097 SolarMutexGuard aGuard;
2098
2100
2101 // construct Point (translate into layout coordinates)
2102 vcl::Window *pWin = GetWindow();
2103 if (!pWin)
2104 {
2105 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
2106 }
2107 Point aPoint( rPoint.X, rPoint.Y );
2108 SwRect aLogBounds( GetBounds( *(GetMap()), GetFrame() ) ); // twip rel to doc root
2109 Point aPixPos( GetMap()->CoreToPixel( aLogBounds ).TopLeft() );
2110 aPoint.setX(aPoint.getX() + aPixPos.getX());
2111 aPoint.setY(aPoint.getY() + aPixPos.getY());
2112 Point aCorePoint( GetMap()->PixelToCore( aPoint ) );
2113 if( !aLogBounds.Contains( aCorePoint ) )
2114 {
2115 // #i12332# rPoint is may also be in rectangle returned by
2116 // getCharacterBounds(getCharacterCount()
2117
2118 awt::Rectangle aRectEndPos =
2120
2121 if (rPoint.X - aRectEndPos.X >= 0 &&
2122 rPoint.X - aRectEndPos.X < aRectEndPos.Width &&
2123 rPoint.Y - aRectEndPos.Y >= 0 &&
2124 rPoint.Y - aRectEndPos.Y < aRectEndPos.Height)
2125 return getCharacterCount();
2126
2127 return -1;
2128 }
2129
2130 // ask core for position
2131 OSL_ENSURE( GetFrame() != nullptr, "The text frame has vanished!" );
2132 OSL_ENSURE( GetFrame()->IsTextFrame(), "The text frame has mutated!" );
2133 const SwTextFrame* pFrame = static_cast<const SwTextFrame*>( GetFrame() );
2134 // construct SwPosition (where GetModelPositionForViewPoint() will put the result into)
2135 SwTextNode* pNode = const_cast<SwTextNode*>(pFrame->GetTextNodeFirst());
2136 SwPosition aPos(*pNode, 0);
2137 SwCursorMoveState aMoveState;
2138 aMoveState.m_bPosMatchesBounds = true;
2139 const bool bSuccess = pFrame->GetModelPositionForViewPoint( &aPos, aCorePoint, &aMoveState );
2140
2141 TextFrameIndex nIndex = pFrame->MapModelToViewPos(aPos);
2142 if (TextFrameIndex(0) < nIndex)
2143 {
2144 assert(bSuccess);
2145 SwRect aResultRect;
2146 pFrame->GetCharRect( aResultRect, aPos );
2147 bool bVert = pFrame->IsVertical();
2148 bool bR2L = pFrame->IsRightToLeft();
2149
2150 if ( (!bVert && aResultRect.Pos().getX() > aCorePoint.getX()) ||
2151 ( bVert && aResultRect.Pos().getY() > aCorePoint.getY()) ||
2152 ( bR2L && aResultRect.Right() < aCorePoint.getX()) )
2153 {
2154 SwPosition aPosPrev(pFrame->MapViewToModelPos(nIndex - TextFrameIndex(1)));
2155 SwRect aResultRectPrev;
2156 pFrame->GetCharRect( aResultRectPrev, aPosPrev );
2157 if ( (!bVert && aResultRectPrev.Pos().getX() < aCorePoint.getX() && aResultRect.Pos().getY() == aResultRectPrev.Pos().getY()) ||
2158 ( bVert && aResultRectPrev.Pos().getY() < aCorePoint.getY() && aResultRect.Pos().getX() == aResultRectPrev.Pos().getX()) ||
2159 ( bR2L && aResultRectPrev.Right() > aCorePoint.getX() && aResultRect.Pos().getY() == aResultRectPrev.Pos().getY()) )
2160 {
2161 --nIndex;
2162 }
2163 }
2164 }
2165
2166 return bSuccess
2168 : -1;
2169}
2170
2172{
2173 SolarMutexGuard aGuard;
2174
2176
2177 sal_Int32 nStart, nEnd;
2178 bool bSelected = GetSelection( nStart, nEnd );
2179 return bSelected
2180 ? GetString().copy( nStart, nEnd - nStart )
2181 : OUString();
2182}
2183
2185{
2186 SolarMutexGuard aGuard;
2187
2189
2190 sal_Int32 nStart, nEnd;
2191 GetSelection( nStart, nEnd );
2192 return nStart;
2193}
2194
2196{
2197 SolarMutexGuard aGuard;
2198
2200
2201 sal_Int32 nStart, nEnd;
2202 GetSelection( nStart, nEnd );
2203 return nEnd;
2204}
2205
2206sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2207{
2208 SolarMutexGuard aGuard;
2209
2211
2212 // parameter checking
2213 sal_Int32 nLength = GetString().getLength();
2214 if ( ! IsValidRange( nStartIndex, nEndIndex, nLength ) )
2215 {
2216 throw lang::IndexOutOfBoundsException();
2217 }
2218
2219 bool bRet = false;
2220
2221 // get cursor shell
2222 SwCursorShell* pCursorShell = GetCursorShell();
2223 if( pCursorShell != nullptr )
2224 {
2225 // create pam for selection
2226 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
2227 TextFrameIndex const nStart(GetPortionData().GetCoreViewPosition(nStartIndex));
2228 TextFrameIndex const nEnd(GetPortionData().GetCoreViewPosition(nEndIndex));
2229 SwPaM aPaM(pFrame->MapViewToModelPos(nStart));
2230 aPaM.SetMark();
2231 *aPaM.GetPoint() = pFrame->MapViewToModelPos(nEnd);
2232
2233 // set PaM at cursor shell
2234 bRet = Select( aPaM );
2235 }
2236
2237 return bRet;
2238}
2239
2241{
2242 SolarMutexGuard aGuard;
2243
2245
2246 return GetString();
2247}
2248
2250 sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2251{
2252 SolarMutexGuard aGuard;
2253
2255
2256 OUString sText( GetString() );
2257
2258 if ( !IsValidRange( nStartIndex, nEndIndex, sText.getLength() ) )
2259 throw lang::IndexOutOfBoundsException();
2260
2261 OrderRange( nStartIndex, nEndIndex );
2262 return sText.copy(nStartIndex, nEndIndex-nStartIndex );
2263}
2264
2265/*accessibility::*/TextSegment SwAccessibleParagraph::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
2266{
2267 SolarMutexGuard aGuard;
2268
2270
2271 /*accessibility::*/TextSegment aResult;
2272 aResult.SegmentStart = -1;
2273 aResult.SegmentEnd = -1;
2274
2275 const OUString rText = GetString();
2276 // implement the silly specification that first position after
2277 // text must return an empty string, rather than throwing an
2278 // IndexOutOfBoundsException, except for LINE, where the last
2279 // line is returned
2280 if( nIndex == rText.getLength() && AccessibleTextType::LINE != nTextType )
2281 return aResult;
2282
2283 // with error checking
2284 i18n::Boundary aBound;
2285 bool bWord = GetTextBoundary( aBound, rText, nIndex, nTextType );
2286
2287 OSL_ENSURE( aBound.startPos >= 0, "illegal boundary" );
2288 OSL_ENSURE( aBound.startPos <= aBound.endPos, "illegal boundary" );
2289
2290 // return word (if present)
2291 if ( bWord )
2292 {
2293 aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos );
2294 aResult.SegmentStart = aBound.startPos;
2295 aResult.SegmentEnd = aBound.endPos;
2296 }
2297
2298 return aResult;
2299}
2300
2301/*accessibility::*/TextSegment SwAccessibleParagraph::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
2302{
2303 SolarMutexGuard aGuard;
2304
2306
2307 const OUString rText = GetString();
2308
2309 /*accessibility::*/TextSegment aResult;
2310 aResult.SegmentStart = -1;
2311 aResult.SegmentEnd = -1;
2312 //If nIndex = 0, then nobefore text so return -1 directly.
2313 if( nIndex == 0 )
2314 return aResult;
2315 //Tab will be return when call WORDTYPE
2316
2317 // get starting pos
2318 i18n::Boundary aBound;
2319 if (nIndex == rText.getLength())
2320 aBound.startPos = aBound.endPos = nIndex;
2321 else
2322 {
2323 bool bTmp = GetTextBoundary( aBound, rText, nIndex, nTextType );
2324
2325 if ( ! bTmp )
2326 aBound.startPos = aBound.endPos = nIndex;
2327 }
2328
2329 // now skip to previous word
2330 if (nTextType==2 || nTextType == 3)
2331 {
2332 i18n::Boundary preBound = aBound;
2333 while(preBound.startPos==aBound.startPos && nIndex > 0)
2334 {
2335 nIndex = min( nIndex, preBound.startPos ) - 1;
2336 if( nIndex < 0 ) break;
2337 GetTextBoundary( preBound, rText, nIndex, nTextType );
2338 }
2339 //if (nIndex>0)
2340 if (nIndex>=0)
2341 //Tab will be return when call WORDTYPE
2342 {
2343 aResult.SegmentText = rText.copy( preBound.startPos, preBound.endPos - preBound.startPos );
2344 aResult.SegmentStart = preBound.startPos;
2345 aResult.SegmentEnd = preBound.endPos;
2346 }
2347 }
2348 else
2349 {
2350 bool bWord = false;
2351 while( !bWord )
2352 {
2353 nIndex = min( nIndex, aBound.startPos ) - 1;
2354 if( nIndex >= 0 )
2355 {
2356 bWord = GetTextBoundary( aBound, rText, nIndex, nTextType );
2357 }
2358 else
2359 break; // exit if beginning of string is reached
2360 }
2361
2362 if (bWord && nIndex<rText.getLength())
2363 {
2364 aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos );
2365 aResult.SegmentStart = aBound.startPos;
2366 aResult.SegmentEnd = aBound.endPos;
2367 }
2368 }
2369 return aResult;
2370}
2371
2372/*accessibility::*/TextSegment SwAccessibleParagraph::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
2373{
2374 SolarMutexGuard aGuard;
2375
2377
2378 /*accessibility::*/TextSegment aResult;
2379 aResult.SegmentStart = -1;
2380 aResult.SegmentEnd = -1;
2381 const OUString rText = GetString();
2382
2383 // implement the silly specification that first position after
2384 // text must return an empty string, rather than throwing an
2385 // IndexOutOfBoundsException
2386 if( nIndex == rText.getLength() )
2387 return aResult;
2388
2389 // get first word, then skip to next word
2390 i18n::Boundary aBound;
2391 GetTextBoundary( aBound, rText, nIndex, nTextType );
2392 bool bWord = false;
2393 while( !bWord )
2394 {
2395 nIndex = max( sal_Int32(nIndex+1), aBound.endPos );
2396 if( nIndex < rText.getLength() )
2397 bWord = GetTextBoundary( aBound, rText, nIndex, nTextType );
2398 else
2399 break; // exit if end of string is reached
2400 }
2401
2402 if ( bWord )
2403 {
2404 aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos );
2405 aResult.SegmentStart = aBound.startPos;
2406 aResult.SegmentEnd = aBound.endPos;
2407 }
2408
2409/*
2410 sal_Bool bWord = sal_False;
2411 bWord = GetTextBoundary( aBound, rText, nIndex, nTextType );
2412
2413 if (nTextType==2)
2414 {
2415 Boundary nexBound=aBound;
2416
2417 // real current word
2418 if( nIndex <= aBound.endPos && nIndex >= aBound.startPos )
2419 {
2420 while(nexBound.endPos==aBound.endPos&&nIndex<rText.getLength())
2421 {
2422 // nIndex = max( (sal_Int32)(nIndex), nexBound.endPos) + 1;
2423 nIndex = max( (sal_Int32)(nIndex), nexBound.endPos) ;
2424 const sal_Unicode* pStr = rText.getStr();
2425 if (pStr)
2426 {
2427 if( pStr[nIndex] == sal_Unicode(' ') )
2428 nIndex++;
2429 }
2430 if( nIndex < rText.getLength() )
2431 {
2432 bWord = GetTextBoundary( nexBound, rText, nIndex, nTextType );
2433 }
2434 }
2435 }
2436
2437 if (bWord && nIndex<rText.getLength())
2438 {
2439 aResult.SegmentText = rText.copy( nexBound.startPos, nexBound.endPos - nexBound.startPos );
2440 aResult.SegmentStart = nexBound.startPos;
2441 aResult.SegmentEnd = nexBound.endPos;
2442 }
2443
2444 }
2445 else
2446 {
2447 bWord = sal_False;
2448 while( !bWord )
2449 {
2450 nIndex = max( (sal_Int32)(nIndex+1), aBound.endPos );
2451 if( nIndex < rText.getLength() )
2452 {
2453 bWord = GetTextBoundary( aBound, rText, nIndex, nTextType );
2454 }
2455 else
2456 break; // exit if end of string is reached
2457 }
2458 if (bWord && nIndex<rText.getLength())
2459 {
2460 aResult.SegmentText = rText.copy( aBound.startPos, aBound.endPos - aBound.startPos );
2461 aResult.SegmentStart = aBound.startPos;
2462 aResult.SegmentEnd = aBound.endPos;
2463 }
2464 }
2465*/
2466 return aResult;
2467}
2468
2469sal_Bool SwAccessibleParagraph::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2470{
2471 SolarMutexGuard aGuard;
2472
2474
2475 // select and copy (through dispatch mechanism)
2476 setSelection( nStartIndex, nEndIndex );
2477 ExecuteAtViewShell( SID_COPY );
2478 return true;
2479}
2480
2482 sal_Int32 nEndIndex, AccessibleScrollType aScrollType )
2483{
2484 SolarMutexGuard aGuard;
2485
2487
2488 // parameter checking
2489 sal_Int32 nLength = GetString().getLength();
2490 if ( ! IsValidRange( nStartIndex, nEndIndex, nLength ) )
2491 throw lang::IndexOutOfBoundsException();
2492
2493 vcl::Window *pWin = GetWindow();
2494 if ( ! pWin )
2495 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
2496
2497 /* Start and end character bounds, in pixels, relative to the paragraph */
2498 awt::Rectangle startR, endR;
2499 startR = getCharacterBounds(nStartIndex);
2500 endR = getCharacterBounds(nEndIndex);
2501
2502 /* Adjust points to fit the bounding box of both bounds. */
2503 Point sP(std::min(startR.X, endR.X), startR.Y);
2504 Point eP(std::max(startR.X + startR.Width, endR.X + endR.Width), endR.Y + endR.Height);
2505
2506 /* Offset the values relative to the view shell frame */
2507 SwRect aFrameLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root
2508 Point aFramePixPos( GetMap()->CoreToPixel( aFrameLogBounds ).TopLeft() );
2509 sP += aFramePixPos;
2510 eP += aFramePixPos;
2511
2512 Point startPoint(GetMap()->PixelToCore(sP));
2513 Point endPoint(GetMap()->PixelToCore(eP));
2514
2515 switch (aScrollType)
2516 {
2517#ifdef notyet
2518 case AccessibleScrollType_SCROLL_TOP_LEFT:
2519 break;
2520 case AccessibleScrollType_SCROLL_BOTTOM_RIGHT:
2521 break;
2522 case AccessibleScrollType_SCROLL_TOP_EDGE:
2523 break;
2524 case AccessibleScrollType_SCROLL_BOTTOM_EDGE:
2525 break;
2526 case AccessibleScrollType_SCROLL_LEFT_EDGE:
2527 break;
2528 case AccessibleScrollType_SCROLL_RIGHT_EDGE:
2529 break;
2530#endif
2531 case AccessibleScrollType_SCROLL_ANYWHERE:
2532 break;
2533 default:
2534 return false;
2535 }
2536
2537 const SwRect aRect(startPoint, endPoint);
2538 SwViewShell* pViewShell = GetMap()->GetShell();
2539 OSL_ENSURE( pViewShell != nullptr, "View shell expected!" );
2540
2541 ScrollMDI(pViewShell, aRect, USHRT_MAX, USHRT_MAX);
2542
2543 return true;
2544}
2545
2546// XAccessibleEditableText
2547
2548sal_Bool SwAccessibleParagraph::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2549{
2550 SolarMutexGuard aGuard;
2551
2553
2554 if( !IsEditableState() )
2555 return false;
2556
2557 // select and cut (through dispatch mechanism)
2558 setSelection( nStartIndex, nEndIndex );
2559 ExecuteAtViewShell( SID_CUT );
2560 return true;
2561}
2562
2564{
2565 SolarMutexGuard aGuard;
2566
2568
2569 if( !IsEditableState() )
2570 return false;
2571
2572 // select and paste (through dispatch mechanism)
2574 ExecuteAtViewShell( SID_PASTE );
2575 return true;
2576}
2577
2578sal_Bool SwAccessibleParagraph::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
2579{
2580 return replaceText( nStartIndex, nEndIndex, OUString() );
2581}
2582
2583sal_Bool SwAccessibleParagraph::insertText( const OUString& sText, sal_Int32 nIndex )
2584{
2585 return replaceText( nIndex, nIndex, sText );
2586}
2587
2589 sal_Int32 nStartIndex, sal_Int32 nEndIndex,
2590 const OUString& sReplacement )
2591{
2592 SolarMutexGuard aGuard;
2593
2595
2596 const OUString& rText = GetString();
2597
2598 if( !IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) )
2599 throw lang::IndexOutOfBoundsException();
2600
2601 if( !IsEditableState() )
2602 return false;
2603
2604 // translate positions
2605 TextFrameIndex nStart;
2606 TextFrameIndex nEnd;
2607 bool bSuccess = GetPortionData().GetEditableRange(
2608 nStartIndex, nEndIndex, nStart, nEnd );
2609
2610 // edit only if the range is editable
2611 if( bSuccess )
2612 {
2613 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
2614 // create SwPosition for nStartIndex
2615 SwPosition aStartPos(pFrame->MapViewToModelPos(nStart));
2616
2617 // create SwPosition for nEndIndex
2618 SwPosition aEndPos(pFrame->MapViewToModelPos(nEnd));
2619
2620 // now create XTextRange as helper and set string
2621 const rtl::Reference<SwXTextRange> xRange(
2623 const_cast<SwDoc&>(pFrame->GetDoc()), aStartPos, &aEndPos));
2624 xRange->setString(sReplacement);
2625
2626 // delete portion data
2628 }
2629
2630 return bSuccess;
2631
2632}
2633
2635 sal_Int32 nStartIndex,
2636 sal_Int32 nEndIndex,
2637 const uno::Sequence<PropertyValue>& rAttributeSet )
2638{
2639 SolarMutexGuard aGuard;
2640
2642
2643 const OUString& rText = GetString();
2644
2645 if( ! IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) )
2646 throw lang::IndexOutOfBoundsException();
2647
2648 if( !IsEditableState() )
2649 return false;
2650
2651 // create a (dummy) text portion for the sole purpose of calling
2652 // setPropertyValue on it
2653 rtl::Reference<SwXTextPortion> xPortion = CreateUnoPortion( nStartIndex,
2654 nEndIndex );
2655
2656 // build sorted index array
2657 sal_Int32 nLength = rAttributeSet.getLength();
2658 const PropertyValue* pPairs = rAttributeSet.getConstArray();
2659 std::vector<sal_Int32> aIndices(nLength);
2660 std::iota(aIndices.begin(), aIndices.end(), 0);
2661 std::sort(aIndices.begin(), aIndices.end(), IndexCompare(pPairs));
2662
2663 // create sorted sequences according to index array
2664 uno::Sequence< OUString > aNames( nLength );
2665 OUString* pNames = aNames.getArray();
2666 uno::Sequence< uno::Any > aValues( nLength );
2667 uno::Any* pValues = aValues.getArray();
2668 for (sal_Int32 i = 0; i < nLength; ++i)
2669 {
2670 const PropertyValue& rVal = pPairs[aIndices[i]];
2671 pNames[i] = rVal.Name;
2672 pValues[i] = rVal.Value;
2673 }
2674 aIndices.clear();
2675
2676 // now set the values
2677 bool bRet = true;
2678 try
2679 {
2680 xPortion->setPropertyValues( aNames, aValues );
2681 }
2682 catch (const UnknownPropertyException&)
2683 {
2684 // error handling through return code!
2685 bRet = false;
2686 }
2687
2688 return bRet;
2689}
2690
2692{
2693 return replaceText(0, GetString().getLength(), sText);
2694}
2695
2696// XAccessibleSelection
2697
2699 sal_Int64 nChildIndex )
2700{
2702
2704}
2705
2707 sal_Int64 nChildIndex )
2708{
2710
2712}
2713
2715{
2717}
2718
2720{
2722
2724}
2725
2727{
2729
2731}
2732
2734 sal_Int64 nSelectedChildIndex )
2735{
2737
2738 return m_aSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex);
2739}
2740
2741// index has to be treated as global child index.
2743 sal_Int64 nChildIndex )
2744{
2746
2748}
2749
2750// XAccessibleHypertext
2751
2752namespace {
2753
2754class SwHyperlinkIter_Impl
2755{
2756 SwTextFrame const& m_rFrame;
2757 sw::MergedAttrIter m_Iter;
2758 TextFrameIndex m_nStt;
2759 TextFrameIndex m_nEnd;
2760
2761public:
2762 explicit SwHyperlinkIter_Impl(const SwTextFrame & rTextFrame);
2763 const SwTextAttr *next(SwTextNode const** ppNode = nullptr);
2764
2765 TextFrameIndex startIdx() const { return m_nStt; }
2766 TextFrameIndex endIdx() const { return m_nEnd; }
2767};
2768
2769}
2770
2771SwHyperlinkIter_Impl::SwHyperlinkIter_Impl(const SwTextFrame & rTextFrame)
2772 : m_rFrame(rTextFrame)
2773 , m_Iter(rTextFrame)
2774 , m_nStt(rTextFrame.GetOffset())
2775{
2776 const SwTextFrame *const pFollFrame = rTextFrame.GetFollow();
2777 m_nEnd = pFollFrame ? pFollFrame->GetOffset() : TextFrameIndex(rTextFrame.GetText().getLength());
2778}
2779
2780const SwTextAttr *SwHyperlinkIter_Impl::next(SwTextNode const** ppNode)
2781{
2782 const SwTextAttr *pAttr = nullptr;
2783 if (ppNode)
2784 {
2785 *ppNode = nullptr;
2786 }
2787
2788 SwTextNode const* pNode(nullptr);
2789 while (SwTextAttr const*const pHt = m_Iter.NextAttr(&pNode))
2790 {
2791 if (RES_TXTATR_INETFMT == pHt->Which())
2792 {
2793 const TextFrameIndex nHtStt(m_rFrame.MapModelToView(pNode, pHt->GetStart()));
2794 const TextFrameIndex nHtEnd(m_rFrame.MapModelToView(pNode, pHt->GetAnyEnd()));
2795 if (nHtEnd > nHtStt &&
2796 ((nHtStt >= m_nStt && nHtStt < m_nEnd) ||
2797 (nHtEnd > m_nStt && nHtEnd <= m_nEnd)))
2798 {
2799 pAttr = pHt;
2800 if (ppNode)
2801 {
2802 *ppNode = pNode;
2803 }
2804 break;
2805 }
2806 }
2807 }
2808
2809 return pAttr;
2810};
2811
2813{
2814 SolarMutexGuard aGuard;
2815
2817
2818 sal_Int32 nCount = 0;
2819 // #i77108# - provide hyperlinks also in editable documents.
2820
2821 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() );
2822 SwHyperlinkIter_Impl aIter(*pTextFrame);
2823 while( aIter.next() )
2824 nCount++;
2825
2826 return nCount;
2827}
2828
2829uno::Reference< XAccessibleHyperlink > SAL_CALL
2831{
2832 SolarMutexGuard aGuard;
2833
2835
2836 uno::Reference< XAccessibleHyperlink > xRet;
2837
2838 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() );
2839 SwHyperlinkIter_Impl aHIter(*pTextFrame);
2840 SwTextNode const* pNode(nullptr);
2841 SwTextAttr* pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode));
2842 for (sal_Int32 nTIndex = 0; pHt && nTIndex <= nLinkIndex; ++nTIndex)
2843 {
2844 if( nTIndex == nLinkIndex )
2845 { // found
2846 if (!m_pHyperTextData)
2849 m_pHyperTextData ->find( pHt );
2850 if (aIter != m_pHyperTextData->end())
2851 {
2852 xRet = (*aIter).second;
2853 }
2854 if (!xRet.is())
2855 {
2856 TextFrameIndex const nHintStart(pTextFrame->MapModelToView(pNode, pHt->GetStart()));
2857 TextFrameIndex const nHintEnd(pTextFrame->MapModelToView(pNode, pHt->GetAnyEnd()));
2858 const sal_Int32 nTmpHStt = GetPortionData().GetAccessiblePosition(
2859 max(aHIter.startIdx(), nHintStart));
2860 const sal_Int32 nTmpHEnd = GetPortionData().GetAccessiblePosition(
2861 min(aHIter.endIdx(), nHintEnd));
2862 xRet = new SwAccessibleHyperlink(*pHt,
2863 *this, nTmpHStt, nTmpHEnd );
2864 if (aIter != m_pHyperTextData->end())
2865 {
2866 (*aIter).second = xRet;
2867 }
2868 else
2869 {
2870 m_pHyperTextData->emplace( pHt, xRet );
2871 }
2872 }
2873 break;
2874 }
2875
2876 // iterate next hyperlink
2877 pHt = const_cast<SwTextAttr*>(aHIter.next(&pNode));
2878 }
2879 if( !xRet.is() )
2880 throw lang::IndexOutOfBoundsException();
2881
2882 return xRet;
2883}
2884
2885sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharIndex )
2886{
2887 SolarMutexGuard aGuard;
2888
2890
2891 // parameter checking
2892 sal_Int32 nLength = GetString().getLength();
2893 if ( ! IsValidPosition( nCharIndex, nLength ) )
2894 {
2895 throw lang::IndexOutOfBoundsException();
2896 }
2897
2898 sal_Int32 nRet = -1;
2899 // #i77108#
2900 {
2901 const SwTextFrame *pTextFrame = static_cast<const SwTextFrame*>( GetFrame() );
2902 SwHyperlinkIter_Impl aHIter(*pTextFrame);
2903
2904 const TextFrameIndex nIdx = GetPortionData().GetCoreViewPosition(nCharIndex);
2905 sal_Int32 nPos = 0;
2906 SwTextNode const* pNode(nullptr);
2907 const SwTextAttr *pHt = aHIter.next(&pNode);
2908 while (pHt && (nIdx < pTextFrame->MapModelToView(pNode, pHt->GetStart())
2909 || nIdx >= pTextFrame->MapModelToView(pNode, pHt->GetAnyEnd())))
2910 {
2911 pHt = aHIter.next(&pNode);
2912 nPos++;
2913 }
2914
2915 if( pHt )
2916 nRet = nPos;
2917 }
2918
2919 if (nRet == -1)
2920 throw lang::IndexOutOfBoundsException();
2921 return nRet;
2922}
2923
2924// #i71360#, #i108125# - adjustments for change tracking text markup
2925sal_Int32 SAL_CALL SwAccessibleParagraph::getTextMarkupCount( sal_Int32 nTextMarkupType )
2926{
2928
2929 std::unique_ptr<SwTextMarkupHelper> pTextMarkupHelper;
2930 switch ( nTextMarkupType )
2931 {
2932 case text::TextMarkupType::TRACK_CHANGE_INSERTION:
2933 case text::TextMarkupType::TRACK_CHANGE_DELETION:
2934 case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE:
2935 {
2936 pTextMarkupHelper.reset( new SwTextMarkupHelper(
2938 *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) );
2939 }
2940 break;
2941 default:
2942 {
2943 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
2944 pTextMarkupHelper.reset(new SwTextMarkupHelper(GetPortionData(), *pFrame));
2945 }
2946 }
2947
2948 return pTextMarkupHelper->getTextMarkupCount( nTextMarkupType );
2949}
2950
2951//MSAA Extension Implementation in app module
2953{
2954 return false;
2955}
2956
2958{
2960
2961 sal_Int32 nSelected = 0;
2962 SwPaM* pCursor = GetCursor( true );
2963 if( pCursor != nullptr )
2964 {
2965 // get SwPosition for my node
2966 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
2967 SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
2968 SwNodeOffset nLastNode;
2969 if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
2970 {
2971 nLastNode = pMerged->pLastNode->GetIndex();
2972 }
2973 else
2974 {
2975 nLastNode = nFirstNode;
2976 }
2977
2978 // iterate over ring
2979 for(SwPaM& rTmpCursor : pCursor->GetRingContainer())
2980 {
2981 // ignore, if no mark
2982 if( rTmpCursor.HasMark() )
2983 {
2984 // check whether frame's node(s) are 'inside' pCursor
2985 SwPosition* pStart = rTmpCursor.Start();
2986 SwNodeOffset nStartIndex = pStart->GetNodeIndex();
2987 SwPosition* pEnd = rTmpCursor.End();
2988 SwNodeOffset nEndIndex = pEnd->GetNodeIndex();
2989 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
2990 {
2991 nSelected++;
2992 }
2993 // else: this PaM doesn't point to this paragraph
2994 }
2995 // else: this PaM is collapsed and doesn't select anything
2996 }
2997 }
2998 return nSelected;
2999
3000}
3001
3002sal_Int32 SAL_CALL SwAccessibleParagraph::getSeletedPositionStart( sal_Int32 nSelectedPortionIndex )
3003{
3004 SolarMutexGuard aGuard;
3005
3007
3008 sal_Int32 nStart=-1, nEnd=-1;
3009 /*sal_Bool bSelected = */GetSelectionAtIndex(&nSelectedPortionIndex, nStart, nEnd );
3010 return nStart;
3011}
3012
3013sal_Int32 SAL_CALL SwAccessibleParagraph::getSeletedPositionEnd( sal_Int32 nSelectedPortionIndex )
3014{
3015 SolarMutexGuard aGuard;
3016
3018
3019 sal_Int32 nStart=-1, nEnd=-1;
3020 /*sal_Bool bSelected = */GetSelectionAtIndex(&nSelectedPortionIndex, nStart, nEnd );
3021 return nEnd;
3022}
3023
3024sal_Bool SAL_CALL SwAccessibleParagraph::removeSelection( sal_Int32 selectionIndex )
3025{
3027
3028 if(selectionIndex < 0) return false;
3029
3030 sal_Int32 nSelected = selectionIndex;
3031
3032 // get the selection, and test whether it affects our text node
3033 SwPaM* pCursor = GetCursor( true );
3034
3035 if( pCursor != nullptr )
3036 {
3037 bool bRet = false;
3038
3039 // get SwPosition for my node
3040 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
3041 SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
3042 SwNodeOffset nLastNode;
3043 if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
3044 {
3045 nLastNode = pMerged->pLastNode->GetIndex();
3046 }
3047 else
3048 {
3049 nLastNode = nFirstNode;
3050 }
3051
3052 // iterate over ring
3053 SwPaM* pRingStart = pCursor;
3054 do
3055 {
3056 // ignore, if no mark
3057 if( pCursor->HasMark() )
3058 {
3059 // check whether frame's node(s) are 'inside' pCursor
3060 SwPosition* pStart = pCursor->Start();
3061 SwNodeOffset nStartIndex = pStart->GetNodeIndex();
3062 SwPosition* pEnd = pCursor->End();
3063 SwNodeOffset nEndIndex = pEnd->GetNodeIndex();
3064 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
3065 {
3066 if( nSelected == 0 )
3067 {
3068 pCursor->MoveTo(nullptr);
3069 delete pCursor;
3070 bRet = true;
3071 }
3072 else
3073 {
3074 nSelected--;
3075 }
3076 }
3077 }
3078 // else: this PaM is collapsed and doesn't select anything
3079 if(!bRet)
3080 pCursor = pCursor->GetNext();
3081 }
3082 while( !bRet && (pCursor != pRingStart) );
3083 }
3084 return true;
3085}
3086
3087sal_Int32 SAL_CALL SwAccessibleParagraph::addSelection( sal_Int32, sal_Int32 startOffset, sal_Int32 endOffset)
3088{
3089 SolarMutexGuard aGuard;
3090
3092
3093 // parameter checking
3094 sal_Int32 nLength = GetString().getLength();
3095 if ( ! IsValidRange( startOffset, endOffset, nLength ) )
3096 {
3097 throw lang::IndexOutOfBoundsException();
3098 }
3099
3100 sal_Int32 nSelectedCount = getSelectedPortionCount();
3101 for ( sal_Int32 i = nSelectedCount ; i >= 0 ; i--)
3102 {
3103 sal_Int32 nStart, nEnd;
3104 bool bSelected = GetSelectionAtIndex(&i, nStart, nEnd );
3105 if(bSelected)
3106 {
3107 if(nStart <= nEnd )
3108 {
3109 if (( startOffset>=nStart && startOffset <=nEnd ) || //startOffset in a selection
3110 ( endOffset>=nStart && endOffset <=nEnd ) || //endOffset in a selection
3111 ( startOffset <= nStart && endOffset >=nEnd) || //start and end include the old selection
3112 ( startOffset >= nStart && endOffset <=nEnd) )
3113 {
3115 }
3116
3117 }
3118 else
3119 {
3120 if (( startOffset>=nEnd && startOffset <=nStart ) || //startOffset in a selection
3121 ( endOffset>=nEnd && endOffset <=nStart ) || //endOffset in a selection
3122 ( startOffset <= nStart && endOffset >=nEnd) || //start and end include the old selection
3123 ( startOffset >= nStart && endOffset <=nEnd) )
3124
3125 {
3127 }
3128 }
3129 }
3130
3131 }
3132
3133 // get cursor shell
3134 SwCursorShell* pCursorShell = GetCursorShell();
3135 if( pCursorShell != nullptr )
3136 {
3137 // create pam for selection
3138 pCursorShell->StartAction();
3139 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
3140 SwPaM* aPaM = pCursorShell->CreateCursor();
3141 aPaM->SetMark();
3142 *aPaM->GetPoint() = pFrame->MapViewToModelPos(GetPortionData().GetCoreViewPosition(startOffset));
3143 *aPaM->GetMark() = pFrame->MapViewToModelPos(GetPortionData().GetCoreViewPosition(endOffset));
3144 pCursorShell->EndAction();
3145 }
3146
3147 return 0;
3148}
3149
3150/*accessibility::*/TextSegment SAL_CALL
3151 SwAccessibleParagraph::getTextMarkup( sal_Int32 nTextMarkupIndex,
3152 sal_Int32 nTextMarkupType )
3153{
3155
3156 std::unique_ptr<SwTextMarkupHelper> pTextMarkupHelper;
3157 switch ( nTextMarkupType )
3158 {
3159 case text::TextMarkupType::TRACK_CHANGE_INSERTION:
3160 case text::TextMarkupType::TRACK_CHANGE_DELETION:
3161 case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE:
3162 {
3163 pTextMarkupHelper.reset( new SwTextMarkupHelper(
3165 *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) );
3166 }
3167 break;
3168 default:
3169 {
3170 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
3171 pTextMarkupHelper.reset(new SwTextMarkupHelper(GetPortionData(), *pFrame));
3172 }
3173 }
3174
3175 return pTextMarkupHelper->getTextMarkup( nTextMarkupIndex, nTextMarkupType );
3176}
3177
3178uno::Sequence< /*accessibility::*/TextSegment > SAL_CALL
3180 sal_Int32 nTextMarkupType )
3181{
3183
3184 // parameter checking
3185 const sal_Int32 nLength = GetString().getLength();
3186 if ( ! IsValidPosition( nCharIndex, nLength ) )
3187 {
3188 throw lang::IndexOutOfBoundsException();
3189 }
3190
3191 std::unique_ptr<SwTextMarkupHelper> pTextMarkupHelper;
3192 switch ( nTextMarkupType )
3193 {
3194 case text::TextMarkupType::TRACK_CHANGE_INSERTION:
3195 case text::TextMarkupType::TRACK_CHANGE_DELETION:
3196 case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE:
3197 {
3198 pTextMarkupHelper.reset( new SwTextMarkupHelper(
3200 *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) );
3201 }
3202 break;
3203 default:
3204 {
3205 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
3206 pTextMarkupHelper.reset(new SwTextMarkupHelper(GetPortionData(), *pFrame));
3207 }
3208 }
3209
3210 return pTextMarkupHelper->getTextMarkupAtIndex( nCharIndex, nTextMarkupType );
3211}
3212
3213// #i89175#
3214sal_Int32 SAL_CALL SwAccessibleParagraph::getLineNumberAtIndex( sal_Int32 nIndex )
3215{
3217
3218 // parameter checking
3219 const sal_Int32 nLength = GetString().getLength();
3220 if ( ! IsValidPosition( nIndex, nLength ) )
3221 {
3222 throw lang::IndexOutOfBoundsException();
3223 }
3224
3225 const sal_Int32 nLineNo = GetPortionData().GetLineNo( nIndex );
3226 return nLineNo;
3227}
3228
3229/*accessibility::*/TextSegment SAL_CALL
3231{
3233
3234 // parameter checking
3235 if ( nLineNo < 0 ||
3236 nLineNo >= GetPortionData().GetLineCount() )
3237 {
3238 throw lang::IndexOutOfBoundsException();
3239 }
3240
3241 i18n::Boundary aLineBound;
3242 GetPortionData().GetBoundaryOfLine( nLineNo, aLineBound );
3243
3244 /*accessibility::*/TextSegment aTextAtLine;
3245 const OUString rText = GetString();
3246 aTextAtLine.SegmentText = rText.copy( aLineBound.startPos,
3247 aLineBound.endPos - aLineBound.startPos );
3248 aTextAtLine.SegmentStart = aLineBound.startPos;
3249 aTextAtLine.SegmentEnd = aLineBound.endPos;
3250
3251 return aTextAtLine;
3252}
3253
3254/*accessibility::*/TextSegment SAL_CALL SwAccessibleParagraph::getTextAtLineWithCaret()
3255{
3257
3258 const sal_Int32 nLineNoOfCaret = getNumberOfLineWithCaret();
3259
3260 if ( nLineNoOfCaret >= 0 &&
3261 nLineNoOfCaret < GetPortionData().GetLineCount() )
3262 {
3263 return getTextAtLineNumber( nLineNoOfCaret );
3264 }
3265
3266 return /*accessibility::*/TextSegment();
3267}
3268
3270{
3272
3273 const sal_Int32 nCaretPos = getCaretPosition();
3274 const sal_Int32 nLength = GetString().getLength();
3275 if ( !IsValidPosition( nCaretPos, nLength ) )
3276 {
3277 return -1;
3278 }
3279
3280 sal_Int32 nLineNo = GetPortionData().GetLineNo( nCaretPos );
3281
3282 // special handling for cursor positioned at end of text line via End key
3283 if ( nCaretPos != 0 )
3284 {
3285 i18n::Boundary aLineBound;
3286 GetPortionData().GetBoundaryOfLine( nLineNo, aLineBound );
3287 if ( nCaretPos == aLineBound.startPos )
3288 {
3290 if ( pCursorShell != nullptr )
3291 {
3292 const awt::Rectangle aCharRect = getCharacterBounds( nCaretPos );
3293
3294 const SwRect& aCursorCoreRect = pCursorShell->GetCharRect();
3295 // translate core coordinates into accessibility coordinates
3296 vcl::Window *pWin = GetWindow();
3297 if (!pWin)
3298 {
3299 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
3300 }
3301
3302 tools::Rectangle aScreenRect( GetMap()->CoreToPixel( aCursorCoreRect ));
3303
3304 SwRect aFrameLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root
3305 Point aFramePixPos( GetMap()->CoreToPixel( aFrameLogBounds ).TopLeft() );
3306 aScreenRect.Move( -aFramePixPos.getX(), -aFramePixPos.getY() );
3307
3308 // convert into AWT Rectangle
3309 const awt::Rectangle aCursorRect( aScreenRect.Left(),
3310 aScreenRect.Top(),
3311 aScreenRect.GetWidth(),
3312 aScreenRect.GetHeight() );
3313
3314 if ( aCharRect.X != aCursorRect.X ||
3315 aCharRect.Y != aCursorRect.Y )
3316 {
3317 --nLineNo;
3318 }
3319 }
3320 }
3321 }
3322
3323 return nLineNo;
3324}
3325
3326// #i108125#
3328{
3329 mpParaChangeTrackInfo->reset();
3330}
3331
3333 sal_Int32 * pSelection, sal_Int32& nStart, sal_Int32& nEnd)
3334{
3335 if (pSelection && *pSelection < 0) return false;
3336
3337 bool bRet = false;
3338 nStart = -1;
3339 nEnd = -1;
3340
3341 // get the selection, and test whether it affects our text node
3342 SwPaM* pCursor = GetCursor( true );
3343 if( pCursor != nullptr )
3344 {
3345 // get SwPosition for my node
3346 SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(GetFrame()));
3347 SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex());
3348 SwNodeOffset nLastNode;
3349 if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara())
3350 {
3351 nLastNode = pMerged->pLastNode->GetIndex();
3352 }
3353 else
3354 {
3355 nLastNode = nFirstNode;
3356 }
3357
3358 // iterate over ring
3359 for(SwPaM& rTmpCursor : pCursor->GetRingContainer())
3360 {
3361 // ignore, if no mark
3362 if( rTmpCursor.HasMark() )
3363 {
3364 // check whether frame's node(s) are 'inside' pCursor
3365 SwPosition* pStart = rTmpCursor.Start();
3366 SwNodeOffset nStartIndex = pStart->GetNodeIndex();
3367 SwPosition* pEnd = rTmpCursor.End();
3368 SwNodeOffset nEndIndex = pEnd->GetNodeIndex();
3369 if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex))
3370 {
3371 if (!pSelection || *pSelection == 0)
3372 {
3373 // translate start and end positions
3374
3375 // start position
3376 sal_Int32 nLocalStart = -1;
3377 if (nStartIndex < nFirstNode)
3378 {
3379 // selection starts in previous node:
3380 // then our local selection starts with the paragraph
3381 nLocalStart = 0;
3382 }
3383 else
3384 {
3385 assert(FrameContainsNode(*pFrame, nStartIndex));
3386
3387 // selection starts in this node:
3388 // then check whether it's before or inside our part of
3389 // the paragraph, and if so, get the proper position
3390 const TextFrameIndex nCoreStart =
3391 pFrame->MapModelToViewPos(*pStart);
3392 if( nCoreStart <
3393 GetPortionData().GetFirstValidCorePosition() )
3394 {
3395 nLocalStart = 0;
3396 }
3397 else if( nCoreStart <=
3398 GetPortionData().GetLastValidCorePosition() )
3399 {
3401 !GetPortionData().IsValidCorePosition(
3402 nCoreStart),
3403 "sw.a11y",
3404 "problem determining valid core position");
3405
3406 nLocalStart =
3408 nCoreStart );
3409 }
3410 }
3411
3412 // end position
3413 sal_Int32 nLocalEnd = -1;
3414 if (nLastNode < nEndIndex)
3415 {
3416 // selection ends in following node:
3417 // then our local selection extends to the end
3418 nLocalEnd = GetPortionData().GetAccessibleString().
3419 getLength();
3420 }
3421 else
3422 {
3423 assert(FrameContainsNode(*pFrame, nEndIndex));
3424
3425 // selection ends in this node: then select everything
3426 // before our part of the node
3427 const TextFrameIndex nCoreEnd =
3428 pFrame->MapModelToViewPos(*pEnd);
3429 if( nCoreEnd >
3430 GetPortionData().GetLastValidCorePosition() )
3431 {
3432 // selection extends beyond out part of this para
3433 nLocalEnd = GetPortionData().GetAccessibleString().
3434 getLength();
3435 }
3436 else if( nCoreEnd >=
3437 GetPortionData().GetFirstValidCorePosition() )
3438 {
3439 // selection is inside our part of this para
3441 !GetPortionData().IsValidCorePosition(
3442 nCoreEnd),
3443 "sw.a11y",
3444 "problem determining valid core position");
3445
3447 nCoreEnd );
3448 }
3449 }
3450
3451 if( ( nLocalStart != -1 ) && ( nLocalEnd != -1 ) )
3452 {
3453 nStart = nLocalStart;
3454 nEnd = nLocalEnd;
3455 bRet = true;
3456 }
3457 } // if hit the index
3458 else
3459 {
3460 --*pSelection;
3461 }
3462 }
3463 // else: this PaM doesn't point to this paragraph
3464 }
3465 // else: this PaM is collapsed and doesn't select anything
3466 if(bRet)
3467 break;
3468 }
3469 }
3470 // else: nocursor -> no selection
3471
3472 if (pSelection && bRet)
3473 {
3474 sal_Int32 nCaretPos = GetCaretPos();
3475 if( nStart == nCaretPos )
3476 std::swap( nStart, nEnd );
3477 }
3478 return bRet;
3479}
3480
3482{
3484
3485 //Get the real heading level, Heading1 ~ Heading10
3486 if (m_nHeadingLevel > 0)
3487 {
3488 return AccessibleRole::HEADING;
3489 }
3490 else
3491 {
3492 return AccessibleRole::PARAGRAPH;
3493 }
3494}
3495
3496//Get the real heading level, Heading1 ~ Heading10
3498{
3499 uno::Reference< css::beans::XPropertySet > xPortion = CreateUnoPortion( 0, 0 );
3500 uno::Any styleAny = xPortion->getPropertyValue( "ParaStyleName" );
3501 OUString sValue;
3502 if (styleAny >>= sValue)
3503 {
3504 sal_Int32 length = sValue.getLength();
3505 if (length == 9 || length == 10)
3506 {
3507 if (sValue.startsWith("Heading"))
3508 {
3509 std::u16string_view intStr = sValue.subView(8);
3510 sal_Int32 headingLevel = o3tl::toInt32(intStr);
3511 return headingLevel;
3512 }
3513 }
3514 }
3515 return -1;
3516}
3517
3519{
3521
3522 uno::Any Ret;
3523 OUString strHeading("heading-level:");
3524 if( m_nHeadingLevel >= 0 )
3525 strHeading += OUString::number(m_nHeadingLevel);
3526 // tdf#84102: expose the same attribute with the name "level"
3527 strHeading += ";level:";
3528 if( m_nHeadingLevel >= 0 )
3529 strHeading += OUString::number(m_nHeadingLevel);
3530 strHeading += ";";
3531
3532 Ret <<= strHeading;
3533
3534 return Ret;
3535}
3536
3537/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
constexpr OUStringLiteral sAccessibleServiceName
Definition: acccontext.hxx:42
static uno::Sequence< OUString > const & getSupplementalAttributeNames()
Definition: accpara.cxx:903
static void SetPutRecursive(SfxItemSet &targetSet, const SfxItemSet &sourceSet)
Definition: accpara.cxx:1426
static bool lcl_GetBackgroundColor(Color &rColor, const SwFrame *pFrame, SwCursorShell *pCursorSh)
Definition: accpara.cxx:797
constexpr OUStringLiteral sServiceName
Definition: accpara.cxx:115
static uno::Sequence< OUString > const & getAttributeNames()
Definition: accpara.cxx:880
constexpr OUStringLiteral sImplementationName
Definition: accpara.cxx:116
std::unordered_map< OUString, css::beans::PropertyValue > tAccParaPropValMap
Definition: accpara.hxx:51
AnyEventRef aEvent
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:34
sal_uInt16 m_nAttr
Definition: authratr.hxx:30
Color m_nColor
Definition: authratr.hxx:31
sal_uInt16 m_nItemId
Definition: authratr.hxx:29
bool IsDark() const
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > & getPropertyEntries() const
const SfxItemPropertyMap & getPropertyMap() const
const SfxItemSet * GetParent() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListeningAll()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Width() const
const Color & GetColor() const
void FireStateChangedEvent(sal_Int64 nState, bool bNewState)
Definition: acccontext.cxx:466
void SetName(const OUString &rName)
Definition: acccontext.hxx:99
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:440
virtual void GetStates(sal_Int64 &rStateSet)
Definition: acccontext.cxx:480
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: acccontext.cxx:687
virtual sal_Int32 SAL_CALL getBackground() override
vcl::Window * GetWindow()
Definition: acccontext.cxx:80
virtual sal_Int32 SAL_CALL getForeground() override
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:112
bool Select(SwPaM *pPaM, SdrObject *pObj, bool bAdd)
std::mutex m_Mutex
Definition: acccontext.hxx:64
SwCursorShell * GetCursorShell()
convenience method to get SwCursorShell through accessibility map
Definition: acccontext.cxx:98
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:116
SwRect GetBounds(const SwAccessibleMap &rAccMap, const SwFrame *pFrame=nullptr)
Definition: accframe.cxx:328
const SwFrame * GetFrame() const
Definition: accframe.hxx:102
std::map< key_type, mapped_type, key_compare >::iterator iterator
void SetCursorContext(const ::rtl::Reference< SwAccessibleContext > &rCursorContext)
Definition: accmap.cxx:2747
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1796
virtual Point LogicToPixel(const Point &rPoint) const override
Definition: accmap.cxx:3032
SwViewShell * GetShell() const
Definition: accmap.hxx:174
virtual sal_Int32 SAL_CALL getSelectedPortionCount() override
Definition: accpara.cxx:2957
bool GetWordBoundary(css::i18n::Boundary &rBound, const OUString &rText, sal_Int32 nPos)
Definition: accpara.cxx:550
std::unique_ptr< SwParaChangeTrackingInfo > mpParaChangeTrackInfo
Definition: accpara.hxx:87
virtual sal_Int32 SAL_CALL getForeground() override
Definition: accpara.cxx:829
virtual sal_Bool SAL_CALL setText(const OUString &sText) override
Definition: accpara.cxx:2691
virtual sal_Bool SAL_CALL insertText(const OUString &sText, sal_Int32 nIndex) override
Definition: accpara.cxx:2583
bool IsHeading() const
Definition: accpara.cxx:209
static bool IsValidRange(sal_Int32 nBegin, sal_Int32 nEnd, sal_Int32 nLength)
Definition: accpara.cxx:516
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
Definition: accpara.cxx:2301
std::unique_ptr< SwAccessiblePortionData > m_pPortionData
Definition: accpara.hxx:74
sal_Int32 m_nHeadingLevel
Definition: accpara.hxx:82
virtual css::uno::Any SAL_CALL getExtendedAttributes() override
Definition: accpara.cxx:3518
static void OrderRange(sal_Int32 &nBegin, sal_Int32 &nEnd)
Definition: accpara.hxx:133
virtual void GetStates(sal_Int64 &rStateSet) override
Definition: accpara.cxx:216
static OUString GetDescription()
Definition: accpara.cxx:123
virtual void InvalidateContent_(bool bVisibleDataFired) override
Definition: accpara.cxx:247
virtual sal_Bool SAL_CALL scrollToPosition(const css::awt::Point &aPoint, sal_Bool isLeftTop) override
Definition: accpara.cxx:2952
friend class SwAccessibleHyperlink
Definition: accpara.hxx:65
bool GetCharBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos)
Definition: accpara.cxx:538
static bool GetParagraphBoundary(css::i18n::Boundary &rBound, std::u16string_view aText)
Definition: accpara.cxx:599
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
Definition: accpara.cxx:2733
OUString GetFieldTypeNameAtIndex(sal_Int32 nIndex)
Definition: accpara.cxx:1158
virtual sal_Bool SAL_CALL cutText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: accpara.cxx:2548
virtual sal_Int32 SAL_CALL getSelectionStart() override
Definition: accpara.cxx:2184
rtl::Reference< SwXTextPortion > CreateUnoPortion(sal_Int32 nStart, sal_Int32 nEnd)
Definition: accpara.cxx:476
virtual void InvalidateCursorPos_() override
Definition: accpara.cxx:329
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
Definition: accpara.cxx:1027
virtual sal_Int32 SAL_CALL addSelection(sal_Int32 selectionIndex, sal_Int32 startOffset, sal_Int32 endOffset) override
Definition: accpara.cxx:3087
css::uno::Sequence< css::style::TabStop > GetCurrentTabStop(sal_Int32 nIndex)
Definition: accpara.cxx:1074
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Definition: accpara.cxx:728
virtual sal_Bool SAL_CALL replaceText(sal_Int32 nStartIndex, sal_Int32 nEndIndex, const OUString &sReplacement) override
Definition: accpara.cxx:2588
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
Definition: accpara.cxx:2706
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
Definition: accpara.cxx:1327
virtual sal_Int32 SAL_CALL getBackground() override
Definition: accpara.cxx:850
bool GetSentenceBoundary(css::i18n::Boundary &rBound, const OUString &rText, sal_Int32 nPos)
Definition: accpara.cxx:574
virtual sal_Int32 SAL_CALL getLineNumberAtIndex(sal_Int32 nIndex) override
Definition: accpara.cxx:3214
std::unique_ptr< SwAccessibleHyperTextData > m_pHyperTextData
Definition: accpara.hxx:75
virtual sal_Bool SAL_CALL pasteText(sal_Int32 nIndex) override
Definition: accpara.cxx:2563
void ExecuteAtViewShell(sal_uInt16 nSlot)
Definition: accpara.cxx:455
virtual OUString SAL_CALL getText() override
Definition: accpara.cxx:2240
SwAccessibleSelectionHelper m_aSelectionHelper
Definition: accpara.hxx:85
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
Definition: accpara.cxx:2372
static bool IsValidPosition(sal_Int32 nPos, sal_Int32 nLength)
Definition: accpara.cxx:510
virtual bool HasCursor() override
Definition: accpara.cxx:425
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
Definition: accpara.cxx:2481
bool GetGlyphBoundary(css::i18n::Boundary &rBound, const OUString &rText, sal_Int32 nPos)
Definition: accpara.cxx:616
virtual sal_Bool SAL_CALL setAttributes(sal_Int32 nStartIndex, sal_Int32 nEndIndex, const css::uno::Sequence< css::beans::PropertyValue > &aAttributeSet) override
Definition: accpara.cxx:2634
SwAccessiblePortionData & GetPortionData()
Definition: accpara.hxx:188
virtual OUString SAL_CALL getAccessibleDescription() override
Definition: accpara.cxx:699
sal_Int32 m_nOldCaretPos
Definition: accpara.hxx:77
sal_Int32 GetRealHeadingLevel()
Definition: accpara.cxx:3497
virtual css::lang::Locale SAL_CALL getLocale() override
Return the parents locale or throw exception if this object has no parent yet/anymore.
Definition: accpara.cxx:712
virtual css::accessibility::TextSegment SAL_CALL getTextAtLineNumber(sal_Int32 nLineNo) override
Definition: accpara.cxx:3230
virtual void SAL_CALL clearAccessibleSelection() override
Definition: accpara.cxx:2714
SwPaM * GetCursor(const bool _bForSelection)
Definition: accpara.cxx:186
virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
Definition: accpara.cxx:2726
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: accpara.cxx:2249
SwAccessibleParagraph(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTextFrame &rTextFrame)
Definition: accpara.cxx:396
virtual ~SwAccessibleParagraph() override
Definition: accpara.cxx:415
static bool IsValidChar(sal_Int32 nPos, sal_Int32 nLength)
Definition: accpara.cxx:504
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getDefaultAttributes(const css::uno::Sequence< OUString > &aRequestedAttributes) override
Definition: accpara.cxx:1586
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
Definition: accpara.cxx:2029
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: accpara.cxx:875
virtual OUString SAL_CALL getImplementationName() override
Definition: accpara.cxx:864
virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nChildIndex) override
Definition: accpara.cxx:2742
virtual sal_Int32 SAL_CALL getHyperLinkCount() override
Definition: accpara.cxx:2812
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: accpara.cxx:3327
bool GetAttributeBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos)
Definition: accpara.cxx:608
virtual sal_Int16 SAL_CALL getAccessibleRole() override
Definition: accpara.cxx:3481
OUString const & GetString()
get the (accessible) text string (requires frame; check before)
Definition: accpara.cxx:118
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: accpara.cxx:2206
virtual css::uno::Sequence< css::accessibility::TextSegment > SAL_CALL getTextMarkupAtIndex(sal_Int32 nCharIndex, sal_Int32 nTextMarkupType) override
Definition: accpara.cxx:3179
virtual css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL getHyperLink(sal_Int32 nLinkIndex) override
Definition: accpara.cxx:2830
virtual sal_Int32 SAL_CALL getSeletedPositionEnd(sal_Int32 nSelectedPortionIndex) override
Definition: accpara.cxx:3013
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: accpara.cxx:2469
bool GetLineBoundary(css::i18n::Boundary &rBound, std::u16string_view aText, sal_Int32 nPos)
Definition: accpara.cxx:587
virtual sal_Int32 SAL_CALL getSeletedPositionStart(sal_Int32 nSelectedPortionIndex) override
Definition: accpara.cxx:3002
sal_Int32 GetCaretPos()
Definition: accpara.cxx:128
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: accpara.cxx:923
virtual sal_Int32 SAL_CALL getNumberOfLineWithCaret() override
Definition: accpara.cxx:3269
const SwRangeRedline * GetRedlineAtIndex()
Definition: accpara.cxx:523
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: accpara.cxx:999
virtual sal_Int32 SAL_CALL getTextMarkupCount(sal_Int32 nTextMarkupType) override
Definition: accpara.cxx:2925
virtual void SAL_CALL grabFocus() override
Definition: accpara.cxx:763
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRunAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
Definition: accpara.cxx:1721
void _getRunAttributesImpl(const sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes, tAccParaPropValMap &rRunAttrSeq)
Definition: accpara.cxx:1624
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: accpara.cxx:985
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: accpara.cxx:869
virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
Definition: accpara.cxx:2698
void _getDefaultAttributesImpl(const css::uno::Sequence< OUString > &aRequestedAttributes, tAccParaPropValMap &rDefAttrSeq, const bool bOnlyCharAttrs=false)
Definition: accpara.cxx:1435
virtual css::accessibility::TextSegment SAL_CALL getTextMarkup(sal_Int32 nTextMarkupIndex, sal_Int32 nTextMarkupType) override
Definition: accpara.cxx:3151
virtual sal_Bool SAL_CALL deleteText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Definition: accpara.cxx:2578
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &aPoint) override
Definition: accpara.cxx:2095
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
Definition: accpara.cxx:1059
virtual css::accessibility::TextSegment SAL_CALL getTextAtLineWithCaret() override
Definition: accpara.cxx:3254
void _correctValues(const sal_Int32 nIndex, std::vector< css::beans::PropertyValue > &rValues)
Definition: accpara.cxx:1801
virtual OUString SAL_CALL getSelectedText() override
Definition: accpara.cxx:2171
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: accpara.cxx:2719
virtual void InvalidateFocus_() override
Definition: accpara.cxx:379
virtual sal_Int32 SAL_CALL getCaretPosition() override
Definition: accpara.cxx:1006
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
Definition: accpara.cxx:2265
bool GetTextBoundary(css::i18n::Boundary &rBound, const OUString &rText, sal_Int32 nPos, sal_Int16 aTextType)
Definition: accpara.cxx:644
virtual sal_Bool SAL_CALL removeSelection(sal_Int32 selectionIndex) override
Definition: accpara.cxx:3024
bool GetSelectionAtIndex(sal_Int32 *pSelection, sal_Int32 &nStart, sal_Int32 &nEnd)
Definition: accpara.cxx:3332
virtual sal_Int32 SAL_CALL getSelectionEnd() override
Definition: accpara.cxx:2195
virtual sal_Int32 SAL_CALL getHyperLinkIndex(sal_Int32 nCharIndex) override
Definition: accpara.cxx:2885
bool GetSelection(sal_Int32 &nStart, sal_Int32 &nEnd)
Definition: accpara.hxx:104
void _getSupplementalAttributesImpl(const css::uno::Sequence< OUString > &aRequestedAttributes, tAccParaPropValMap &rSupplementalAttrSeq)
Definition: accpara.cxx:1743
virtual sal_Int32 SAL_CALL getCharacterCount() override
Definition: accpara.cxx:2086
collect text portion data from the layout through SwPortionHandler interface
Definition: accportions.hxx:40
void GetBoundaryOfLine(const sal_Int32 nLineNo, css::i18n::Boundary &rLineBound)
bool IsIndexInFootnode(sal_Int32 nIndex)
sal_Int32 GetFieldIndex(sal_Int32 nPos) const
void GetSentenceBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos)
void GetAttributeBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos) const
bool IsInGrayPortion(sal_Int32 nPos)
bool GetEditableRange(sal_Int32 nStart, sal_Int32 nEnd, TextFrameIndex &rCoreStart, TextFrameIndex &rCoreEnd) const
Convert start and end positions into core positions.
TextFrameIndex GetCoreViewPosition(sal_Int32 nPos) const
get the position in the core view string for a given (accessibility) position
void GetLineBoundary(css::i18n::Boundary &rBound, sal_Int32 nPos) const
get the start & end positions of the sentence
void GetLastLineBoundary(css::i18n::Boundary &rBound) const
const OUString & GetAccessibleString() const
get the text string, as presented by the layout
sal_Int32 GetAccessiblePosition(TextFrameIndex nPos) const
get the position in the accessibility string for a given view position
TextFrameIndex FillSpecialPos(sal_Int32 nPos, SwSpecialPos &rPos, SwSpecialPos *&rpPos) const
fill a SwSpecialPos structure, suitable for calling SwTextFrame->GetCharRect Returns the core positio...
sal_Int32 GetLineNo(const sal_Int32 nPos) const
bool isAccessibleChildSelected(sal_Int64 nChildIndex)
void selectAccessibleChild(sal_Int64 nChildIndex)
css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex)
void deselectAccessibleChild(sal_Int64 nChildIndex)
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Definition: breakit.hxx:63
const css::lang::Locale & GetLocale(const LanguageType aLang)
Definition: breakit.hxx:68
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:59
bool HasSwAttrSet() const
Definition: node.hxx:494
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
void StartAction()
Definition: crsrsh.cxx:226
const SwRect & GetCharRect() const
Definition: crsrsh.hxx:533
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
SwPaM * CreateCursor()
delete the current cursor and make the following into the current
Definition: crsrsh.cxx:123
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
bool IsTableMode() const
Definition: crsrsh.hxx:660
Definition: doc.hxx:195
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:343
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1803
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1331
bool IsFrameSelected() const
Definition: feshview.cxx:1253
size_t IsObjSelected() const
Definition: feshview.cxx:1245
sal_uInt16 GetFormatCount(SwFieldTypesEnum nTypeId, bool bHtmlMode) const
Definition: fldmgr.cxx:678
void GetSubTypes(SwFieldTypesEnum nId, std::vector< OUString > &rToFill)
Definition: fldmgr.cxx:575
OUString GetFormatStr(SwFieldTypesEnum nTypeId, sal_uInt32 nFormatId) const
Definition: fldmgr.cxx:721
virtual OUString GetName() const
Only in derived classes.
Definition: fldbas.cxx:137
SwFieldIds Which() const
Definition: fldbas.hxx:275
static const OUString & GetTypeStr(SwFieldTypesEnum nTypeId)
Definition: fldbas.cxx:122
Base class of all fields.
Definition: fldbas.hxx:295
SwFieldTypesEnum GetTypeId() const
Definition: fldbas.cxx:261
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:346
sal_uInt32 GetFormat() const
Query parameters for dialog and for BASIC.
Definition: fldbas.hxx:406
SwFieldType * GetTyp() const
Definition: fldbas.hxx:401
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
const SwField * GetField() const
Definition: fmtfld.hxx:131
const OUString & GetName() const
Definition: format.hxx:131
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
SwTextFrame * DynCastTextFrame()
Definition: findfrm.cxx:1914
SwContentFrame * FindPrevCnt()
Definition: findfrm.cxx:200
SwFrameType GetType() const
Definition: frame.hxx:521
bool IsRightToLeft() const
Definition: frame.hxx:993
bool GetBackgroundBrush(drawinglayer::attribute::SdrAllFillAttributesHelperPtr &rFillAttributes, const SvxBrushItem *&rpBrush, std::optional< Color > &rxColor, SwRect &rOrigRect, bool bLowerMode, bool bConsiderTextBox) const
Determine the background brush for the frame: the background brush is taken from it-self or from its ...
Definition: paintfrm.cxx:7432
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
bool IsVertical() const
Definition: frame.hxx:979
bool IsFlyFrame() const
Definition: frame.hxx:1216
virtual css::uno::Sequence< css::style::TabStop > GetTabStopInfo(SwTwips)
Definition: frame.hxx:515
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
Definition: findfrm.cxx:216
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
bool IsRefToNumItemCrossRefBookmark() const
Definition: reffld.cxx:386
bool IsRefToHeadingCrossRefBookmark() const
Definition: reffld.cxx:380
const AuthorCharAttr & GetFormatAuthorAttr() const
Definition: modcfg.hxx:253
const AuthorCharAttr & GetDeletedAuthorAttr() const
Definition: modcfg.hxx:249
const AuthorCharAttr & GetInsertAuthorAttr() const
Definition: modcfg.hxx:245
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:903
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwDoc & GetDoc()
Definition: node.hxx:233
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
bool IsInFrontOfLabel() const
Definition: pam.hxx:225
const SwPosition * End() const
Definition: pam.hxx:271
SwPaM * GetNext()
Definition: pam.hxx:320
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1940
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
bool IsOn() const
Definition: docufld.hxx:613
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
sal_Int32 GetAnyEnd() const
end (if available), else start
Definition: txatbase.hxx:161
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:199
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:166
SwDoc & GetDoc()
Definition: txtfrm.hxx:470
SwTextFrame * GetFollow()
Definition: txtfrm.hxx:869
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
Definition: txtfrm.cxx:1246
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
Definition: txtfrm.cxx:1343
TextFrameIndex GetOffset() const
Definition: txtfrm.hxx:448
bool HasPara() const
Definition: txtfrm.hxx:833
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
Definition: txtfrm.cxx:1231
sw::MergedPara * GetMergedPara()
Definition: txtfrm.hxx:460
TextFrameIndex MapModelToView(SwTextNode const *pNode, sal_Int32 nIndex) const
Definition: txtfrm.cxx:1252
void VisitPortions(SwPortionHandler &rPH) const
Visit all portions for Accessibility.
Definition: txtfrm.cxx:3967
TextFrameIndex MapModelToViewPos(SwPosition const &rPos) const
Definition: txtfrm.cxx:1267
bool IsInside(TextFrameIndex nPos) const
Respect the Follows.
Definition: txtfrm.hxx:843
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:467
virtual bool GetCharRect(SwRect &rRect, const SwPosition &rPos, SwCursorMoveState *pCMS=nullptr, bool bAllowFarAway=true) const override
Returns the view rectangle for the rPos model position.
Definition: frmcrsr.cxx:178
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
Definition: txtfrm.cxx:1293
SwTextNode const * GetTextNodeForParaProps() const
Definition: txtfrm.cxx:1303
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
In nOffset returns the offset of the char within the set text buffer, which is closest to the positio...
Definition: frmcrsr.cxx:661
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
bool HasBullet() const
Returns if this text node has a bullet.
Definition: ndtxt.cxx:3227
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:291
SwWrongList * GetWrong()
Definition: txtedt.cxx:2223
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
End: Data collected during idle time.
Definition: node.hxx:770
bool IsOutline() const
Returns if this text node is an outline.
Definition: ndtxt.cxx:4163
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
Definition: itratr.cxx:859
bool HasNumber(SwRootFrame const *pLayout=nullptr) const
Returns if this text node has a number.
Definition: ndtxt.cxx:3211
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:897
o3tl::span< const SfxItemPropertyMapEntry > GetPropertyMapEntries(sal_uInt16 PropertyId)
Definition: unomap.cxx:73
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1082
const Color & GetFieldShadingsColor() const
Definition: viewopt.cxx:526
bool IsOnlineSpell() const
Definition: viewopt.hxx:539
Color GetRetoucheColor() const
Definition: viewimp.cxx:290
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:434
SwViewShellImp * Imp()
Definition: viewsh.hxx:190
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:452
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
Definition: wrong.cxx:103
static rtl::Reference< SwXTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1199
static bool implInitTextChangedEvent(std::u16string_view rOldString, std::u16string_view rNewString, css::uno::Any &rDeleted, css::uno::Any &rInserted)
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:91
void MoveTo(value_type *pDestRing)
Removes this item from its current ring container and adds it to another ring container.
Definition: ring.hxx:135
ring_container GetRingContainer()
Definition: ring.hxx:240
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long GetHeight() const
constexpr tools::Long Left() const
void GrabFocus()
bool HasFocus() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
ColorTransparency
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLUE(0x00, 0x00, 0x80)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define COL_NONE_COLOR
int nCount
float u
#define max(a, b)
void ScrollMDI(SwViewShell const *pVwSh, const SwRect &rRect, sal_uInt16 nRangeX, sal_uInt16 nRangeY)
Definition: edtwin3.cxx:35
SwFieldIds
Definition: fldbas.hxx:46
LINESTYLE_WAVE
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr sal_uInt16 RES_CHRATR_END(46)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SfxInt16Item > RES_PARATR_LIST_LEVEL(83)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr sal_uInt16 RES_PARATR_END(82)
constexpr TypedWhichId< SvxTabStopItem > RES_PARATR_TABSTOP(68)
constexpr TypedWhichId< SvxLineSpacingItem > RES_PARATR_LINESPACING(RES_PARATR_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr sal_uInt16 RES_PARATR_LIST_BEGIN(RES_PARATR_END)
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr sal_uInt16 RES_PARATR_LIST_END(88)
constexpr TypedWhichId< SvxRightMarginItem > RES_MARGIN_RIGHT(93)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:294
double getLength(const B2DPolygon &rCandidate)
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< typename M::mapped_type > mapValuesToSequence(M const &map)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
int i
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
static constexpr auto Items
bool FrameContainsNode(SwContentFrame const &rFrame, SwNodeOffset nNodeIndex)
Definition: txtfrm.cxx:290
TextFrameIndex MapModelToView(MergedPara const &, SwTextNode const *pNode, sal_Int32 nIndex)
Definition: txtfrm.cxx:1183
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
@ REF_SETREFATTR
Definition: reffld.hxx:37
@ REF_SEQUENCEFLD
Definition: reffld.hxx:38
@ REF_FOOTNOTE
Definition: reffld.hxx:41
@ REF_BOOKMARK
Definition: reffld.hxx:39
@ REF_ENDNOTE
Definition: reffld.hxx:42
bool m_bRealHeight
should the real height be calculated?
Definition: crstate.hxx:141
SwSpecialPos * m_pSpecialPos
for positions inside fields
Definition: crstate.hxx:136
bool m_bRealWidth
Calculation of the width required.
Definition: crstate.hxx:149
bool m_bPosMatchesBounds
GetModelPositionForViewPoint should not return the next position if screen position is inside second ...
Definition: crstate.hxx:152
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
SwDoc & GetDoc() const
Returns the document this position is in.
Definition: pam.cxx:217
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Definition: txtfrm.hxx:971
Object Value
#define SW_MOD()
Definition: swmodule.hxx:256
unsigned char sal_Bool
sal_uInt16 sal_Unicode
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:28
#define PROPERTY_MAP_ACCESSIBILITY_TEXT_ATTRIBUTE
Definition: unomap.hxx:125
@ PORTION_TEXT
Definition: unoport.hxx:55
constexpr OUStringLiteral UNO_NAME_CHAR_CONTOURED
Definition: unoprnms.hxx:256
constexpr OUStringLiteral UNO_NAME_PARA_LEFT_MARGIN
Definition: unoprnms.hxx:58
constexpr OUStringLiteral UNO_NAME_CHAR_SHADOWED
constexpr OUStringLiteral UNO_NAME_PARA_RIGHT_MARGIN
Definition: unoprnms.hxx:59
constexpr OUStringLiteral UNO_NAME_CHAR_EMPHASIS
Definition: unoprnms.hxx:153
constexpr OUStringLiteral UNO_NAME_CHAR_BACK_COLOR
Definition: unoprnms.hxx:148
constexpr OUStringLiteral UNO_NAME_CHAR_UNDERLINE
constexpr OUStringLiteral UNO_NAME_PARA_FIRST_LINE_INDENT
Definition: unoprnms.hxx:64
constexpr OUStringLiteral UNO_NAME_PARA_STYLE_NAME
Definition: unoprnms.hxx:189
constexpr OUStringLiteral UNO_NAME_CHAR_POSTURE
constexpr OUStringLiteral UNO_NAME_TABSTOPS
Definition: unoprnms.hxx:336
constexpr OUStringLiteral UNO_NAME_WRITING_MODE
Definition: unoprnms.hxx:719
constexpr OUStringLiteral UNO_NAME_CHAR_COLOR
constexpr OUStringLiteral UNO_NAME_NUMBERING_LEVEL
constexpr OUStringLiteral UNO_NAME_CHAR_ESCAPEMENT
Definition: unoprnms.hxx:125
constexpr OUStringLiteral UNO_NAME_CHAR_STRIKEOUT
Definition: unoprnms.hxx:127
constexpr OUStringLiteral UNO_NAME_PARA_ADJUST
Definition: unoprnms.hxx:187
constexpr OUStringLiteral UNO_NAME_PARA_LINE_SPACING
Definition: unoprnms.hxx:154
constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT
constexpr OUStringLiteral UNO_NAME_PARA_BOTTOM_MARGIN
Definition: unoprnms.hxx:156
constexpr OUStringLiteral UNO_NAME_CHAR_FONT_NAME
Definition: unoprnms.hxx:97
constexpr OUStringLiteral UNO_NAME_CHAR_UNDERLINE_COLOR
Definition: unoprnms.hxx:123
constexpr OUStringLiteral UNO_NAME_CHAR_WEIGHT
constexpr OUStringLiteral UNO_NAME_NUMBERING_RULES
size_t pos
sal_Int32 nLength