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