2010-10-14 01:27:31 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2002-06-26 11:01:21 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
2008-04-11 05:04:24 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2002-06-26 11:01:21 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 11:09:02 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_comphelper.hxx"
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
// includes --------------------------------------------------------------
|
|
|
|
#include <comphelper/accessibletexthelper.hxx>
|
2003-04-24 11:27:52 -05:00
|
|
|
#include <com/sun/star/accessibility/AccessibleTextType.hpp>
|
2002-06-26 11:01:21 -05:00
|
|
|
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
|
|
|
|
#include <com/sun/star/i18n/WordType.hpp>
|
|
|
|
#include <com/sun/star/i18n/KCharacterType.hpp>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2003-05-22 07:33:54 -05:00
|
|
|
#include <com/sun/star/accessibility/TextSegment.hpp>
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2003-04-24 11:27:52 -05:00
|
|
|
#include <algorithm>
|
2002-06-26 11:01:21 -05:00
|
|
|
|
|
|
|
//..............................................................................
|
|
|
|
namespace comphelper
|
|
|
|
{
|
|
|
|
//..............................................................................
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2003-04-24 11:27:52 -05:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
2002-06-26 11:01:21 -05:00
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
// OCommonAccessibleText
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
OCommonAccessibleText::OCommonAccessibleText()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OCommonAccessibleText::~OCommonAccessibleText()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Reference < i18n::XBreakIterator > OCommonAccessibleText::implGetBreakIterator()
|
|
|
|
{
|
|
|
|
if ( !m_xBreakIter.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
|
|
|
|
if ( xMSF.is() )
|
|
|
|
{
|
|
|
|
m_xBreakIter = Reference< i18n::XBreakIterator >
|
|
|
|
( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.BreakIterator" ) ) ), UNO_QUERY );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_xBreakIter;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Reference < i18n::XCharacterClassification > OCommonAccessibleText::implGetCharacterClassification()
|
|
|
|
{
|
|
|
|
if ( !m_xCharClass.is() )
|
|
|
|
{
|
|
|
|
Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
|
|
|
|
if ( xMSF.is() )
|
|
|
|
{
|
|
|
|
m_xCharClass = Reference< i18n::XCharacterClassification >
|
|
|
|
( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.CharacterClassification" ) ) ), UNO_QUERY );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_xCharClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Bool OCommonAccessibleText::implIsValidBoundary( i18n::Boundary& rBoundary, sal_Int32 nLength )
|
|
|
|
{
|
|
|
|
return ( rBoundary.startPos >= 0 ) && ( rBoundary.startPos < nLength ) && ( rBoundary.endPos >= 0 ) && ( rBoundary.endPos <= nLength );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
sal_Bool OCommonAccessibleText::implIsValidIndex( sal_Int32 nIndex, sal_Int32 nLength )
|
|
|
|
{
|
|
|
|
return ( nIndex >= 0 ) && ( nIndex < nLength );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool OCommonAccessibleText::implIsValidRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength )
|
|
|
|
{
|
|
|
|
return ( nStartIndex >= 0 ) && ( nStartIndex <= nLength ) && ( nEndIndex >= 0 ) && ( nEndIndex <= nLength );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OCommonAccessibleText::implGetGlyphBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
2002-09-18 07:49:44 -05:00
|
|
|
|
|
|
|
if ( implIsValidIndex( nIndex, sText.getLength() ) )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
|
|
|
|
if ( xBreakIter.is() )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Int32 nCount = 1;
|
|
|
|
sal_Int32 nDone;
|
|
|
|
sal_Int32 nStartIndex = xBreakIter->previousCharacters( sText, nIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
|
|
|
|
if ( nDone != 0 )
|
|
|
|
nStartIndex = xBreakIter->nextCharacters( sText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
|
|
|
|
sal_Int32 nEndIndex = xBreakIter->nextCharacters( sText, nStartIndex, implGetLocale(), i18n::CharacterIteratorMode::SKIPCELL, nCount, nDone );
|
|
|
|
if ( nDone != 0 )
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nStartIndex;
|
|
|
|
rBoundary.endPos = nEndIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
2002-09-18 07:49:44 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nIndex;
|
|
|
|
rBoundary.endPos = nIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool OCommonAccessibleText::implGetWordBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
sal_Bool bWord = sal_False;
|
|
|
|
::rtl::OUString sText( implGetText() );
|
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidIndex( nIndex, sText.getLength() ) )
|
|
|
|
{
|
|
|
|
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
|
|
|
|
if ( xBreakIter.is() )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
rBoundary = xBreakIter->getWordBoundary( sText, nIndex, implGetLocale(), i18n::WordType::ANY_WORD, sal_True );
|
|
|
|
|
|
|
|
// it's a word, if the first character is an alpha-numeric character
|
|
|
|
Reference< i18n::XCharacterClassification > xCharClass = implGetCharacterClassification();
|
|
|
|
if ( xCharClass.is() )
|
|
|
|
{
|
|
|
|
sal_Int32 nType = xCharClass->getCharacterType( sText, rBoundary.startPos, implGetLocale() );
|
|
|
|
if ( ( nType & ( i18n::KCharacterType::LETTER | i18n::KCharacterType::DIGIT ) ) != 0 )
|
|
|
|
bWord = sal_True;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
2002-09-18 07:49:44 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nIndex;
|
|
|
|
rBoundary.endPos = nIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
|
|
|
|
return bWord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OCommonAccessibleText::implGetSentenceBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
2002-09-18 07:49:44 -05:00
|
|
|
|
|
|
|
if ( implIsValidIndex( nIndex, sText.getLength() ) )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
Locale aLocale = implGetLocale();
|
|
|
|
Reference < i18n::XBreakIterator > xBreakIter = implGetBreakIterator();
|
|
|
|
if ( xBreakIter.is() )
|
|
|
|
{
|
|
|
|
rBoundary.endPos = xBreakIter->endOfSentence( sText, nIndex, aLocale );
|
|
|
|
rBoundary.startPos = xBreakIter->beginOfSentence( sText, rBoundary.endPos, aLocale );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nIndex;
|
|
|
|
rBoundary.endPos = nIndex;
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OCommonAccessibleText::implGetParagraphBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidIndex( nIndex, sText.getLength() ) )
|
|
|
|
{
|
|
|
|
rBoundary.startPos = 0;
|
|
|
|
rBoundary.endPos = sText.getLength();
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Int32 nFound = sText.lastIndexOf( (sal_Unicode)'\n', nIndex );
|
|
|
|
if ( nFound != -1 )
|
|
|
|
rBoundary.startPos = nFound + 1;
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
nFound = sText.indexOf( (sal_Unicode)'\n', nIndex );
|
|
|
|
if ( nFound != -1 )
|
|
|
|
rBoundary.endPos = nFound + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nIndex;
|
|
|
|
rBoundary.endPos = nIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void OCommonAccessibleText::implGetLineBoundary( i18n::Boundary& rBoundary, sal_Int32 nIndex )
|
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
::rtl::OUString sText( implGetText() );
|
2003-06-27 02:41:38 -05:00
|
|
|
sal_Int32 nLength = sText.getLength();
|
2002-09-18 07:49:44 -05:00
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
if ( implIsValidIndex( nIndex, nLength ) || nIndex == nLength )
|
2002-09-18 07:49:44 -05:00
|
|
|
{
|
|
|
|
rBoundary.startPos = 0;
|
2003-06-27 02:41:38 -05:00
|
|
|
rBoundary.endPos = nLength;
|
2002-09-18 07:49:44 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rBoundary.startPos = nIndex;
|
|
|
|
rBoundary.endPos = nIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Unicode OCommonAccessibleText::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
|
|
|
|
|
|
|
if ( !implIsValidIndex( nIndex, sText.getLength() ) )
|
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
return sText.getStr()[nIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OCommonAccessibleText::getCharacterCount() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return implGetText().getLength();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OCommonAccessibleText::getSelectedText() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sText;
|
|
|
|
sal_Int32 nStartIndex;
|
|
|
|
sal_Int32 nEndIndex;
|
|
|
|
|
|
|
|
implGetSelection( nStartIndex, nEndIndex );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sText = getTextRange( nStartIndex, nEndIndex );
|
|
|
|
}
|
|
|
|
catch ( IndexOutOfBoundsException& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return sText;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OCommonAccessibleText::getSelectionStart() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
sal_Int32 nStartIndex;
|
|
|
|
sal_Int32 nEndIndex;
|
|
|
|
|
|
|
|
implGetSelection( nStartIndex, nEndIndex );
|
|
|
|
|
|
|
|
return nStartIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OCommonAccessibleText::getSelectionEnd() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
sal_Int32 nStartIndex;
|
|
|
|
sal_Int32 nEndIndex;
|
|
|
|
|
|
|
|
implGetSelection( nStartIndex, nEndIndex );
|
|
|
|
|
|
|
|
return nEndIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OCommonAccessibleText::getText() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return implGetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OCommonAccessibleText::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
|
|
|
|
|
|
|
if ( !implIsValidRange( nStartIndex, nEndIndex, sText.getLength() ) )
|
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
sal_Int32 nMinIndex = ::std::min( nStartIndex, nEndIndex );
|
|
|
|
sal_Int32 nMaxIndex = ::std::max( nStartIndex, nEndIndex );
|
|
|
|
|
|
|
|
return sText.copy( nMinIndex, nMaxIndex - nMinIndex );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OCommonAccessibleText::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Int32 nLength = sText.getLength();
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( !implIsValidIndex( nIndex, nLength ) && nIndex != nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
i18n::Boundary aBoundary;
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment aResult;
|
2003-05-22 07:33:54 -05:00
|
|
|
aResult.SegmentStart = -1;
|
|
|
|
aResult.SegmentEnd = -1;
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
switch ( aTextType )
|
|
|
|
{
|
|
|
|
case AccessibleTextType::CHARACTER:
|
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidIndex( nIndex, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( nIndex, 1 );
|
|
|
|
aResult.SegmentStart = nIndex;
|
|
|
|
aResult.SegmentEnd = nIndex+1;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::GLYPH:
|
|
|
|
{
|
|
|
|
// get glyph at index
|
|
|
|
implGetGlyphBoundary( aBoundary, nIndex );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::WORD:
|
|
|
|
{
|
|
|
|
// get word at index
|
|
|
|
sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::SENTENCE:
|
|
|
|
{
|
|
|
|
// get sentence at index
|
|
|
|
implGetSentenceBoundary( aBoundary, nIndex );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::PARAGRAPH:
|
|
|
|
{
|
|
|
|
// get paragraph at index
|
|
|
|
implGetParagraphBoundary( aBoundary, nIndex );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::LINE:
|
|
|
|
{
|
|
|
|
// get line at index
|
|
|
|
implGetLineBoundary( aBoundary, nIndex );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
2003-06-27 02:41:38 -05:00
|
|
|
case AccessibleTextType::ATTRIBUTE_RUN:
|
|
|
|
{
|
|
|
|
// TODO: implGetAttributeRunBoundary() (incompatible!)
|
|
|
|
|
|
|
|
aResult.SegmentText = sText;
|
|
|
|
aResult.SegmentStart = 0;
|
|
|
|
aResult.SegmentEnd = nLength;
|
|
|
|
}
|
|
|
|
break;
|
2002-06-26 11:01:21 -05:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// unknown text type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
return aResult;
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OCommonAccessibleText::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Int32 nLength = sText.getLength();
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( !implIsValidIndex( nIndex, nLength ) && nIndex != nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
i18n::Boundary aBoundary;
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment aResult;
|
2003-05-22 07:33:54 -05:00
|
|
|
aResult.SegmentStart = -1;
|
|
|
|
aResult.SegmentEnd = -1;
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
switch ( aTextType )
|
|
|
|
{
|
|
|
|
case AccessibleTextType::CHARACTER:
|
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidIndex( nIndex - 1, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( nIndex - 1, 1 );
|
|
|
|
aResult.SegmentStart = nIndex-1;
|
|
|
|
aResult.SegmentEnd = nIndex;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::GLYPH:
|
|
|
|
{
|
|
|
|
// get glyph at index
|
|
|
|
implGetGlyphBoundary( aBoundary, nIndex );
|
|
|
|
// get previous glyph
|
|
|
|
if ( aBoundary.startPos > 0 )
|
|
|
|
{
|
|
|
|
implGetGlyphBoundary( aBoundary, aBoundary.startPos - 1 );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::WORD:
|
|
|
|
{
|
|
|
|
// get word at index
|
|
|
|
implGetWordBoundary( aBoundary, nIndex );
|
|
|
|
// get previous word
|
|
|
|
sal_Bool bWord = sal_False;
|
|
|
|
while ( !bWord && aBoundary.startPos > 0 )
|
|
|
|
bWord = implGetWordBoundary( aBoundary, aBoundary.startPos - 1 );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::SENTENCE:
|
|
|
|
{
|
|
|
|
// get sentence at index
|
|
|
|
implGetSentenceBoundary( aBoundary, nIndex );
|
|
|
|
// get previous sentence
|
|
|
|
if ( aBoundary.startPos > 0 )
|
|
|
|
{
|
|
|
|
implGetSentenceBoundary( aBoundary, aBoundary.startPos - 1 );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::PARAGRAPH:
|
|
|
|
{
|
|
|
|
// get paragraph at index
|
|
|
|
implGetParagraphBoundary( aBoundary, nIndex );
|
|
|
|
// get previous paragraph
|
|
|
|
if ( aBoundary.startPos > 0 )
|
|
|
|
{
|
|
|
|
implGetParagraphBoundary( aBoundary, aBoundary.startPos - 1 );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::LINE:
|
|
|
|
{
|
|
|
|
// get line at index
|
|
|
|
implGetLineBoundary( aBoundary, nIndex );
|
|
|
|
// get previous line
|
|
|
|
if ( aBoundary.startPos > 0 )
|
|
|
|
{
|
|
|
|
implGetLineBoundary( aBoundary, aBoundary.startPos - 1 );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-06-27 02:41:38 -05:00
|
|
|
case AccessibleTextType::ATTRIBUTE_RUN:
|
|
|
|
{
|
|
|
|
// TODO: implGetAttributeRunBoundary() (incompatible!)
|
|
|
|
}
|
|
|
|
break;
|
2002-06-26 11:01:21 -05:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// unknown text type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
return aResult;
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OCommonAccessibleText::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
::rtl::OUString sText( implGetText() );
|
2002-09-18 07:49:44 -05:00
|
|
|
sal_Int32 nLength = sText.getLength();
|
2002-06-26 11:01:21 -05:00
|
|
|
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( !implIsValidIndex( nIndex, nLength ) && nIndex != nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
i18n::Boundary aBoundary;
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment aResult;
|
2003-05-22 07:33:54 -05:00
|
|
|
aResult.SegmentStart = -1;
|
|
|
|
aResult.SegmentEnd = -1;
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
switch ( aTextType )
|
|
|
|
{
|
|
|
|
case AccessibleTextType::CHARACTER:
|
|
|
|
{
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidIndex( nIndex + 1, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( nIndex + 1, 1 );
|
|
|
|
aResult.SegmentStart = nIndex+1;
|
|
|
|
aResult.SegmentEnd = nIndex+2;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::GLYPH:
|
|
|
|
{
|
|
|
|
// get glyph at index
|
|
|
|
implGetGlyphBoundary( aBoundary, nIndex );
|
|
|
|
// get next glyph
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( aBoundary.endPos < nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
implGetGlyphBoundary( aBoundary, aBoundary.endPos );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::WORD:
|
|
|
|
{
|
|
|
|
// get word at index
|
|
|
|
implGetWordBoundary( aBoundary, nIndex );
|
|
|
|
// get next word
|
|
|
|
sal_Bool bWord = sal_False;
|
2002-09-18 07:49:44 -05:00
|
|
|
while ( !bWord && aBoundary.endPos < nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
bWord = implGetWordBoundary( aBoundary, aBoundary.endPos );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::SENTENCE:
|
|
|
|
{
|
|
|
|
// get sentence at index
|
|
|
|
implGetSentenceBoundary( aBoundary, nIndex );
|
|
|
|
// get next sentence
|
|
|
|
sal_Int32 nEnd = aBoundary.endPos;
|
|
|
|
sal_Int32 nI = aBoundary.endPos;
|
|
|
|
sal_Bool bFound = sal_False;
|
2002-09-18 07:49:44 -05:00
|
|
|
while ( !bFound && ++nI < nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
implGetSentenceBoundary( aBoundary, nI );
|
|
|
|
bFound = ( aBoundary.endPos > nEnd );
|
|
|
|
}
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( bFound && implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::PARAGRAPH:
|
|
|
|
{
|
|
|
|
// get paragraph at index
|
|
|
|
implGetParagraphBoundary( aBoundary, nIndex );
|
|
|
|
// get next paragraph
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( aBoundary.endPos < nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
implGetParagraphBoundary( aBoundary, aBoundary.endPos );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case AccessibleTextType::LINE:
|
|
|
|
{
|
|
|
|
// get line at index
|
|
|
|
implGetLineBoundary( aBoundary, nIndex );
|
|
|
|
// get next line
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( aBoundary.endPos < nLength )
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
implGetLineBoundary( aBoundary, aBoundary.endPos );
|
2002-09-18 07:49:44 -05:00
|
|
|
if ( implIsValidBoundary( aBoundary, nLength ) )
|
2003-05-22 07:33:54 -05:00
|
|
|
{
|
|
|
|
aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
|
|
|
|
aResult.SegmentStart = aBoundary.startPos;
|
|
|
|
aResult.SegmentEnd = aBoundary.endPos;
|
|
|
|
}
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2003-06-27 02:41:38 -05:00
|
|
|
case AccessibleTextType::ATTRIBUTE_RUN:
|
|
|
|
{
|
|
|
|
// TODO: implGetAttributeRunBoundary() (incompatible!)
|
|
|
|
}
|
|
|
|
break;
|
2002-06-26 11:01:21 -05:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
// unknown text type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
return aResult;
|
2002-06-26 11:01:21 -05:00
|
|
|
}
|
|
|
|
|
2003-04-24 11:27:52 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool OCommonAccessibleText::implInitTextChangedEvent(
|
|
|
|
const rtl::OUString& rOldString,
|
|
|
|
const rtl::OUString& rNewString,
|
2003-05-22 07:33:54 -05:00
|
|
|
::com::sun::star::uno::Any& rDeleted,
|
|
|
|
::com::sun::star::uno::Any& rInserted) // throw()
|
2003-04-24 11:27:52 -05:00
|
|
|
{
|
|
|
|
sal_uInt32 nLenOld = rOldString.getLength();
|
|
|
|
sal_uInt32 nLenNew = rNewString.getLength();
|
|
|
|
|
|
|
|
// equal
|
|
|
|
if ((0 == nLenOld) && (0 == nLenNew))
|
|
|
|
return false;
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment aDeletedText;
|
|
|
|
TextSegment aInsertedText;
|
2003-04-24 11:27:52 -05:00
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
aDeletedText.SegmentStart = -1;
|
|
|
|
aDeletedText.SegmentEnd = -1;
|
|
|
|
aInsertedText.SegmentStart = -1;
|
|
|
|
aInsertedText.SegmentEnd = -1;
|
2003-04-24 11:27:52 -05:00
|
|
|
|
|
|
|
// insert only
|
|
|
|
if ((0 == nLenOld) && (nLenNew > 0))
|
|
|
|
{
|
2003-05-22 07:33:54 -05:00
|
|
|
aInsertedText.SegmentStart = 0;
|
|
|
|
aInsertedText.SegmentEnd = nLenNew;
|
|
|
|
aInsertedText.SegmentText = rNewString.copy( aInsertedText.SegmentStart, aInsertedText.SegmentEnd - aInsertedText.SegmentStart );
|
|
|
|
|
|
|
|
rInserted <<= aInsertedText;
|
2003-04-24 11:27:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete only
|
|
|
|
if ((nLenOld > 0) && (0 == nLenNew))
|
|
|
|
{
|
2003-05-22 07:33:54 -05:00
|
|
|
aDeletedText.SegmentStart = 0;
|
|
|
|
aDeletedText.SegmentEnd = nLenOld;
|
|
|
|
aDeletedText.SegmentText = rOldString.copy( aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart );
|
|
|
|
|
|
|
|
rDeleted <<= aDeletedText;
|
2003-04-24 11:27:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const sal_Unicode* pFirstDiffOld = rOldString.getStr();
|
|
|
|
const sal_Unicode* pLastDiffOld = rOldString.getStr() + nLenOld;
|
|
|
|
const sal_Unicode* pFirstDiffNew = rNewString.getStr();
|
|
|
|
const sal_Unicode* pLastDiffNew = rNewString.getStr() + nLenNew;
|
|
|
|
|
|
|
|
// find first difference
|
|
|
|
while ((*pFirstDiffOld == *pFirstDiffNew) &&
|
|
|
|
(pFirstDiffOld < pLastDiffOld) &&
|
|
|
|
(pFirstDiffNew < pLastDiffNew))
|
|
|
|
{
|
|
|
|
pFirstDiffOld++;
|
|
|
|
pFirstDiffNew++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// equality test
|
|
|
|
if ((0 == *pFirstDiffOld) && (0 == *pFirstDiffNew))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// find last difference
|
2003-05-22 07:33:54 -05:00
|
|
|
while ( ( pLastDiffOld > pFirstDiffOld) &&
|
|
|
|
( pLastDiffNew > pFirstDiffNew) &&
|
|
|
|
(pLastDiffOld[-1] == pLastDiffNew[-1]))
|
2003-04-24 11:27:52 -05:00
|
|
|
{
|
|
|
|
pLastDiffOld--;
|
|
|
|
pLastDiffNew--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pFirstDiffOld < pLastDiffOld)
|
|
|
|
{
|
2003-05-22 07:33:54 -05:00
|
|
|
aDeletedText.SegmentStart = pFirstDiffOld - rOldString.getStr();
|
|
|
|
aDeletedText.SegmentEnd = pLastDiffOld - rOldString.getStr();
|
|
|
|
aDeletedText.SegmentText = rOldString.copy( aDeletedText.SegmentStart, aDeletedText.SegmentEnd - aDeletedText.SegmentStart );
|
2003-04-24 11:27:52 -05:00
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
rDeleted <<= aDeletedText;
|
2003-04-24 11:27:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pFirstDiffNew < pLastDiffNew)
|
|
|
|
{
|
2003-05-22 07:33:54 -05:00
|
|
|
aInsertedText.SegmentStart = pFirstDiffNew - rNewString.getStr();
|
|
|
|
aInsertedText.SegmentEnd = pLastDiffNew - rNewString.getStr();
|
|
|
|
aInsertedText.SegmentText = rNewString.copy( aInsertedText.SegmentStart, aInsertedText.SegmentEnd - aInsertedText.SegmentStart );
|
2003-04-24 11:27:52 -05:00
|
|
|
|
2003-05-22 07:33:54 -05:00
|
|
|
rInserted <<= aInsertedText;
|
2003-04-24 11:27:52 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-26 11:01:21 -05:00
|
|
|
//==============================================================================
|
|
|
|
// OAccessibleTextHelper
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
OAccessibleTextHelper::OAccessibleTextHelper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
OAccessibleTextHelper::OAccessibleTextHelper( IMutex* _pExternalLock )
|
|
|
|
:OAccessibleExtendedComponentHelper( _pExternalLock )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XInterface
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleTextHelper, OAccessibleExtendedComponentHelper, OAccessibleTextHelper_Base )
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XTypeProvider
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleTextHelper, OAccessibleExtendedComponentHelper, OAccessibleTextHelper_Base )
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XAccessibleText
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Unicode OAccessibleTextHelper::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getCharacter( nIndex );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OAccessibleTextHelper::getCharacterCount() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getCharacterCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OAccessibleTextHelper::getSelectedText() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getSelectedText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OAccessibleTextHelper::getSelectionStart() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getSelectionStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 OAccessibleTextHelper::getSelectionEnd() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getSelectionEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OAccessibleTextHelper::getText() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::rtl::OUString OAccessibleTextHelper::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OAccessibleTextHelper::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OAccessibleTextHelper::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-06-27 02:41:38 -05:00
|
|
|
TextSegment OAccessibleTextHelper::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2002-06-26 11:01:21 -05:00
|
|
|
{
|
|
|
|
OExternalLockGuard aGuard( this );
|
|
|
|
|
|
|
|
return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//..............................................................................
|
|
|
|
} // namespace comphelper
|
|
|
|
//..............................................................................
|
2010-10-14 01:27:31 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|