summaryrefslogtreecommitdiff
path: root/svx/source/accessibility/AccessibleEditableTextPara.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/accessibility/AccessibleEditableTextPara.cxx')
-rw-r--r--svx/source/accessibility/AccessibleEditableTextPara.cxx150
1 files changed, 98 insertions, 52 deletions
diff --git a/svx/source/accessibility/AccessibleEditableTextPara.cxx b/svx/source/accessibility/AccessibleEditableTextPara.cxx
index 7f43f3d81a..55775b8fbb 100644
--- a/svx/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/svx/source/accessibility/AccessibleEditableTextPara.cxx
@@ -806,7 +806,7 @@ namespace accessibility
// must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) )
{
- uno::Reference< XAccessibleText > aAccText = this;
+ uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this);
aRet <<= aAccText;
}
else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) )
@@ -912,65 +912,18 @@ namespace accessibility
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- // append first 40 characters from text, or first line, if shorter
- // (writer takes first sentence here, but that's not supported
- // from EditEngine)
- // throws if defunc
- ::rtl::OUString aLine;
-
- if( getCharacterCount() )
- aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText;
-
- // Get the string from the resource for the specified id.
- String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) );
- String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
- sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
- sParaIndex );
-
- if( aLine.getLength() > MaxDescriptionLen )
- {
- ::rtl::OUString aCurrWord;
- sal_Int32 i;
-
- // search backward from MaxDescriptionLen for previous word start
- for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText,
- i=MaxDescriptionLen,
- aLine=::rtl::OUString();
- i>=0;
- --i )
- {
- if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord )
- {
- if( i == 0 )
- // prevent completely empty string
- aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText;
- else
- aLine = getTextRange(0, i);
- }
- }
- }
+// ::vos::OGuard aGuard( Application::GetSolarMutex() );
- return ::rtl::OUString( sStr ) + aLine;
+ return ::rtl::OUString();
}
::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException)
{
DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
- // throws if defunc
- sal_Int32 nPara( GetParagraphIndex() );
-
- // Get the string from the resource for the specified id.
- String sStr = ::rtl::OUString( SVX_RESSTR (RID_SVXSTR_A11Y_PARAGRAPH_NAME) );
- String sParaIndex = ::rtl::OUString::valueOf( nPara );
- sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
- sParaIndex );
+// ::vos::OGuard aGuard( Application::GetSolarMutex() );
- return ::rtl::OUString( sStr );
+ return ::rtl::OUString();
}
uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException)
@@ -2113,6 +2066,99 @@ namespace accessibility
return aOutSequence;
}
+ // XAccessibleMultiLineText
+ sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+ {
+ DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
+
+ sal_Int32 nRes = -1;
+ sal_Int32 nPara = GetParagraphIndex();
+
+ SvxTextForwarder &rCacheTF = GetTextForwarder();
+ const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
+ DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" );
+ if (bValidPara)
+ {
+ // we explicitly allow for the index to point at the character right behind the text
+ if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< USHORT >(nPara) ))
+ nRes = rCacheTF.GetLineNumberAtIndex( static_cast< USHORT >(nPara), static_cast< USHORT >(nIndex) );
+ else
+ throw lang::IndexOutOfBoundsException();
+ }
+ return nRes;
+ }
+
+ // XAccessibleMultiLineText
+ ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+ {
+ DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
+
+ ::com::sun::star::accessibility::TextSegment aResult;
+ sal_Int32 nPara = GetParagraphIndex();
+ SvxTextForwarder &rCacheTF = GetTextForwarder();
+ const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
+ DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" );
+ if (bValidPara)
+ {
+ if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< USHORT >(nPara) ))
+ {
+ USHORT nStart = 0, nEnd = 0;
+ rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< USHORT >(nPara), static_cast< USHORT >(nLineNo) );
+ if (nStart != 0xFFFF && nEnd != 0xFFFF)
+ {
+ try
+ {
+ aResult.SegmentText = getTextRange( nStart, nEnd );
+ aResult.SegmentStart = nStart;
+ aResult.SegmentEnd = nEnd;
+ }
+ catch (lang::IndexOutOfBoundsException)
+ {
+ // this is not the exception that should be raised in this function ...
+ DBG_ASSERT( 0, "unexpected exception" );
+ }
+ }
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+ }
+ return aResult;
+ }
+
+ // XAccessibleMultiLineText
+ ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException)
+ {
+ DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
+
+ ::com::sun::star::accessibility::TextSegment aResult;
+ try
+ {
+ aResult = getTextAtLineNumber( getNumberOfLineWithCaret() );
+ }
+ catch (lang::IndexOutOfBoundsException &)
+ {
+ // this one needs to be catched since this interface does not allow for it.
+ }
+ return aResult;
+ }
+
+ // XAccessibleMultiLineText
+ sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException)
+ {
+ DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
+
+ sal_Int32 nRes = -1;
+ try
+ {
+ nRes = getLineNumberAtIndex( getCaretPosition() );
+ }
+ catch (lang::IndexOutOfBoundsException &)
+ {
+ // this one needs to be catched since this interface does not allow for it.
+ }
+ return nRes;
+ }
+
// XServiceInfo
::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException)