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