diff options
author | Oliver-Rainer Wittmann <od@openoffice.org> | 2010-02-03 16:26:18 +0100 |
---|---|---|
committer | Oliver-Rainer Wittmann <od@openoffice.org> | 2010-02-03 16:26:18 +0100 |
commit | 8d5a379f239ee595058a5c4b4d7d81041d3722f1 (patch) | |
tree | 67475b2422977f473a006b7e29f69b4879403849 /sw/source | |
parent | 03847281f1a8a9e8cfe56143a4cef9df6b1adf2a (diff) |
sw33a11y01: #i88070# - accessible Writer comments - fixes and part 2
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/access/accframe.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/access/accfrmobj.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/access/accfrmobj.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/access/accmap.cxx | 56 | ||||
-rw-r--r-- | sw/source/core/view/viewimp.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/docvw/PostItMgr.cxx | 20 | ||||
-rw-r--r-- | sw/source/ui/docvw/SidebarWin.cxx | 20 | ||||
-rw-r--r-- | sw/source/ui/docvw/SidebarWinAcc.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/docvw/frmsidebarwincontainer.cxx | 18 | ||||
-rw-r--r-- | sw/source/ui/docvw/frmsidebarwincontainer.hxx | 4 |
10 files changed, 122 insertions, 36 deletions
diff --git a/sw/source/core/access/accframe.hxx b/sw/source/core/access/accframe.hxx index 316932335a91..031948d8813f 100644 --- a/sw/source/core/access/accframe.hxx +++ b/sw/source/core/access/accframe.hxx @@ -114,12 +114,14 @@ protected: public: // Return the SwFrm this context is attached to. - const SwFrm *GetFrm() const { return mpFrm; }; - + const SwFrm* GetFrm() const { return mpFrm; }; static const SwFrm* GetParent( const sw::access::SwAccessibleChild& rFrmOrObj, sal_Bool bInPagePreview ); + sal_Int32 GetChildIndex( SwAccessibleMap& rAccMap, + const sw::access::SwAccessibleChild& rChild ) const; + protected: // Return the bounding box of the frame clipped to the vis area. If @@ -136,8 +138,6 @@ protected: sal_Int32 GetChildCount( SwAccessibleMap& rAccMap ) const; sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap, sal_Int32 nPos ) const; - sal_Int32 GetChildIndex( SwAccessibleMap& rAccMap, - const sw::access::SwAccessibleChild& rChild ) const; sw::access::SwAccessibleChild GetChildAtPixel( const Point& rPos, SwAccessibleMap& rAccMap ) const; void GetChildren( SwAccessibleMap& rAccMap, diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index c71e272602c4..7add8f133a1a 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -85,18 +85,25 @@ SwAccessibleChild::SwAccessibleChild( Window* pWindow ) SwAccessibleChild::SwAccessibleChild( const SwFrm* pFrm, - const SdrObject* pDrawObj ) + const SdrObject* pDrawObj, + Window* pWindow ) { if ( pFrm ) { Init( pFrm ); } - else + else if ( pDrawObj ) { Init( pDrawObj ); } - ASSERT( (!pFrm || pFrm == mpFrm) && (!pDrawObj || pDrawObj == mpDrawObj), - "invalid frame/object combination" ); + else if ( pWindow ) + { + Init( pWindow ); + } + ASSERT( (!pFrm || pFrm == mpFrm) && + (!pDrawObj || pDrawObj == mpDrawObj) && + (!pWindow || pWindow == mpWindow), + "invalid frame/object/window combination" ); } diff --git a/sw/source/core/access/accfrmobj.hxx b/sw/source/core/access/accfrmobj.hxx index 9cdff0be34ec..70c71f259e98 100644 --- a/sw/source/core/access/accfrmobj.hxx +++ b/sw/source/core/access/accfrmobj.hxx @@ -48,7 +48,8 @@ class SwAccessibleChild explicit SwAccessibleChild( const SwFrm* pFrm ); explicit SwAccessibleChild( Window* pWindow ); SwAccessibleChild( const SwFrm* pFrm, - const SdrObject* pDrawObj ); + const SdrObject* pDrawObj, + Window* pWindow ); SwAccessibleChild( const SwAccessibleChild& r ); SwAccessibleChild& operator=( const SwAccessibleChild& r ); diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index d498800ec670..b7f3f76e6922 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -1681,10 +1681,12 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj ) } -void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, +void SwAccessibleMap::Dispose( const SwFrm *pFrm, + const SdrObject *pObj, + Window* pWindow, sal_Bool bRecursive ) { - SwAccessibleChild aFrmOrObj( pFrm, pObj ); + SwAccessibleChild aFrmOrObj( pFrm, pObj, pWindow ); // Indeed, the following assert checks the frame's accessible flag, // because that's the one that is evaluated in the layout. The frame @@ -1693,11 +1695,11 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, ASSERT( !aFrmOrObj.GetSwFrm() || aFrmOrObj.GetSwFrm()->IsAccessibleFrm(), "non accessible frame should be disposed" ); - ::vos::ORef< SwAccessibleContext > xAccImpl; - ::vos::ORef< SwAccessibleContext > xParentAccImpl; - ::vos::ORef< ::accessibility::AccessibleShape > xShapeAccImpl; if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { + ::vos::ORef< SwAccessibleContext > xAccImpl; + ::vos::ORef< SwAccessibleContext > xParentAccImpl; + ::vos::ORef< ::accessibility::AccessibleShape > xShapeAccImpl; // get accessible context for frame { vos::OGuard aGuard( maMutex ); @@ -1808,9 +1810,10 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, const SdrObject *pObj, + Window* pWindow, const SwRect& rOldBox ) { - SwAccessibleChild aFrmOrObj( pFrm, pObj ); + SwAccessibleChild aFrmOrObj( pFrm, pObj, pWindow ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { ::vos::ORef< SwAccessibleContext > xAccImpl; @@ -2238,6 +2241,43 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) } } +sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrm& rParentFrm, + Window& rChild ) const +{ + sal_Int32 nIndex( -1 ); + + SwAccessibleChild aFrmOrObj( &rParentFrm ); + if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) + { + uno::Reference < XAccessible > xAcc; + { + vos::OGuard aGuard( maMutex ); + + if( mpFrmMap ) + { + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); + if( aIter != mpFrmMap->end() ) + { + xAcc = (*aIter).second; + } + } + } + + if( xAcc.is() ) + { + SwAccessibleContext *pAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); + + nIndex = pAccImpl->GetChildIndex( const_cast<SwAccessibleMap&>(*this), + SwAccessibleChild( &rChild ) ); + } + } + + return nIndex; +} + + // OD 15.01.2003 #103492# - complete re-factoring of method due to new page/print // preview functionality. void SwAccessibleMap::UpdatePreview( const std::vector<PrevwPage*>& _rPrevwPages, @@ -2474,7 +2514,7 @@ sal_Bool SwAccessibleMap::ReplaceChild ( // Also get keep parent. uno::Reference < XAccessible > xParent( pCurrentChild->getAccessibleParent() ); pCurrentChild = 0; // well be realease by dispose - Dispose( 0, pObj ); + Dispose( 0, pObj, 0 ); { vos::OGuard aGuard( maMutex ); @@ -2511,7 +2551,7 @@ sal_Bool SwAccessibleMap::ReplaceChild ( } SwRect aEmptyRect; - InvalidatePosOrSize( 0, pObj, aEmptyRect ); + InvalidatePosOrSize( 0, pObj, 0, aEmptyRect ); return sal_True; } diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index 7bb1aabe07c8..e6602adf70c0 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -442,7 +442,7 @@ void SwViewImp::DisposeAccessible( const SwFrm *pFrm, do { if( pTmp->Imp()->IsAccessible() ) - pTmp->Imp()->GetAccessibleMap().Dispose( pFrm, pObj, bRecursive ); + pTmp->Imp()->GetAccessibleMap().Dispose( pFrm, pObj, 0, bRecursive ); pTmp = (ViewShell *)pTmp->GetNext(); } while ( pTmp != pVSh ); } @@ -456,7 +456,7 @@ void SwViewImp::MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj, do { if( pTmp->Imp()->IsAccessible() ) - pTmp->Imp()->GetAccessibleMap().InvalidatePosOrSize( pFrm, pObj, + pTmp->Imp()->GetAccessibleMap().InvalidatePosOrSize( pFrm, pObj, 0, rOldFrm ); pTmp = (ViewShell *)pTmp->GetNext(); } while ( pTmp != pVSh ); diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 936fa8d2368e..9f2c027c31ba 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -38,6 +38,7 @@ #include <SidebarWin.hxx> #include <AnnotationWin.hxx> #include <frmsidebarwincontainer.hxx> +#include <accmap.hxx> #include <SidebarWindowsConsts.hxx> #include <AnchorOverlayObject.hxx> @@ -175,8 +176,6 @@ SwPostItMgr::SwPostItMgr(SwView* pView) SwPostItMgr::~SwPostItMgr() { - delete mpFrmSidebarWinContainer; - if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); // forget about all our Sidebar windows @@ -186,6 +185,9 @@ SwPostItMgr::~SwPostItMgr() for(std::vector<SwPostItPageItem*>::iterator i = mPages.begin(); i!= mPages.end() ; i++) delete (*i); mPages.clear(); + + delete mpFrmSidebarWinContainer; + mpFrmSidebarWinContainer = 0; } void SwPostItMgr::CheckForRemovedPostIts() @@ -2007,7 +2009,12 @@ void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm, mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer(); } - mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); + const bool bInserted = mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); + if ( bInserted && + mpWrtShell->GetAccessibleMap() ) + { + mpWrtShell->GetAccessibleMap()->InvalidatePosOrSize( 0, 0, &rSidebarWin, SwRect() ); + } } void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, @@ -2015,7 +2022,12 @@ void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, { if ( mpFrmSidebarWinContainer != 0 ) { - mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + const bool bRemoved = mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + if ( bRemoved && + mpWrtShell->GetAccessibleMap() ) + { + mpWrtShell->GetAccessibleMap()->Dispose( 0, 0, &rSidebarWin ); + } } } diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx index 683d51325547..b6276669d58a 100644 --- a/sw/source/ui/docvw/SidebarWin.cxx +++ b/sw/source/ui/docvw/SidebarWin.cxx @@ -122,6 +122,7 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, , mbReadonly( false ) , mbIsFollow( false ) , mrSidebarItem( rSidebarItem ) + , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm ) { mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView ); if ( mpShadow ) @@ -136,6 +137,9 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, SwSidebarWin::~SwSidebarWin() { + mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm), + *this ); + if ( mpSidebarTxtControl ) { if ( mpOutlinerView ) @@ -1206,15 +1210,23 @@ bool SwSidebarWin::IsScrollbarVisible() const void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem ) { - const bool bAnchorChanged = mrSidebarItem.maLayoutInfo.mpAnchorFrm != - rSidebarItem.maLayoutInfo.mpAnchorFrm; + const bool bAnchorChanged = mpAnchorFrm != rSidebarItem.maLayoutInfo.mpAnchorFrm; if ( bAnchorChanged ) { - mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm), - *this ); + mrMgr.DisconnectSidebarWinFromFrm( *(mpAnchorFrm), *this ); } mrSidebarItem = rSidebarItem; + mpAnchorFrm = mrSidebarItem.maLayoutInfo.mpAnchorFrm; + + if ( GetWindowPeer() ) + { + SidebarWinAccessible* pAcc = + static_cast<SidebarWinAccessible*>( GetWindowPeer() ); + ASSERT( dynamic_cast<SidebarWinAccessible*>( GetWindowPeer() ), + "<SwSidebarWin::ChangeSidebarItem(..)> - unexpected type of window peer -> crash possible!" ); + pAcc->ChangeSidebarItem( mrSidebarItem ); + } if ( bAnchorChanged ) { diff --git a/sw/source/ui/docvw/SidebarWinAcc.cxx b/sw/source/ui/docvw/SidebarWinAcc.cxx index a484f2068c67..65bf4c792073 100644 --- a/sw/source/ui/docvw/SidebarWinAcc.cxx +++ b/sw/source/ui/docvw/SidebarWinAcc.cxx @@ -87,14 +87,16 @@ class SidebarWinAccessibleContext : public VCLXAccessibleComponent { vos::OGuard aGuard(maMutex); - if ( mpAnchorFrm && + sal_Int32 nIndex( -1 ); + + if ( mpAnchorFrm && GetWindow() && mrViewShell.GetAccessibleMap() ) { - // ODsTODO - + nIndex = mrViewShell.GetAccessibleMap()->GetChildIndex( *mpAnchorFrm, + *GetWindow() ); } - return -1; + return nIndex; } private: diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.cxx b/sw/source/ui/docvw/frmsidebarwincontainer.cxx index 457c11761ee1..b5e406dcf69b 100644 --- a/sw/source/ui/docvw/frmsidebarwincontainer.cxx +++ b/sw/source/ui/docvw/frmsidebarwincontainer.cxx @@ -106,24 +106,31 @@ SwFrmSidebarWinContainer::~SwFrmSidebarWinContainer() delete mpFrmSidebarWinContainer; } -void SwFrmSidebarWinContainer::insert( const SwFrm& rFrm, +bool SwFrmSidebarWinContainer::insert( const SwFrm& rFrm, const SwFmtFld& rFmtFld, SwSidebarWin& rSidebarWin ) { + bool bInserted( false ); + FrmKey aFrmKey( &rFrm ); SidebarWinContainer& rSidebarWinContainer = (*mpFrmSidebarWinContainer)[ aFrmKey ]; SidebarWinKey aSidebarWinKey( *(rFmtFld.GetTxtFld()->GetStart()) ); if ( rSidebarWinContainer.empty() || - rSidebarWinContainer.find( aSidebarWinKey) != rSidebarWinContainer.end() ) + rSidebarWinContainer.find( aSidebarWinKey) == rSidebarWinContainer.end() ) { rSidebarWinContainer[ aSidebarWinKey ] = &rSidebarWin; + bInserted = true; } + + return bInserted; } -void SwFrmSidebarWinContainer::remove( const SwFrm& rFrm, +bool SwFrmSidebarWinContainer::remove( const SwFrm& rFrm, const SwSidebarWin& rSidebarWin ) { + bool bRemoved( false ); + FrmKey aFrmKey( &rFrm ); FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey ); if ( aFrmIter != mpFrmSidebarWinContainer->end() ) @@ -136,10 +143,13 @@ void SwFrmSidebarWinContainer::remove( const SwFrm& rFrm, if ( (*aIter).second == &rSidebarWin ) { rSidebarWinContainer.erase( aIter ); + bRemoved = true; break; } } } + + return bRemoved; } bool SwFrmSidebarWinContainer::empty( const SwFrm& rFrm ) @@ -176,6 +186,8 @@ SwSidebarWin* SwFrmSidebarWinContainer::get( const SwFrm& rFrm, pRet = (*aIter).second; break; } + + --nCounter; } } diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.hxx b/sw/source/ui/docvw/frmsidebarwincontainer.hxx index 6144d955b38b..1583f36a0bb6 100644 --- a/sw/source/ui/docvw/frmsidebarwincontainer.hxx +++ b/sw/source/ui/docvw/frmsidebarwincontainer.hxx @@ -48,11 +48,11 @@ class SwFrmSidebarWinContainer SwFrmSidebarWinContainer(); ~SwFrmSidebarWinContainer(); - void insert( const SwFrm& rFrm, + bool insert( const SwFrm& rFrm, const SwFmtFld& rFmtFld, SwSidebarWin& rSidebarWin ); - void remove( const SwFrm& rFrm, + bool remove( const SwFrm& rFrm, const SwSidebarWin& rSidebarWin ); bool empty( const SwFrm& rFrm ); |