diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
commit | e7c6e5d2c248cfb935c91882a3a1e64fea7550b4 (patch) | |
tree | d2f45902cbd12ac6b651e486687130e01272d79f /svx/source/accessibility/AccessibleEditableTextPara.cxx | |
parent | 2484e4f7faa1f052ff48d2192ffb5931a71faa8f (diff) | |
parent | d1886d07b439e7197f731c9d98c0b2ec31c62faa (diff) |
merge commit to DEV300_m57
Diffstat (limited to 'svx/source/accessibility/AccessibleEditableTextPara.cxx')
-rw-r--r-- | svx/source/accessibility/AccessibleEditableTextPara.cxx | 150 |
1 files changed, 98 insertions, 52 deletions
diff --git a/svx/source/accessibility/AccessibleEditableTextPara.cxx b/svx/source/accessibility/AccessibleEditableTextPara.cxx index 27963bfdffc4..1c0ce04bb1d6 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) |