25#include <com/sun/star/text/TextMarkupType.hpp>
26#include <com/sun/star/accessibility/TextSegment.hpp>
27#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28#include <com/sun/star/lang/IllegalArgumentException.hpp>
31#include <osl/diagnose.h>
42 getTextMarkupFunc(
const sal_Int32 nTextMarkupType))()
const
44 switch ( nTextMarkupType )
46 case text::TextMarkupType::SPELLCHECK:
51 case text::TextMarkupType::PROOFREADING:
57 case text::TextMarkupType::SMARTTAG:
65 throw lang::IllegalArgumentException();
74 : mrPortionData( rPortionData )
75 , m_pTextFrame(&rTextFrame)
76 , mpTextMarkupList( nullptr )
83 : mrPortionData( rPortionData )
84 , m_pTextFrame( nullptr )
85 , mpTextMarkupList( &rTextMarkupList )
92 std::unique_ptr<sw::WrongListIteratorCounter> pIter;
113 sal_Int32 nTextMarkupCount( 0 );
115 std::unique_ptr<sw::WrongListIteratorCounter> pIter =
getIterator(nTextMarkupType);
119 for (sal_uInt16
i = 0;
i < pIter->GetElementCount();
i++)
121 std::optional<std::pair<TextFrameIndex, TextFrameIndex>> oIndices = pIter->GetElementAt(
i);
126 return nTextMarkupCount;
129css::accessibility::TextSegment
131 const sal_Int32 nTextMarkupType )
134 nTextMarkupIndex < 0 )
136 throw lang::IndexOutOfBoundsException();
139 css::accessibility::TextSegment aTextMarkupSegment;
140 aTextMarkupSegment.SegmentStart = -1;
141 aTextMarkupSegment.SegmentEnd = -1;
143 std::unique_ptr<sw::WrongListIteratorCounter> pIter =
getIterator(nTextMarkupType);
146 std::optional<std::pair<TextFrameIndex, TextFrameIndex>> oElement;
147 const sal_uInt16 nIterElementCount = pIter->GetElementCount();
148 sal_Int32 nIndexInPortion = 0;
149 sal_uInt16 nIterIndex = 0;
150 while (!oElement && nIterIndex < nIterElementCount)
155 std::optional<std::pair<TextFrameIndex, TextFrameIndex>> oIndices = pIter->GetElementAt(nIterIndex);
158 if (nIndexInPortion == nTextMarkupIndex)
170 const sal_Int32 nStartPos =
172 const sal_Int32 nEndPos =
174 aTextMarkupSegment.SegmentText = rText.copy( nStartPos, nEndPos - nStartPos );
175 aTextMarkupSegment.SegmentStart = nStartPos;
176 aTextMarkupSegment.SegmentEnd = nEndPos;
180 OSL_FAIL(
"<SwTextMarkupHelper::getTextMarkup(..)> - missing <SwWrongArea> instance" );
184 return aTextMarkupSegment;
187css::uno::Sequence< css::accessibility::TextSegment >
189 const sal_Int32 nTextMarkupType )
199 return uno::Sequence< css::accessibility::TextSegment >();
202 std::unique_ptr<sw::WrongListIteratorCounter> pIter =
getIterator(nTextMarkupType);
203 std::vector< css::accessibility::TextSegment > aTmpTextMarkups;
207 sal_uInt16
count(pIter->GetElementCount());
208 for (sal_uInt16
i = 0;
i <
count; ++
i)
210 auto const oElement(pIter->GetElementAt(
i));
212 oElement->first <= nCoreCharIndex &&
213 nCoreCharIndex < oElement->second)
215 const sal_Int32 nStartPos =
217 const sal_Int32 nEndPos =
219 css::accessibility::TextSegment aTextMarkupSegment;
220 aTextMarkupSegment.SegmentText = rText.copy( nStartPos, nEndPos - nStartPos );
221 aTextMarkupSegment.SegmentStart = nStartPos;
222 aTextMarkupSegment.SegmentEnd = nEndPos;
223 aTmpTextMarkups.push_back( aTextMarkupSegment );
collect text portion data from the layout through SwPortionHandler interface
TextFrameIndex GetCoreViewPosition(sal_Int32 nPos) const
get the position in the core view string for a given (accessibility) position
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
bool IsValidCorePosition(TextFrameIndex nPos) const
Determine whether this core position is valid for these portions.
Represents the visualization of a paragraph.
SwTextFrame const * m_pTextFrame
const SwAccessiblePortionData & mrPortionData
SwTextMarkupHelper(const SwAccessiblePortionData &rPortionData, const SwTextFrame &rTextFrame)
sal_Int32 getTextMarkupCount(const sal_Int32 nTextMarkupType)
std::unique_ptr< sw::WrongListIteratorCounter > getIterator(sal_Int32 nTextMarkupType)
css::uno::Sequence< css::accessibility::TextSegment > getTextMarkupAtIndex(const sal_Int32 nCharIndex, const sal_Int32 nTextMarkupType)
css::accessibility::TextSegment getTextMarkup(const sal_Int32 nTextMarkupIndex, const sal_Int32 nTextMarkupType)
const SwWrongList * mpTextMarkupList
SwTextNode is a paragraph in the document model.
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)