You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/11/20 01:50:01 UTC

svn commit: r1543679 [20/32] - in /openoffice/branches/capstone2013: ./ main/ main/accessibility/inc/accessibility/extended/ main/accessibility/inc/accessibility/helper/ main/accessibility/inc/accessibility/standard/ main/accessibility/source/extended/...

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accframe.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accframe.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accframe.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accframe.cxx Wed Nov 20 00:49:46 2013
@@ -61,7 +61,9 @@ using namespace sw::access;
 {
 	sal_Int32 nCount = 0;
 
-    const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap );
+    // const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap );
+    const SwAccessibleChildSList aVisList( pFrm->PaintArea(), *pFrm, rAccMap );
+
     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
 	while( aIter != aVisList.end() )
 	{
@@ -163,7 +165,10 @@ using namespace sw::access;
     if( SwAccessibleChildMap::IsSortingRequired( rFrm ) )
 	{
 		// We need a sorted list here
-        const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
+		//IAccessibility2 Implementation 2009-----
+        // const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap );
+        const SwAccessibleChildMap aVisMap( rFrm.PaintArea(), rFrm, rAccMap );
+		//-----IAccessibility2 Implementation 2009
         SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() );
 		while( aIter != aVisMap.end() && !bFound )
 		{
@@ -189,7 +194,12 @@ using namespace sw::access;
 	{
 		// The unsorted list is sorted enough, because it return lower
 		// frames in the correct order.
-        const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
+
+		//IAccessibility2 Implementation 2009-----
+        // const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap );
+        const SwAccessibleChildSList aVisList( rFrm.PaintArea(), rFrm, rAccMap );
+		//-----IAccessibility2 Implementation 2009
+
         SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
 		while( aIter != aVisList.end() && !bFound )
 		{
@@ -425,7 +435,8 @@ SwAccessibleFrame::SwAccessibleFrame( co
                                       sal_Bool bIsPagePreview ) :
 	maVisArea( rVisArea ),
 	mpFrm( pF ),
-    mbIsInPagePreview( bIsPagePreview )
+    mbIsInPagePreview( bIsPagePreview ),
+    bIsAccDocUse( sal_False )
 {
 }
 

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accframe.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accframe.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accframe.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accframe.hxx Wed Nov 20 00:49:46 2013
@@ -52,8 +52,9 @@ protected:
     static sal_Int32 GetChildCount( SwAccessibleMap& rAccMap,
                                     const SwRect& rVisArea,
 									const SwFrm *pFrm,
-                                    sal_Bool bInPagePreview );
-private:
+                                    sal_Bool bInPagePreviewr );
+
+// private:
     static sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap,
                                                    const SwRect& rVisArea,
                                                    const SwFrm& rFrm,
@@ -104,6 +105,12 @@ protected:
 					   const SwFrm *pFrm,
                        sal_Bool bIsPagePreview );
 	virtual ~SwAccessibleFrame();
+	
+	//IAccessibility2 Implementation 2009-----
+	// MT: Move to private area?
+	sal_Bool bIsAccDocUse;
+	//-----IAccessibility2 Implementation 2009
+	
 
 public:
 	// Return the SwFrm this context is attached to.

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.cxx Wed Nov 20 00:49:46 2013
@@ -42,6 +42,26 @@
 #include "accmap.hxx"
 #include "accframebase.hxx"
 
+//IAccessibility2 Implementation 2009-----
+#ifndef _CRSRSH_HXX
+#include <crsrsh.hxx>
+#endif
+#ifndef _FESH_HXX
+#include "fesh.hxx"
+#endif
+#ifndef _TXTFRM_HXX
+#include <txtfrm.hxx>
+#endif
+#ifndef _NDTXT_HXX
+#include <ndtxt.hxx>
+#endif
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+#ifndef _FMTANCHR_HXX
+#include <fmtanchr.hxx>
+#endif
+//-----IAccessibility2 Implementation 2009
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
 using ::rtl::OUString;
@@ -93,6 +113,10 @@ void SwAccessibleFrameBase::GetStates(
 		if( pWin && pWin->HasFocus() )
 			rStateSet.AddState( AccessibleStateType::FOCUSED );
 	}
+	//IAccessibility2 Implementation 2009-----
+	if( GetSelectedState() )
+		rStateSet.AddState( AccessibleStateType::SELECTED );
+	//-----IAccessibility2 Implementation 2009
 }
 
 
@@ -166,20 +190,26 @@ void SwAccessibleFrameBase::_InvalidateC
 		Window *pWin = GetWindow();
 		if( pWin && pWin->HasFocus() && bNewSelected )
 			FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
-		FireStateChangedEvent( AccessibleStateType::SELECTED, bNewSelected );
+		//IAccessibility2 Implementation 2009-----
+		//FireStateChangedEvent( AccessibleStateType::SELECTED, bNewSelected );
 		if( pWin && pWin->HasFocus() && !bNewSelected )
 			FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
-
-		uno::Reference< XAccessible > xParent( GetWeakParent() );
-		if( xParent.is() )
+		if(bNewSelected)
 		{
-			SwAccessibleContext *pAcc =
-				static_cast <SwAccessibleContext *>( xParent.get() );
-
-			AccessibleEventObject aEvent;
-			aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
-			pAcc->FireAccessibleEvent( aEvent );
+			uno::Reference< XAccessible > xParent( GetWeakParent() );
+			if( xParent.is() )
+			{
+				SwAccessibleContext *pAcc =
+					static_cast <SwAccessibleContext *>( xParent.get() );
+				
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+				uno::Reference< XAccessible > xChild(this);
+				aEvent.NewValue <<= xChild;
+				pAcc->FireAccessibleEvent( aEvent );
+			}
 		}
+		//-----IAccessibility2 Implementation 2009
 	}
 }
 
@@ -247,13 +277,13 @@ void SwAccessibleFrameBase::Modify( cons
 		break;
 	case RES_OBJECTDYING:
         // mba: it seems that this class intentionally does not call code in base class SwClient
-		if( GetRegisteredIn() ==
-				static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) )
+		if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) )
 			GetRegisteredInNonConst()->Remove( this );
 		break;
 
 	case RES_FMT_CHG:
-		if( static_cast< const SwFmtChg * >(pNew)->pChangedFmt == GetRegisteredIn() &&
+		if( pOld && 
+			static_cast< const SwFmtChg * >(pNew)->pChangedFmt == GetRegisteredIn() &&
 			static_cast< const SwFmtChg * >(pOld)->pChangedFmt->IsFmtInDTOR() )
 			GetRegisteredInNonConst()->Remove( this );
 		break;
@@ -273,3 +303,124 @@ void SwAccessibleFrameBase::Dispose( sal
 
 	SwAccessibleContext::Dispose( bRecursive );
 }
+//IAccessibility2 Implementation 2009-----
+//Get the selection cursor of the document.
+SwPaM* SwAccessibleFrameBase::GetCrsr()
+{
+    // get the cursor shell; if we don't have any, we don't have a
+    // cursor/selection either
+    SwPaM* pCrsr = NULL;
+    SwCrsrShell* pCrsrShell = GetCrsrShell();
+    if( pCrsrShell != NULL && !pCrsrShell->IsTableMode() )
+    {
+		SwFEShell *pFESh = pCrsrShell->ISA( SwFEShell )
+							? static_cast< SwFEShell * >( pCrsrShell ) : 0;
+		if( !pFESh ||
+			!(pFESh->IsFrmSelected() || pFESh->IsObjSelected() > 0) )
+		{
+			// get the selection, and test whether it affects our text node
+			pCrsr = pCrsrShell->GetCrsr( sal_False /* ??? */ );
+		}
+    }
+
+    return pCrsr;
+}
+//Return the selected state of the object.
+//when the object's anchor are in the selection cursor, we should return true.
+sal_Bool SwAccessibleFrameBase::GetSelectedState( )
+{
+	vos::OGuard aGuard(Application::GetSolarMutex());
+
+	//IAccessibility2 Implementation 2009-----
+	if(GetMap()->IsDocumentSelAll())
+	{
+		return sal_True;
+	}
+	//-----IAccessibility2 Implementation 2009
+
+	// SELETED.
+	SwFlyFrm* pFlyFrm = getFlyFrm();
+	const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt();
+	const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor();
+	const SwPosition *pPos = pAnchor.GetCntntAnchor();
+	if( !pPos )
+		return sal_False;
+	int pIndex = pPos->nContent.GetIndex();
+	if( pPos->nNode.GetNode().GetTxtNode() )
+	{
+		SwPaM* pCrsr = GetCrsr();
+		if( pCrsr != NULL )
+		{
+			const SwTxtNode* pNode = pPos->nNode.GetNode().GetTxtNode();
+			sal_uLong nHere = pNode->GetIndex();
+
+			// iterate over ring
+			SwPaM* pRingStart = pCrsr;
+			do
+			{
+				// ignore, if no mark
+				if( pCrsr->HasMark() )
+				{
+					// check whether nHere is 'inside' pCrsr
+					SwPosition* pStart = pCrsr->Start();
+					sal_uLong nStartIndex = pStart->nNode.GetIndex();
+					SwPosition* pEnd = pCrsr->End();
+					sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+					if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex)  )
+					{
+						if( pAnchor.GetAnchorId() == FLY_AS_CHAR )
+						{
+                            //IAccessibility2 Implementation 2009-----
+							if( (nHere == nStartIndex) && (pIndex >= pStart->nContent.GetIndex()) || (nHere > nStartIndex) )
+								if( (nHere == nEndIndex) && (pIndex < pEnd->nContent.GetIndex()) || (nHere < nEndIndex) )
+								return sal_True;
+							//-----IAccessibility2 Implementation 2009
+						}
+						else if( pAnchor.GetAnchorId() == FLY_AT_PARA )
+						{
+							if( ((nHere > nStartIndex) || pStart->nContent.GetIndex() ==0 )
+								&& (nHere < nEndIndex ) )
+								return sal_True;
+						}
+						break;
+					}
+					// else: this PaM doesn't point to this paragraph
+				}
+				// else: this PaM is collapsed and doesn't select anything
+
+				// next PaM in ring
+				pCrsr = static_cast<SwPaM*>( pCrsr->GetNext() );
+			}
+			while( pCrsr != pRingStart );
+		}
+	}
+	return sal_False;
+}
+
+SwFlyFrm* SwAccessibleFrameBase::getFlyFrm() const
+{
+	SwFlyFrm* pFlyFrm = NULL;
+
+	const SwFrm* pFrm = GetFrm();
+	DBG_ASSERT( pFrm != NULL, "frame expected" );
+	if( pFrm->IsFlyFrm() )
+	{
+		pFlyFrm = static_cast<SwFlyFrm*>( const_cast<SwFrm*>( pFrm ) );
+	}
+
+	return pFlyFrm;
+}
+
+sal_Bool SwAccessibleFrameBase::SetSelectedState( sal_Bool )
+{
+	sal_Bool bParaSeleted = GetSelectedState() || IsSelected();
+
+	if(bIsSeletedInDoc != bParaSeleted)
+	{
+		bIsSeletedInDoc = bParaSeleted;
+		FireStateChangedEvent( AccessibleStateType::SELECTED, bParaSeleted );
+		return sal_True;
+	}
+	return sal_False;
+}
+//-----IAccessibility2 Implementation 2009

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accframebase.hxx Wed Nov 20 00:49:46 2013
@@ -23,6 +23,12 @@
 #ifndef _ACCFRAMEBASE_HXX
 #define _ACCFRAMEBASE_HXX
 
+//IAccessibility2 Implementation 2009-----
+#ifndef _PAM_HXX
+#include <pam.hxx>
+#endif
+//-----IAccessibility2 Implementation 2009
+
 #include <acccontext.hxx>
 
 #include <calbck.hxx>
@@ -42,6 +48,11 @@ protected:
 	// This drived class additionaly sets SELECTABLE(1), SELECTED(+),
 	// FOCUSABLE(1) and FOCUSED(+)
 	virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet );
+	//IAccessibility2 Implementation 2009-----
+	SwFlyFrm* getFlyFrm() const;
+	sal_Bool GetSelectedState( );
+	SwPaM* GetCrsr();
+	//-----IAccessibility2 Implementation 2009
 
 	virtual void _InvalidateCursorPos();
 	virtual void _InvalidateFocus();
@@ -61,6 +72,8 @@ public:
 
 	// The object is not visible an longer and should be destroyed
 	virtual void Dispose( sal_Bool bRecursive = sal_False );
+	virtual sal_Bool SetSelectedState( sal_Bool bSeleted );
+	//-----IAccessibility2 Implementation 2009
 };
 
 

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.cxx Wed Nov 20 00:49:46 2013
@@ -40,6 +40,10 @@
 #include <fmtanchr.hxx>
 #include <dcontact.hxx>
 
+//IAccessibility2 Implementation 2009-----
+#include <pam.hxx>
+//-----IAccessibility2 Implementation 2009
+
 #include <vcl/window.hxx>
 
 namespace css = ::com::sun::star;
@@ -174,6 +178,25 @@ bool SwAccessibleChild::IsBoundAsChar() 
     return bRet;
 }
 
+//IAccessibility2 Implementation 2009-----
+sal_uInt32 SwAccessibleChild::GetAnchorPosition() const
+{
+	if( mpDrawObj )
+	{
+            const SwFrmFmt *pFrmFmt = ::FindFrmFmt( mpDrawObj );
+            if ( pFrmFmt )
+            {
+		const SwPosition *pPos = pFrmFmt->GetAnchor().GetCntntAnchor();
+                if ( pPos )
+                {
+		    return pPos->nContent.GetIndex();
+                }
+            }
+	}
+	return 0;
+}
+//-----IAccessibility2 Implementation 2009
+
 SwAccessibleChild::SwAccessibleChild( const SwAccessibleChild& r )
     : mpFrm( r.mpFrm )
     , mpDrawObj( r.mpDrawObj )

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobj.hxx Wed Nov 20 00:49:46 2013
@@ -63,6 +63,10 @@ class SwAccessibleChild
 
         bool IsAccessible( sal_Bool bPagePreview ) const;
         bool IsBoundAsChar() const;
+        
+		//IAccessibility2 Implementation 2009-----
+		sal_uInt32 GetAnchorPosition() const; 
+		//-----IAccessibility2 Implementation 2009
 
         bool IsVisibleChildrenOnly() const;
         SwRect GetBox( const SwAccessibleMap& rAccMap ) const;

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.cxx Wed Nov 20 00:49:46 2013
@@ -162,3 +162,97 @@ SwAccessibleChildMap::SwAccessibleChildM
            ( rFrm.IsTxtFrm() &&
              rFrm.GetDrawObjs() );
 }
+
+/* MT: The two insert methods had been introduced in the IA2 CWS (OOO310m11), but meanwhile we also have some in DEV300m80 (above)
+       Not sure if they have something which needs to be update in above methods.
+       Also, since there is no SwFrmOrObjMap CTOR anymore, the updated code in DEV300 might need some of the changes flagged with //IAccessibility2 Implementation 2009-----
+
+//IAccessibility2 Implementation 2009-----
+::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( 
+		sal_uInt32 nOrd,  Point nPos, const SwFrmOrObj& rLower )
+{
+	SwFrmOrObjMapKey aKey( SwFrmOrObjMapKey::TEXT, nOrd, nPos );
+	value_type aEntry( aKey, rLower );
+	return _SwFrmOrObjMap::insert( aEntry );
+}
+
+::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( 
+		const SdrObject *pObj, const SwFrmOrObj& rLower, const SwDoc *pDoc , Point nPos)
+{
+	if( !bLayerIdsValid )
+	{
+		nHellId = pDoc->GetHellId();
+		nControlsId = pDoc->GetControlsId();
+		bLayerIdsValid = sal_True;
+	}
+
+	SdrLayerID nLayer = pObj->GetLayer();
+	SwFrmOrObjMapKey::LayerId eLayerId = (nHellId == nLayer)
+					? SwFrmOrObjMapKey::HELL	
+					: ((nControlsId == nLayer) ? SwFrmOrObjMapKey::CONTROLS
+											   : SwFrmOrObjMapKey::HEAVEN);
+	SwFrmOrObjMapKey aKey( eLayerId, pObj->GetOrdNum(), nPos );
+	value_type aEntry( aKey, rLower );
+	return _SwFrmOrObjMap::insert( aEntry );
+}
+//-----IAccessibility2 Implementation 2009
+
+SwFrmOrObjMap::SwFrmOrObjMap(
+		const SwRect& rVisArea, const SwFrm *pFrm ) :
+	bLayerIdsValid( sal_False )
+{
+	SwFrmOrObj aFrm( pFrm );
+	sal_Bool bVisibleOnly = aFrm.IsVisibleChildrenOnly();
+
+	sal_uInt32 nPos = 0;
+	SwFrmOrObj aLower( pFrm->GetLower() );
+	while( aLower.GetSwFrm() )
+	{
+		//IAccessibility2 Implementation 2009-----
+		if( !bVisibleOnly || aLower.GetBox().IsOver( rVisArea ) )
+			insert( nPos++, aLower.GetBounds().Pos(), aLower );
+		//-----IAccessibility2 Implementation 2009
+		aLower = aLower.GetSwFrm()->GetNext();
+	}
+
+	if( pFrm->IsPageFrm() )
+	{
+		ASSERT( bVisibleOnly, "page frame within tab frame???" );
+		const SwPageFrm *pPgFrm =
+			static_cast< const SwPageFrm * >( pFrm );
+        const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs();
+		if( pObjs )
+		{
+			const SwDoc *pDoc = pPgFrm->GetFmt()->GetDoc();
+			for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
+			{
+                aLower = (*pObjs)[i]->GetDrawObj();
+				//IAccessibility2 Implementation 2009-----
+				if( aLower.GetBox().IsOver( rVisArea ) )
+					insert( aLower.GetSdrObject(), aLower, pDoc , aLower.GetBounds().Pos() ); 
+				//-----IAccessibility2 Implementation 2009
+			}
+		}
+	}
+	else if( pFrm->IsTxtFrm() )
+	{
+		const SwDoc *pDoc = static_cast< const SwTxtFrm * >( pFrm )->GetNode()
+																   ->GetDoc();
+        const SwSortedObjs *pObjs = pFrm->GetDrawObjs();
+		if( pObjs )
+		{
+			for( sal_uInt16 i=0; i<pObjs->Count(); i++ )
+			{
+                aLower = (*pObjs)[i]->GetDrawObj();
+				//IAccessibility2 Implementation 2009-----
+				if( aLower.IsBoundAsChar() &&
+					(!bVisibleOnly || aLower.GetBox().IsOver( rVisArea )) )
+					insert( aLower.GetSdrObject(), aLower, pDoc , Point(aLower.GetAnchorPosition(),0) );
+				//-----IAccessibility2 Implementation 2009
+			}
+		}
+	}
+}
+
+*/ 
+

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accfrmobjmap.hxx Wed Nov 20 00:49:46 2013
@@ -26,6 +26,7 @@
 #include <accfrmobj.hxx>
 
 #include <svx/svdtypes.hxx>
+#include <tools/gen.hxx>
 
 #include <map>
 
@@ -43,25 +44,58 @@ public:
     inline SwAccessibleChildMapKey()
         : eLayerId( INVALID )
         , nOrdNum( 0 )
+        , nPosNum( 0, 0 )
     {}
 
     inline SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd )
         : eLayerId( eId )
         , nOrdNum( nOrd )
+        , nPosNum( 0, 0 )
     {}
 
+//IAccessibility2 Implementation 2009-----
+    inline SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd, Point nPos )
+        : eLayerId( eId )
+        , nOrdNum( nOrd )
+        , nPosNum( nPos )
+    {}
+//-----IAccessibility2 Implementation 2009    
+
     inline bool operator()( const SwAccessibleChildMapKey& r1,
                             const SwAccessibleChildMapKey& r2 ) const
     {
-        return (r1.eLayerId == r2.eLayerId)
-               ? (r1.nOrdNum < r2.nOrdNum)
-               : (r1.eLayerId < r2.eLayerId);
+//IAccessibility2 Implementation 2009-----
+//        return (r1.eLayerId == r2.eLayerId)
+//               ? (r1.nOrdNum < r2.nOrdNum)
+//               : (r1.eLayerId < r2.eLayerId);
+	return (r1.eLayerId == r2.eLayerId) ? 
+		   ( (r1.nPosNum == r2.nPosNum) ?(r1.nOrdNum < r2.nOrdNum) : 
+		   (r1.nPosNum.getY() == r2.nPosNum.getY()? r1.nPosNum.getX() < r2.nPosNum.getX() : 
+		   	r1.nPosNum.getY() < r2.nPosNum.getY()) ) :
+		   (r1.eLayerId < r2.eLayerId);
+//-----IAccessibility2 Implementation 2009    
     }
+    
+    /* MT: Need to get this position parameter stuff in dev300 somehow...
+	//IAccessibility2 Implementation 2009-----
+	//This methods are used to insert an object to the map, adding a position parameter.
+	::std::pair< iterator, bool > insert( sal_uInt32 nOrd, Point nPos, 
+										  const SwFrmOrObj& rLower );	
+	::std::pair< iterator, bool > insert( const SdrObject *pObj,
+								   	 	  const SwFrmOrObj& rLower,
+									   	  const SwDoc *pDoc,
+									   	  Point nPos);	
+	//-----IAccessibility2 Implementation 2009    
+	*/
 
 private:
 
     LayerId eLayerId;
     sal_uInt32 nOrdNum;
+    
+	//IAccessibility2 Implementation 2009-----
+	Point nPosNum; 
+	//-----IAccessibility2 Implementation 2009
 
 };
 

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.cxx Wed Nov 20 00:49:46 2013
@@ -33,6 +33,11 @@
 #include "accgraphic.hxx"
 
 using namespace ::com::sun::star;
+//IAccessibility2 Implementation 2009-----
+#ifndef _FMTURL_HXX //autogen
+#include <fmturl.hxx>
+#endif
+//-----IAccessibility2 Implementation 2009
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::accessibility;
@@ -91,3 +96,15 @@ Sequence< sal_Int8 > SAL_CALL SwAccessib
     }
     return aId;
 }
+//IAccessibility2 Implementation 2009-----
+//	Return this object's role.
+sal_Int16 SAL_CALL SwAccessibleGraphic::getAccessibleRole (void)
+        throw (::com::sun::star::uno::RuntimeException)
+{
+		SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() );
+
+		if(aURL.GetMap() )
+			return AccessibleRole::IMAGE_MAP ;
+		return AccessibleRole::GRAPHIC ;
+}
+//-----IAccessibility2 Implementation 2009

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accgraphic.hxx Wed Nov 20 00:49:46 2013
@@ -59,6 +59,10 @@ public:
 
 	//=====  XTypeProvider  ====================================================
     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
+	//IAccessibility2 Implementation 2009-----
+	///	Return this object's role.
+	virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException);
+	//-----IAccessibility2 Implementation 2009
 };
 
 

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.cxx Wed Nov 20 00:49:46 2013
@@ -139,3 +139,20 @@ Sequence< sal_Int8 > SAL_CALL SwAccessib
     }
     return aId;
 }
+
+//IAccessibility2 Implementation 2009-----
+sal_Int32 SAL_CALL SwAccessibleHeaderFooter::getBackground() 
+		throw (::com::sun::star::uno::RuntimeException)
+{
+	Reference< XAccessible > xParent =  getAccessibleParent();
+	if (xParent.is())
+	{
+		Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY);
+		if(xAccContext.is())
+		{
+			return xAccContext->getBackground();
+		}
+	}
+	return SwAccessibleContext::getBackground();
+}
+//-----IAccessibility2 Implementation 2009

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.hxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.hxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accheaderfooter.hxx Wed Nov 20 00:49:46 2013
@@ -74,6 +74,11 @@ public:
 
 	//=====  XTypeProvider  ====================================================
     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
+	//IAccessibility2 Implementation 2009-----
+	//=====  XAccessibleComponent  ============================================
+	sal_Int32 SAL_CALL getBackground() 
+		throw (::com::sun::star::uno::RuntimeException);
+	//-----IAccessibility2 Implementation 2009
 };
 
 

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/acchyperlink.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/acchyperlink.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/acchyperlink.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/acchyperlink.cxx Wed Nov 20 00:49:46 2013
@@ -32,9 +32,23 @@
 #include <accpara.hxx>
 #include <acchyperlink.hxx>
 
+//IAccessibility2 Implementation 2009-----
+#include <comphelper/processfactory.hxx>
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XLINKTARGETSUPPLIER_HPP_
+#include <com/sun/star/document/XLinkTargetSupplier.hpp>
+#endif
+//-----IAccessibility2 Implementation 2009
+
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
 using ::rtl::OUString;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
 
 SwAccessibleHyperlink::SwAccessibleHyperlink( sal_uInt16 nHPos,
 	SwAccessibleParagraph *p, sal_Int32 nStt, sal_Int32 nEnd ) :
@@ -78,8 +92,12 @@ sal_Bool SAL_CALL SwAccessibleHyperlink:
 
 	sal_Bool bRet = sal_False;
 
+	//IAccessibility2 Implementation 2009-----
+	if(nIndex != 0)
+		throw new IndexOutOfBoundsException;
 	const SwTxtAttr *pTxtAttr = GetTxtAttr();
-	if( pTxtAttr && 0 == nIndex )
+	if( pTxtAttr /*&& 0 == nIndex*/ ) 
+	//-----IAccessibility2 Implementation 2009
 	{
 		const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
 		if( rINetFmt.GetValue().Len() )
@@ -111,23 +129,28 @@ OUString SAL_CALL SwAccessibleHyperlink:
 {
 	OUString sDesc;
 
+	//IAccessibility2 Implementation 2009-----
+	if(nIndex != 0)
+		throw new IndexOutOfBoundsException;
 	const SwTxtAttr *pTxtAttr = GetTxtAttr();
-	if( pTxtAttr && 0 == nIndex )
+	if( pTxtAttr /*&& 0 == nIndex*/ ) 
 	{
 		const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
 		sDesc = OUString( rINetFmt.GetValue() );
 	}
-
+	//-----IAccessibility2 Implementation 2009
 	return sDesc;
 }
 
 uno::Reference< XAccessibleKeyBinding > SAL_CALL
-	SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex ) 
+	SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 ) 
 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
 {
 	uno::Reference< XAccessibleKeyBinding > xKeyBinding;
 
-	if( isValid() && 0==nIndex )
+	//IAccessibility2 Implementation 2009-----
+	if( isValid() /*&& 0 == nIndex*/ ) 
+	//-----IAccessibility2 Implementation 2009
 	{
 		::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
 		   	new ::comphelper::OAccessibleKeyBindingHelper();
@@ -146,17 +169,40 @@ uno::Reference< XAccessibleKeyBinding > 
 
 // XAccessibleHyperlink
 uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionAnchor(
-        sal_Int32 /*nIndex*/ ) 
+        sal_Int32 nIndex) 
 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
 {
-	return uno::Any();
+	uno::Any aRet;
+	//IAccessibility2 Implementation 2009-----
+	if(nIndex != 0)
+		throw new IndexOutOfBoundsException;
+	//End Added.	
+	::rtl::OUString text = OUString( xPara->GetString() );
+	::rtl::OUString retText =  text.copy(nStartIdx, nEndIdx - nStartIdx);
+	aRet <<= retText;
+	//-----IAccessibility2 Implementation 2009
+	return aRet;
 }
 
 uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionObject( 
-            sal_Int32 /*nIndex*/ ) 
+            sal_Int32 nIndex ) 
 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
 {
-	return uno::Any();
+	//IAccessibility2 Implementation 2009-----
+	if(nIndex != 0)
+		throw new IndexOutOfBoundsException;
+	//End Added.
+	const SwTxtAttr *pTxtAttr = GetTxtAttr();
+	::rtl::OUString retText;
+	if( pTxtAttr /*&& 0 == nIndex*/ ) 
+	{
+		const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
+		retText = OUString( rINetFmt.GetValue() );
+	}
+	uno::Any aRet;
+	aRet <<= retText;
+	return aRet;
+	//-----IAccessibility2 Implementation 2009
 }
 
 sal_Int32 SAL_CALL SwAccessibleHyperlink::getStartIndex() 
@@ -175,7 +221,57 @@ sal_Bool SAL_CALL SwAccessibleHyperlink:
 		throw (uno::RuntimeException)
 {
 	vos::OGuard aGuard(Application::GetSolarMutex());
-	return xPara.isValid();
+	//IAccessibility2 Implementation 2009-----
+	//	return xPara.isValid();
+	if (xPara.isValid())
+	{
+		const SwTxtAttr *pTxtAttr = GetTxtAttr();
+		::rtl::OUString sText;
+		if( pTxtAttr ) 
+		{
+			const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
+			sText = OUString( rINetFmt.GetValue() );
+			::rtl::OUString sToken = ::rtl::OUString::createFromAscii("#");
+			sal_Int32 nPos = sText.indexOf(sToken);
+			if (nPos==0)//document link
+			{
+				uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+				if( ! xFactory.is() )
+					return sal_False;
+				uno::Reference< com::sun::star::frame::XDesktop > xDesktop( xFactory->createInstance( OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
+					uno::UNO_QUERY );
+				if( !xDesktop.is() )
+					return sal_False;	
+				uno::Reference< lang::XComponent > xComp;
+				xComp = xDesktop->getCurrentComponent();
+				if( !xComp.is() )
+					return sal_False;	
+				uno::Reference< com::sun::star::document::XLinkTargetSupplier >  xLTS(xComp, uno::UNO_QUERY);
+				if ( !xLTS.is())
+					return sal_False;
+			
+				uno::Reference< ::com::sun::star::container::XNameAccess > xLinks = xLTS->getLinks();
+				uno::Reference< ::com::sun::star::container::XNameAccess > xSubLinks;
+				const uno::Sequence< OUString > aNames( xLinks->getElementNames() );
+				const sal_uLong nLinks = aNames.getLength();
+				const OUString* pNames = aNames.getConstArray();
+				
+				for( sal_uLong i = 0; i < nLinks; i++ )
+				{
+					uno::Any aAny;
+					OUString aLink( *pNames++ );
+					aAny = xLinks->getByName( aLink );
+					aAny >>= xSubLinks;
+					if (xSubLinks->hasByName(sText.copy(1)) )
+						return sal_True;
+				}
+			}
+			else//internet
+				return sal_True;
+		}
+	}//xpara valid
+	return sal_False;
+	//-----IAccessibility2 Implementation 2009
 }
 
 void SwAccessibleHyperlink::Invalidate()

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accmap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accmap.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accmap.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accmap.cxx Wed Nov 20 00:49:46 2013
@@ -34,6 +34,7 @@
 
 #include <map>
 #include <list>
+#include <vector>
 #include <accmap.hxx>
 #include <acccontext.hxx>
 #include <accdoc.hxx>
@@ -60,11 +61,26 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <svx/ShapeTypeHandler.hxx>
 #include <vcl/svapp.hxx>
+//IAccessibility2 Implementation 2009-----
+#ifndef _SVX_ACCESSIBILITY_SHAPE_TYPE_HANDLER_HXX
+#include <svx/ShapeTypeHandler.hxx>
+#endif
+#ifndef _SVX_ACCESSIBILITY_SVX_SHAPE_TYPES_HXX
+#include <svx/SvxShapeTypes.hxx>
+#endif
+#ifndef _SVDPAGE_HXX
+#include <svx/svdpage.hxx>
+#endif
 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <cppuhelper/implbase1.hxx>
 #include <pagepreviewlayout.hxx>
+#include <dcontact.hxx>
+#include <svx/unoapi.hxx>
+#include <svx/svdmark.hxx>
+#include <doc.hxx>
 #include <pam.hxx>
 #include <ndtxt.hxx>
 #include <dflyobj.hxx>
@@ -278,7 +294,9 @@ SwAccessibleObjShape_Impl
 		{
 			const SdrObject *pObj = (*aIter).first;
 			uno::Reference < XAccessible > xAcc( (*aIter).second );
-			if( nSelShapes && pFESh->IsObjSelected( *pObj ) )
+			//IAccessibility2 Implementation 2009-----
+			if( nSelShapes && pFESh &&pFESh->IsObjSelected( *pObj ) )
+			//-----IAccessibility2 Implementation 2009
 			{
 				// selected objects are inserted from the back
 				--pSelShape;
@@ -334,20 +352,31 @@ private:
 	SwAccessibleEvent_Impl& operator==( const SwAccessibleEvent_Impl& );
 
 public:
+	//IAccessibility2 Implementation 2009-----
+	const SwFrm* mpParentFrm;	// The object that fires the event
+	sal_Bool IsNoXaccParentFrm() const 
+	{
+		return CHILD_POS_CHANGED == meType && mpParentFrm != 0;
+	}
+	uno::WeakReference < XAccessible > GetxAcc() const { return mxAcc;}
+	//-----IAccessibility2 Implementation 2009
+public:
     SwAccessibleEvent_Impl( EventType eT,
                             SwAccessibleContext *pA,
                             const SwAccessibleChild& rFrmOrObj )
         : mxAcc( pA ),
           maFrmOrObj( rFrmOrObj ),
           meType( eT ),
-          mnStates( 0 )
+          mnStates( 0 ),
+          mpParentFrm( 0 )
 	{}
 
     SwAccessibleEvent_Impl( EventType eT,
                             const SwAccessibleChild& rFrmOrObj )
         : maFrmOrObj( rFrmOrObj ),
           meType( eT ),
-          mnStates( 0 )
+          mnStates( 0 ),
+          mpParentFrm( 0 )
 	{
 		ASSERT( SwAccessibleEvent_Impl::DISPOSE == meType,
 				"wrong event constructor, DISPOSE only" );
@@ -355,7 +384,8 @@ public:
 
     SwAccessibleEvent_Impl( EventType eT )
         : meType( eT ),
-          mnStates( 0 )
+          mnStates( 0 ),
+          mpParentFrm( 0 )
 	{
         ASSERT( SwAccessibleEvent_Impl::SHAPE_SELECTION == meType,
 				"wrong event constructor, SHAPE_SELECTION only" );
@@ -369,7 +399,8 @@ public:
           mxAcc( pA ),
           maFrmOrObj( rFrmOrObj ),
           meType( eT ),
-          mnStates( 0 )
+          mnStates( 0 ),
+          mpParentFrm( 0 )
 	{
 		ASSERT( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType ||
 				SwAccessibleEvent_Impl::POS_CHANGED == meType,
@@ -384,12 +415,28 @@ public:
         : mxAcc( pA ),
           maFrmOrObj( rFrmOrObj ),
           meType( eT ),
-          mnStates( _nStates )
+          mnStates( _nStates ),
+          mpParentFrm( 0 )
 	{
 		ASSERT( SwAccessibleEvent_Impl::CARET_OR_STATES == meType,
 				"wrong event constructor, CARET_OR_STATES only" );
 	}
 
+	//IAccessibility2 Implementation 2009-----
+	SwAccessibleEvent_Impl( EventType eT, 
+                                const SwFrm *pParentFrm,
+				const SwAccessibleChild& rFrmOrObj, 
+                                const SwRect& rR ) :
+		maOldBox( rR ),
+                maFrmOrObj( rFrmOrObj ),
+                meType( eT ),
+		mnStates( 0 ),
+                mpParentFrm( pParentFrm )
+	{
+		OSL_ENSURE( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType,
+			"wrong event constructor, CHILD_POS_CHANGED only" );
+	}
+	//-----IAccessibility2 Implementation 2009
     // <SetType(..)> only used in method <SwAccessibleMap::AppendEvent(..)>
     inline void SetType( EventType eT )
     {
@@ -493,8 +540,47 @@ public:
     {
         return mbFiring;
     }
+	//IAccessibility2 Implementation 2009-----
+	struct XAccisNULL
+	{
+		bool operator()(const SwAccessibleEvent_Impl& e)
+		{
+			return e.IsNoXaccParentFrm();
+		}
+	};
+	void MoveInvalidXAccToEnd();
+	//-----IAccessibility2 Implementation 2009
 };
 
+//IAccessibility2 Implementation 2009-----
+void SwAccessibleEventList_Impl::MoveInvalidXAccToEnd()
+{
+	int nSize = size();
+	if (nSize < 2 )
+	{
+		return;
+	}
+	SwAccessibleEventList_Impl lstEvent;
+	iterator li = begin();
+	for ( ;li != end();)
+	{
+		SwAccessibleEvent_Impl e = *li;
+		if (e.IsNoXaccParentFrm())
+		{
+			iterator liNext = li;
+			++liNext;
+			erase(li);
+			li = liNext;
+			lstEvent.insert(lstEvent.end(),e);
+		}
+		else
+			++li;
+	}
+	OSL_ENSURE(size() + lstEvent.size() == nSize ,"");
+	insert(end(),lstEvent.begin(),lstEvent.end());
+	OSL_ENSURE(size() == nSize ,"");
+}
+//-----IAccessibility2 Implementation 2009
 //------------------------------------------------------------------------------
 // The shape list is filled if an accessible shape is destroyed. It
 // simply keeps a reference to the accessible shape's XShape. These
@@ -825,6 +911,25 @@ static sal_Bool AreInSameTable( const un
 void SwAccessibleMap::FireEvent( const SwAccessibleEvent_Impl& rEvent )
 {
 	::vos::ORef < SwAccessibleContext > xAccImpl( rEvent.GetContext() );
+	//IAccessibility2 Implementation 2009-----
+	if (!xAccImpl.isValid() && rEvent.mpParentFrm != 0 )
+	{
+		SwAccessibleContextMap_Impl::iterator aIter =
+			mpFrmMap->find( rEvent.mpParentFrm );
+		if( aIter != mpFrmMap->end() )
+		{
+			uno::Reference < XAccessible > xAcc( (*aIter).second );
+			if (xAcc.is())
+			{
+				uno::Reference < XAccessibleContext >  xContext(xAcc,uno::UNO_QUERY);
+				if (xContext.is() && xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
+				{
+					xAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
+				}
+			}			
+		}
+	}
+	//-----IAccessibility2 Implementation 2009
 	if( SwAccessibleEvent_Impl::SHAPE_SELECTION == rEvent.GetType() )
 	{
 		DoInvalidateShapeSelection();
@@ -1042,8 +1147,324 @@ void SwAccessibleMap::InvalidateShapeSel
 		DoInvalidateShapeSelection();
 	}
 }
+//IAccessibility2 Implementation 2009-----
+//This method should implement the following functions:
+//1.find the shape objects and set the selected state.
+//2.find the Swframe objects and set the selected state.
+//3.find the paragraph objects and set the selected state.
+void SwAccessibleMap::InvalidateShapeInParaSelection()
+{
+	SwAccessibleObjShape_Impl *pShapes = 0;
+	SwAccessibleObjShape_Impl *pSelShape = 0;
+	size_t nShapes = 0;
+
+	const ViewShell *pVSh = GetShell();
+	const SwFEShell *pFESh = pVSh->ISA( SwFEShell ) ?
+							static_cast< const SwFEShell * >( pVSh ) : 0;
+	SwPaM* pCrsr = pFESh ? pFESh->GetCrsr( sal_False /* ??? */ ) : NULL;//IAccessibility2 Implementation 2009
+
+	//sal_uInt16 nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
 
-void SwAccessibleMap::DoInvalidateShapeSelection()
+	{
+		vos::OGuard aGuard( maMutex );
+		if( mpShapeMap )
+			pShapes = mpShapeMap->Copy( nShapes, pFESh, &pSelShape );
+	}
+	
+	sal_Bool bIsSelAll =IsDocumentSelAll();
+	
+	if( mpShapeMap )
+	{
+		//Checked for shapes.
+		_SwAccessibleShapeMap_Impl::const_iterator aIter = mpShapeMap->begin();
+		_SwAccessibleShapeMap_Impl::const_iterator aEndIter = mpShapeMap->end();
+		::vos::ORef< SwAccessibleContext > xParentAccImpl;
+
+		if( bIsSelAll)
+		{
+			while( aIter != aEndIter )
+			{
+				uno::Reference < XAccessible > xAcc( (*aIter).second );
+				if( xAcc.is() )
+					(static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED );
+				
+				++aIter;
+			}	
+		}
+		else
+		{
+			while( aIter != aEndIter )
+			{
+				sal_Bool bChanged = sal_False;
+				sal_Bool bMarked = sal_False;
+				SwAccessibleChild pFrm( (*aIter).first );
+				
+				const SwFrmFmt *pFrmFmt = (*aIter).first ? ::FindFrmFmt( (*aIter).first ) : 0;
+				if( !pFrmFmt ) { ++aIter; continue; }
+				const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor();
+				const SwPosition *pPos = pAnchor.GetCntntAnchor();
+				
+				if(pAnchor.GetAnchorId() == FLY_AT_PAGE)
+				{
+					uno::Reference < XAccessible > xAcc( (*aIter).second );
+					if(xAcc.is())
+						(static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED );
+					
+					++aIter; continue;
+				}
+				
+				if( !pPos ) { ++aIter; continue; } 
+				if( pPos->nNode.GetNode().GetTxtNode() )
+				{
+					int pIndex = pPos->nContent.GetIndex();
+					SwPaM* pTmpCrsr = pCrsr;
+					if( pTmpCrsr != NULL )
+					{
+						const SwTxtNode* pNode = pPos->nNode.GetNode().GetTxtNode();
+						sal_uLong nHere = pNode->GetIndex();
+						
+						do
+						{
+							// ignore, if no mark
+							if( pTmpCrsr->HasMark() )
+							{
+								bMarked = sal_True;
+								// check whether nHere is 'inside' pCrsr
+								SwPosition* pStart = pTmpCrsr->Start();
+								sal_uLong nStartIndex = pStart->nNode.GetIndex();
+								SwPosition* pEnd = pTmpCrsr->End();
+								sal_uLong nEndIndex = pEnd->nNode.GetIndex();
+								if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex)  )
+								{
+									if( pAnchor.GetAnchorId() == FLY_AS_CHAR )
+									{
+										if( ( (nHere == nStartIndex) && (pIndex >= pStart->nContent.GetIndex()) || (nHere > nStartIndex) )
+											&&( (nHere == nEndIndex) && (pIndex < pEnd->nContent.GetIndex()) || (nHere < nEndIndex) ) )
+										{
+											uno::Reference < XAccessible > xAcc( (*aIter).second );
+											if( xAcc.is() )
+												bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED );
+										}
+										else
+										{
+											uno::Reference < XAccessible > xAcc( (*aIter).second );
+											if( xAcc.is() )
+												bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED );
+										}
+									}
+									else if( pAnchor.GetAnchorId() == FLY_AT_PARA )
+									{
+										if( ((nHere > nStartIndex) || pStart->nContent.GetIndex() ==0 )
+											&& (nHere < nEndIndex ) )
+										{
+											uno::Reference < XAccessible > xAcc( (*aIter).second );
+											if( xAcc.is() )
+												bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->SetState( AccessibleStateType::SELECTED );
+										}
+										else
+										{
+											uno::Reference < XAccessible > xAcc( (*aIter).second );
+											if(xAcc.is()) 
+												bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED );
+										}
+									}
+								}
+							}
+							// next PaM in ring
+							pTmpCrsr = static_cast<SwPaM*>( pTmpCrsr->GetNext() );
+						}
+						while( pTmpCrsr != pCrsr );
+					}
+					if( !bMarked )
+					{
+						SwAccessibleObjShape_Impl  *pShape = pShapes;
+						size_t nNumShapes = nShapes;
+						while( nNumShapes )
+						{
+							if( pShape < pSelShape && (pShape->first==(*aIter).first) )
+							{
+								uno::Reference < XAccessible > xAcc( (*aIter).second );
+								if(xAcc.is())
+									bChanged = (static_cast < ::accessibility::AccessibleShape* >(xAcc.get()))->ResetState( AccessibleStateType::SELECTED );
+							}
+							--nNumShapes;
+							++pShape;
+						}
+					}
+				}
+				++aIter;
+			}//while( aIter != aEndIter )
+		}//else
+	}
+	
+	//Checked for FlyFrm
+	SwAccessibleContextMap_Impl::iterator aIter = mpFrmMap->begin();
+	while( aIter != mpFrmMap->end() )
+	{
+		const SwFrm *pFrm = (*aIter).first;
+		if(pFrm->IsFlyFrm())
+		{
+			sal_Bool bFrmChanged = sal_False;
+			uno::Reference < XAccessible > xAcc = (*aIter).second;
+			
+			if(xAcc.is())
+			{
+				SwAccessibleFrameBase *pAccFrame = (static_cast< SwAccessibleFrameBase * >(xAcc.get()));
+				bFrmChanged = pAccFrame->SetSelectedState( sal_True );
+				if (bFrmChanged)
+				{
+					const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm * >( pFrm );
+					const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt();
+					if (pFrmFmt)
+					{
+						const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor();
+						if( pAnchor.GetAnchorId() == FLY_AS_CHAR )
+						{
+							uno::Reference< XAccessible > xAccParent = pAccFrame->getAccessibleParent();
+							if (xAccParent.is())
+							{
+								uno::Reference< XAccessibleContext > xAccContext = xAccParent->getAccessibleContext();
+								if(xAccContext.is() && xAccContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
+								{
+									SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xAccContext.get());
+									if(pAccFrame->IsSeletedInDoc())
+									{
+										m_setParaAdd.insert(pAccPara);
+									}
+									else if(m_setParaAdd.count(pAccPara) == 0)
+									{
+										m_setParaRemove.insert(pAccPara);
+									}
+								}
+							}
+						}
+					}
+                }
+			}
+		}
+		++aIter;
+	}
+	typedef std::vector< SwAccessibleContext* > VEC_PARA;
+	VEC_PARA vecAdd;
+	VEC_PARA vecRemove;
+	//Checked for Paras.
+	SwPaM* pTmpCrsr = pCrsr;
+	sal_Bool bMarkChanged = sal_False;
+	SwAccessibleContextMap_Impl mapTemp;
+	if( pTmpCrsr != NULL )
+	{
+		do
+		{
+			if( pTmpCrsr->HasMark() )
+			{
+				SwNodeIndex nStartIndex( pTmpCrsr->Start()->nNode );
+				SwNodeIndex nEndIndex( pTmpCrsr->End()->nNode );
+				while(nStartIndex <= nEndIndex)
+				{
+					SwFrm *pFrm = NULL;
+					if(nStartIndex.GetNode().IsCntntNode())
+					{	
+						SwCntntNode* pCNd = (SwCntntNode*)&(nStartIndex.GetNode());
+						SwClientIter aClientIter( *pCNd );
+						pFrm = (SwFrm*)aClientIter.First( TYPE(SwFrm));
+					}
+					else if( nStartIndex.GetNode().IsTableNode() )
+					{
+						SwTableNode * pTable= (SwTableNode *)&(nStartIndex.GetNode());
+						SwFrmFmt* pFmt = const_cast<SwFrmFmt*>(pTable->GetTable().GetFrmFmt());
+						SwClientIter aClientIter( *pFmt );
+						pFrm = (SwFrm*)aClientIter.First( TYPE(SwFrm));
+					}
+					
+                    if( pFrm && mpFrmMap)
+					{
+						aIter = mpFrmMap->find( pFrm );
+						if( aIter != mpFrmMap->end() )
+						{
+							uno::Reference < XAccessible > xAcc = (*aIter).second;
+							sal_Bool isChanged = sal_False;
+							if( xAcc.is() )
+							{
+								isChanged = (static_cast< SwAccessibleContext * >(xAcc.get()))->SetSelectedState( sal_True );
+							}
+							if(!isChanged)
+							{
+								SwAccessibleContextMap_Impl::iterator aEraseIter = mpSeletedFrmMap->find( pFrm );
+								if(aEraseIter != mpSeletedFrmMap->end())
+									mpSeletedFrmMap->erase(aEraseIter);
+							}
+							else
+							{
+								bMarkChanged = sal_True;
+								vecAdd.push_back(static_cast< SwAccessibleContext * >(xAcc.get()));
+							}
+							
+							mapTemp.insert( SwAccessibleContextMap_Impl::value_type( pFrm, xAcc ) );
+						}
+					}
+					nStartIndex++;
+				}
+			}
+			pTmpCrsr = static_cast<SwPaM*>( pTmpCrsr->GetNext() );
+		}
+		while( pTmpCrsr != pCrsr );
+	}
+	if( !mpSeletedFrmMap )
+		mpSeletedFrmMap = new SwAccessibleContextMap_Impl;
+	if( !mpSeletedFrmMap->empty() )
+	{
+		aIter = mpSeletedFrmMap->begin();
+		while( aIter != mpSeletedFrmMap->end() )
+		{
+			uno::Reference < XAccessible > xAcc = (*aIter).second;
+			if(xAcc.is())
+				(static_cast< SwAccessibleContext * >(xAcc.get()))->SetSelectedState( sal_False );
+			++aIter;
+			vecRemove.push_back(static_cast< SwAccessibleContext * >(xAcc.get()));
+		}
+		bMarkChanged = sal_True;
+		mpSeletedFrmMap->clear();
+	}
+	
+	if( !mapTemp.empty() )
+	{
+		aIter = mapTemp.begin();
+		while( aIter != mapTemp.end() )
+		{
+			mpSeletedFrmMap->insert( SwAccessibleContextMap_Impl::value_type( (*aIter).first, (*aIter).second ) );
+			++aIter;
+		}
+		mapTemp.clear();
+	}
+	if( bMarkChanged && mpFrmMap)
+	{
+		VEC_PARA::iterator vi = vecAdd.begin();
+		for (; vi != vecAdd.end() ; ++vi)
+		{
+			AccessibleEventObject aEvent;
+			aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+			SwAccessibleContext* pAccPara = *vi;
+			if (pAccPara)
+			{
+				pAccPara->FireAccessibleEvent( aEvent );
+			}			
+		}
+		vi = vecRemove.begin();
+		for (; vi != vecRemove.end() ; ++vi)
+		{
+			AccessibleEventObject aEvent;
+			aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
+			SwAccessibleContext* pAccPara = *vi;
+			if (pAccPara)
+			{
+				pAccPara->FireAccessibleEvent( aEvent );
+			}			
+		}
+	}
+}
+
+//Marge with DoInvalidateShapeFocus
+void SwAccessibleMap::DoInvalidateShapeSelection(sal_Bool bInvalidateFocusMode /*=sal_False*/)
 {
 	SwAccessibleObjShape_Impl *pShapes = 0;
 	SwAccessibleObjShape_Impl *pSelShape = 0;
@@ -1053,7 +1474,14 @@ void SwAccessibleMap::DoInvalidateShapeS
 	const SwFEShell *pFESh = pVSh->ISA( SwFEShell ) ?
 							static_cast< const SwFEShell * >( pVSh ) : 0;
 	sal_uInt16 nSelShapes = pFESh ? pFESh->IsObjSelected() : 0;
+	
 
+	//when InvalidateFocus Call this function ,and the current selected shape count is not 1 ,
+	//return 
+	if (bInvalidateFocusMode && nSelShapes != 1)
+	{
+		return;
+	}
 	{
 		vos::OGuard aGuard( maMutex );
 		if( mpShapeMap )
@@ -1062,24 +1490,71 @@ void SwAccessibleMap::DoInvalidateShapeS
 
 	if( pShapes )
 	{
-		::std::list< const SwFrm * > aParents;
+		typedef std::vector< ::vos::ORef < ::accessibility::AccessibleShape >  >  VEC_SHAPE;
+		VEC_SHAPE vecxShapeAdd;
+		VEC_SHAPE vecxShapeRemove;
+		int nCountSelectedShape=0;
+
 		Window *pWin = GetShell()->GetWin();
 		sal_Bool bFocused = pWin && pWin->HasFocus();
 		SwAccessibleObjShape_Impl *pShape = pShapes;
+		int nShapeCount = nShapes;
+		while( nShapeCount )
+		{
+			//if( pShape->second.isValid() )
+			if (pShape->second.isValid() && IsInSameLevel(pShape->first, pFESh))
+				{
+				if( pShape < pSelShape )
+				{
+					if(pShape->second->ResetState( AccessibleStateType::SELECTED ))
+					{
+						vecxShapeRemove.push_back(pShape->second);
+					}
+					pShape->second->ResetState( AccessibleStateType::FOCUSED );
+				}
+			}
+			--nShapeCount;
+			++pShape;
+		}
+
+		VEC_SHAPE::iterator vi =vecxShapeRemove.begin();
+		for (; vi != vecxShapeRemove.end(); ++vi)
+		{
+			::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr());
+			if (pAccShape)
+			{
+				pAccShape->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), uno::Any());
+			}
+		}
+
+		pShape = pShapes;
 		while( nShapes )
 		{
-			if( pShape->second.isValid() )
+			//if( pShape->second.isValid() )
+			if (pShape->second.isValid() && IsInSameLevel(pShape->first, pFESh))
 			{
-				sal_Bool bChanged;
+				// IA2 - why?
+				// sal_Bool bChanged;
 				if( pShape >= pSelShape )
 				{
-					bChanged =
-						pShape->second->SetState( AccessibleStateType::SELECTED );
+					// IA2: first fire focus event
+					// bChanged = pShape->second->SetState( AccessibleStateType::SELECTED );					
+
+					//first fire focus event
 					if( bFocused && 1 == nSelShapes )
 						pShape->second->SetState( AccessibleStateType::FOCUSED );
 					else
 						pShape->second->ResetState( AccessibleStateType::FOCUSED );
+
+					// IA2 CWS:
+					if(pShape->second->SetState( AccessibleStateType::SELECTED ))
+					{
+						vecxShapeAdd.push_back(pShape->second);
+					}
+					++nCountSelectedShape;
 				}
+				/* MT: This still was in DEV300m80, but was removed in IA2 CWS.
+				   Someone needs to check what should happen here, see original diff CWS oo31ia2 vs. OOO310M11
 				else
 				{
 					bChanged =
@@ -1093,47 +1568,97 @@ void SwAccessibleMap::DoInvalidateShapeS
                                                     GetShell()->IsPreView() );
                     aParents.push_back( pParent );
 				}
+				*/
 			}
 
 			--nShapes;
 			++pShape;
 		}
-		if( aParents.size() > 0 )
+
+		const int SELECTION_WITH_NUM =10;
+		if (vecxShapeAdd.size() > SELECTION_WITH_NUM )
 		{
-			::std::list< const SwFrm * >::const_iterator aIter = aParents.begin();
-			::std::list< const SwFrm * >::const_iterator aEndIter = aParents.end();
-			while( aIter != aEndIter )
+			uno::Reference< XAccessible > xDoc = GetDocumentView( );
+			 SwAccessibleContext * pCont = static_cast<SwAccessibleContext *>(xDoc.get());
+			 if (pCont)
+			 {
+				 AccessibleEventObject aEvent;
+				 aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN;
+				 pCont->FireAccessibleEvent(aEvent);
+			 }
+		}
+		else
+		{
+			short nEventID = AccessibleEventId::SELECTION_CHANGED_ADD;
+			if (nCountSelectedShape <= 1 && vecxShapeAdd.size() == 1 )
+			{
+				nEventID = AccessibleEventId::SELECTION_CHANGED;
+			}
+			vi = vecxShapeAdd.begin();
+			for (; vi != vecxShapeAdd.end(); ++vi)
 			{
-				::vos::ORef< SwAccessibleContext > xParentAccImpl;
+				::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr());
+				if (pAccShape)
 				{
-					vos::OGuard aGuard( maMutex );
-					if(  mpFrmMap )
+					pAccShape->CommitChange(nEventID, uno::Any(), uno::Any());
+				}				
+			}
+		}
+
+		vi = vecxShapeAdd.begin();
+		for (; vi != vecxShapeAdd.end(); ++vi)
+		{
+			::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr());
+			if (pAccShape)
+			{
+				SdrObject *pObj = GetSdrObjectFromXShape(pAccShape->GetXShape());
+				SwFrmFmt *pFrmFmt = pObj ? FindFrmFmt( pObj ) : NULL;
+				if (pFrmFmt)
+				{
+					const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor();
+					if( pAnchor.GetAnchorId() == FLY_AS_CHAR )
 					{
-						SwAccessibleContextMap_Impl::const_iterator aMapIter =
-							mpFrmMap->find( *aIter );
-						if( aMapIter != mpFrmMap->end() )
+						uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent();
+						if (xPara.is())
 						{
-							uno::Reference < XAccessible > xAcc( (*aMapIter).second );
-							xParentAccImpl =
-								static_cast< SwAccessibleContext *>( xAcc.get() );
+							uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext();
+							if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
+							{
+								SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get());
+								if (pAccPara)
+								{
+									m_setParaAdd.insert(pAccPara);
+								}
+							}
 						}
 					}
 				}
-				if( xParentAccImpl.isValid() )
+			}
+		}
+		vi = vecxShapeRemove.begin();
+		for (; vi != vecxShapeRemove.end(); ++vi)
+		{
+			::accessibility::AccessibleShape *pAccShape = static_cast< ::accessibility::AccessibleShape * >(vi->getBodyPtr());
+			if (pAccShape)
+			{
+				uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent();
+				uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext();
+				if (xParaContext.is() && xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
 				{
-					AccessibleEventObject aEvent;
-					aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
-					xParentAccImpl->FireAccessibleEvent( aEvent );
+					SwAccessibleParagraph* pAccPara = static_cast< SwAccessibleParagraph *>(xPara.get());
+					if (m_setParaAdd.count(pAccPara) == 0 )
+					{
+						m_setParaRemove.insert(pAccPara);
+					}
 				}
-
-				++aIter;
 			}
-		}
-
+		}		
 		delete[] pShapes;
 	}
 }
 
+//Marge with DoInvalidateShapeSelection
+/*
 void SwAccessibleMap::DoInvalidateShapeFocus()
 {
 	const ViewShell *pVSh = GetShell();
@@ -1177,7 +1702,8 @@ void SwAccessibleMap::DoInvalidateShapeF
 		delete[] pShapes;
 	}
 }
-
+*/
+//-----IAccessibility2 Implementation 2009
 
 SwAccessibleMap::SwAccessibleMap( ViewShell *pSh ) :
 	mpFrmMap( 0  ),
@@ -1193,7 +1719,8 @@ SwAccessibleMap::SwAccessibleMap( ViewSh
 	mnPara( 1 ),
 	mnFootnote( 1 ),
 	mnEndnote( 1 ),
-	mbShapeSelected( sal_False )
+	mbShapeSelected( sal_False ),
+	mpSeletedFrmMap(NULL)//IAccessibility2 Implementation 2009
 {
 	pSh->GetLayout()->AddAccessibleShell();
 }
@@ -1214,10 +1741,28 @@ SwAccessibleMap::~SwAccessibleMap()
 		}
 	}
 
+	//IAccessibility2 Implementation 2009-----
+	if(xAcc.is())
+	{
 	SwAccessibleDocument *pAcc =
 		static_cast< SwAccessibleDocument * >( xAcc.get() );
 	pAcc->Dispose( sal_True );
-
+	}
+	if( mpFrmMap )
+	{
+		SwAccessibleContextMap_Impl::iterator aIter = mpFrmMap->begin();
+		while( aIter != mpFrmMap->end() )
+		{
+			uno::Reference < XAccessible > xTmp = (*aIter).second;
+			if( xTmp.is() )
+			{
+				SwAccessibleContext *pTmp = static_cast< SwAccessibleContext * >( xTmp.get() );
+				pTmp->SetMap(NULL);
+			}
+			++aIter;
+		}
+	}
+	//-----IAccessibility2 Implementation 2009
 	{
 		vos::OGuard aGuard( maMutex );
 #ifdef DBG_UTIL
@@ -1298,6 +1843,7 @@ SwAccessibleMap::~SwAccessibleMap()
 		mpEvents = 0;
 	}
 	mpVSh->GetLayout()->RemoveAccessibleShell();
+	delete mpSeletedFrmMap;//IAccessibility2 Implementation 2009
 }
 
 uno::Reference< XAccessible > SwAccessibleMap::_GetDocumentView(
@@ -1429,7 +1975,7 @@ uno::Reference< XAccessible> SwAccessibl
 						sal_Bool bIsEndnote =
 							SwAccessibleFootnote::IsEndnote( pFtnFrm );
 						pAcc = new SwAccessibleFootnote( this, bIsEndnote,
-									(bIsEndnote ? mnEndnote++ : mnFootnote++),
+									/*(bIsEndnote ? mnEndnote++ : mnFootnote++),*/
 									pFtnFrm );
 					}
 					break;
@@ -1584,6 +2130,10 @@ uno::Reference< XAccessible> SwAccessibl
 					}
 					// TODO: focus!!!
 				}
+				//IAccessibility2 Implementation 2009-----
+				if (xAcc.is())
+					AddGroupContext(pObj, xAcc);
+				//-----IAccessibility2 Implementation 2009
 			}
 		}
 	}
@@ -1594,6 +2144,105 @@ uno::Reference< XAccessible> SwAccessibl
 
 	return xAcc;
 }
+//IAccessibility2 Implementation 2009-----
+sal_Bool SwAccessibleMap::IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh)
+{
+	if (pFESh)
+		return pFESh->IsObjSameLevelWithMarked(pObj);
+	return sal_False;
+}
+void SwAccessibleMap::AddShapeContext(const SdrObject *pObj, uno::Reference < XAccessible > xAccShape)
+{
+	vos::OGuard aGuard( maMutex );
+
+	if( mpShapeMap )
+	{
+		SwAccessibleShapeMap_Impl::value_type aEntry( pObj, xAccShape );
+		mpShapeMap->insert( aEntry );
+	}
+
+}
+
+//Added by yanjun for sym2_6407
+void SwAccessibleMap::RemoveGroupContext(const SdrObject *pParentObj, ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccParent)
+{
+	vos::OGuard aGuard( maMutex );
+	if (mpShapeMap && pParentObj && pParentObj->IsGroupObject() && xAccParent.is())
+	{
+		uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext();
+		if (xContext.is())
+		{
+			for (sal_Int32 i = 0; i < xContext->getAccessibleChildCount(); ++i)
+			{
+				uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i);
+				if (xChild.is())
+				{
+					uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext();
+					if (xChildContext.is())
+					{
+						if (xChildContext->getAccessibleRole() == AccessibleRole::SHAPE)
+						{
+							::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get());
+							uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape();
+							if (xShape.is())
+							{
+								SdrObject* pObj = GetSdrObjectFromXShape(xShape);
+								if (pObj)
+									RemoveContext(pObj);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+}
+//End
+
+
+void SwAccessibleMap::AddGroupContext(const SdrObject *pParentObj, uno::Reference < XAccessible > xAccParent)
+{
+	vos::OGuard aGuard( maMutex );
+	if( mpShapeMap )
+	{
+		//here get all the sub list.
+		if (pParentObj->IsGroupObject())
+		{
+			if (xAccParent.is())
+			{
+				uno::Reference < XAccessibleContext > xContext = xAccParent->getAccessibleContext();
+				if (xContext.is())
+				{
+					sal_Int32 nChildren = xContext->getAccessibleChildCount();
+					for(sal_Int32 i = 0; i<nChildren; i++)
+					{
+						uno::Reference < XAccessible > xChild = xContext->getAccessibleChild(i);
+						if (xChild.is())
+						{
+							uno::Reference < XAccessibleContext > xChildContext = xChild->getAccessibleContext();
+							if (xChildContext.is())
+							{
+								short nRole = xChildContext->getAccessibleRole();
+								if (nRole == AccessibleRole::SHAPE)
+								{
+									::accessibility::AccessibleShape* pAccShape = static_cast < ::accessibility::AccessibleShape* >( xChild.get());
+									uno::Reference < drawing::XShape > xShape = pAccShape->GetXShape();
+									if (xShape.is())
+									{
+										SdrObject* pObj = GetSdrObjectFromXShape(xShape);
+										AddShapeContext(pObj, xChild);
+										AddGroupContext(pObj,xChild);
+									}
+								}
+							}
+						}	
+					}
+				}
+			}
+		}
+	}				
+}
+//-----IAccessibility2 Implementation 2009
 
 ::vos::ORef < ::accessibility::AccessibleShape > SwAccessibleMap::GetContextImpl(
 			const SdrObject *pObj,
@@ -1656,13 +2305,16 @@ void SwAccessibleMap::RemoveContext( con
 			mpShapeMap->find( pObj );
 		if( aIter != mpShapeMap->end() )
 		{
+			//IAccessible2 Implementation 2009 ----
+			uno::Reference < XAccessible > xAcc( (*aIter).second );
 			mpShapeMap->erase( aIter );
-
+			RemoveGroupContext(pObj, xAcc);
 			// The shape selection flag is not cleared, but one might do
 			// so but has to make sure that the removed context is the one
 			// that is selected.
-
-			if( mpShapeMap->empty() )
+			
+			if( mpShapeMap && mpShapeMap->empty() )
+			//---- IAccessible2 Implementation 2009
 			{
 				delete mpShapeMap;
 				mpShapeMap = 0;
@@ -1809,6 +2461,7 @@ void SwAccessibleMap::InvalidatePosOrSiz
 	{
 		::vos::ORef< SwAccessibleContext > xAccImpl;
 		::vos::ORef< SwAccessibleContext > xParentAccImpl;
+		const SwFrm *pParent =NULL; //IAccessibility2 Implementation 2009
 		{
 			vos::OGuard aGuard( maMutex );
 
@@ -1831,7 +2484,7 @@ void SwAccessibleMap::InvalidatePosOrSiz
 				{
 					// Otherwise we look if the parent is accessible.
 					// If not, there is nothing to do.
-					const SwFrm *pParent =
+					pParent = //IAccessibility2 Implementation 2009
 						SwAccessibleFrame::GetParent( aFrmOrObj,
                                                       GetShell()->IsPreView());
 
@@ -1881,7 +2534,54 @@ void SwAccessibleMap::InvalidatePosOrSiz
 														  rOldBox );
 			}
 		}
+		//IAccessibility2 Implementation 2009-----
+		else if(pParent)
+		{
+/*
+For child graphic and it's parent paragraph,if split 2 graphic to 2 paragraph,
+will delete one graphic swfrm and new create 1 graphic swfrm ,
+then the new paragraph and the new graphic SwFrm will add .
+but when add graphic SwFrm ,the accessible of the new Paragraph is not created yet.
+so the new graphic accessible 'parent is NULL,
+so run here: save the parent's SwFrm not the accessible object parent,
+*/		
+			sal_Bool bIsValidFrm = sal_False;
+			sal_Bool bIsTxtParent = sal_False;
+			if (aFrmOrObj.GetSwFrm())
+			{
+				int nType = pFrm->GetType();
+				if ( FRM_FLY == nType )
+				{
+					bIsValidFrm =sal_True;
+				}
+			}
+			else if(pObj)
+			{
+				int nType = pParent->GetType();
+				if (FRM_TXT == nType)
+				{
+					bIsTxtParent =sal_True;
+				}
+			}
+//			sal_Bool bIsVisibleChildrenOnly =aFrmOrObj.IsVisibleChildrenOnly() ;
+//			sal_Bool bIsBoundAsChar =aFrmOrObj.IsBoundAsChar() ;//bIsVisibleChildrenOnly && bIsBoundAsChar && 
+			if((bIsValidFrm || bIsTxtParent) )
+			{
+				if( GetShell()->ActionPend() )
+				{
+					SwAccessibleEvent_Impl aEvent(
+						SwAccessibleEvent_Impl::CHILD_POS_CHANGED,
+						pParent, aFrmOrObj, rOldBox );
+					AppendEvent( aEvent );
+				}
+				else
+				{
+					OSL_ENSURE(false,"");
+				}
+			}
+		}
 	}
+	//-----IAccessibility2 Implementation 2009
 }
 
 void SwAccessibleMap::InvalidateContent( const SwFrm *pFrm )
@@ -2016,6 +2716,29 @@ void SwAccessibleMap::InvalidateCursorPo
 				mpFrmMap->find( aFrmOrObj.GetSwFrm() );
 			if( aIter != mpFrmMap->end() )
 				xAcc = (*aIter).second;
+			//IAccessibility2 Implementation 2009-----
+			else
+			{
+				SwRect rcEmpty;
+				const SwTabFrm* pTabFrm = aFrmOrObj.GetSwFrm()->FindTabFrm();
+				if (pTabFrm)
+				{
+					InvalidatePosOrSize(pTabFrm,0,0,rcEmpty);
+				}
+				else
+				{
+					InvalidatePosOrSize(aFrmOrObj.GetSwFrm(),0,0,rcEmpty);
+				}
+
+
+				aIter =
+					mpFrmMap->find( aFrmOrObj.GetSwFrm() );
+				if( aIter != mpFrmMap->end() )
+				{
+					xAcc = (*aIter).second;
+				}
+			}
+			//-----IAccessibility2 Implementation 2009
 
 			// For cells, some extra thoughts are necessary,
 			// because invalidating the cursor for one cell
@@ -2044,18 +2767,202 @@ void SwAccessibleMap::InvalidateCursorPo
 					xAcc = GetContext( aFrmOrObj.GetSwFrm(), sal_True );
 			}
 		}
+        //IAccessibility2 Implementation 2009-----
+        else if (bShapeSelected)
+        {
+            const SwFEShell *pFESh = pVSh ? static_cast< const SwFEShell * >( pVSh ) : NULL ;
+            if(pFESh)
+            {
+                const SdrMarkList *pMarkList = pFESh->GetMarkList();
+                if (pMarkList != NULL && pMarkList->GetMarkCount() == 1)
+                {
+                    SdrObject *pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
+					::vos::ORef < ::accessibility::AccessibleShape > pAccShapeImpl = GetContextImpl(pObj,NULL,sal_False);
+                    if (!pAccShapeImpl.isValid())
+                    {
+                        while (pObj && pObj->GetUpGroup())
+                        {
+                            pObj = pObj->GetUpGroup();
+                        }
+                        if (pObj != NULL)
+                        {
+                            const SwFrm *pParent = SwAccessibleFrame::GetParent( SwAccessibleChild(pObj), GetShell()->IsPreView() );
+                            if( pParent )
+                            {
+                                ::vos::ORef< SwAccessibleContext > xParentAccImpl = GetContextImpl(pParent,sal_False);
+                                if (!xParentAccImpl.isValid())
+                                {
+                                    const SwTabFrm* pTabFrm = pParent->FindTabFrm();
+                                    if (pTabFrm)
+                                    {   
+                                        //The Table should not add in acc.because the "pParent" is not add to acc .
+                                        uno::Reference< XAccessible>  xAccParentTab = GetContext(pTabFrm,sal_True);//Should Create.
+
+                                        const SwFrm *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pTabFrm), GetShell()->IsPreView() );
+                                        if (pParentRoot)
+                                        {
+                                            ::vos::ORef< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,sal_False);
+                                            if(xParentAccImplRoot.isValid())
+                                            {
+                                                AccessibleEventObject aEvent;
+                                                aEvent.EventId = AccessibleEventId::CHILD;
+                                                aEvent.NewValue <<= xAccParentTab;
+                                                xParentAccImplRoot->FireAccessibleEvent( aEvent );
+                                            }
+                                        }
+
+                                        //Get "pParent" acc again.
+                                        xParentAccImpl = GetContextImpl(pParent,sal_False);
+                                    }
+                                    else
+                                    {   
+                                        //directly create this acc para .
+                                        xParentAccImpl = GetContextImpl(pParent,sal_True);//Should Create.
+
+                                        const SwFrm *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pParent), GetShell()->IsPreView() );
+
+                                        ::vos::ORef< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,sal_False);
+                                        if(xParentAccImplRoot.isValid())
+                                        {
+                                            AccessibleEventObject aEvent;
+                                            aEvent.EventId = AccessibleEventId::CHILD;
+                                            aEvent.NewValue <<= uno::Reference< XAccessible>(xParentAccImpl.getBodyPtr());
+                                            xParentAccImplRoot->FireAccessibleEvent( aEvent );
+                                        }
+                                    }
+                                }
+                                if (xParentAccImpl.isValid())
+                                {
+                                    uno::Reference< XAccessible>  xAccShape = 
+                                        GetContext(pObj,xParentAccImpl.getBodyPtr(),sal_True);
+
+                                    AccessibleEventObject aEvent;
+                                    aEvent.EventId = AccessibleEventId::CHILD;
+                                    aEvent.NewValue <<= xAccShape;
+                                    xParentAccImpl->FireAccessibleEvent( aEvent );
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
 	}
 
+	m_setParaAdd.clear();
+	m_setParaRemove.clear();
 	if( xOldAcc.is() && xOldAcc != xAcc )
 		InvalidateCursorPosition( xOldAcc );
 	if( bOldShapeSelected || bShapeSelected )
 		InvalidateShapeSelection();
 	if( xAcc.is() )
 		InvalidateCursorPosition( xAcc );
+
+	InvalidateShapeInParaSelection();
+
+	SET_PARA::iterator si = m_setParaRemove.begin();
+	for (; si != m_setParaRemove.end() ; ++si)
+	{
+		SwAccessibleParagraph* pAccPara = *si;
+		if(pAccPara && pAccPara->getSelectedAccessibleChildCount() == 0 && pAccPara->getSelectedText().getLength() == 0)
+		{
+			if(pAccPara->SetSelectedState(sal_False))
+			{
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
+				pAccPara->FireAccessibleEvent( aEvent );
+			}
+		}			
+	}
+	si = m_setParaAdd.begin();
+	for (; si != m_setParaAdd.end() ; ++si)
+	{
+		SwAccessibleParagraph* pAccPara = *si;
+		if(pAccPara && pAccPara->SetSelectedState(sal_True))
+		{
+			AccessibleEventObject aEvent;
+			aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+			pAccPara->FireAccessibleEvent( aEvent );
+		}
+	}
+    //-----IAccessibility2 Implementation 2009
+}
+
+//IAccessibility2 Implementation 2009-----
+//Notify the page change event to bridge. 
+void SwAccessibleMap::FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
+{
+	uno::Reference<XAccessible> xAcc = GetDocumentView( );
+    	if ( xAcc.is() )
+    	{
+    		SwAccessibleDocumentBase *pAcc =
+			static_cast< SwAccessibleDocumentBase * >( xAcc.get() );
+			if (pAcc)
+			{
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::PAGE_CHANGED;
+				aEvent.OldValue <<= nOldPage;
+				aEvent.NewValue <<= nNewPage;
+				pAcc->FireAccessibleEvent( aEvent );
+			}
+    	}
+}
+ 
+void SwAccessibleMap::FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection)
+{
+	uno::Reference<XAccessible> xAcc = GetDocumentView( );
+    	if ( xAcc.is() )
+    	{
+    		SwAccessibleDocumentBase *pAcc =
+			static_cast< SwAccessibleDocumentBase * >( xAcc.get() );
+			if (pAcc)
+			{
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::SECTION_CHANGED;
+				aEvent.OldValue <<= nOldSection;
+				aEvent.NewValue <<= nNewSection;
+				pAcc->FireAccessibleEvent( aEvent );
+
+			}
+    	}
+}
+void SwAccessibleMap::FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn)
+{
+	uno::Reference<XAccessible> xAcc = GetDocumentView( );
+    	if ( xAcc.is() )
+    	{
+    		SwAccessibleDocumentBase *pAcc =
+			static_cast< SwAccessibleDocumentBase * >( xAcc.get() );
+		if (pAcc)
+		{
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::COLUMN_CHANGED;
+				aEvent.OldValue <<= nOldColumn;
+				aEvent.NewValue <<= nNewColumn;
+				pAcc->FireAccessibleEvent( aEvent );
+			
+		}
+    	}
 }
+//-----IAccessibility2 Implementation 2009
 
 void SwAccessibleMap::InvalidateFocus()
 {
+	//IAccessibility2 Implementation 2009-----
+	if(GetShell()->IsPreView())
+	{
+		uno::Reference<XAccessible> xAcc = _GetDocumentView( sal_True );
+		if (xAcc.get())
+		{
+			SwAccessiblePreview *pAccPreview = static_cast<SwAccessiblePreview *>(xAcc.get());
+			if (pAccPreview)
+			{
+				pAccPreview->InvalidateFocus();
+				return ;
+			}			
+		}
+	}
+	//-----IAccessibility2 Implementation 2009
 	uno::Reference < XAccessible > xAcc;
 	sal_Bool bShapeSelected;
 	{
@@ -2071,10 +2978,12 @@ void SwAccessibleMap::InvalidateFocus()
 			static_cast< SwAccessibleContext *>( xAcc.get() );
 		pAccImpl->InvalidateFocus();
 	}
-	else if( bShapeSelected  )
+	//IAccessibility2 Implementation 2009-----
+	else
 	{
-		DoInvalidateShapeFocus();
+		DoInvalidateShapeSelection(sal_True);
 	}
+	//-----IAccessibility2 Implementation 2009 
 }
 
 void SwAccessibleMap::SetCursorContext(
@@ -2357,6 +3266,9 @@ void SwAccessibleMap::FireEvents()
 		if( mpEvents )
 		{
 			mpEvents->SetFiring();
+			//IAccessibility2 Implementation 2009-----
+			mpEvents->MoveInvalidXAccToEnd();
+			//-----IAccessibility2 Implementation 2009
 			SwAccessibleEventList_Impl::iterator aIter = mpEvents->begin();
 			while( aIter != mpEvents->end() )
 			{
@@ -2547,6 +3459,92 @@ sal_Bool SwAccessibleMap::ReplaceChild (
 	return sal_True;
 }
 
+//IAccessibility2 Implementation 2009-----
+//Get the accessible control shape from the model object, here model object is with XPropertySet type
+::accessibility::AccessibleControlShape * SwAccessibleMap::GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet* pSet) throw (::com::sun::star::uno::RuntimeException)
+{
+	if( mpShapeMap )
+	{
+		SwAccessibleShapeMap_Impl::const_iterator aIter = mpShapeMap->begin();
+		SwAccessibleShapeMap_Impl::const_iterator aEndIter = mpShapeMap->end();
+		while( aIter != aEndIter)
+		{
+			uno::Reference < XAccessible > xAcc( (*aIter).second );
+			::accessibility::AccessibleShape *pAccShape =
+				static_cast < ::accessibility::AccessibleShape* >( xAcc.get() );
+			if(pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == ::accessibility::DRAWING_CONTROL)
+			{
+				::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
+				if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet)
+					return pCtlAccShape;
+			}
+			++aIter;
+		}
+	}
+	return NULL;
+}
+
+::com::sun::star::uno::Reference< XAccessible >
+    SwAccessibleMap::GetAccessibleCaption (const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape)
+    throw (::com::sun::star::uno::RuntimeException)
+{
+		SdrObject* captionedObject = GetSdrObjectFromXShape(xShape);
+
+		SwDrawContact *pContact = (SwDrawContact*)GetUserCall( captionedObject );
+		ASSERT( RES_DRAWFRMFMT == pContact->GetFmt()->Which(),
+				"fail" );
+		if( !pContact )
+			return 0;
+
+		SwDrawFrmFmt *pCaptionedFmt = (SwDrawFrmFmt *)pContact->GetFmt();
+		if( !pCaptionedFmt )
+			return 0;
+
+		SwFlyFrm* pFrm = NULL;
+		if (pCaptionedFmt->HasCaption())
+		{
+			const SwFrmFmt *pCaptionFrmFmt = pCaptionedFmt->GetCaptionFmt();
+			SwClientIter aIter (*(SwModify*)pCaptionFrmFmt);
+			pFrm = (SwFlyFrm*)aIter.First( TYPE ( SwFlyFrm ));
+		}
+		if (!pFrm)
+			return 0;
+		//SwFrmFmt* pFrm = pCaptionedFmt->GetCaptionFmt();
+		uno::Reference < XAccessible > xAcc( GetContext((SwFrm*)pFrm,sal_True) );
+		//Reference < XAccessibleShape > xAccShape( xAcc, UNO_QUERY );
+		
+		uno::Reference< XAccessibleContext > xAccContext = xAcc->getAccessibleContext();
+		if( xAccContext.is() )
+		{	//get the parent of caption frame, which is paragaph
+			uno::Reference< XAccessible > xAccParent = xAccContext->getAccessibleParent();
+			if(xAccParent.is())
+			{
+				//get the great parent of caption frame which is text frame.
+				uno::Reference< XAccessibleContext > xAccParentContext = xAccParent->getAccessibleContext();
+				uno::Reference< XAccessible > xAccGreatParent = xAccParentContext->getAccessibleParent();
+				if(xAccGreatParent.is())
+				{
+					AccessibleEventObject aEvent;
+					aEvent.EventId = AccessibleEventId::CHILD;
+					aEvent.NewValue <<= xAccParent;
+					( static_cast< SwAccessibleContext * >(xAccGreatParent.get()) )->FireAccessibleEvent( aEvent );
+
+				}
+
+				AccessibleEventObject aEvent;
+				aEvent.EventId = AccessibleEventId::CHILD;
+				aEvent.NewValue <<= xAcc;
+				( static_cast< SwAccessibleContext * >(xAccParent.get()) )->FireAccessibleEvent( aEvent );
+			}
+		}
+		
+		if(xAcc.get())
+			return xAcc;
+		else
+			return NULL;
+
+}
+//-----IAccessibility2 Implementation 2009
 Point SwAccessibleMap::PixelToCore( const Point& rPoint ) const
 {
 	Point aPoint;
@@ -2872,3 +3870,10 @@ const SwRect& SwAccessibleMap::GetVisAre
            : GetShell()->VisArea();
 }
 
+//IAccessibility2 Implementation 2009-----
+sal_Bool SwAccessibleMap::IsDocumentSelAll()
+{
+	return GetShell()->GetDoc()->IsPrepareSelAll();
+}
+//-----IAccessibility2 Implementation 2009
+

Modified: openoffice/branches/capstone2013/main/sw/source/core/access/accnotextframe.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/capstone2013/main/sw/source/core/access/accnotextframe.cxx?rev=1543679&r1=1543678&r2=1543679&view=diff
==============================================================================
--- openoffice/branches/capstone2013/main/sw/source/core/access/accnotextframe.cxx (original)
+++ openoffice/branches/capstone2013/main/sw/source/core/access/accnotextframe.cxx Wed Nov 20 00:49:46 2013
@@ -39,10 +39,20 @@
 #include <hints.hxx>
 // <--
 #include "accnotextframe.hxx"
+//IAccessibility2 Implementation 2009-----
+#include <fmturl.hxx>
+#include <accnotexthyperlink.hxx>
+#include <svtools/imap.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#include <doc.hxx>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
 using ::rtl::OUString;
+using utl::AccessibleRelationSetHelper;
+//-----IAccessibility2 Implementation 2009
 
 const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const
 {
@@ -52,7 +62,13 @@ const SwNoTxtNode *SwAccessibleNoTextFra
 	{
 		const SwCntntFrm *pCntFrm =
 			static_cast<const SwCntntFrm *>( pFlyFrm->Lower() );
-		pNd = pCntFrm->GetNode()->GetNoTxtNode();
+		//IAccessibility2 Implementation 2009-----
+		const SwCntntNode* pSwCntntNode = pCntFrm->GetNode();
+		if(pSwCntntNode != NULL)
+		{
+			pNd = pSwCntntNode->GetNoTxtNode();
+		}
+		//-----IAccessibility2 Implementation 2009
 	}
 
 	return pNd;
@@ -203,6 +219,12 @@ OUString SAL_CALL SwAccessibleNoTextFram
 	vos::OGuard aGuard(Application::GetSolarMutex());
 
 	CHECK_FOR_DEFUNC( XAccessibleContext )
+	//IAccessibility2 Implementation 2009-----
+	// OUString longDesc;	
+	// const SwFlyFrmFmt* pFlyFmt = GetShell()->GetDoc()->FindFlyByName( GetName(), 0);
+	// longDesc = OUString( pFlyFmt->GetLongDescription() );
+	// return  longDesc; MT: Do not return longDesc, which still is empty - why was the line above commented out?
+	//-----IAccessibility2 Implementation 2009
 
     return msDesc;
 }
@@ -224,6 +246,15 @@ uno::Any SAL_CALL SwAccessibleNoTextFram
         aAny <<= xImage;
         return aAny;
     }
+	//IAccessibility2 Implementation 2009-----
+	else if ( aType == ::getCppuType((uno::Reference<XAccessibleHypertext> *)0) )
+    {
+		uno::Reference<XAccessibleHypertext> aAccHypertext = this;
+		uno::Any aAny;
+		aAny <<= aAccHypertext;
+		return aAny;
+    }
+	//-----IAccessibility2 Implementation 2009
     else
         return SwAccessibleContext::queryInterface( aType );
 }
@@ -269,3 +300,137 @@ sal_Int32 SAL_CALL SwAccessibleNoTextFra
 {
     return getSize().Width;
 }
+//IAccessibility2 Implementation 2009-----
+//=====  XAccesibleText  ==================================================
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
+sal_Bool SAL_CALL SwAccessibleNoTextFrame::setCaretPosition( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
+sal_Unicode SAL_CALL SwAccessibleNoTextFrame::getCharacter( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
+::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL SwAccessibleNoTextFrame::getCharacterAttributes( sal_Int32 , const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
+{
+	uno::Sequence<beans::PropertyValue> aValues(0);
+	return aValues;
+}
+::com::sun::star::awt::Rectangle SAL_CALL SwAccessibleNoTextFrame::getCharacterBounds( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
+{
+	return com::sun::star::awt::Rectangle(0, 0, 0, 0 );
+}
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getIndexAtPoint( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException){return 0;}
+::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
+sal_Bool SAL_CALL SwAccessibleNoTextFrame::setSelection( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;}
+::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getText(  ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
+::rtl::OUString SAL_CALL SwAccessibleNoTextFrame::getTextRange( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return OUString();}
+::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextAtIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+	::com::sun::star::accessibility::TextSegment aResult;
+	return aResult;
+}
+::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBeforeIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+	::com::sun::star::accessibility::TextSegment aResult;
+	return aResult;
+}
+::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBehindIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
+{
+	::com::sun::star::accessibility::TextSegment aResult;
+	return aResult;
+}
+
+sal_Bool SAL_CALL SwAccessibleNoTextFrame::copyText( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;}
+
+
+//
+//  XAccessibleHyperText
+//
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkCount()
+throw (uno::RuntimeException)
+{
+	vos::OGuard aGuard(Application::GetSolarMutex());
+
+	CHECK_FOR_DEFUNC( XAccessibleHypertext );
+
+	sal_Int32 nCount = 0;
+	SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() );
+
+	if(aURL.GetMap() || aURL.GetURL().Len())
+		nCount = 1;
+
+	return nCount;
+}
+
+uno::Reference< XAccessibleHyperlink > SAL_CALL 
+	SwAccessibleNoTextFrame::getHyperLink( sal_Int32 nLinkIndex )
+	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+	vos::OGuard aGuard(Application::GetSolarMutex());
+	CHECK_FOR_DEFUNC( XAccessibleHypertext );
+
+	uno::Reference< XAccessibleHyperlink > xRet;
+
+	SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() );
+
+	if( nLinkIndex > 0 )
+		throw lang::IndexOutOfBoundsException();
+
+	if( aURL.GetMap() || aURL.GetURL().Len() )
+	{
+		if ( !alink.is() )
+		{
+			alink = new SwAccessibleNoTextHyperlink( this, GetFrm() );
+		}		
+
+		return alink;
+	}
+
+	return NULL;
+}
+
+sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkIndex( sal_Int32 )
+	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+	vos::OGuard aGuard(Application::GetSolarMutex());
+	CHECK_FOR_DEFUNC( XAccessibleHypertext );
+
+	sal_Int32 nRet = 0;
+	
+	return nRet;
+}
+
+AccessibleRelation SwAccessibleNoTextFrame::makeRelation( sal_Int16 nType, const SwFlyFrm* pFrm )
+{
+	uno::Sequence<uno::Reference<XInterface> > aSequence(1);
+    aSequence[0] = GetMap()->GetContext( pFrm );
+	return AccessibleRelation( nType, aSequence );
+}
+
+
+uno::Reference<XAccessibleRelationSet> SAL_CALL SwAccessibleNoTextFrame::getAccessibleRelationSet( )
+	throw ( uno::RuntimeException )
+{
+	vos::OGuard aGuard(Application::GetSolarMutex());
+	CHECK_FOR_DEFUNC( XAccessibleContext );
+
+    // get the caption frame, and insert label relations into helper
+
+    AccessibleRelationSetHelper* pHelper = new AccessibleRelationSetHelper();
+
+	SwFlyFrm* pFlyFrm = getFlyFrm();
+	DBG_ASSERT( pFlyFrm != NULL, "fly frame expected" );
+	
+	SwFlyFrm* pCaptionFrm = NULL;
+	const SwFrmFmt* pFrm = pFlyFrm ->GetFmt()->GetCaptionFmt();
+	if (pFrm)
+	{
+		SwClientIter aIter (*(SwModify*)pFrm);
+		pCaptionFrm = (SwFlyFrm*)aIter.First( TYPE ( SwFlyFrm ));
+	}
+	if(pCaptionFrm!=NULL)
+	{
+		pHelper->AddRelation( makeRelation( AccessibleRelationType::DESCRIBED_BY, pCaptionFrm ) );
+	}
+	
+	return pHelper;
+}
+//-----IAccessibility2 Implementation 2009