1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <comphelper/accessiblecontexthelper.hxx>
21 #include <comphelper/accessibletexthelper.hxx>
22 #include <com/sun/star/accessibility/AccessibleTextType.hpp>
23 #include <com/sun/star/i18n/BreakIterator.hpp>
24 #include <com/sun/star/i18n/CharacterIteratorMode.hpp>
25 #include <com/sun/star/i18n/CharacterClassification.hpp>
26 #include <com/sun/star/i18n/WordType.hpp>
27 #include <com/sun/star/i18n/KCharacterType.hpp>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29 #include <comphelper/processfactory.hxx>
30 #include <com/sun/star/accessibility/TextSegment.hpp>
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::lang
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::accessibility
;
46 // OCommonAccessibleText
49 OCommonAccessibleText::OCommonAccessibleText()
54 OCommonAccessibleText::~OCommonAccessibleText()
59 Reference
< i18n::XBreakIterator
> const & OCommonAccessibleText::implGetBreakIterator()
61 if ( !m_xBreakIter
.is() )
63 Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
64 m_xBreakIter
= i18n::BreakIterator::create(xContext
);
71 Reference
< i18n::XCharacterClassification
> const & OCommonAccessibleText::implGetCharacterClassification()
73 if ( !m_xCharClass
.is() )
75 m_xCharClass
= i18n::CharacterClassification::create( ::comphelper::getProcessComponentContext() );
82 bool OCommonAccessibleText::implIsValidBoundary( i18n::Boundary
const & rBoundary
, sal_Int32 nLength
)
84 return ( rBoundary
.startPos
>= 0 ) && ( rBoundary
.startPos
< nLength
) && ( rBoundary
.endPos
>= 0 ) && ( rBoundary
.endPos
<= nLength
);
88 bool OCommonAccessibleText::implIsValidIndex( sal_Int32 nIndex
, sal_Int32 nLength
)
90 return ( nIndex
>= 0 ) && ( nIndex
< nLength
);
94 bool OCommonAccessibleText::implIsValidRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
, sal_Int32 nLength
)
96 return ( nStartIndex
>= 0 ) && ( nStartIndex
<= nLength
) && ( nEndIndex
>= 0 ) && ( nEndIndex
<= nLength
);
100 void OCommonAccessibleText::implGetGlyphBoundary( const OUString
& rText
, i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
102 if ( implIsValidIndex( nIndex
, rText
.getLength() ) )
104 Reference
< i18n::XBreakIterator
> xBreakIter
= implGetBreakIterator();
105 if ( xBreakIter
.is() )
107 sal_Int32 nCount
= 1;
109 sal_Int32 nStartIndex
= xBreakIter
->previousCharacters( rText
, nIndex
, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL
, nCount
, nDone
);
111 nStartIndex
= xBreakIter
->nextCharacters( rText
, nStartIndex
, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL
, nCount
, nDone
);
112 sal_Int32 nEndIndex
= xBreakIter
->nextCharacters( rText
, nStartIndex
, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL
, nCount
, nDone
);
115 rBoundary
.startPos
= nStartIndex
;
116 rBoundary
.endPos
= nEndIndex
;
122 rBoundary
.startPos
= nIndex
;
123 rBoundary
.endPos
= nIndex
;
128 bool OCommonAccessibleText::implGetWordBoundary( const OUString
& rText
, i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
132 if ( implIsValidIndex( nIndex
, rText
.getLength() ) )
134 Reference
< i18n::XBreakIterator
> xBreakIter
= implGetBreakIterator();
135 if ( xBreakIter
.is() )
137 rBoundary
= xBreakIter
->getWordBoundary( rText
, nIndex
, implGetLocale(), i18n::WordType::ANY_WORD
, true );
139 // it's a word, if the first character is an alpha-numeric character
140 Reference
< i18n::XCharacterClassification
> xCharClass
= implGetCharacterClassification();
141 if ( xCharClass
.is() )
143 sal_Int32 nType
= xCharClass
->getCharacterType( rText
, rBoundary
.startPos
, implGetLocale() );
144 if ( ( nType
& ( i18n::KCharacterType::LETTER
| i18n::KCharacterType::DIGIT
) ) != 0 )
151 rBoundary
.startPos
= nIndex
;
152 rBoundary
.endPos
= nIndex
;
159 void OCommonAccessibleText::implGetSentenceBoundary( const OUString
& rText
, i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
161 if ( implIsValidIndex( nIndex
, rText
.getLength() ) )
163 Locale aLocale
= implGetLocale();
164 Reference
< i18n::XBreakIterator
> xBreakIter
= implGetBreakIterator();
165 if ( xBreakIter
.is() )
167 rBoundary
.endPos
= xBreakIter
->endOfSentence( rText
, nIndex
, aLocale
);
168 rBoundary
.startPos
= xBreakIter
->beginOfSentence( rText
, rBoundary
.endPos
, aLocale
);
173 rBoundary
.startPos
= nIndex
;
174 rBoundary
.endPos
= nIndex
;
179 void OCommonAccessibleText::implGetParagraphBoundary( const OUString
& rText
, i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
181 if ( implIsValidIndex( nIndex
, rText
.getLength() ) )
183 rBoundary
.startPos
= 0;
184 rBoundary
.endPos
= rText
.getLength();
186 sal_Int32 nFound
= rText
.lastIndexOf( '\n', nIndex
);
188 rBoundary
.startPos
= nFound
+ 1;
190 nFound
= rText
.indexOf( '\n', nIndex
);
192 rBoundary
.endPos
= nFound
+ 1;
196 rBoundary
.startPos
= nIndex
;
197 rBoundary
.endPos
= nIndex
;
202 void OCommonAccessibleText::implGetLineBoundary( const OUString
& rText
, i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
204 sal_Int32 nLength
= rText
.getLength();
206 if ( implIsValidIndex( nIndex
, nLength
) || nIndex
== nLength
)
208 rBoundary
.startPos
= 0;
209 rBoundary
.endPos
= nLength
;
213 rBoundary
.startPos
= nIndex
;
214 rBoundary
.endPos
= nIndex
;
219 sal_Unicode
OCommonAccessibleText::implGetCharacter( std::u16string_view rText
, sal_Int32 nIndex
)
221 if ( !implIsValidIndex( nIndex
, rText
.size() ) )
222 throw IndexOutOfBoundsException();
224 return rText
[nIndex
];
227 OUString
OCommonAccessibleText::getSelectedText()
230 sal_Int32 nStartIndex
;
233 implGetSelection( nStartIndex
, nEndIndex
);
237 sText
= implGetTextRange( implGetText(), nStartIndex
, nEndIndex
);
239 catch ( IndexOutOfBoundsException
& )
247 sal_Int32
OCommonAccessibleText::getSelectionStart()
249 sal_Int32 nStartIndex
;
252 implGetSelection( nStartIndex
, nEndIndex
);
258 sal_Int32
OCommonAccessibleText::getSelectionEnd()
260 sal_Int32 nStartIndex
;
263 implGetSelection( nStartIndex
, nEndIndex
);
269 OUString
OCommonAccessibleText::implGetTextRange( std::u16string_view rText
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
272 if ( !implIsValidRange( nStartIndex
, nEndIndex
, rText
.size() ) )
273 throw IndexOutOfBoundsException();
275 sal_Int32 nMinIndex
= std::min( nStartIndex
, nEndIndex
);
276 sal_Int32 nMaxIndex
= std::max( nStartIndex
, nEndIndex
);
278 return OUString(rText
.substr( nMinIndex
, nMaxIndex
- nMinIndex
));
281 TextSegment
OCommonAccessibleText::getTextAtIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
283 OUString
sText( implGetText() );
284 sal_Int32 nLength
= sText
.getLength();
286 if ( !implIsValidIndex( nIndex
, nLength
) && nIndex
!= nLength
)
287 throw IndexOutOfBoundsException();
289 i18n::Boundary aBoundary
;
291 aResult
.SegmentStart
= -1;
292 aResult
.SegmentEnd
= -1;
296 case AccessibleTextType::CHARACTER
:
298 if ( implIsValidIndex( nIndex
, nLength
) )
300 auto nIndexEnd
= nIndex
;
301 sText
.iterateCodePoints(&nIndexEnd
);
303 aResult
.SegmentText
= sText
.copy( nIndex
, nIndexEnd
- nIndex
);
304 aResult
.SegmentStart
= nIndex
;
305 aResult
.SegmentEnd
= nIndexEnd
;
309 case AccessibleTextType::GLYPH
:
311 // get glyph at index
312 implGetGlyphBoundary( sText
, aBoundary
, nIndex
);
313 if ( implIsValidBoundary( aBoundary
, nLength
) )
315 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
316 aResult
.SegmentStart
= aBoundary
.startPos
;
317 aResult
.SegmentEnd
= aBoundary
.endPos
;
321 case AccessibleTextType::WORD
:
324 bool bWord
= implGetWordBoundary( sText
, aBoundary
, nIndex
);
325 if ( bWord
&& implIsValidBoundary( aBoundary
, nLength
) )
327 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
328 aResult
.SegmentStart
= aBoundary
.startPos
;
329 aResult
.SegmentEnd
= aBoundary
.endPos
;
333 case AccessibleTextType::SENTENCE
:
335 // get sentence at index
336 implGetSentenceBoundary( sText
, aBoundary
, nIndex
);
337 if ( implIsValidBoundary( aBoundary
, nLength
) )
339 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
340 aResult
.SegmentStart
= aBoundary
.startPos
;
341 aResult
.SegmentEnd
= aBoundary
.endPos
;
345 case AccessibleTextType::PARAGRAPH
:
347 // get paragraph at index
348 implGetParagraphBoundary( sText
, aBoundary
, nIndex
);
349 if ( implIsValidBoundary( aBoundary
, nLength
) )
351 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
352 aResult
.SegmentStart
= aBoundary
.startPos
;
353 aResult
.SegmentEnd
= aBoundary
.endPos
;
357 case AccessibleTextType::LINE
:
360 implGetLineBoundary( sText
, aBoundary
, nIndex
);
361 if ( implIsValidBoundary( aBoundary
, nLength
) )
363 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
364 aResult
.SegmentStart
= aBoundary
.startPos
;
365 aResult
.SegmentEnd
= aBoundary
.endPos
;
369 case AccessibleTextType::ATTRIBUTE_RUN
:
371 // TODO: implGetAttributeRunBoundary() (incompatible!)
373 aResult
.SegmentText
= sText
;
374 aResult
.SegmentStart
= 0;
375 aResult
.SegmentEnd
= nLength
;
388 TextSegment
OCommonAccessibleText::getTextBeforeIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
390 OUString
sText( implGetText() );
391 sal_Int32 nLength
= sText
.getLength();
393 if ( !implIsValidIndex( nIndex
, nLength
) && nIndex
!= nLength
)
394 throw IndexOutOfBoundsException();
396 i18n::Boundary aBoundary
;
398 aResult
.SegmentStart
= -1;
399 aResult
.SegmentEnd
= -1;
403 case AccessibleTextType::CHARACTER
:
405 if ( implIsValidIndex( nIndex
- 1, nLength
) )
407 sText
.iterateCodePoints(&nIndex
, -1);
408 auto nIndexEnd
= nIndex
;
409 sText
.iterateCodePoints(&nIndexEnd
);
410 aResult
.SegmentText
= sText
.copy(nIndex
, nIndexEnd
- nIndex
);
411 aResult
.SegmentStart
= nIndex
;
412 aResult
.SegmentEnd
= nIndexEnd
;
416 case AccessibleTextType::GLYPH
:
418 // get glyph at index
419 implGetGlyphBoundary( sText
, aBoundary
, nIndex
);
420 // get previous glyph
421 if ( aBoundary
.startPos
> 0 )
423 implGetGlyphBoundary( sText
, aBoundary
, aBoundary
.startPos
- 1 );
424 if ( implIsValidBoundary( aBoundary
, nLength
) )
426 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
427 aResult
.SegmentStart
= aBoundary
.startPos
;
428 aResult
.SegmentEnd
= aBoundary
.endPos
;
433 case AccessibleTextType::WORD
:
436 implGetWordBoundary( sText
, aBoundary
, nIndex
);
439 while ( !bWord
&& aBoundary
.startPos
> 0 )
440 bWord
= implGetWordBoundary( sText
, aBoundary
, aBoundary
.startPos
- 1 );
441 if ( bWord
&& implIsValidBoundary( aBoundary
, nLength
) )
443 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
444 aResult
.SegmentStart
= aBoundary
.startPos
;
445 aResult
.SegmentEnd
= aBoundary
.endPos
;
449 case AccessibleTextType::SENTENCE
:
451 // get sentence at index
452 implGetSentenceBoundary( sText
, aBoundary
, nIndex
);
453 // get previous sentence
454 if ( aBoundary
.startPos
> 0 )
456 implGetSentenceBoundary( sText
, aBoundary
, aBoundary
.startPos
- 1 );
457 if ( implIsValidBoundary( aBoundary
, nLength
) )
459 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
460 aResult
.SegmentStart
= aBoundary
.startPos
;
461 aResult
.SegmentEnd
= aBoundary
.endPos
;
466 case AccessibleTextType::PARAGRAPH
:
468 // get paragraph at index
469 implGetParagraphBoundary( sText
, aBoundary
, nIndex
);
470 // get previous paragraph
471 if ( aBoundary
.startPos
> 0 )
473 implGetParagraphBoundary( sText
, aBoundary
, aBoundary
.startPos
- 1 );
474 if ( implIsValidBoundary( aBoundary
, nLength
) )
476 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
477 aResult
.SegmentStart
= aBoundary
.startPos
;
478 aResult
.SegmentEnd
= aBoundary
.endPos
;
483 case AccessibleTextType::LINE
:
486 implGetLineBoundary( sText
, aBoundary
, nIndex
);
488 if ( aBoundary
.startPos
> 0 )
490 implGetLineBoundary( sText
, aBoundary
, aBoundary
.startPos
- 1 );
491 if ( implIsValidBoundary( aBoundary
, nLength
) )
493 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
494 aResult
.SegmentStart
= aBoundary
.startPos
;
495 aResult
.SegmentEnd
= aBoundary
.endPos
;
500 case AccessibleTextType::ATTRIBUTE_RUN
:
502 // TODO: implGetAttributeRunBoundary() (incompatible!)
515 TextSegment
OCommonAccessibleText::getTextBehindIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
517 OUString
sText( implGetText() );
518 sal_Int32 nLength
= sText
.getLength();
520 if ( !implIsValidIndex( nIndex
, nLength
) && nIndex
!= nLength
)
521 throw IndexOutOfBoundsException();
523 i18n::Boundary aBoundary
;
525 aResult
.SegmentStart
= -1;
526 aResult
.SegmentEnd
= -1;
530 case AccessibleTextType::CHARACTER
:
532 if ( implIsValidIndex( nIndex
+ 1, nLength
) )
534 sText
.iterateCodePoints(&nIndex
);
535 auto nIndexEnd
= nIndex
;
536 sText
.iterateCodePoints(&nIndexEnd
);
537 aResult
.SegmentText
= sText
.copy(nIndex
, nIndexEnd
- nIndex
);
538 aResult
.SegmentStart
= nIndex
;
539 aResult
.SegmentEnd
= nIndexEnd
;
543 case AccessibleTextType::GLYPH
:
545 // get glyph at index
546 implGetGlyphBoundary( sText
, aBoundary
, nIndex
);
548 if ( aBoundary
.endPos
< nLength
)
550 implGetGlyphBoundary( sText
, aBoundary
, aBoundary
.endPos
);
551 if ( implIsValidBoundary( aBoundary
, nLength
) )
553 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
554 aResult
.SegmentStart
= aBoundary
.startPos
;
555 aResult
.SegmentEnd
= aBoundary
.endPos
;
560 case AccessibleTextType::WORD
:
563 implGetWordBoundary( sText
, aBoundary
, nIndex
);
566 while ( !bWord
&& aBoundary
.endPos
< nLength
)
567 bWord
= implGetWordBoundary( sText
, aBoundary
, aBoundary
.endPos
);
568 if ( bWord
&& implIsValidBoundary( aBoundary
, nLength
) )
570 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
571 aResult
.SegmentStart
= aBoundary
.startPos
;
572 aResult
.SegmentEnd
= aBoundary
.endPos
;
576 case AccessibleTextType::SENTENCE
:
578 // get sentence at index
579 implGetSentenceBoundary( sText
, aBoundary
, nIndex
);
581 sal_Int32 nEnd
= aBoundary
.endPos
;
582 sal_Int32 nI
= aBoundary
.endPos
;
584 while ( !bFound
&& ++nI
< nLength
)
586 implGetSentenceBoundary( sText
, aBoundary
, nI
);
587 bFound
= ( aBoundary
.endPos
> nEnd
);
589 if ( bFound
&& implIsValidBoundary( aBoundary
, nLength
) )
591 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
592 aResult
.SegmentStart
= aBoundary
.startPos
;
593 aResult
.SegmentEnd
= aBoundary
.endPos
;
597 case AccessibleTextType::PARAGRAPH
:
599 // get paragraph at index
600 implGetParagraphBoundary( sText
, aBoundary
, nIndex
);
601 // get next paragraph
602 if ( aBoundary
.endPos
< nLength
)
604 implGetParagraphBoundary( sText
, aBoundary
, aBoundary
.endPos
);
605 if ( implIsValidBoundary( aBoundary
, nLength
) )
607 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
608 aResult
.SegmentStart
= aBoundary
.startPos
;
609 aResult
.SegmentEnd
= aBoundary
.endPos
;
614 case AccessibleTextType::LINE
:
617 implGetLineBoundary( sText
, aBoundary
, nIndex
);
619 if ( aBoundary
.endPos
< nLength
)
621 implGetLineBoundary( sText
, aBoundary
, aBoundary
.endPos
);
622 if ( implIsValidBoundary( aBoundary
, nLength
) )
624 aResult
.SegmentText
= sText
.copy( aBoundary
.startPos
, aBoundary
.endPos
- aBoundary
.startPos
);
625 aResult
.SegmentStart
= aBoundary
.startPos
;
626 aResult
.SegmentEnd
= aBoundary
.endPos
;
631 case AccessibleTextType::ATTRIBUTE_RUN
:
633 // TODO: implGetAttributeRunBoundary() (incompatible!)
646 bool OCommonAccessibleText::implInitTextChangedEvent(
647 std::u16string_view rOldString
,
648 std::u16string_view rNewString
,
649 css::uno::Any
& rDeleted
,
650 css::uno::Any
& rInserted
) // throw()
652 size_t nLenOld
= rOldString
.size();
653 size_t nLenNew
= rNewString
.size();
656 if ((0 == nLenOld
) && (0 == nLenNew
))
659 TextSegment aDeletedText
;
660 TextSegment aInsertedText
;
662 aDeletedText
.SegmentStart
= -1;
663 aDeletedText
.SegmentEnd
= -1;
664 aInsertedText
.SegmentStart
= -1;
665 aInsertedText
.SegmentEnd
= -1;
668 if ((0 == nLenOld
) && (nLenNew
> 0))
670 aInsertedText
.SegmentStart
= 0;
671 aInsertedText
.SegmentEnd
= nLenNew
;
672 aInsertedText
.SegmentText
= rNewString
.substr( aInsertedText
.SegmentStart
, aInsertedText
.SegmentEnd
- aInsertedText
.SegmentStart
);
674 rInserted
<<= aInsertedText
;
679 if ((nLenOld
> 0) && (0 == nLenNew
))
681 aDeletedText
.SegmentStart
= 0;
682 aDeletedText
.SegmentEnd
= nLenOld
;
683 aDeletedText
.SegmentText
= rOldString
.substr( aDeletedText
.SegmentStart
, aDeletedText
.SegmentEnd
- aDeletedText
.SegmentStart
);
685 rDeleted
<<= aDeletedText
;
689 auto pFirstDiffOld
= rOldString
.begin();
690 auto pLastDiffOld
= rOldString
.end();
691 auto pFirstDiffNew
= rNewString
.begin();
692 auto pLastDiffNew
= rNewString
.end();
694 // find first difference
695 while ((pFirstDiffOld
< pLastDiffOld
) && (pFirstDiffNew
< pLastDiffNew
)
696 && (*pFirstDiffOld
== *pFirstDiffNew
))
703 if (pFirstDiffOld
== pLastDiffOld
&& pFirstDiffNew
== pLastDiffNew
)
706 // find last difference
707 while ( ( pLastDiffOld
> pFirstDiffOld
) &&
708 ( pLastDiffNew
> pFirstDiffNew
) &&
709 (pLastDiffOld
[-1] == pLastDiffNew
[-1]))
715 if (pFirstDiffOld
< pLastDiffOld
)
717 aDeletedText
.SegmentStart
= pFirstDiffOld
- rOldString
.begin();
718 aDeletedText
.SegmentEnd
= pLastDiffOld
- rOldString
.begin();
719 aDeletedText
.SegmentText
= rOldString
.substr( aDeletedText
.SegmentStart
, aDeletedText
.SegmentEnd
- aDeletedText
.SegmentStart
);
721 rDeleted
<<= aDeletedText
;
724 if (pFirstDiffNew
< pLastDiffNew
)
726 aInsertedText
.SegmentStart
= pFirstDiffNew
- rNewString
.begin();
727 aInsertedText
.SegmentEnd
= pLastDiffNew
- rNewString
.begin();
728 aInsertedText
.SegmentText
= rNewString
.substr( aInsertedText
.SegmentStart
, aInsertedText
.SegmentEnd
- aInsertedText
.SegmentStart
);
730 rInserted
<<= aInsertedText
;
736 // OAccessibleTextHelper
739 OAccessibleTextHelper::OAccessibleTextHelper( )
747 OUString
OAccessibleTextHelper::getSelectedText()
749 OExternalLockGuard
aGuard( this );
751 return OCommonAccessibleText::getSelectedText();
755 sal_Int32
OAccessibleTextHelper::getSelectionStart()
757 OExternalLockGuard
aGuard( this );
759 return OCommonAccessibleText::getSelectionStart();
763 sal_Int32
OAccessibleTextHelper::getSelectionEnd()
765 OExternalLockGuard
aGuard( this );
767 return OCommonAccessibleText::getSelectionEnd();
771 TextSegment
OAccessibleTextHelper::getTextAtIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
773 OExternalLockGuard
aGuard( this );
775 return OCommonAccessibleText::getTextAtIndex( nIndex
, aTextType
);
779 TextSegment
OAccessibleTextHelper::getTextBeforeIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
781 OExternalLockGuard
aGuard( this );
783 return OCommonAccessibleText::getTextBeforeIndex( nIndex
, aTextType
);
787 TextSegment
OAccessibleTextHelper::getTextBehindIndex( sal_Int32 nIndex
, sal_Int16 aTextType
)
789 OExternalLockGuard
aGuard( this );
791 return OCommonAccessibleText::getTextBehindIndex( nIndex
, aTextType
);
795 } // namespace comphelper
798 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */