diff options
author | Oliver-Rainer Wittmann <od@openoffice.org> | 2010-02-24 10:47:49 +0100 |
---|---|---|
committer | Oliver-Rainer Wittmann <od@openoffice.org> | 2010-02-24 10:47:49 +0100 |
commit | e1ea41bc9c2f658d047a8841d1c2d061e1e704b8 (patch) | |
tree | 4a396c3ca1dc64c8b75fb9401d89b48a8adf0af9 /sw/source/core/access | |
parent | 723a40a9525fdd7450f5716eec800eca99615732 (diff) |
sw33a11y01: #i108125# - provide tracked changes of type insertion, deletion and format change at a paragraph as text markup at the UNO-A11y-API
Diffstat (limited to 'sw/source/core/access')
-rw-r--r-- | sw/source/core/access/accmap.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/access/accpara.cxx | 373 | ||||
-rw-r--r-- | sw/source/core/access/accpara.hxx | 21 | ||||
-rw-r--r-- | sw/source/core/access/makefile.mk | 3 | ||||
-rw-r--r-- | sw/source/core/access/parachangetrackinginfo.cxx | 231 | ||||
-rw-r--r-- | sw/source/core/access/parachangetrackinginfo.hxx | 59 | ||||
-rw-r--r-- | sw/source/core/access/textmarkuphelper.cxx | 55 | ||||
-rw-r--r-- | sw/source/core/access/textmarkuphelper.hxx | 29 |
8 files changed, 594 insertions, 181 deletions
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index b7f3f76e6922..5937e251cb57 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -1420,8 +1420,8 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, { case FRM_TXT: mnPara++; - pAcc = new SwAccessibleParagraph( this, - static_cast< const SwTxtFrm * >( pFrm ) ); + pAcc = new SwAccessibleParagraph( *this, + static_cast< const SwTxtFrm& >( *pFrm ) ); break; case FRM_HEADER: pAcc = new SwAccessibleHeaderFooter( this, diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index d9ccda18c68f..029731389493 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -79,15 +79,15 @@ #include <viewimp.hxx> #include <boost/scoped_ptr.hpp> #include <textmarkuphelper.hxx> +// --> OD 2010-02-22 #i10825# +#include <parachangetrackinginfo.hxx> +#include <com/sun/star/text/TextMarkupType.hpp> +// <-- #include <algorithm> using namespace ::com::sun::star; -using namespace ::com::sun::star::i18n; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; -using ::rtl::OUString; using beans::PropertyValue; using beans::XMultiPropertySet; @@ -119,15 +119,15 @@ const SwTxtNode* SwAccessibleParagraph::GetTxtNode() const return pNode; } -OUString SwAccessibleParagraph::GetString() +::rtl::OUString SwAccessibleParagraph::GetString() { return GetPortionData().GetAccessibleString(); } -OUString SwAccessibleParagraph::GetDescription() +::rtl::OUString SwAccessibleParagraph::GetDescription() { // --> OD 2004-09-29 #117933# - provide empty description for paragraphs - return OUString(); + return ::rtl::OUString(); // <-- } @@ -376,11 +376,11 @@ void SwAccessibleParagraph::GetStates( void SwAccessibleParagraph::_InvalidateContent( sal_Bool bVisibleDataFired ) { - OUString sOldText( GetString() ); + ::rtl::OUString sOldText( GetString() ); ClearPortionData(); - const OUString& rText = GetString(); + const ::rtl::OUString& rText = GetString(); if( rText != sOldText ) { @@ -412,8 +412,8 @@ void SwAccessibleParagraph::_InvalidateContent( sal_Bool bVisibleDataFired ) if( bNewIsHeading != bOldIsHeading || rText != sOldText ) { - OUString sNewDesc( GetDescription() ); - OUString sOldDesc; + ::rtl::OUString sNewDesc( GetDescription() ); + ::rtl::OUString sOldDesc; { vos::OGuard aGuard( aMutex ); sOldDesc = sDesc; @@ -490,19 +490,27 @@ void SwAccessibleParagraph::_InvalidateFocus() } SwAccessibleParagraph::SwAccessibleParagraph( - SwAccessibleMap* pInitMap, - const SwTxtFrm *pTxtFrm ) : - SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, pTxtFrm ), - pPortionData( NULL ), - pHyperTextData( NULL ), - nOldCaretPos( -1 ), - aSelectionHelper( *this ) + SwAccessibleMap& rInitMap, + const SwTxtFrm& rTxtFrm ) + // --> OD 2010-02-24 #i108125# + : SwClient( const_cast<SwTxtNode*>(rTxtFrm.GetTxtNode()) ) + // <-- + , SwAccessibleContext( &rInitMap, AccessibleRole::PARAGRAPH, &rTxtFrm ) + , sDesc() + , pPortionData( NULL ) + , pHyperTextData( NULL ) + , nOldCaretPos( -1 ) + , bIsHeading( sal_False ) + , aSelectionHelper( *this ) + // --> OD 2010-02-19 #i108125# + , mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTxtFrm ) ) + // <-- { vos::OGuard aGuard(Application::GetSolarMutex()); bIsHeading = IsHeading(); // --> OD 2004-09-27 #117970# - set an empty accessibility name for paragraphs - SetName( OUString() ); + SetName( ::rtl::OUString() ); // <-- // If this object has the focus, then it is remembered by the map itself. @@ -515,6 +523,9 @@ SwAccessibleParagraph::~SwAccessibleParagraph() delete pPortionData; delete pHyperTextData; + // --> OD 2010-02-22 #i108125# + delete mpParaChangeTrackInfo; + // <-- } sal_Bool SwAccessibleParagraph::HasCursor() @@ -635,8 +646,8 @@ sal_Bool SwAccessibleParagraph::IsValidRange( sal_Bool SwAccessibleParagraph::GetCharBoundary( - Boundary& rBound, - const OUString&, + i18n::Boundary& rBound, + const ::rtl::OUString&, sal_Int32 nPos ) { rBound.startPos = nPos; @@ -645,8 +656,8 @@ sal_Bool SwAccessibleParagraph::GetCharBoundary( } sal_Bool SwAccessibleParagraph::GetWordBoundary( - Boundary& rBound, - const OUString& rText, + i18n::Boundary& rBound, + const ::rtl::OUString& rText, sal_Int32 nPos ) { sal_Bool bRet = sal_False; @@ -658,12 +669,12 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); - Locale aLocale = pBreakIt->GetLocale( + lang::Locale aLocale = pBreakIt->GetLocale( GetTxtNode()->GetLang( nModelPos ) ); // which type of word are we interested in? // (DICTIONARY_WORD includes punctuation, ANY_WORD doesn't.) - const USHORT nWordType = WordType::ANY_WORD; + const USHORT nWordType = i18n::WordType::ANY_WORD; // get word boundary, as the Break-Iterator sees fit. rBound = pBreakIt->GetBreakIter()->getWordBoundary( @@ -684,8 +695,8 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( } sal_Bool SwAccessibleParagraph::GetSentenceBoundary( - Boundary& rBound, - const OUString&, + i18n::Boundary& rBound, + const ::rtl::OUString&, sal_Int32 nPos ) { GetPortionData().GetSentenceBoundary( rBound, nPos ); @@ -693,8 +704,8 @@ sal_Bool SwAccessibleParagraph::GetSentenceBoundary( } sal_Bool SwAccessibleParagraph::GetLineBoundary( - Boundary& rBound, - const OUString& rText, + i18n::Boundary& rBound, + const ::rtl::OUString& rText, sal_Int32 nPos ) { if( rText.getLength() == nPos ) @@ -705,8 +716,8 @@ sal_Bool SwAccessibleParagraph::GetLineBoundary( } sal_Bool SwAccessibleParagraph::GetParagraphBoundary( - Boundary& rBound, - const OUString& rText, + i18n::Boundary& rBound, + const ::rtl::OUString& rText, sal_Int32 ) { rBound.startPos = 0; @@ -715,8 +726,8 @@ sal_Bool SwAccessibleParagraph::GetParagraphBoundary( } sal_Bool SwAccessibleParagraph::GetAttributeBoundary( - Boundary& rBound, - const OUString&, + i18n::Boundary& rBound, + const ::rtl::OUString&, sal_Int32 nPos ) { GetPortionData().GetAttributeBoundary( rBound, nPos ); @@ -724,8 +735,8 @@ sal_Bool SwAccessibleParagraph::GetAttributeBoundary( } sal_Bool SwAccessibleParagraph::GetGlyphBoundary( - Boundary& rBound, - const OUString& rText, + i18n::Boundary& rBound, + const ::rtl::OUString& rText, sal_Int32 nPos ) { sal_Bool bRet = sal_False; @@ -738,11 +749,11 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); - Locale aLocale = pBreakIt->GetLocale( + lang::Locale aLocale = pBreakIt->GetLocale( GetTxtNode()->GetLang( nModelPos ) ); // get word boundary, as the Break-Iterator sees fit. - const USHORT nIterMode = CharacterIteratorMode::SKIPCELL; + const USHORT nIterMode = i18n::CharacterIteratorMode::SKIPCELL; sal_Int32 nDone = 0; rBound.endPos = pBreakIt->GetBreakIter()->nextCharacters( rText, nPos, aLocale, nIterMode, 1, nDone ); @@ -764,20 +775,20 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( sal_Bool SwAccessibleParagraph::GetTextBoundary( - Boundary& rBound, - const OUString& rText, + i18n::Boundary& rBound, + const ::rtl::OUString& rText, sal_Int32 nPos, sal_Int16 nTextType ) throw ( - IndexOutOfBoundsException, - IllegalArgumentException, + lang::IndexOutOfBoundsException, + lang::IllegalArgumentException, uno::RuntimeException) { // error checking if( !( AccessibleTextType::LINE == nTextType ? IsValidPosition( nPos, rText.getLength() ) : IsValidChar( nPos, rText.getLength() ) ) ) - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); sal_Bool bRet; @@ -812,13 +823,13 @@ sal_Bool SwAccessibleParagraph::GetTextBoundary( break; default: - throw IllegalArgumentException( ); + throw lang::IllegalArgumentException( ); } return bRet; } -OUString SAL_CALL SwAccessibleParagraph::getAccessibleDescription (void) +::rtl::OUString SAL_CALL SwAccessibleParagraph::getAccessibleDescription (void) throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -832,7 +843,7 @@ OUString SAL_CALL SwAccessibleParagraph::getAccessibleDescription (void) return sDesc; } -Locale SAL_CALL SwAccessibleParagraph::getLocale (void) +lang::Locale SAL_CALL SwAccessibleParagraph::getLocale (void) throw (IllegalAccessibleComponentStateException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -844,7 +855,7 @@ Locale SAL_CALL SwAccessibleParagraph::getLocale (void) } const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode(); - Locale aLoc( pBreakIt->GetLocale( pTxtNd->GetLang( 0 ) ) ); + lang::Locale aLoc( pBreakIt->GetLocale( pTxtNd->GetLang( 0 ) ) ); return aLoc; } @@ -997,10 +1008,10 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getBackground() } // <-- -OUString SAL_CALL SwAccessibleParagraph::getImplementationName() +::rtl::OUString SAL_CALL SwAccessibleParagraph::getImplementationName() throw( uno::RuntimeException ) { - return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName)); + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName)); } sal_Bool SAL_CALL SwAccessibleParagraph::supportsService( @@ -1013,13 +1024,13 @@ sal_Bool SAL_CALL SwAccessibleParagraph::supportsService( sizeof(sAccessibleServiceName)-1 ); } -Sequence< OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames() +uno::Sequence< ::rtl::OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames() throw( uno::RuntimeException ) { - Sequence< OUString > aRet(2); - OUString* pArray = aRet.getArray(); - pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) ); - pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) ); + uno::Sequence< ::rtl::OUString > aRet(2); + ::rtl::OUString* pArray = aRet.getArray(); + pArray[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) ); + pArray[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) ); return aRet; } @@ -1027,10 +1038,10 @@ Sequence< OUString > SAL_CALL SwAccessibleParagraph::getSupportedServiceNames() //===== XInterface ======================================================= // -Any SwAccessibleParagraph::queryInterface( const Type& rType ) - throw (RuntimeException) +uno::Any SwAccessibleParagraph::queryInterface( const uno::Type& rType ) + throw (uno::RuntimeException) { - Any aRet; + uno::Any aRet; if ( rType == ::getCppuType((uno::Reference<XAccessibleText> *)0) ) { uno::Reference<XAccessibleText> aAccText = (XAccessibleText *) *this; // resolve ambiguity @@ -1082,9 +1093,9 @@ Any SwAccessibleParagraph::queryInterface( const Type& rType ) } //====== XTypeProvider ==================================================== -Sequence< Type > SAL_CALL SwAccessibleParagraph::getTypes() throw(RuntimeException) +uno::Sequence< uno::Type > SAL_CALL SwAccessibleParagraph::getTypes() throw(uno::RuntimeException) { - Sequence< Type > aTypes( SwAccessibleContext::getTypes() ); + uno::Sequence< uno::Type > aTypes( SwAccessibleContext::getTypes() ); sal_Int32 nIndex = aTypes.getLength(); // --> OD 2006-07-13 #i63870# @@ -1093,7 +1104,7 @@ Sequence< Type > SAL_CALL SwAccessibleParagraph::getTypes() throw(RuntimeExcepti // add type accessibility::XAccessibleTextMarkup and accessibility::XAccessibleMultiLineText aTypes.realloc( nIndex + 6 ); - Type* pTypes = aTypes.getArray(); + uno::Type* pTypes = aTypes.getArray(); pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleEditableText > * >( 0 ) ); pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleTextAttributes > * >( 0 ) ); pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) ); @@ -1105,11 +1116,11 @@ Sequence< Type > SAL_CALL SwAccessibleParagraph::getTypes() throw(RuntimeExcepti return aTypes; } -Sequence< sal_Int8 > SAL_CALL SwAccessibleParagraph::getImplementationId() - throw(RuntimeException) +uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleParagraph::getImplementationId() + throw(uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - static Sequence< sal_Int8 > aId( 16 ); + static uno::Sequence< sal_Int8 > aId( 16 ); static sal_Bool bInit = sal_False; if(!bInit) { @@ -1125,7 +1136,7 @@ Sequence< sal_Int8 > SAL_CALL SwAccessibleParagraph::getImplementationId() // sal_Int32 SwAccessibleParagraph::getCaretPosition() - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1147,7 +1158,7 @@ sal_Int32 SwAccessibleParagraph::getCaretPosition() } sal_Bool SAL_CALL SwAccessibleParagraph::setCaretPosition( sal_Int32 nIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1157,7 +1168,7 @@ sal_Bool SAL_CALL SwAccessibleParagraph::setCaretPosition( sal_Int32 nIndex ) sal_Int32 nLength = GetString().getLength(); if ( ! IsValidPosition( nIndex, nLength ) ) { - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } sal_Bool bRet = sal_False; @@ -1180,13 +1191,13 @@ sal_Bool SAL_CALL SwAccessibleParagraph::setCaretPosition( sal_Int32 nIndex ) } sal_Unicode SwAccessibleParagraph::getCharacter( sal_Int32 nIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); - OUString sText( GetString() ); + ::rtl::OUString sText( GetString() ); // return character (if valid) if( IsValidChar(nIndex, sText.getLength() ) ) @@ -1194,25 +1205,25 @@ sal_Unicode SwAccessibleParagraph::getCharacter( sal_Int32 nIndex ) return sText.getStr()[nIndex]; } else - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } // --> OD 2006-07-20 #i63870# // re-implement method on behalf of methods <_getDefaultAttributesImpl(..)> and // <_getRunAttributesImpl(..)> -Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( +uno::Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( sal_Int32 nIndex, const uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); - const OUString& rText = GetString(); + const ::rtl::OUString& rText = GetString(); if( ! IsValidChar( nIndex, rText.getLength() ) ) - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); // retrieve default character attributes tAccParaPropValMap aDefAttrSeq; @@ -1223,7 +1234,7 @@ Sequence<PropertyValue> SwAccessibleParagraph::getCharacterAttributes( _getRunAttributesImpl( nIndex, aRequestedAttributes, aRunAttrSeq ); // merge default and run attributes - Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); + uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); PropertyValue* pValues = aValues.getArray(); sal_Int32 i = 0; for ( tAccParaPropValMap::const_iterator aDefIter = aDefAttrSeq.begin(); @@ -1341,7 +1352,7 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( const SfxPoolItem* pItem = pSet->GetItem( aPropIt->nWID ); if ( pItem ) { - Any aVal; + uno::Any aVal; pItem->QueryValue( aVal, aPropIt->nMemberId ); PropertyValue rPropVal; @@ -1359,14 +1370,14 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( // add property value entry for the paragraph style if ( !bOnlyCharAttrs && pTxtNode->GetTxtColl() ) { - const OUString sParaStyleName = - OUString::createFromAscii( + const ::rtl::OUString sParaStyleName = + ::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_PARA_STYLE_NAME ).pName ); if ( aDefAttrSeq.find( sParaStyleName ) == aDefAttrSeq.end() ) { PropertyValue rPropVal; rPropVal.Name = sParaStyleName; - Any aVal( makeAny( OUString( pTxtNode->GetTxtColl()->GetName() ) ) ); + uno::Any aVal( uno::makeAny( ::rtl::OUString( pTxtNode->GetTxtColl()->GetName() ) ) ); rPropVal.Value = aVal; rPropVal.Handle = -1; rPropVal.State = beans::PropertyState_DEFAULT_VALUE; @@ -1380,8 +1391,8 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( // resolve value text::WritingMode2::PAGE of property value entry WritingMode if ( !bOnlyCharAttrs && GetFrm() ) { - const OUString sWritingMode = - OUString::createFromAscii( + const ::rtl::OUString sWritingMode = + ::rtl::OUString::createFromAscii( GetPropName( UNO_NAME_WRITING_MODE ).pName ); tAccParaPropValMap::iterator aIter = aDefAttrSeq.find( sWritingMode ); if ( aIter != aDefAttrSeq.end() ) @@ -1434,7 +1445,7 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( } else { - const OUString* pReqAttrs = aRequestedAttributes.getConstArray(); + const ::rtl::OUString* pReqAttrs = aRequestedAttributes.getConstArray(); const sal_Int32 nLength = aRequestedAttributes.getLength(); for( sal_Int32 i = 0; i < nLength; ++i ) { @@ -1447,8 +1458,8 @@ void SwAccessibleParagraph::_getDefaultAttributesImpl( } } -Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes( - const Sequence< ::rtl::OUString >& aRequestedAttributes ) +uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes( + const uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) throw ( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1457,7 +1468,7 @@ Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes( tAccParaPropValMap aDefAttrSeq; _getDefaultAttributesImpl( aRequestedAttributes, aDefAttrSeq ); - Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); + uno::Sequence< PropertyValue > aValues( aDefAttrSeq.size() ); PropertyValue* pValues = aValues.getArray(); sal_Int32 i = 0; for ( tAccParaPropValMap::const_iterator aIter = aDefAttrSeq.begin(); @@ -1544,7 +1555,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl( // the corresponding default character attributes, are excluded. if ( aSet.GetItemState( aPropIt->nWID, TRUE, &pItem ) == SFX_ITEM_SET ) { - Any aVal; + uno::Any aVal; pItem->QueryValue( aVal, aPropIt->nMemberId ); PropertyValue rPropVal; @@ -1572,7 +1583,7 @@ void SwAccessibleParagraph::_getRunAttributesImpl( } else { - const OUString* pReqAttrs = aRequestedAttributes.getConstArray(); + const ::rtl::OUString* pReqAttrs = aRequestedAttributes.getConstArray(); const sal_Int32 nLength = aRequestedAttributes.getLength(); for( sal_Int32 i = 0; i < nLength; ++i ) { @@ -1588,27 +1599,27 @@ void SwAccessibleParagraph::_getRunAttributesImpl( delete pPaM; } -Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes( +uno::Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes( sal_Int32 nIndex, - const Sequence< ::rtl::OUString >& aRequestedAttributes ) - throw ( IndexOutOfBoundsException, + const uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); { - const OUString& rText = GetString(); + const ::rtl::OUString& rText = GetString(); if ( !IsValidChar( nIndex, rText.getLength() ) ) { - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } } tAccParaPropValMap aRunAttrSeq; _getRunAttributesImpl( nIndex, aRequestedAttributes, aRunAttrSeq ); - Sequence< PropertyValue > aValues( aRunAttrSeq.size() ); + uno::Sequence< PropertyValue > aValues( aRunAttrSeq.size() ); PropertyValue* pValues = aValues.getArray(); sal_Int32 i = 0; for ( tAccParaPropValMap::const_iterator aIter = aRunAttrSeq.begin(); @@ -1625,7 +1636,7 @@ Sequence< PropertyValue > SwAccessibleParagraph::getRunAttributes( awt::Rectangle SwAccessibleParagraph::getCharacterBounds( sal_Int32 nIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1636,7 +1647,7 @@ awt::Rectangle SwAccessibleParagraph::getCharacterBounds( IsValidChar -> IsValidPosition */ if( ! (IsValidPosition( nIndex, GetString().getLength() ) ) ) - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); /* #i12332# */ sal_Bool bBehindText = sal_False; @@ -1688,7 +1699,7 @@ awt::Rectangle SwAccessibleParagraph::getCharacterBounds( } sal_Int32 SwAccessibleParagraph::getCharacterCount() - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1698,7 +1709,7 @@ sal_Int32 SwAccessibleParagraph::getCharacterCount() } sal_Int32 SwAccessibleParagraph::getIndexAtPoint( const awt::Point& rPoint ) - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1774,8 +1785,8 @@ sal_Int32 SwAccessibleParagraph::getIndexAtPoint( const awt::Point& rPoint ) : -1L; } -OUString SwAccessibleParagraph::getSelectedText() - throw (RuntimeException) +::rtl::OUString SwAccessibleParagraph::getSelectedText() + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1783,11 +1794,13 @@ OUString SwAccessibleParagraph::getSelectedText() sal_Int32 nStart, nEnd; sal_Bool bSelected = GetSelection( nStart, nEnd ); - return bSelected ? GetString().copy( nStart, nEnd - nStart ) : OUString(); + return bSelected + ? GetString().copy( nStart, nEnd - nStart ) + : ::rtl::OUString(); } sal_Int32 SwAccessibleParagraph::getSelectionStart() - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1799,7 +1812,7 @@ sal_Int32 SwAccessibleParagraph::getSelectionStart() } sal_Int32 SwAccessibleParagraph::getSelectionEnd() - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1811,7 +1824,7 @@ sal_Int32 SwAccessibleParagraph::getSelectionEnd() } sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1821,7 +1834,7 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 n sal_Int32 nLength = GetString().getLength(); if ( ! IsValidRange( nStartIndex, nEndIndex, nLength ) ) { - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } sal_Bool bRet = sal_False; @@ -1846,8 +1859,8 @@ sal_Bool SwAccessibleParagraph::setSelection( sal_Int32 nStartIndex, sal_Int32 n return bRet; } -OUString SwAccessibleParagraph::getText() - throw (RuntimeException) +::rtl::OUString SwAccessibleParagraph::getText() + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1856,15 +1869,15 @@ OUString SwAccessibleParagraph::getText() return GetString(); } -OUString SwAccessibleParagraph::getTextRange( +::rtl::OUString SwAccessibleParagraph::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); - OUString sText( GetString() ); + ::rtl::OUString sText( GetString() ); if ( IsValidRange( nStartIndex, nEndIndex, sText.getLength() ) ) { @@ -1872,7 +1885,7 @@ OUString SwAccessibleParagraph::getTextRange( return sText.copy(nStartIndex, nEndIndex-nStartIndex ); } else - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } /*accessibility::*/TextSegment SwAccessibleParagraph::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType ) throw (lang::IndexOutOfBoundsException, lang::IllegalArgumentException, uno::RuntimeException) @@ -1885,7 +1898,7 @@ OUString SwAccessibleParagraph::getTextRange( aResult.SegmentStart = -1; aResult.SegmentEnd = -1; - const OUString rText = GetString(); + const ::rtl::OUString rText = GetString(); // implement the silly specification that first position after // text must return an empty string, rather than throwing an // IndexOutOfBoundsException, except for LINE, where the last @@ -1894,7 +1907,7 @@ OUString SwAccessibleParagraph::getTextRange( return aResult; // with error checking - Boundary aBound; + i18n::Boundary aBound; sal_Bool bWord = GetTextBoundary( aBound, rText, nIndex, nTextType ); DBG_ASSERT( aBound.startPos >= 0, "illegal boundary" ); @@ -1917,14 +1930,14 @@ OUString SwAccessibleParagraph::getTextRange( CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); - const OUString rText = GetString(); + const ::rtl::OUString rText = GetString(); /*accessibility::*/TextSegment aResult; aResult.SegmentStart = -1; aResult.SegmentEnd = -1; // get starting pos - Boundary aBound; + i18n::Boundary aBound; if (nIndex == rText.getLength()) aBound.startPos = aBound.endPos = nIndex; else @@ -1964,7 +1977,7 @@ OUString SwAccessibleParagraph::getTextRange( /*accessibility::*/TextSegment aResult; aResult.SegmentStart = -1; aResult.SegmentEnd = -1; - const OUString rText = GetString(); + const ::rtl::OUString rText = GetString(); // implement the silly specification that first position after // text must return an empty string, rather than throwing an @@ -1974,7 +1987,7 @@ OUString SwAccessibleParagraph::getTextRange( // get first word, then skip to next word - Boundary aBound; + i18n::Boundary aBound; GetTextBoundary( aBound, rText, nIndex, nTextType ); sal_Bool bWord = sal_False; while( !bWord ) @@ -1996,7 +2009,7 @@ OUString SwAccessibleParagraph::getTextRange( } sal_Bool SwAccessibleParagraph::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { CHECK_FOR_DEFUNC_THIS( XAccessibleText, *this ); vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2013,7 +2026,7 @@ sal_Bool SwAccessibleParagraph::copyText( sal_Int32 nStartIndex, sal_Int32 nEndI // sal_Bool SwAccessibleParagraph::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { CHECK_FOR_DEFUNC( XAccessibleEditableText ); vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2028,7 +2041,7 @@ sal_Bool SwAccessibleParagraph::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIn } sal_Bool SwAccessibleParagraph::pasteText( sal_Int32 nIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { CHECK_FOR_DEFUNC( XAccessibleEditableText ); vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2043,27 +2056,27 @@ sal_Bool SwAccessibleParagraph::pasteText( sal_Int32 nIndex ) } sal_Bool SwAccessibleParagraph::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { - return replaceText( nStartIndex, nEndIndex, OUString() ); + return replaceText( nStartIndex, nEndIndex, ::rtl::OUString() ); } -sal_Bool SwAccessibleParagraph::insertText( const OUString& sText, sal_Int32 nIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) +sal_Bool SwAccessibleParagraph::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { return replaceText( nIndex, nIndex, sText ); } sal_Bool SwAccessibleParagraph::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, - const OUString& sReplacement ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + const ::rtl::OUString& sReplacement ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleEditableText ); - const OUString& rText = GetString(); + const ::rtl::OUString& rText = GetString(); if( IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) ) { @@ -2099,7 +2112,7 @@ sal_Bool SwAccessibleParagraph::replaceText( return bSuccess; } else - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } struct IndexCompare @@ -2116,16 +2129,16 @@ struct IndexCompare sal_Bool SwAccessibleParagraph::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, - const Sequence<PropertyValue>& rAttributeSet ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + const uno::Sequence<PropertyValue>& rAttributeSet ) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleEditableText ); - const OUString& rText = GetString(); + const ::rtl::OUString& rText = GetString(); if( ! IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) ) - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); if( !IsEditableState() ) return sal_False; @@ -2146,10 +2159,10 @@ sal_Bool SwAccessibleParagraph::setAttributes( sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); // create sorted sequences accoring to index array - Sequence<OUString> aNames( nLength ); - OUString* pNames = aNames.getArray(); - Sequence<Any> aValues( nLength ); - Any* pValues = aValues.getArray(); + uno::Sequence< ::rtl::OUString > aNames( nLength ); + ::rtl::OUString* pNames = aNames.getArray(); + uno::Sequence< uno::Any > aValues( nLength ); + uno::Any* pValues = aValues.getArray(); for( i = 0; i < nLength; i++ ) { const PropertyValue& rVal = pPairs[pIndices[i]]; @@ -2173,8 +2186,8 @@ sal_Bool SwAccessibleParagraph::setAttributes( return bRet; } -sal_Bool SwAccessibleParagraph::setText( const OUString& sText ) - throw (RuntimeException) +sal_Bool SwAccessibleParagraph::setText( const ::rtl::OUString& sText ) + throw (uno::RuntimeException) { return replaceText(0, GetString().getLength(), sText); } @@ -2183,7 +2196,7 @@ sal_Bool SwAccessibleParagraph::setText( const OUString& sText ) void SwAccessibleParagraph::selectAccessibleChild( sal_Int32 nChildIndex ) - throw ( IndexOutOfBoundsException, + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { CHECK_FOR_DEFUNC( XAccessibleSelection ); @@ -2193,7 +2206,7 @@ void SwAccessibleParagraph::selectAccessibleChild( sal_Bool SwAccessibleParagraph::isAccessibleChildSelected( sal_Int32 nChildIndex ) - throw ( IndexOutOfBoundsException, + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { CHECK_FOR_DEFUNC( XAccessibleSelection ); @@ -2227,7 +2240,7 @@ sal_Int32 SwAccessibleParagraph::getSelectedAccessibleChildCount( ) uno::Reference<XAccessible> SwAccessibleParagraph::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) - throw ( IndexOutOfBoundsException, + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException) { CHECK_FOR_DEFUNC( XAccessibleSelection ); @@ -2238,7 +2251,7 @@ uno::Reference<XAccessible> SwAccessibleParagraph::getSelectedAccessibleChild( // --> OD 2004-11-16 #111714# - index has to be treated as global child index. void SwAccessibleParagraph::deselectAccessibleChild( sal_Int32 nChildIndex ) - throw ( IndexOutOfBoundsException, + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) { CHECK_FOR_DEFUNC( XAccessibleSelection ); @@ -2300,7 +2313,7 @@ const SwTxtAttr *SwHyperlinkIter_Impl::next() }; sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkCount() - throw (RuntimeException) + throw (uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -2322,7 +2335,7 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkCount() uno::Reference< XAccessibleHyperlink > SAL_CALL SwAccessibleParagraph::getHyperLink( sal_Int32 nLinkIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleHypertext ); @@ -2371,13 +2384,13 @@ uno::Reference< XAccessibleHyperlink > SAL_CALL } if( !xRet.is() ) - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); return xRet; } sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharIndex ) - throw (IndexOutOfBoundsException, uno::RuntimeException) + throw (lang::IndexOutOfBoundsException, uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); CHECK_FOR_DEFUNC( XAccessibleHypertext ); @@ -2386,7 +2399,7 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharInde sal_Int32 nLength = GetString().getLength(); if ( ! IsValidPosition( nCharIndex, nLength ) ) { - throw IndexOutOfBoundsException(); + throw lang::IndexOutOfBoundsException(); } sal_Int32 nRet = -1; @@ -2415,13 +2428,30 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getHyperLinkIndex( sal_Int32 nCharInde } // --> OD 2008-05-26 #i71360# +// --> OD 2010-02-22 #i108125# - adjustments for change tracking text markup sal_Int32 SAL_CALL SwAccessibleParagraph::getTextMarkupCount( sal_Int32 nTextMarkupType ) throw (lang::IllegalArgumentException, uno::RuntimeException) { - SwTextMarkupHelper aTextMarkupHelper( *GetTxtNode(), GetPortionData() ); + std::auto_ptr<SwTextMarkupHelper> pTextMarkupHelper; + switch ( nTextMarkupType ) + { + case text::TextMarkupType::TRACK_CHANGE_INSERTION: + case text::TextMarkupType::TRACK_CHANGE_DELETION: + case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( + GetPortionData(), + *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) ); + } + break; + default: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( GetPortionData(), *GetTxtNode() ) ); + } + } - return aTextMarkupHelper.getTextMarkupCount( nTextMarkupType ); + return pTextMarkupHelper->getTextMarkupCount( nTextMarkupType ); } /*accessibility::*/TextSegment SAL_CALL @@ -2431,9 +2461,25 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getTextMarkupCount( sal_Int32 nTextMar lang::IllegalArgumentException, uno::RuntimeException) { - SwTextMarkupHelper aTextMarkupHelper( *GetTxtNode(), GetPortionData() ); + std::auto_ptr<SwTextMarkupHelper> pTextMarkupHelper; + switch ( nTextMarkupType ) + { + case text::TextMarkupType::TRACK_CHANGE_INSERTION: + case text::TextMarkupType::TRACK_CHANGE_DELETION: + case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( + GetPortionData(), + *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) ); + } + break; + default: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( GetPortionData(), *GetTxtNode() ) ); + } + } - return aTextMarkupHelper.getTextMarkup( nTextMarkupIndex, nTextMarkupType ); + return pTextMarkupHelper->getTextMarkup( nTextMarkupIndex, nTextMarkupType ); } uno::Sequence< /*accessibility::*/TextSegment > SAL_CALL @@ -2450,9 +2496,25 @@ uno::Sequence< /*accessibility::*/TextSegment > SAL_CALL throw lang::IndexOutOfBoundsException(); } - SwTextMarkupHelper aTextMarkupHelper( *GetTxtNode(), GetPortionData() ); + std::auto_ptr<SwTextMarkupHelper> pTextMarkupHelper; + switch ( nTextMarkupType ) + { + case text::TextMarkupType::TRACK_CHANGE_INSERTION: + case text::TextMarkupType::TRACK_CHANGE_DELETION: + case text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( + GetPortionData(), + *(mpParaChangeTrackInfo->getChangeTrackingTextMarkupList( nTextMarkupType ) )) ); + } + break; + default: + { + pTextMarkupHelper.reset( new SwTextMarkupHelper( GetPortionData(), *GetTxtNode() ) ); + } + } - return aTextMarkupHelper.getTextMarkupAtIndex( nCharIndex, nTextMarkupType ); + return pTextMarkupHelper->getTextMarkupAtIndex( nCharIndex, nTextMarkupType ); } // <-- @@ -2484,7 +2546,7 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getLineNumberAtIndex( sal_Int32 nIndex throw lang::IndexOutOfBoundsException(); } - Boundary aLineBound; + i18n::Boundary aLineBound; GetPortionData().GetBoundaryOfLine( nLineNo, aLineBound ); /*accessibility::*/TextSegment aTextAtLine; @@ -2526,7 +2588,7 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getNumberOfLineWithCaret() // special handling for cursor positioned at end of text line via End key if ( nCaretPos != 0 ) { - Boundary aLineBound; + i18n::Boundary aLineBound; GetPortionData().GetBoundaryOfLine( nLineNo, aLineBound ); if ( nCaretPos == aLineBound.startPos ) { @@ -2564,4 +2626,11 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getNumberOfLineWithCaret() return nLineNo; } +// --> OD 2010-02-19 #i108125# +void SwAccessibleParagraph::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) +{ + mpParaChangeTrackInfo->reset(); + + SwClient::Modify( pOld, pNew ); +} // <-- diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index d06235196dbb..ae751e905c7f 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -39,6 +39,9 @@ #include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp> #include <hash_map> #include <accselectionhelper.hxx> +// --> OD 2010-02-19 #i108125# +#include <calbck.hxx> +// <-- class SwTxtFrm; class SwTxtNode; @@ -46,6 +49,10 @@ class SwPaM; class SwAccessiblePortionData; class SwAccessibleHyperTextData; class SwXTextPortion; +// --> OD 2010-02-19 #i108125# +class SwParaChangeTrackingInfo; +// <-- + namespace rtl { class OUString; } namespace com { namespace sun { namespace star { namespace i18n { struct Boundary; } @@ -58,6 +65,9 @@ typedef ::std::hash_map< ::rtl::OUString, ::std::equal_to< ::rtl::OUString > > tAccParaPropValMap; class SwAccessibleParagraph : + // --> OD 2010-02-19 #i108125# + public SwClient, + // <-- public SwAccessibleContext, public ::com::sun::star::accessibility::XAccessibleEditableText, public com::sun::star::accessibility::XAccessibleSelection, @@ -87,6 +97,9 @@ class SwAccessibleParagraph : // implementation for XAccessibleSelection SwAccessibleSelectionHelper aSelectionHelper; + // --> OD 2010-02-19 #i108125# + SwParaChangeTrackingInfo* mpParaChangeTrackInfo; + // <-- /// get the SwTxtNode (requires frame; check before) const SwTxtNode* GetTxtNode() const; @@ -226,13 +239,17 @@ protected: public: - SwAccessibleParagraph( SwAccessibleMap* pInitMap, - const SwTxtFrm *pTxtFrm ); + SwAccessibleParagraph( SwAccessibleMap& rInitMap, + const SwTxtFrm& rTxtFrm ); inline operator ::com::sun::star::accessibility::XAccessibleText *(); virtual sal_Bool HasCursor(); // required by map to remember that object + // --> OD 2010-02-19 #i108125# + virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew); + // <-- + //===== XAccessibleContext ============================================== /// Return this object's description. diff --git a/sw/source/core/access/makefile.mk b/sw/source/core/access/makefile.mk index 402933f129ca..a514d7062501 100644 --- a/sw/source/core/access/makefile.mk +++ b/sw/source/core/access/makefile.mk @@ -67,7 +67,8 @@ SLOFILES = \ $(SLO)$/accselectionhelper.obj \ $(SLO)$/acctable.obj \ $(SLO)$/acctextframe.obj \ - $(SLO)$/textmarkuphelper.obj + $(SLO)$/textmarkuphelper.obj \ + $(SLO)$/parachangetrackinginfo.obj EXCEPTIONSFILES= \ $(SLO)$/acccell.obj \ diff --git a/sw/source/core/access/parachangetrackinginfo.cxx b/sw/source/core/access/parachangetrackinginfo.cxx new file mode 100644 index 000000000000..7c1e25f05c93 --- /dev/null +++ b/sw/source/core/access/parachangetrackinginfo.cxx @@ -0,0 +1,231 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ + +#include "precompiled_sw.hxx" + +#include <parachangetrackinginfo.hxx> + +#include <errhdl.hxx> +#include <wrong.hxx> +#include <com/sun/star/text/TextMarkupType.hpp> + +#include <txtfrm.hxx> +#include <ndtxt.hxx> +#include <IDocumentRedlineAccess.hxx> +#include <docary.hxx> +#include <redline.hxx> + +namespace css = com::sun::star; + +namespace { + void initChangeTrackTextMarkupLists( const SwTxtFrm& rTxtFrm, + SwWrongList*& opChangeTrackInsertionTextMarkupList, + SwWrongList*& opChangeTrackDeletionTextMarkupList, + SwWrongList*& opChangeTrackFormatChangeTextMarkupList ) + { + opChangeTrackInsertionTextMarkupList = new SwWrongList( WRONGLIST_CHANGETRACKING ); + opChangeTrackDeletionTextMarkupList = new SwWrongList( WRONGLIST_CHANGETRACKING ); + opChangeTrackFormatChangeTextMarkupList = new SwWrongList( WRONGLIST_CHANGETRACKING ); + + if ( !rTxtFrm.GetTxtNode() ) + { + ASSERT( false, + "<initChangeTrackTextMarkupLists(..) - missing <SwTxtNode> instance!" ); + return; + } + const SwTxtNode& rTxtNode( *(rTxtFrm.GetTxtNode()) ); + + const IDocumentRedlineAccess* pIDocChangeTrack( rTxtNode.getIDocumentRedlineAccess() ); + if ( !pIDocChangeTrack ) + { + ASSERT( false, + "<initChangeTrackTextMarkupLists(..) - missing <IDocumentRedlineAccess> instance!" ); + return; + } + + if ( !IDocumentRedlineAccess::IsShowChanges( pIDocChangeTrack->GetRedlineMode() ) || + pIDocChangeTrack->GetRedlineTbl().Count() == 0 ) + { + // nothing to do --> empty change track text markup lists. + return; + } + + const sal_uInt16 nIdxOfFirstRedlineForTxtNode = + pIDocChangeTrack->GetRedlinePos( rTxtNode, USHRT_MAX ); + if ( nIdxOfFirstRedlineForTxtNode == USHRT_MAX ) + { + // nothing to do --> empty change track text markup lists. + return; + } + + const xub_StrLen nTxtFrmTextStartPos = rTxtFrm.IsFollow() + ? rTxtFrm.GetOfst() + : 0; + const xub_StrLen nTxtFrmTextEndPos = rTxtFrm.HasFollow() + ? rTxtFrm.GetFollow()->GetOfst() + : rTxtFrm.GetTxt().Len(); + + // iteration over the redlines which overlap with the text node. + const SwRedlineTbl& rRedlineTbl = pIDocChangeTrack->GetRedlineTbl(); + const USHORT nRedlineCount( rRedlineTbl.Count() ); + for ( sal_uInt16 nActRedline = nIdxOfFirstRedlineForTxtNode; + nActRedline < nRedlineCount; + ++nActRedline) + { + const SwRedline* pActRedline = rRedlineTbl[ nActRedline ]; + if ( pActRedline->Start()->nNode > rTxtNode.GetIndex() ) + { + break; + } + + xub_StrLen nTxtNodeChangeTrackStart( STRING_LEN ); + xub_StrLen nTxtNodeChangeTrackEnd( STRING_LEN ); + pActRedline->CalcStartEnd( rTxtNode.GetIndex(), + nTxtNodeChangeTrackStart, + nTxtNodeChangeTrackEnd ); + if ( nTxtNodeChangeTrackStart > nTxtFrmTextEndPos || + nTxtNodeChangeTrackEnd < nTxtFrmTextStartPos ) + { + // Consider only redlines which overlap with the text frame's text. + continue; + } + + SwWrongList* pMarkupList( 0 ); + switch ( pActRedline->GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + { + pMarkupList = opChangeTrackInsertionTextMarkupList; + } + break; + case nsRedlineType_t::REDLINE_DELETE: + { + pMarkupList = opChangeTrackDeletionTextMarkupList; + } + break; + case nsRedlineType_t::REDLINE_FORMAT: + { + pMarkupList = opChangeTrackFormatChangeTextMarkupList; + } + break; + default: + { + // other types are not considered + } + } + if ( pMarkupList ) + { + const xub_StrLen nTxtFrmChangeTrackStart = + nTxtNodeChangeTrackStart <= nTxtFrmTextStartPos + ? nTxtFrmTextStartPos + : nTxtNodeChangeTrackStart; + + const xub_StrLen nTxtFrmChangeTrackEnd = + nTxtNodeChangeTrackEnd >= nTxtFrmTextEndPos + ? nTxtFrmTextEndPos + : nTxtNodeChangeTrackEnd; + + pMarkupList->Insert( rtl::OUString(), 0, + nTxtFrmChangeTrackStart, + nTxtFrmChangeTrackEnd - nTxtFrmChangeTrackStart, + pMarkupList->Count() ); + } + } // eof iteration over the redlines which overlap with the text node + } +} // eof anonymous namespace + +SwParaChangeTrackingInfo::SwParaChangeTrackingInfo( const SwTxtFrm& rTxtFrm ) + : mrTxtFrm( rTxtFrm ) + , mpChangeTrackInsertionTextMarkupList( 0 ) + , mpChangeTrackDeletionTextMarkupList( 0 ) + , mpChangeTrackFormatChangeTextMarkupList( 0 ) +{ +} + + +SwParaChangeTrackingInfo::~SwParaChangeTrackingInfo() +{ + reset(); +} + +void SwParaChangeTrackingInfo::reset() +{ + delete mpChangeTrackInsertionTextMarkupList; + mpChangeTrackInsertionTextMarkupList = 0; + + delete mpChangeTrackDeletionTextMarkupList; + mpChangeTrackDeletionTextMarkupList = 0; + + delete mpChangeTrackFormatChangeTextMarkupList; + mpChangeTrackFormatChangeTextMarkupList = 0; +} + +const SwWrongList* SwParaChangeTrackingInfo::getChangeTrackingTextMarkupList( const sal_Int32 nTextMarkupType ) +{ + SwWrongList* pChangeTrackingTextMarkupList = 0; + + if ( mpChangeTrackInsertionTextMarkupList == 0 ) + { + ASSERT( mpChangeTrackDeletionTextMarkupList == 0, + "<SwParaChangeTrackingInfo::getChangeTrackingTextMarkupList(..) - <mpChangeTrackDeletionTextMarkupList> expected to be NULL." ); + ASSERT( mpChangeTrackFormatChangeTextMarkupList == 0, + "<SwParaChangeTrackingInfo::getChangeTrackingTextMarkupList(..) - <mpChangeTrackFormatChangeTextMarkupList> expected to be NULL." ); + initChangeTrackTextMarkupLists( mrTxtFrm, + mpChangeTrackInsertionTextMarkupList, + mpChangeTrackDeletionTextMarkupList, + mpChangeTrackFormatChangeTextMarkupList ); + } + + switch ( nTextMarkupType ) + { + case css::text::TextMarkupType::TRACK_CHANGE_INSERTION: + { + pChangeTrackingTextMarkupList = mpChangeTrackInsertionTextMarkupList; + } + break; + case css::text::TextMarkupType::TRACK_CHANGE_DELETION: + { + pChangeTrackingTextMarkupList = mpChangeTrackDeletionTextMarkupList; + } + break; + case css::text::TextMarkupType::TRACK_CHANGE_FORMATCHANGE: + { + pChangeTrackingTextMarkupList = mpChangeTrackFormatChangeTextMarkupList; + } + break; + default: + { + ASSERT( false, + "<SwParaChangeTrackingInfo::getChangeTrackingTextMarkupList(..)> - misusage - unexpected text markup type for change tracking." ); + } + } + + return pChangeTrackingTextMarkupList; +} diff --git a/sw/source/core/access/parachangetrackinginfo.hxx b/sw/source/core/access/parachangetrackinginfo.hxx new file mode 100644 index 000000000000..91131f37b757 --- /dev/null +++ b/sw/source/core/access/parachangetrackinginfo.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * 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. + * + ************************************************************************/ +#ifndef _PARACHANGETRACKINGINFO_HXX_ +#define _PARACHANGETRACKINGINFO_HXX_ + +#include <sal/types.h> + +class SwTxtFrm; +class SwWrongList; + +class SwParaChangeTrackingInfo +{ + public: + explicit SwParaChangeTrackingInfo( const SwTxtFrm& rTxtFrm ); + ~SwParaChangeTrackingInfo(); + + void reset(); + + const SwWrongList* getChangeTrackingTextMarkupList( const sal_Int32 nTextMarkupType ); + + private: + SwParaChangeTrackingInfo( const SwParaChangeTrackingInfo& ); + SwParaChangeTrackingInfo& operator=( const SwParaChangeTrackingInfo& ); + + const SwTxtFrm& mrTxtFrm; + + SwWrongList* mpChangeTrackInsertionTextMarkupList; + SwWrongList* mpChangeTrackDeletionTextMarkupList; + SwWrongList* mpChangeTrackFormatChangeTextMarkupList; +}; +#endif + diff --git a/sw/source/core/access/textmarkuphelper.cxx b/sw/source/core/access/textmarkuphelper.cxx index be68370f7df3..1d56515e6c2a 100644 --- a/sw/source/core/access/textmarkuphelper.cxx +++ b/sw/source/core/access/textmarkuphelper.cxx @@ -37,7 +37,7 @@ #include <algorithm> #include <comphelper/stlunosequence.hxx> -#include "errhdl.hxx" +#include <errhdl.hxx> #include <com/sun/star/text/TextMarkupType.hpp> #include <com/sun/star/accessibility/TextSegment.hpp> @@ -84,22 +84,39 @@ namespace { } } -// implementation of calss <SwTextMarkupoHelper> -SwTextMarkupHelper::SwTextMarkupHelper( const SwTxtNode& rTxtNode, - const SwAccessiblePortionData& rPortionData ) - : mrTxtNode( rTxtNode ), - mrPortionData( rPortionData ) +// implementation of class <SwTextMarkupoHelper> +SwTextMarkupHelper::SwTextMarkupHelper( const SwAccessiblePortionData& rPortionData, + const SwTxtNode& rTxtNode ) + : mrPortionData( rPortionData ) + // --> OD 2010-02-19 #i108125# + , mpTxtNode( &rTxtNode ) + , mpTextMarkupList( 0 ) + // <-- { } -sal_Int32 SwTextMarkupHelper::getTextMarkupCount( sal_Int32 nTextMarkupType ) +// --> OD 2010-02-19 #i108125# +SwTextMarkupHelper::SwTextMarkupHelper( const SwAccessiblePortionData& rPortionData, + const SwWrongList& rTextMarkupList ) + : mrPortionData( rPortionData ) + , mpTxtNode( 0 ) + , mpTextMarkupList( &rTextMarkupList ) +{ +} +// <-- + +sal_Int32 SwTextMarkupHelper::getTextMarkupCount( const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { sal_Int32 nTextMarkupCount( 0 ); + // --> OD 2010-02-19 #i108125# const SwWrongList* pTextMarkupList = - getTextMarkupList( mrTxtNode, nTextMarkupType ); + mpTextMarkupList + ? mpTextMarkupList + : getTextMarkupList( *mpTxtNode, nTextMarkupType ); + // <-- if ( pTextMarkupList ) { nTextMarkupCount = pTextMarkupList->Count(); @@ -108,8 +125,8 @@ sal_Int32 SwTextMarkupHelper::getTextMarkupCount( sal_Int32 nTextMarkupType ) return nTextMarkupCount; } ::com::sun::star::accessibility::TextSegment - SwTextMarkupHelper::getTextMarkup( sal_Int32 nTextMarkupIndex, - sal_Int32 nTextMarkupType ) + SwTextMarkupHelper::getTextMarkup( const sal_Int32 nTextMarkupIndex, + const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) @@ -124,8 +141,12 @@ sal_Int32 SwTextMarkupHelper::getTextMarkupCount( sal_Int32 nTextMarkupType ) aTextMarkupSegment.SegmentStart = -1; aTextMarkupSegment.SegmentEnd = -1; + // --> OD 2010-02-19 #i108125# const SwWrongList* pTextMarkupList = - getTextMarkupList( mrTxtNode, nTextMarkupType ); + mpTextMarkupList + ? mpTextMarkupList + : getTextMarkupList( *mpTxtNode, nTextMarkupType ); + // <-- if ( pTextMarkupList ) { const SwWrongArea* pTextMarkup = @@ -152,8 +173,8 @@ sal_Int32 SwTextMarkupHelper::getTextMarkupCount( sal_Int32 nTextMarkupType ) } ::com::sun::star::uno::Sequence< ::com::sun::star::accessibility::TextSegment > - SwTextMarkupHelper::getTextMarkupAtIndex( sal_Int32 nCharIndex, - sal_Int32 nTextMarkupType ) + SwTextMarkupHelper::getTextMarkupAtIndex( const sal_Int32 nCharIndex, + const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) @@ -169,9 +190,13 @@ sal_Int32 SwTextMarkupHelper::getTextMarkupCount( sal_Int32 nTextMarkupType ) return uno::Sequence< ::com::sun::star::accessibility::TextSegment >(); } - ::std::vector< ::com::sun::star::accessibility::TextSegment > aTmpTextMarkups; + // --> OD 2010-02-19 #i108125# const SwWrongList* pTextMarkupList = - getTextMarkupList( mrTxtNode, nTextMarkupType ); + mpTextMarkupList + ? mpTextMarkupList + : getTextMarkupList( *mpTxtNode, nTextMarkupType ); + // <-- + ::std::vector< ::com::sun::star::accessibility::TextSegment > aTmpTextMarkups; if ( pTextMarkupList ) { const ::rtl::OUString rText = mrPortionData.GetAccessibleString(); diff --git a/sw/source/core/access/textmarkuphelper.hxx b/sw/source/core/access/textmarkuphelper.hxx index 6dda5c74f50f..705485258969 100644 --- a/sw/source/core/access/textmarkuphelper.hxx +++ b/sw/source/core/access/textmarkuphelper.hxx @@ -40,30 +40,37 @@ namespace com { namespace sun { namespace star { namespace accessibility { struct TextSegment; } } } } -class SwTxtNode; class SwAccessiblePortionData; +class SwTxtNode; +// --> OD 2010-02-19 #i108125# +class SwWrongList; +// <-- class SwTextMarkupHelper { public: - SwTextMarkupHelper( const SwTxtNode& rTxtNode, - const SwAccessiblePortionData& rPortionData ); + SwTextMarkupHelper( const SwAccessiblePortionData& rPortionData, + const SwTxtNode& rTxtNode ); + // --> OD 2010-02-19 #i108125# + SwTextMarkupHelper( const SwAccessiblePortionData& rPortionData, + const SwWrongList& rTextMarkupList ); + // <-- ~SwTextMarkupHelper() {} - sal_Int32 getTextMarkupCount( sal_Int32 nTextMarkupType ) + sal_Int32 getTextMarkupCount( const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); ::com::sun::star::accessibility::TextSegment getTextMarkup( - sal_Int32 nTextMarkupIndex, - sal_Int32 nTextMarkupType ) + const sal_Int32 nTextMarkupIndex, + const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Sequence< ::com::sun::star::accessibility::TextSegment > - getTextMarkupAtIndex( sal_Int32 nCharIndex, - sal_Int32 nTextMarkupType ) + getTextMarkupAtIndex( const sal_Int32 nCharIndex, + const sal_Int32 nTextMarkupType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); @@ -72,8 +79,12 @@ class SwTextMarkupHelper SwTextMarkupHelper( const SwTextMarkupHelper& ); SwTextMarkupHelper& operator=( const SwTextMarkupHelper& ); - const SwTxtNode& mrTxtNode; const SwAccessiblePortionData& mrPortionData; + + // --> OD 2010-02-19 #i108125# + const SwTxtNode* mpTxtNode; + const SwWrongList* mpTextMarkupList; + // <-- }; #endif |