diff options
-rw-r--r-- | sw/inc/accmap.hxx | 44 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/access/acccontext.cxx | 199 | ||||
-rw-r--r-- | sw/source/core/access/acccontext.hxx | 24 | ||||
-rw-r--r-- | sw/source/core/access/accframe.cxx | 115 | ||||
-rw-r--r-- | sw/source/core/access/accframe.hxx | 33 | ||||
-rw-r--r-- | sw/source/core/access/accfrmobj.cxx | 93 | ||||
-rw-r--r-- | sw/source/core/access/accfrmobj.hxx | 34 | ||||
-rw-r--r-- | sw/source/core/access/accmap.cxx | 668 | ||||
-rw-r--r-- | sw/source/core/access/accselectionhelper.cxx | 208 | ||||
-rw-r--r-- | sw/source/core/access/accselectionhelper.hxx | 7 | ||||
-rw-r--r-- | sw/source/core/access/acctable.cxx | 23 | ||||
-rw-r--r-- | sw/source/core/access/acctable.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/access/makefile.mk | 6 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/inc/viewimp.hxx | 41 | ||||
-rw-r--r-- | sw/source/core/layout/fly.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/view/viewimp.cxx | 19 |
18 files changed, 1162 insertions, 410 deletions
diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx index b073522cec10..58b58622814a 100644 --- a/sw/inc/accmap.hxx +++ b/sw/inc/accmap.hxx @@ -2,9 +2,9 @@ * * $RCSfile: accmap.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: mib $ $Date: 2002-05-06 12:26:27 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:22:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,12 +68,18 @@ #ifndef _SAL_TYPES_H_ #include <sal/types.h> #endif +#ifndef _CPPUHELPER_WEAKREF_HXX_ +#include <cppuhelper/weakref.hxx> +#endif #ifndef _VOS_REF_HXX_ #include <vos/ref.hxx> #endif #ifndef _VOS_MUTEX_HXX_ //autogen #include <vos/mutex.hxx> #endif +#ifndef _SVX_ACCESSIBILITY_IACCESSIBLE_VIEW_FORWARDER_HXX +#include <svx/IAccessibleViewForwarder.hxx> +#endif #ifndef _VIEWSH_HXX #include "viewsh.hxx" #endif @@ -85,12 +91,14 @@ class SwAccessibleContext; class SwAccessibleContextMap_Impl; class SwAccessibleEventList_Impl; class SwAccessibleEventMap_Impl; +class SwShapeList_Impl; class SdrObject; namespace accessibility { class AccessibleShape; } class SwAccessibleShapeMap_Impl; struct SwAccessibleEvent_Impl; class SwRect; class ViewShell; +class SwFrmOrObj; // real states for events #define ACC_STATE_EDITABLE 0x01 @@ -105,25 +113,33 @@ class ViewShell; #define ACC_STATE_MASK 0x1F -class SwAccessibleMap +class SwAccessibleMap : public accessibility::IAccessibleViewForwarder { ::vos::OMutex maMutex; ::vos::OMutex maEventMutex; SwAccessibleContextMap_Impl *mpFrmMap; SwAccessibleShapeMap_Impl *mpShapeMap; + SwShapeList_Impl *mpShapes; SwAccessibleEventList_Impl *mpEvents; SwAccessibleEventMap_Impl *mpEventMap; ViewShell *mpVSh; + + ::com::sun::star::uno::WeakReference < ::drafts::com::sun::star::accessibility::XAccessible > mxCursorContext; + sal_Int32 mnPara; sal_Int32 mnFootnote; sal_Int32 mnEndnote; - static void FireEvent( const SwAccessibleEvent_Impl& rEvent ); + sal_Bool mbShapeSelected; + + void FireEvent( const SwAccessibleEvent_Impl& rEvent ); void AppendEvent( const SwAccessibleEvent_Impl& rEvent ); void InvalidateCursorPosition( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible>& rAcc ); + void DoInvalidateShapeSelection(); + void InvalidateShapeSelection(); void _InvalidateRelationSet( const SwFrm* pFrm, sal_Bool bFrom ); @@ -145,23 +161,26 @@ public: ::vos::ORef < ::accessibility::AccessibleShape > GetContextImpl( const SdrObject *pObj, - const SwAccessibleContext *pParentImpl, + SwAccessibleContext *pParentImpl, sal_Bool bCreate = sal_True ); ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible> GetContext( const SdrObject *pObj, - const SwAccessibleContext *pParentImpl, + SwAccessibleContext *pParentImpl, sal_Bool bCreate = sal_True ); ViewShell *GetShell() const { return mpVSh; } const SwRect& GetVisArea() const { return mpVSh->VisArea(); } void RemoveContext( const SwFrm *pFrm ); + void RemoveContext( const SdrObject *pObj ); // Dispose frame and its children if bRecursive is set - void Dispose( const SwFrm *pFrm, sal_Bool bRecursive=sal_False ); + void Dispose( const SwFrm *pFrm, const SdrObject *pObj, + sal_Bool bRecursive=sal_False ); - void InvalidatePosOrSize( const SwFrm *pFrm, const SwRect& rOldFrm ); + void InvalidatePosOrSize( const SwFrm *pFrm, const SdrObject *pObj, + const SwRect& rOldFrm ); void InvalidateContent( const SwFrm *pFrm ); @@ -177,6 +196,15 @@ public: void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow ); void FireEvents(); + + // IAccessibleViewForwarder + + virtual sal_Bool IsValid() const; + virtual Rectangle GetVisibleArea() const; + virtual Point LogicToPixel (const Point& rPoint) const; + virtual Size LogicToPixel (const Size& rSize) const; + virtual Point PixelToLogic (const Point& rPoint) const; + virtual Size PixelToLogic (const Size& rSize) const; }; #endif diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 40d0cde5c497..10ffdd894b49 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fesh.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: ama $ $Date: 2002-04-09 14:17:34 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:22:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -430,6 +430,9 @@ public: USHORT IsObjSelected() const; //Liefert gleich die Anzahl der Objekte, //zaehlt aber nicht die Objekte in Gruppen. +#ifdef ACCESSIBLE_LAYOUT + sal_Bool IsObjSelected( const SdrObject& rObj ) const; +#endif void EndTextEdit(); //Loescht ggf. das Objekt. diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index 7de43e7e3ac1..95676b52a45a 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: acccontext.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: dvo $ $Date: 2002-05-06 14:03:40 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -245,36 +245,36 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, if( rLower.IsAccessible() ) { Action eAction = NONE; - if( pLower ) + if( aBox.IsOver( rNewVisArea ) ) { - if( aBox.IsOver( rNewVisArea ) ) + if( aBox.IsOver( rOldVisArea ) ) { - if( aBox.IsOver( rOldVisArea ) ) - { - eAction = SCROLLED_WITHIN; - } - else - { - if( bVisibleOnly ) - eAction = SCROLLED_IN; - else - eAction = SCROLLED; - } + eAction = SCROLLED_WITHIN; } - else if( aBox.IsOver( rOldVisArea ) ) + else { if( bVisibleOnly ) - eAction = SCROLLED_OUT; + eAction = SCROLLED_IN; else eAction = SCROLLED; } - else if( !bVisibleOnly ) - { - // This wouldn't be required if the SwAccessibleFrame, - // wouldn't know about the vis area. + } + else if( aBox.IsOver( rOldVisArea ) ) + { + if( bVisibleOnly ) + eAction = SCROLLED_OUT; + else eAction = SCROLLED; - } - if( NONE != eAction ) + } + else if( !bVisibleOnly ) + { + // This wouldn't be required if the SwAccessibleFrame, + // wouldn't know about the vis area. + eAction = SCROLLED; + } + if( NONE != eAction ) + { + if( pLower ) { ::vos::ORef< SwAccessibleContext > xAccImpl = GetMap()->GetContextImpl( pLower, SCROLLED_OUT == eAction || @@ -302,10 +302,39 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, ChildrenScrolled( pLower, rOldVisArea ); } } - } - else - { - // TODO: SdrObjects + else + { + ::vos::ORef< accessibility::AccessibleShape > xAccImpl = + GetMap()->GetContextImpl( rLower.GetSdrObject(), + this, + SCROLLED_OUT == eAction || + SCROLLED_IN == eAction ); + if( xAccImpl.isValid() ) + { + switch( eAction ) + { + case SCROLLED: + case SCROLLED_WITHIN: + xAccImpl->ViewForwarderChanged( + accessibility::IAccessibleViewForwarderListener::ChangeType::VISIBLE_AREA, + GetMap() ); + break; + case SCROLLED_IN: + ScrolledInShape( rLower.GetSdrObject(), + xAccImpl.getBodyPtr() ); + break; + case SCROLLED_OUT: + { + xAccImpl->ViewForwarderChanged( + accessibility::IAccessibleViewForwarderListener::ChangeType::VISIBLE_AREA, + GetMap() ); + DisposeShape( rLower.GetSdrObject(), + xAccImpl.getBodyPtr() ); + } + break; + } + } + } } } else if( pLower && (!bVisibleOnly || @@ -444,14 +473,11 @@ void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm, } else { - Reference< XAccessible > xAcc( GetMap()->GetContext( - rLower.GetSdrObject(), - this, sal_False ) ); - if( xAcc.is() ) - { - Reference < XComponent > xComp( xAcc, UNO_QUERY ); - xComp->dispose(); - } + ::vos::ORef< accessibility::AccessibleShape > xAccImpl( + GetMap()->GetContextImpl( rLower.GetSdrObject(), + this, sal_False ) ); + if( xAccImpl.isValid() ) + DisposeShape( rLower.GetSdrObject(), xAccImpl.getBodyPtr() ); } ++aIter; } @@ -1011,6 +1037,33 @@ Sequence< OUString > SAL_CALL SwAccessibleContext::getSupportedServiceNames() THROW_RUNTIME_EXCEPTION( XServiceInfo, "supported services needs to be overloaded" ) } +void SwAccessibleContext::DisposeShape( const SdrObject *pObj, + accessibility::AccessibleShape *pAccImpl ) +{ + ::vos::ORef< accessibility::AccessibleShape > xAccImpl( pAccImpl ); + if( !xAccImpl.isValid() ) + xAccImpl = GetMap()->GetContextImpl( pObj, this, sal_True ); + + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::ACCESSIBLE_CHILD_EVENT; + Reference< XAccessible > xAcc( xAccImpl.getBodyPtr() ); + aEvent.OldValue <<= xAcc; + FireAccessibleEvent( aEvent ); + + GetMap()->RemoveContext( pObj ); + xAccImpl->dispose(); +} + +void SwAccessibleContext::ScrolledInShape( const SdrObject *pObj, + accessibility::AccessibleShape *pAccImpl ) +{ + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::ACCESSIBLE_CHILD_EVENT; + Reference< XAccessible > xAcc( pAccImpl ); + aEvent.NewValue <<= xAcc; + FireAccessibleEvent( aEvent ); +} + void SwAccessibleContext::Dispose( sal_Bool bRecursive ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1067,22 +1120,35 @@ void SwAccessibleContext::Dispose( sal_Bool bRecursive ) bDisposing = sal_False; } -void SwAccessibleContext::DisposeChild( const SwFrm *pFrm, sal_Bool bRecursive ) +void SwAccessibleContext::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, + sal_Bool bRecursive ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwFrmOrObj aFrm( GetFrm() ); - if( IsShowing( pFrm ) || !aFrm.IsVisibleChildrenOnly() ) + SwFrmOrObj aFrmOrObj( GetFrm() ); + if( IsShowing( rChildFrmOrObj ) || !aFrmOrObj.IsVisibleChildrenOnly() ) { // If the object could have existed before, than there is nothing to do, // because no wrapper exists now and therefor no one is interested to // get notified of the movement. - ::vos::ORef< SwAccessibleContext > xAccImpl = - GetMap()->GetContextImpl( pFrm, sal_True ); - xAccImpl->Dispose( bRecursive ); + if( rChildFrmOrObj.GetSwFrm() ) + { + ::vos::ORef< SwAccessibleContext > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(), + sal_True ); + xAccImpl->Dispose( bRecursive ); + } + else + { + ::vos::ORef< accessibility::AccessibleShape > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + this, sal_True ); + DisposeShape( rChildFrmOrObj.GetSdrObject(), + xAccImpl.getBodyPtr() ); + } } - else if( bRecursive ) - DisposeChildren( GetFrm(), bRecursive ); + else if( bRecursive && rChildFrmOrObj.GetSwFrm() ) + DisposeChildren( rChildFrmOrObj.GetSwFrm(), bRecursive ); } void SwAccessibleContext::InvalidatePosOrSize( const SwRect& rOldPos ) @@ -1120,24 +1186,37 @@ void SwAccessibleContext::InvalidatePosOrSize( const SwRect& rOldPos ) } } -void SwAccessibleContext::InvalidateChildPosOrSize( const SwFrm *pFrm, - const SwRect& rOldFrm ) +void SwAccessibleContext::InvalidateChildPosOrSize( + const SwFrmOrObj& rChildFrmOrObj, + const SwRect& rOldFrm ) { vos::OGuard aGuard(Application::GetSolarMutex()); SwFrmOrObj aFrm( GetFrm() ); sal_Bool bNew = rOldFrm.IsEmpty() || (rOldFrm.Left() == 0 && rOldFrm.Top()); - if( IsShowing( pFrm ) ) + if( IsShowing( rChildFrmOrObj ) ) { // If the object could have existed before, than there is nothing to do, // because no wrapper exists now and therefor no one is interested to // get notified of the movement. if( bNew || (aFrm.IsVisibleChildrenOnly() && !IsShowing( rOldFrm )) ) { - // The frame becomes visible. A child event must be send. - ::vos::ORef< SwAccessibleContext > xAccImpl = - GetMap()->GetContextImpl( pFrm, sal_True ); - xAccImpl->ScrolledIn(); + if( rChildFrmOrObj.GetSwFrm() ) + { + // The frame becomes visible. A child event must be send. + ::vos::ORef< SwAccessibleContext > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(), + sal_True ); + xAccImpl->ScrolledIn(); + } + else + { + ::vos::ORef< accessibility::AccessibleShape > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + this, sal_True ); + ScrolledInShape( rChildFrmOrObj.GetSdrObject(), + xAccImpl.getBodyPtr() ); + } } } else @@ -1149,10 +1228,22 @@ void SwAccessibleContext::InvalidateChildPosOrSize( const SwFrm *pFrm, if( aFrm.IsVisibleChildrenOnly() && !bNew && IsShowing( rOldFrm ) ) { - ::vos::ORef< SwAccessibleContext > xAccImpl = - GetMap()->GetContextImpl( pFrm, sal_True ); - xAccImpl->SetParent( this ); - xAccImpl->Dispose( sal_True ); + if( rChildFrmOrObj.GetSwFrm() ) + { + ::vos::ORef< SwAccessibleContext > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(), + sal_True ); + xAccImpl->SetParent( this ); + xAccImpl->Dispose( sal_True ); + } + else + { + ::vos::ORef< accessibility::AccessibleShape > xAccImpl = + GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + this, sal_True ); + DisposeShape( rChildFrmOrObj.GetSdrObject(), + xAccImpl.getBodyPtr() ); + } } } } diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index b0a1ac97422d..b2829fe01412 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: acccontext.hxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: dvo $ $Date: 2002-05-06 14:03:40 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,9 @@ #ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ILLEGALACCESSIBLECOMPONENTSTATEEXCEPTION_HDL_ #include <drafts/com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include <com/sun/star/lang/XServiceInfo.hpp> #endif @@ -104,6 +107,7 @@ class Window; class SwAccessibleMap; class SwCrsrShell; namespace utl { class AccessibleStateSetHelper; }; +namespace accessibility { class AccessibleShape; } class SwAccessibleContext : public ::cppu::WeakImplHelper5< @@ -195,6 +199,11 @@ protected: void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm, sal_Bool bRecursive ); + void SwAccessibleContext::DisposeShape( const SdrObject *pObj, + ::accessibility::AccessibleShape *pAccImpl ); + void SwAccessibleContext::ScrolledInShape( const SdrObject *pObj, + ::accessibility::AccessibleShape *pAccImpl ); + virtual void _InvalidateContent( sal_Bool bVisibleDataFired ); virtual void _InvalidateCursorPos(); @@ -372,13 +381,14 @@ public: virtual void Dispose( sal_Bool bRecursive = sal_False ); // The child object is not visible an longer and should be destroyed - virtual void DisposeChild( const SwFrm *pFrm, sal_Bool bRecursive ); + virtual void DisposeChild( const SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive ); // The object has been moved by the layout virtual void InvalidatePosOrSize( const SwRect& rFrm ); // The vhild object has been moved by the layout - virtual void InvalidateChildPosOrSize( const SwFrm *pFrm, const SwRect& rFrm ); + virtual void InvalidateChildPosOrSize( const SwFrmOrObj& rFrmOrObj, + const SwRect& rFrm ); // The content may have changed (but it hasn't tohave changed) void InvalidateContent(); @@ -416,7 +426,11 @@ const sal_Char sMissingWindow[] = "window is missing"; #define CHECK_FOR_DEFUNC( ifc ) \ if( !(GetFrm() && GetMap()) ) \ { \ - THROW_RUNTIME_EXCEPTION( ifc, sDefunc ); \ + Reference < ifc > xThis( this ); \ + ::com::sun::star::lang::DisposedException aExcept( \ + OUString( RTL_CONSTASCII_USTRINGPARAM(sDefunc) ), \ + xThis ); \ + throw aExcept; \ } #define CHECK_FOR_WINDOW( i, w ) \ diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index c4280b499a04..7fce5509c3ea 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: accframe.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: os $ $Date: 2002-04-25 13:57:37 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,9 +113,15 @@ #ifndef _PAGEDESC_HXX #include <pagedesc.hxx> #endif +#ifndef _FMTANCHR_HXX +#include <fmtanchr.hxx> +#endif #ifndef _FLDBAS_HXX #include <fldbas.hxx> #endif +#ifndef _DCONTACT_HXX +#include <dcontact.hxx> +#endif #ifndef _ACCMAP_HXX #include <accmap.hxx> @@ -337,6 +343,52 @@ SwFrmOrObj SwAccessibleFrame::GetChildAt( const SwRect& rVisArea, return aRet; } +void SwAccessibleFrame::GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, + ::std::list< SwFrmOrObj >& rChildren ) +{ + if( SwFrmOrObjMap::IsSortingRequired( pFrm ) ) + { + // We need a sorted list here + const SwFrmOrObjMap aVisMap( rVisArea, pFrm ); + SwFrmOrObjMap::const_iterator aIter( aVisMap.begin() ); + while( aIter != aVisMap.end() ) + { + const SwFrmOrObj& rLower = (*aIter).second; + if( rLower.IsAccessible() ) + { + rChildren.push_back( rLower ); + } + else if( rLower.GetSwFrm() ) + { + // There are no unaccessible SdrObjects that count + GetChildren( rVisArea, rLower.GetSwFrm(), rChildren ); + } + ++aIter; + } + } + else + { + // The unsorted list is sorted enough, because it return lower + // frames in the correct order. + const SwFrmOrObjSList aVisList( rVisArea, pFrm ); + SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + while( aIter != aVisList.end() ) + { + const SwFrmOrObj& rLower = *aIter; + if( rLower.IsAccessible() ) + { + rChildren.push_back( rLower ); + } + else if( rLower.GetSwFrm() ) + { + // There are no unaccessible SdrObjects that count + GetChildren( rVisArea, rLower.GetSwFrm(), rChildren ); + } + ++aIter; + } + } +} + void SwAccessibleFrame::MergeLowerBounds( SwRect& rBounds, const SwRect& rVisArea, const SwFrm *pFrm ) @@ -437,31 +489,60 @@ SwAccessibleFrame::~SwAccessibleFrame() { } -const SwFrm *SwAccessibleFrame::GetParent( const SwFrm *pFrm ) +const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj ) { SwFrmOrObj aParent; - if( pFrm->IsFlyFrm() ) + const SwFrm *pFrm = rFrmOrObj.GetSwFrm(); + if( pFrm ) { - const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); - if( pFly->IsFlyInCntFrm() ) + if( pFrm->IsFlyFrm() ) { - // For FLY_IN_CNTNT the parent is the anchor - aParent = pFly->GetAnchor(); - ASSERT( aParent.IsAccessible(), - "parent is not accessible" ); + const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); + if( pFly->IsFlyInCntFrm() ) + { + // For FLY_IN_CNTNT the parent is the anchor + aParent = pFly->GetAnchor(); + ASSERT( aParent.IsAccessible(), + "parent is not accessible" ); + } + else + { + // In any other case the parent is the root frm + aParent = pFly->FindRootFrm(); + } } else { - // In any other case the parent is the root frm - aParent = pFly->FindRootFrm(); + SwFrmOrObj aUpper( pFrm->GetUpper() ); + while( aUpper.GetSwFrm() && !aUpper.IsAccessible() ) + aUpper = aUpper.GetSwFrm()->GetUpper(); + aParent = aUpper; } } - else + else if( rFrmOrObj.GetSdrObject() ) { - SwFrmOrObj aUpper( pFrm->GetUpper() ); - while( aUpper.GetSwFrm() && !aUpper.IsAccessible() ) - aUpper = aUpper.GetSwFrm()->GetUpper(); - aParent = aUpper; + const SwDrawContact *pContact = + static_cast< const SwDrawContact* >( + GetUserCall( rFrmOrObj.GetSdrObject() ) ); + ASSERT( pContact, "sdr contact is missing" ); + if( pContact ) + { + const SwFrmFmt *pFrmFmt = pContact->GetFmt(); + ASSERT( pFrmFmt, "frame format is missing" ); + if( pFrmFmt && FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() ) + { + // For FLY_IN_CNTNT the parent is the anchor + aParent = pContact->GetAnchor(); + ASSERT( aParent.IsAccessible(), + "parent is not accessible" ); + + } + else + { + // In any other case the parent is the root frm + aParent = pContact->GetAnchor()->FindRootFrm(); + } + } } return aParent.GetSwFrm(); diff --git a/sw/source/core/access/accframe.hxx b/sw/source/core/access/accframe.hxx index e77b3a77ac32..2e8ba181c60f 100644 --- a/sw/source/core/access/accframe.hxx +++ b/sw/source/core/access/accframe.hxx @@ -2,9 +2,9 @@ * * $RCSfile: accframe.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: mib $ $Date: 2002-04-11 13:45:32 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,6 +64,7 @@ #ifndef _SAL_TYPES_H_ #include <sal/types.h> #endif +#include <list> #ifndef _FRAME_HXX #include <frame.hxx> #endif @@ -90,6 +91,8 @@ class SwAccessibleFrame static SwFrmOrObj GetChildAt( const SwRect& rVisArea, const SwFrm *pFrm, const Point& rPos ); + static void GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, + ::std::list< SwFrmOrObj >& rChildren ); static void MergeLowerBounds( SwRect& rBounds, const SwRect& rVisArea, @@ -101,8 +104,8 @@ protected: sal_Bool IsOpaque( ViewShell *pVSh ) const; inline sal_Bool IsShowing( const SwRect& rFrm ) const; - inline sal_Bool IsShowing( const SwFrm *pFrm ) const; - inline sal_Bool IsShowing() const { return IsShowing( GetFrm() ); } + inline sal_Bool IsShowing( const SwFrmOrObj& rFrmOrObj ) const; + inline sal_Bool IsShowing() const; void ClearFrm() { pFrm = 0; } @@ -115,7 +118,7 @@ public: const SwFrm *GetFrm() const { return pFrm; }; - static const SwFrm *GetParent( const SwFrm *pFrm ); + static const SwFrm *GetParent( const SwFrmOrObj& rFrmOrObj ); protected: @@ -133,6 +136,7 @@ protected: inline SwFrmOrObj GetChild( sal_Int32 nPos ) const; inline sal_Int32 GetChildIndex( const SwFrmOrObj& rChild ) const; inline SwFrmOrObj GetChildAt( const Point& rPos ) const; + inline void GetChildren( ::std::list< SwFrmOrObj >& rChildren ) const; inline void SetVisArea( const SwRect& rNewVisArea ); const SwRect& GetVisArea() const { return aVisArea; } @@ -146,14 +150,21 @@ inline sal_Bool SwAccessibleFrame::IsShowing( const SwRect& rFrm ) const return rFrm.IsOver( aVisArea ); } -inline sal_Bool SwAccessibleFrame::IsShowing( const SwFrm *pFrm ) const +inline sal_Bool SwAccessibleFrame::IsShowing( const SwFrmOrObj& rFrmOrObj ) const { - return IsShowing( pFrm->Frm().SVRect() ); + return IsShowing( rFrmOrObj.GetBox() ); +} + +inline sal_Bool SwAccessibleFrame::IsShowing() const +{ + SwFrmOrObj aFrmOrObj( GetFrm() ); + return IsShowing( aFrmOrObj ); } inline const SwFrm *SwAccessibleFrame::GetParent() const { - return GetParent( pFrm ); + SwFrmOrObj aFrmOrObj( GetFrm() ); + return GetParent( aFrmOrObj ); } inline sal_Int32 SwAccessibleFrame::GetChildCount() const @@ -177,6 +188,12 @@ inline SwFrmOrObj SwAccessibleFrame::GetChildAt( const Point& rPos ) const return GetChildAt( aVisArea, pFrm, rPos ); } +inline void SwAccessibleFrame::GetChildren( + ::std::list< SwFrmOrObj >& rChildren ) const +{ + GetChildren( aVisArea, pFrm, rChildren ); +} + inline void SwAccessibleFrame::SetVisArea( const SwRect& rNewVisArea ) { aVisArea = rNewVisArea; diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index 00d6e25b3334..4deaaea188b7 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -2,9 +2,9 @@ * * $RCSfile: accfrmobj.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mib $ $Date: 2002-04-05 12:05:04 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,90 +65,31 @@ #pragma hdrstop -#ifndef _PAGEFRM_HXX -#include <pagefrm.hxx> +#ifndef _FRMFMT_HXX +#include <frmfmt.hxx> #endif -#ifndef _ACCFLYMAP_HXX -#include <accflymap.hxx> +#ifndef _FMTANCHR_HXX +#include <fmtanchr.hxx> #endif #ifndef _ACCFRMOBJ_HXX #include <accfrmobj.hxx> #endif +#ifndef _DCONTACT_HXX +#include <dcontact.hxx> +#endif -SwFrmOrObjIter::SwFrmOrObjIter( const SwFrm *pF ) : - pFrm( pF ), - aNext( pF->GetLower() ), - nNextObj( 0 ) -{ - if( !aNext.GetSwFrm() ) - { - // No lowers? Maybe thare are some fly frames or SdrObjects - if( pFrm->IsPageFrm() ) - { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( pFrm ); - const SwSortDrawObjs *pObjs = pPgFrm->GetSortedObjs(); - if( pObjs && pObjs->Count() > 0 ) - aNext = (*pObjs)[0]; - } - } -} - -const SwFrmOrObj& SwFrmOrObjIter::Next() +sal_Bool SwFrmOrObj::IsBoundAsChar() const { - aCurr = aNext; - if( !aCurr.GetSdrObject() ) // We are within the lowers + // currently only SwFrms are accessible + if( pFrm ) { - ASSERT( aCurr.GetSwFrm(), "next called at end of iterator" ); - if( aCurr.GetSwFrm() ) - { - aNext = aCurr.GetSwFrm()->GetNext(); - if( !aNext.GetSwFrm() ) // This was the last lower, but maybe - { // maybe there are some draw objs - if( pFrm->IsPageFrm() ) - { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( pFrm ); - const SwSortDrawObjs *pObjs = pPgFrm->GetSortedObjs(); - if( pObjs && pObjs->Count() > 0 ) - aNext = (*pObjs)[0]; - } - } - } + return pFrm->IsFlyFrm() && + static_cast< const SwFlyFrm *>(pFrm)->IsFlyInCntFrm(); } else { - nNextObj++; - aNext = (const SdrObject *)0; // clear next - if( pFrm->IsPageFrm() ) - { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( pFrm ); - const SwSortDrawObjs *pObjs = pPgFrm->GetSortedObjs(); - if( pObjs && nNextObj < pObjs->Count() ) - aNext = (*pObjs)[nNextObj]; - } - } - - return aCurr; -} - -SwFrmOrObjSortedIter::SwFrmOrObjSortedIter( const SwFrm *pF, - sal_Bool bReverse ) : - pFrm( pF ), - aNext( pF->GetLower() ), - nNextObj( 0 ) -{ - if( !aNext.GetSwFrm() ) - { - // No lowers? Maybe thare are some fly frames or SdrObjects - if( pFrm->IsPageFrm() ) - { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( pFrm ); - const SwSortDrawObjs *pObjs = pPgFrm->GetSortedObjs(); - if( pObjs && pObjs->Count() > 0 ) - aNext = (*pObjs)[0]; - } + const SwFrmFmt *pFrmFmt = pObj ? ::FindFrmFmt( pObj ) : 0; + return pFrmFmt ? FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId() + : sal_False; } } diff --git a/sw/source/core/access/accfrmobj.hxx b/sw/source/core/access/accfrmobj.hxx index 650a50773c95..5510ed56eee8 100644 --- a/sw/source/core/access/accfrmobj.hxx +++ b/sw/source/core/access/accfrmobj.hxx @@ -2,9 +2,9 @@ * * $RCSfile: accfrmobj.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2002-04-11 13:45:32 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,6 +87,7 @@ public: inline SwFrmOrObj(); inline SwFrmOrObj( const SdrObject *pO ); inline SwFrmOrObj( const SwFrm *pF ); + inline SwFrmOrObj( const SwFrm *pF, const SdrObject *pO ); inline SwFrmOrObj( const SwFrmOrObj& r ); inline SwFrmOrObj& operator=( const SwFrmOrObj& r ); @@ -103,7 +104,7 @@ public: inline const SwFrm *GetSwFrm() const; inline sal_Bool IsAccessible() const; - inline sal_Bool IsBoundAsChar() const; + sal_Bool IsBoundAsChar() const; inline sal_Bool IsVisibleChildrenOnly() const; inline SwRect GetBox() const; inline SwRect GetBounds() const; @@ -139,6 +140,17 @@ inline SwFrmOrObj::SwFrmOrObj( const SwFrm *pF ) Init( pF ); } +inline SwFrmOrObj::SwFrmOrObj( const SwFrm *pF, const SdrObject *pO ) +{ + if( pF ) + Init( pF ); + else + Init( pO ); + ASSERT( (!pF || pF == pFrm) && (!pO || pO == pObj), + "invalid frame/object combination" ); + +} + inline SwFrmOrObj::SwFrmOrObj( const SwFrmOrObj& r ) : pObj( r.pObj ), pFrm( r.pFrm ) {} @@ -194,19 +206,13 @@ inline const SwFrm *SwFrmOrObj::GetSwFrm() const inline sal_Bool SwFrmOrObj::IsAccessible() const { - // currently only SwFrms are accessible - return pFrm && pFrm->IsAccessibleFrm() && - ( !pFrm->IsCellFrm() || - static_cast<const SwCellFrm *>( pFrm )->GetTabBox() - ->GetSttNd() != 0 ); + return ( pFrm && pFrm->IsAccessibleFrm() && + ( !pFrm->IsCellFrm() || + static_cast<const SwCellFrm *>( pFrm )->GetTabBox() + ->GetSttNd() != 0 ) ) || + pObj; } -inline sal_Bool SwFrmOrObj::IsBoundAsChar() const -{ - // currently only SwFrms are accessible - return pFrm && pFrm->IsFlyFrm() && - static_cast< const SwFlyFrm *>(pFrm)->IsFlyInCntFrm(); -} inline sal_Bool SwFrmOrObj::IsVisibleChildrenOnly() const { diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index a6f75bcbbe84..005e155ede30 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: accmap.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: mib $ $Date: 2002-05-06 12:25:14 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,18 @@ #ifndef _CPPUHELPER_WEAKREF_HXX_ #include <cppuhelper/weakref.hxx> #endif +#ifndef _SV_WINDOW_HXX +#include <vcl/window.hxx> +#endif +#ifndef _SVDMODEL_HXX +#include <svx/svdmodel.hxx> +#endif +#ifndef SVX_UNOMOD_HXX +#include <svx/unomod.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif #include <map> #include <list> @@ -131,6 +143,12 @@ #ifndef _NDTYP_HXX #include <ndtyp.hxx> #endif +#ifndef _DOC_HXX +#include <doc.hxx> +#endif +#ifndef _SVX_ACCESSIBILITY_SHAPE_TYPE_HANDLER_HXX +#include <svx/ShapeTypeHandler.hxx> +#endif #ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_SHAPE_HXX #include <svx/AccessibleShape.hxx> #endif @@ -141,11 +159,21 @@ #ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ #include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp> #endif +#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ +#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp> +#endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTBROADCASTER_HPP_ +#include <com/sun/star/document/XEventBroadcaster.hpp> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif using namespace ::com::sun::star::uno; using namespace ::drafts::com::sun::star::accessibility; using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::document; using namespace ::rtl; struct SwFrmFunc @@ -166,7 +194,6 @@ public: #ifndef PRODUCT sal_Bool mbLocked; #endif - WeakReference < XAccessible > mxCursorContext; SwAccessibleContextMap_Impl() #ifndef PRODUCT @@ -177,6 +204,78 @@ public: }; //------------------------------------------------------------------------------ +class SwDrawModellListener_Impl : public SfxListener, + public ::cppu::WeakImplHelper1< XEventBroadcaster > +{ + mutable ::osl::Mutex maListenerMutex; + ::cppu::OInterfaceContainerHelper maEventListeners; + SdrModel *mpDrawModel; + +public: + + SwDrawModellListener_Impl( SdrModel *pDrawModel ); + virtual ~SwDrawModellListener_Impl(); + + virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); +}; + +SwDrawModellListener_Impl::SwDrawModellListener_Impl( SdrModel *pDrawModel ) : + maEventListeners( maListenerMutex ), + mpDrawModel( pDrawModel ) +{ + StartListening( *mpDrawModel ); +} + +SwDrawModellListener_Impl::~SwDrawModellListener_Impl() +{ + EndListening( *mpDrawModel ); +} + +void SAL_CALL SwDrawModellListener_Impl::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) +{ + maEventListeners.addInterface( xListener ); +} + +void SAL_CALL SwDrawModellListener_Impl::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) +{ + maEventListeners.removeInterface( xListener ); +} + +void SwDrawModellListener_Impl::Notify( SfxBroadcaster& rBC, + const SfxHint& rHint ) +{ + const SdrHint *pSdrHint = PTR_CAST( SdrHint, &rHint ); + if( !pSdrHint ) + return; + + EventObject aEvent; + if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel, pSdrHint, aEvent ) ) + return; + + ::cppu::OInterfaceIteratorHelper aIter( maEventListeners ); + while( aIter.hasMoreElements() ) + { + Reference < XEventListener > xListener( aIter.next(), + UNO_QUERY ); + try + { + xListener->notifyEvent( aEvent ); + } + catch( ::com::sun::star::uno::RuntimeException& r ) + { +#ifdef DEBUG + ByteString aError( "Runtime exception caught while notifying shape.:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + } + } +} + +//------------------------------------------------------------------------------ struct SwShapeFunc { sal_Bool operator()( const SdrObject * p1, @@ -188,18 +287,30 @@ struct SwShapeFunc typedef ::std::map < const SdrObject *, WeakReference < XAccessible >, SwShapeFunc > _SwAccessibleShapeMap_Impl; class SwAccessibleShapeMap_Impl: public _SwAccessibleShapeMap_Impl + { + accessibility::AccessibleShapeTreeInfo maInfo; + public: #ifndef PRODUCT sal_Bool mbLocked; #endif - SwAccessibleShapeMap_Impl() + SwAccessibleShapeMap_Impl( SwAccessibleMap *pMap ) #ifndef PRODUCT : mbLocked( sal_False ) #endif - {} + { + maInfo.SetSdrView( pMap->GetShell()->GetDrawView() ); + maInfo.SetWindow( pMap->GetShell()->GetWin() ); + maInfo.SetViewForwarder( pMap ); + Reference < XEventBroadcaster > xModelBroadcaster = + new SwDrawModellListener_Impl( + pMap->GetShell()->GetDoc()->MakeDrawModel() ); + maInfo.SetControllerBroadcaster( xModelBroadcaster ); + } + const accessibility::AccessibleShapeTreeInfo& GetInfo() const { return maInfo; } }; //------------------------------------------------------------------------------ @@ -207,7 +318,7 @@ struct SwAccessibleEvent_Impl { public: enum EventType { CARET_OR_STATES, INVALID_CONTENT, POS_CHANGED, - CHILD_POS_CHANGED, DISPOSE }; + CHILD_POS_CHANGED, SHAPE_SELECTION, DISPOSE }; private: SwRect maOldBox; // the old bounds for CHILD_POS_CHANGED @@ -232,6 +343,12 @@ public: ASSERT( SwAccessibleEvent_Impl::DISPOSE == meType, "wrong event constructor, DISPOSE only" ); } + SwAccessibleEvent_Impl( EventType eT ) : + meType( eT ), mnStates( 0 ) + { + ASSERT( SwAccessibleEvent_Impl::SHAPE_SELECTION == meType, + "wrong event constructor, SHAPE_SELECTION only" ); + } SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, const SwFrmOrObj& rFrmOrObj, const SwRect& rR ) : meType( eT ), mxAcc( pA ), maFrmOrObj( rFrmOrObj ), maOldBox( rR ), @@ -257,7 +374,7 @@ public: inline const SwRect& GetOldBox() const { return maOldBox; } inline void SetOldBox( const SwRect& rOldBox ) { maOldBox = rOldBox; } - inline const SwFrm *GetFrm() const { return maFrmOrObj.GetSwFrm(); } + inline const SwFrmOrObj& GetFrmOrObj() const { return maFrmOrObj; } inline void SetStates( sal_uInt8 nSt ) { mnStates |= nSt; } inline sal_Bool IsUpdateCursorPos() const { return (mnStates & ACC_STATE_CARET) != 0; } @@ -293,7 +410,44 @@ public: }; //------------------------------------------------------------------------------ -typedef ::std::map < const SwFrm *, SwAccessibleEventList_Impl::iterator, SwFrmFunc > _SwAccessibleEventMap_Impl; +// The shape list is filled if an accessible shape is destroyed. It +// simply keeps a reference to the accessible shape's XShape. These +// references are destroyed within the EndAction when firing events, +// There are twp reason for this. First of all, a new accessible shape +// for the XShape might be created soon. It's then cheaper if the XShape +// still exists. The other reason are situations where an accessible shape +// is destroyed within an SwFrmFmt::Modify. In this case, destryoing +// the XShape at the same time (indirectly by destroying the accessible +// shape) leads to an assert, because a client of the Modify is destroyed +// within a Modify call. + +typedef ::std::list < Reference < XShape > > _SwShapeList_Impl; + +class SwShapeList_Impl: public _SwShapeList_Impl +{ +public: + + SwShapeList_Impl() {} +}; + + +//------------------------------------------------------------------------------ +struct SwFrmOrObjFunc +{ + sal_Bool operator()( const SwFrmOrObj& r1, + const SwFrmOrObj& r2 ) const + { + const void *p1 = r1.GetSwFrm() + ? static_cast < const void * >( r1.GetSwFrm()) + : static_cast < const void * >( r1.GetSdrObject() ); + const void *p2 = r2.GetSwFrm() + ? static_cast < const void * >( r2.GetSwFrm()) + : static_cast < const void * >( r2.GetSdrObject() ); + return p1 < p2; + } +}; +typedef ::std::map < SwFrmOrObj, SwAccessibleEventList_Impl::iterator, + SwFrmOrObjFunc > _SwAccessibleEventMap_Impl; class SwAccessibleEventMap_Impl: public _SwAccessibleEventMap_Impl { @@ -344,9 +498,12 @@ void SwAccessibleMap::FireEvent( const SwAccessibleEvent_Impl& rEvent ) xAccImpl->InvalidatePosOrSize( rEvent.GetOldBox() ); break; case SwAccessibleEvent_Impl::CHILD_POS_CHANGED: - xAccImpl->InvalidateChildPosOrSize( rEvent.GetFrm(), + xAccImpl->InvalidateChildPosOrSize( rEvent.GetFrmOrObj(), rEvent.GetOldBox() ); break; + case SwAccessibleEvent_Impl::SHAPE_SELECTION: + DoInvalidateShapeSelection(); + break; case SwAccessibleEvent_Impl::DISPOSE: ASSERT( xAccImpl.isValid(), "dispose event has been stored" ); @@ -388,7 +545,7 @@ void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent ) { SwAccessibleEventMap_Impl::iterator aIter = - mpEventMap->find( rEvent.GetFrm() ); + mpEventMap->find( rEvent.GetFrmOrObj() ); if( aIter != mpEventMap->end() ) { SwAccessibleEvent_Impl aEvent( *(*aIter).second ); @@ -440,6 +597,11 @@ void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent ) SwAccessibleEvent_Impl::CHILD_POS_CHANGED, "invalid event combination" ); break; + case SwAccessibleEvent_Impl::SHAPE_SELECTION: + ASSERT( aEvent.GetType() == + SwAccessibleEvent_Impl::SHAPE_SELECTION, + "invalid event combination" ); + break; case SwAccessibleEvent_Impl::DISPOSE: // DISPOSE events overwrite all others. They are not stored // but executed immediatly to avoid broadcasting of @@ -464,7 +626,7 @@ void SwAccessibleMap::AppendEvent( const SwAccessibleEvent_Impl& rEvent ) } else if( SwAccessibleEvent_Impl::DISPOSE != rEvent.GetType() ) { - SwAccessibleEventMap_Impl::value_type aEntry( rEvent.GetFrm(), + SwAccessibleEventMap_Impl::value_type aEntry( rEvent.GetFrmOrObj(), mpEvents->insert( mpEvents->end(), rEvent ) ); mpEventMap->insert( aEntry ); } @@ -491,16 +653,116 @@ void SwAccessibleMap::InvalidateCursorPosition( } } +void SwAccessibleMap::InvalidateShapeSelection() +{ + if( GetShell()->ActionPend() ) + { + SwAccessibleEvent_Impl aEvent( + SwAccessibleEvent_Impl::SHAPE_SELECTION ); + AppendEvent( aEvent ); + } + else + { + DoInvalidateShapeSelection(); + } +} + +void SwAccessibleMap::DoInvalidateShapeSelection() +{ + ::vos::ORef < accessibility::AccessibleShape > *pShapes = 0; + ::vos::ORef < accessibility::AccessibleShape > *pSelShape = 0; + size_t nShapes = 0; + + const ViewShell *pVSh = GetShell(); + const SwFEShell *pFESh = pVSh->ISA( SwFEShell ) ? + static_cast< const SwFEShell * >( pVSh ) : 0; + sal_uInt16 nSelShapes = pFESh ? pFESh->IsObjSelected() : 0; + + { + vos::OGuard aGuard( maMutex ); + if( mpShapeMap ) + { + nShapes = mpShapeMap->size(); + if( nShapes > 0 ) + { + pShapes = + new ::vos::ORef < accessibility::AccessibleShape >[nShapes]; + + SwAccessibleShapeMap_Impl::iterator aIter = mpShapeMap->begin(); + SwAccessibleShapeMap_Impl::iterator aEndIter = mpShapeMap->end(); + + ::vos::ORef < accessibility::AccessibleShape > *pShape = pShapes; + pSelShape = &(pShapes[nShapes]); + while( aIter != aEndIter ) + { + const SdrObject *pObj = (*aIter).first; + Reference < XAccessible > xAcc( (*aIter).second ); + if( nSelShapes && pFESh->IsObjSelected( *pObj ) ) + { + // selected objects are inserted from the back + --pSelShape; + *pSelShape = + static_cast < accessibility::AccessibleShape* >( + xAcc.get() ); + --nSelShapes; + } + else + { + *pShape = + static_cast < accessibility::AccessibleShape* >( + xAcc.get() ); + ++pShape; + } + ++aIter; + } + ASSERT( pSelShape == pShape, "copying shapes went wrong!" ); + } + } + } + + if( pShapes ) + { + ::vos::ORef < accessibility::AccessibleShape > *pShape = pShapes; + while( nShapes ) + { + if( pShape->isValid() ) + { + if( pShape >= pSelShape ) + { + (*pShape)->SetState( AccessibleStateType::SELECTED ); + if( 1 == nSelShapes ) + (*pShape)->SetState( AccessibleStateType::FOCUSED ); + else + (*pShape)->ResetState( AccessibleStateType::FOCUSED ); + } + else + { + (*pShape)->ResetState( AccessibleStateType::SELECTED ); + (*pShape)->ResetState( AccessibleStateType::FOCUSED ); + } + } + + --nShapes; + ++pShape; + } + // TODO: Selection event + + delete[] pShapes; + } +} + SwAccessibleMap::SwAccessibleMap( ViewShell *pSh ) : mpFrmMap( 0 ), mpShapeMap( 0 ), + mpShapes( 0 ), mpEvents( 0 ), mpEventMap( 0 ), mpVSh( pSh ), mnPara( 1 ), mnFootnote( 1 ), - mnEndnote( 1 ) + mnEndnote( 1 ), + mbShapeSelected( sal_False ) { pSh->GetLayout()->AddAccessibleShell(); } @@ -565,6 +827,8 @@ SwAccessibleMap::~SwAccessibleMap() mpFrmMap = 0; delete mpShapeMap; mpShapeMap = 0; + delete mpShapes; + mpShapes = 0; } { @@ -642,6 +906,7 @@ Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, { Reference < XAccessible > xAcc; Reference < XAccessible > xOldCursorAcc; + sal_Bool bOldShapeSelected = sal_False; { vos::OGuard aGuard( maMutex ); @@ -725,7 +990,7 @@ Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, } if( pAcc->HasCursor() && - !AreInSameTable( mpFrmMap->mxCursorContext, pFrm ) ) + !AreInSameTable( mxCursorContext, pFrm ) ) { // If the new context has the focus, and if we know // another context that had the focus, then the focus @@ -741,8 +1006,11 @@ Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, // the new context as the one that has the focus // currently. - xOldCursorAcc = mpFrmMap->mxCursorContext; - mpFrmMap->mxCursorContext = xAcc; + xOldCursorAcc = mxCursorContext; + mxCursorContext = xAcc; + + bOldShapeSelected = mbShapeSelected; + mbShapeSelected = sal_False; } } } @@ -752,6 +1020,8 @@ Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, // Invalidate focus for old object when map is not locked if( xOldCursorAcc.is() ) InvalidateCursorPosition( xOldCursorAcc ); + if( bOldShapeSelected ) + InvalidateShapeSelection(); return xAcc; } @@ -770,7 +1040,7 @@ Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, Reference< XAccessible> SwAccessibleMap::GetContext( const SdrObject *pObj, - const SwAccessibleContext *pParentImpl, + SwAccessibleContext *pParentImpl, sal_Bool bCreate ) { Reference < XAccessible > xAcc; @@ -780,7 +1050,7 @@ Reference< XAccessible> SwAccessibleMap::GetContext( vos::OGuard aGuard( maMutex ); if( !mpShapeMap && bCreate ) - mpShapeMap = new SwAccessibleShapeMap_Impl; + mpShapeMap = new SwAccessibleShapeMap_Impl( this ); if( mpShapeMap ) { SwAccessibleShapeMap_Impl::iterator aIter = @@ -796,7 +1066,11 @@ Reference< XAccessible> SwAccessibleMap::GetContext( UNO_QUERY ); if( xShape.is() ) { - // pAcc = ... + accessibility::ShapeTypeHandler& rShapeTypeHandler = + accessibility::ShapeTypeHandler::Instance(); + Reference < XAccessible > xParent( pParentImpl ); + pAcc = rShapeTypeHandler.CreateAccessibleObject( xShape, + xParent, mpShapeMap->GetInfo() ); } xAcc = pAcc; @@ -828,7 +1102,7 @@ Reference< XAccessible> SwAccessibleMap::GetContext( ::vos::ORef < accessibility::AccessibleShape > SwAccessibleMap::GetContextImpl( const SdrObject *pObj, - const SwAccessibleContext *pParentImpl, + SwAccessibleContext *pParentImpl, sal_Bool bCreate ) { Reference < XAccessible > xAcc( GetContext( pObj, pParentImpl, bCreate ) ); @@ -852,8 +1126,10 @@ void SwAccessibleMap::RemoveContext( const SwFrm *pFrm ) { mpFrmMap->erase( aIter ); - // Remove reference to old caret object - Reference < XAccessible > xOldAcc( mpFrmMap->mxCursorContext ); + // Remove reference to old caret object. Though mxCursorContext + // is a weak reference and cleared automatically, clearing it + // directly makes sure to not keep a defunctional object. + Reference < XAccessible > xOldAcc( mxCursorContext ); if( xOldAcc.is() ) { SwAccessibleContext *pOldAccImpl = @@ -862,7 +1138,7 @@ void SwAccessibleMap::RemoveContext( const SwFrm *pFrm ) if( pOldAccImpl->GetFrm() == pFrm ) { xOldAcc.clear(); // get an empty ref - mpFrmMap->mxCursorContext = xOldAcc; + mxCursorContext = xOldAcc; } } @@ -875,50 +1151,110 @@ void SwAccessibleMap::RemoveContext( const SwFrm *pFrm ) } } +void SwAccessibleMap::RemoveContext( const SdrObject *pObj ) +{ + vos::OGuard aGuard( maMutex ); -void SwAccessibleMap::Dispose( const SwFrm *pFrm, sal_Bool bRecursive ) + if( mpShapeMap ) + { + SwAccessibleShapeMap_Impl::iterator aIter = + mpShapeMap->find( pObj ); + if( aIter != mpShapeMap->end() ) + { + mpShapeMap->erase( aIter ); + + // 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() ) + { + delete mpShapeMap; + mpShapeMap = 0; + } + } + } +} + + +void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, + sal_Bool bRecursive ) { + SwFrmOrObj aFrmOrObj( pFrm, pObj ); + // Indeed, the following assert checks the frame's accessible flag, // because that's the one that is evaluated in the layout. The frame // might not be accessible anyway. That's the case for cell frames that // contain further cells. - ASSERT( pFrm->IsAccessibleFrm(), + ASSERT( !aFrmOrObj.GetSwFrm() || aFrmOrObj.GetSwFrm()->IsAccessibleFrm(), "non accessible frame should be disposed" ); - SwFrmOrObj aFrmOrObj( pFrm ); - Reference < XAccessible > xAcc; - Reference < XAccessible > xParentAcc; + ::vos::ORef< SwAccessibleContext > xAccImpl; + ::vos::ORef< SwAccessibleContext > xParentAccImpl; + ::vos::ORef< ::accessibility::AccessibleShape > xShapeAccImpl; if( aFrmOrObj.IsAccessible() ) { // get accessible context for frame { vos::OGuard aGuard( maMutex ); - if( mpFrmMap ) + // First of all look for an accessible context for a frame + if( aFrmOrObj.GetSwFrm() && mpFrmMap ) { SwAccessibleContextMap_Impl::iterator aIter = - mpFrmMap->find( pFrm ); + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); if( aIter != mpFrmMap->end() ) { - xAcc = (*aIter).second; + Reference < XAccessible > xAcc( (*aIter).second ); + xAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); } - else - { - // Otherwise we look if the parent is accessible. - // If not, there is nothing to do. - const SwFrm *pParent = - SwAccessibleFrame::GetParent( aFrmOrObj.GetSwFrm() ); + } + if( !xAccImpl.isValid() && mpFrmMap ) + { + // If there is none, look if the parent is accessible. + const SwFrm *pParent = + SwAccessibleFrame::GetParent( aFrmOrObj ); - if( pParent ) + if( pParent ) + { + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( pParent ); + if( aIter != mpFrmMap->end() ) { - aIter = mpFrmMap->find( pParent ); - if( aIter != mpFrmMap->end() ) - { - xParentAcc = (*aIter).second; - } + Reference < XAccessible > xAcc( (*aIter).second ); + xParentAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); } } } + if( !xParentAccImpl.isValid() && !aFrmOrObj.GetSwFrm() && + mpShapeMap ) + { + SwAccessibleShapeMap_Impl::iterator aIter = + mpShapeMap->find( aFrmOrObj.GetSdrObject() ); + if( aIter != mpShapeMap->end() ) + { + Reference < XAccessible > xAcc( (*aIter).second ); + xShapeAccImpl = + static_cast< accessibility::AccessibleShape *>( xAcc.get() ); + } + } + if( pObj && GetShell()->ActionPend() && + (xParentAccImpl.isValid() || xShapeAccImpl.isValid()) ) + { + // Keep a reference to the XShape to avoid that it + // is deleted with a SwFrmFmt::Modify. + Reference < XShape > xShape( + const_cast< SdrObject * >( pObj )->getUnoShape(), + UNO_QUERY ); + if( xShape.is() ) + { + if( !mpShapes ) + mpShapes = new SwShapeList_Impl; + mpShapes->push_back( xShape ); + } + } } // remove events stored for the frame @@ -927,7 +1263,7 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, sal_Bool bRecursive ) if( mpEvents ) { SwAccessibleEventMap_Impl::iterator aIter = - mpEventMap->find( aFrmOrObj.GetSwFrm() ); + mpEventMap->find( aFrmOrObj ); if( aIter != mpEventMap->end() ) { SwAccessibleEvent_Impl aEvent( @@ -941,98 +1277,104 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, sal_Bool bRecursive ) // the frame. If the frame is no context for it but disposing should // take place recursive, the frame's children have to be disposed // anyway, so we have to create the context then. - if( xAcc.is() ) + if( xAccImpl.isValid() ) { - SwAccessibleContext *pAccImpl = - static_cast< SwAccessibleContext *>( xAcc.get() ); - pAccImpl->Dispose( bRecursive ); + xAccImpl->Dispose( bRecursive ); } - else if( xParentAcc.is() ) + else if( xParentAccImpl.isValid() ) { // If the frame is a cell frame, the table must be notified. // If we are in an action, a table model change event will // be broadcasted at the end of the action to give the table // a chance to generate a single table change event. - SwAccessibleContext *pAccImpl = - static_cast< SwAccessibleContext *>( xParentAcc.get() ); - pAccImpl->DisposeChild( aFrmOrObj.GetSwFrm(), bRecursive ); + xParentAccImpl->DisposeChild( aFrmOrObj, bRecursive ); + } + else if( xShapeAccImpl.isValid() ) + { + RemoveContext( aFrmOrObj.GetSdrObject() ); + xShapeAccImpl->dispose(); } } } void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, + const SdrObject *pObj, const SwRect& rOldBox ) { - SwFrmOrObj aFrmOrObj( pFrm ); + SwFrmOrObj aFrmOrObj( pFrm, pObj ); if( aFrmOrObj.IsAccessible() ) { - Reference < XAccessible > xAcc; - Reference < XAccessible > xParentAcc; + ::vos::ORef< SwAccessibleContext > xAccImpl; + ::vos::ORef< SwAccessibleContext > xParentAccImpl; { vos::OGuard aGuard( maMutex ); if( mpFrmMap ) { - SwAccessibleContextMap_Impl::iterator aIter = - mpFrmMap->find( aFrmOrObj.GetSwFrm() ); - if( aIter != mpFrmMap->end() ) + if( aFrmOrObj.GetSwFrm() ) { - // If there is an accesible object already it is - // notified directly. - xAcc = (*aIter).second; + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); + if( aIter != mpFrmMap->end() ) + { + // If there is an accesible object already it is + // notified directly. + Reference < XAccessible > xAcc( (*aIter).second ); + xAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); + } } - else + if( !xAccImpl.isValid() ) { // Otherwise we look if the parent is accessible. // If not, there is nothing to do. const SwFrm *pParent = - SwAccessibleFrame::GetParent( aFrmOrObj.GetSwFrm() ); + SwAccessibleFrame::GetParent( aFrmOrObj ); if( pParent ) { - aIter = mpFrmMap->find( pParent ); + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( pParent ); if( aIter != mpFrmMap->end() ) { - xParentAcc = (*aIter).second; + Reference < XAccessible > xAcc( (*aIter).second ); + xParentAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); } } } } } - if( xAcc.is() ) + if( xAccImpl.isValid() ) { ASSERT( !rOldBox.IsEmpty(), "context should have a size" ); - SwAccessibleContext *pAccImpl = - static_cast< SwAccessibleContext *>( xAcc.get() ); if( GetShell()->ActionPend() ) { SwAccessibleEvent_Impl aEvent( - SwAccessibleEvent_Impl::POS_CHANGED, pAccImpl, + SwAccessibleEvent_Impl::POS_CHANGED, xAccImpl.getBodyPtr(), aFrmOrObj, rOldBox ); AppendEvent( aEvent ); } else { - pAccImpl->InvalidatePosOrSize( rOldBox ); + xAccImpl->InvalidatePosOrSize( rOldBox ); } } - else if( xParentAcc.is() ) + else if( xParentAccImpl.isValid() ) { - SwAccessibleContext *pAccImpl = - static_cast< SwAccessibleContext *>(xParentAcc.get()); if( GetShell()->ActionPend() ) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CHILD_POS_CHANGED, - pAccImpl, aFrmOrObj, rOldBox ); + xParentAccImpl.getBodyPtr(), aFrmOrObj, rOldBox ); AppendEvent( aEvent ); } else { - pAccImpl->InvalidateChildPosOrSize( aFrmOrObj.GetSwFrm(), - rOldBox ); + xParentAccImpl->InvalidateChildPosOrSize( aFrmOrObj, + rOldBox ); } } } @@ -1078,6 +1420,7 @@ void SwAccessibleMap::InvalidateContent( const SwFrm *pFrm ) void SwAccessibleMap::InvalidateCursorPosition( const SwFrm *pFrm ) { SwFrmOrObj aFrmOrObj( pFrm ); + sal_Bool bShapeSelected = sal_False; const ViewShell *pVSh = GetShell(); if( pVSh->ISA( SwCrsrShell ) ) { @@ -1100,63 +1443,68 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrm *pFrm ) } else if( (nObjCount = pFESh->IsObjSelected()) > 0 ) { + bShapeSelected = sal_True; aFrmOrObj = static_cast<const SwFrm *>( 0 ); } } } - ASSERT( aFrmOrObj.IsAccessible(), "frame is not accessible" ); + ASSERT( bShapeSelected || aFrmOrObj.IsAccessible(), + "frame is not accessible" ); Reference < XAccessible > xOldAcc; Reference < XAccessible > xAcc; + sal_Bool bOldShapeSelected = sal_False; { vos::OGuard aGuard( maMutex ); - if( mpFrmMap ) + xOldAcc = mxCursorContext; + mxCursorContext = xAcc; // clear reference + + bOldShapeSelected = mbShapeSelected; + mbShapeSelected = bShapeSelected; + + if( aFrmOrObj.GetSwFrm() && mpFrmMap ) { - xOldAcc = mpFrmMap->mxCursorContext; - mpFrmMap->mxCursorContext = xAcc; // clear reference + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); + if( aIter != mpFrmMap->end() ) + xAcc = (*aIter).second; - if( aFrmOrObj.IsAccessible() ) + // For cells, some extra thoughts are necessary, + // because invalidating the cursor for one cell + // invalidates the cursor for all cells of the same + // table. For this reason, we don't want to + // invalidate the cursor for the old cursor object + // and the new one if they are within the same table, + // because this would result in doing the work twice. + // Moreover, we have to make sure to invalidate the + // cursor even if the current cell has no accessible object. + // If the old cursor objects exists and is in the same + // table, its the best choice, because using it avoids + // an unnessarary cursor invalidation cycle when creating + // a new object for the current cell. + if( aFrmOrObj.GetSwFrm()->IsCellFrm() ) { - SwAccessibleContextMap_Impl::iterator aIter = - mpFrmMap->find( aFrmOrObj.GetSwFrm() ); - if( aIter != mpFrmMap->end() ) - xAcc = (*aIter).second; - - // For cells, some extra thoughts are necessary, - // because invalidating the cursor for one cell - // invalidates the cursor for all cells of the same - // table. For this reason, we don't want to - // invalidate the cursor for the old cursor object - // and the new one if they are within the same table, - // because this would result in doing the work twice. - // Moreover, we have to make sure to invalidate the - // cursor even if the current cell has no accessible object. - // If the old cursor objects exists and is in the same - // table, its the best choice, because using it avoids - // an unnessarary cursor invalidation cycle when creating - // a new object for the current cell. - if( aFrmOrObj.GetSwFrm()->IsCellFrm() ) + if( xOldAcc.is() && + AreInSameTable( xOldAcc, aFrmOrObj.GetSwFrm() ) ) { - if( xOldAcc.is() && - AreInSameTable( xOldAcc, aFrmOrObj.GetSwFrm() ) ) - { - if( xAcc.is() ) - xOldAcc = xAcc; // avoid extra invalidation - else - xAcc = xOldAcc; // make sure ate least one - } - if( !xAcc.is() ) - xAcc = GetContext( aFrmOrObj.GetSwFrm(), sal_True ); + if( xAcc.is() ) + xOldAcc = xAcc; // avoid extra invalidation + else + xAcc = xOldAcc; // make sure ate least one } + if( !xAcc.is() ) + xAcc = GetContext( aFrmOrObj.GetSwFrm(), sal_True ); } } } if( xOldAcc.is() && xOldAcc != xAcc ) InvalidateCursorPosition( xOldAcc ); + if( bOldShapeSelected || bShapeSelected ) + InvalidateShapeSelection(); if( xAcc.is() ) InvalidateCursorPosition( xAcc ); } @@ -1165,11 +1513,8 @@ void SwAccessibleMap::SetCursorContext( const ::vos::ORef < SwAccessibleContext >& rCursorContext ) { vos::OGuard aGuard( maMutex ); - if( mpFrmMap ) - { - Reference < XAccessible > xAcc( rCursorContext.getBodyPtr() ); - mpFrmMap->mxCursorContext = xAcc; - } + Reference < XAccessible > xAcc( rCursorContext.getBodyPtr() ); + mxCursorContext = xAcc; } void SwAccessibleMap::InvalidateStates( sal_uInt8 nStates ) @@ -1246,21 +1591,94 @@ void SwAccessibleMap::InvalidateRelationSet( const SwFrm* pMaster, void SwAccessibleMap::FireEvents() { - vos::OGuard aGuard( maEventMutex ); - if( mpEvents ) { - mpEvents->SetFiring(); - SwAccessibleEventList_Impl::iterator aIter = mpEvents->begin(); - while( aIter != mpEvents->end() ) + vos::OGuard aGuard( maEventMutex ); + if( mpEvents ) + { + mpEvents->SetFiring(); + SwAccessibleEventList_Impl::iterator aIter = mpEvents->begin(); + while( aIter != mpEvents->end() ) + { + FireEvent( *aIter ); + ++aIter; + } + + delete mpEventMap; + mpEventMap = 0; + + delete mpEvents; + mpEvents = 0; + } + } + { + vos::OGuard aGuard( maMutex ); + if( mpShapes ) { - FireEvent( *aIter ); - ++aIter; + delete mpShapes; + mpShapes = 0; } } - delete mpEventMap; - mpEventMap = 0; +} + +sal_Bool SwAccessibleMap::IsValid() const +{ + return sal_True; +} + +Rectangle SwAccessibleMap::GetVisibleArea() const +{ + MapMode aSrc( MAP_TWIP ); + MapMode aDest( MAP_100TH_MM ); + return OutputDevice::LogicToLogic( GetVisArea().SVRect(), aSrc, aDest ); +} + +Point SwAccessibleMap::LogicToPixel( const Point& rPoint ) const +{ + MapMode aSrc( MAP_100TH_MM ); + MapMode aDest( MAP_TWIP ); + Point aPoint( OutputDevice::LogicToLogic( rPoint, aSrc, aDest ) ); + if( GetShell()->GetWin() ) + aPoint = GetShell()->GetWin()->LogicToPixel( aPoint ); + + return aPoint; +} + +Size SwAccessibleMap::LogicToPixel( const Size& rSize ) const +{ + MapMode aSrc( MAP_100TH_MM ); + MapMode aDest( MAP_TWIP ); + Size aSize( OutputDevice::LogicToLogic( rSize, aSrc, aDest ) ); + if( GetShell()->GetWin() ) + aSize = GetShell()->GetWin()->LogicToPixel( aSize ); + + return aSize; +} + +Point SwAccessibleMap::PixelToLogic( const Point& rPoint ) const +{ + Point aPoint; + if( GetShell()->GetWin() ) + { + aPoint = GetShell()->GetWin()->PixelToLogic( rPoint ); + MapMode aSrc( MAP_TWIP ); + MapMode aDest( MAP_100TH_MM ); + aPoint = OutputDevice::LogicToLogic( aPoint, aSrc, aDest ); + } + + return aPoint; +} + +Size SwAccessibleMap::PixelToLogic( const Size& rSize ) const +{ + Size aSize; + if( GetShell()->GetWin() ) + { + aSize = GetShell()->GetWin()->PixelToLogic( rSize ); + MapMode aSrc( MAP_TWIP ); + MapMode aDest( MAP_100TH_MM ); + aSize = OutputDevice::LogicToLogic( aSize, aSrc, aDest ); + } - delete mpEvents; - mpEvents = 0; + return aSize; } diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index edbb9882f1a4..9114a5437a32 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: accselectionhelper.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: dvo $ $Date: 2002-04-12 12:48:59 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,9 @@ #ifndef _ACCMAP_HXX #include <accmap.hxx> #endif +#ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_SHAPE_HXX +#include <svx/AccessibleShape.hxx> +#endif #ifndef _VIEWSH_HXX #include <viewsh.hxx> @@ -125,25 +128,6 @@ SwFEShell* SwAccessibleSelectionHelper::GetFEShell() return pFEShell; } -const SwFlyFrm* SwAccessibleSelectionHelper::GetSelectedChildFlyFrame() -{ - const SwFlyFrm* pSelectedChildFlyFrame = NULL; - - SwFEShell* pFEShell = GetFEShell(); - if( pFEShell != NULL ) - { - // Get the selected frame, and check if it's ours (rather - // than, say, child of a paragraph). - const SwFlyFrm* pFlyFrm = pFEShell->GetCurrFlyFrm(); - if( (pFlyFrm != NULL) && - (rContext.GetParent(pFlyFrm) == rContext.GetFrm()) ) - pSelectedChildFlyFrame = pFlyFrm; - } - // else: no FE-Shell -> no selected frames -> no selected children - - return pSelectedChildFlyFrame; -} - //===== XAccessibleSelection ============================================ @@ -162,13 +146,18 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( // we can only select fly frames, so we ignore (should: return // false) all other attempts at child selection sal_Bool bRet = sal_False; - const SwFrm* pFrm = aChild.GetSwFrm(); SwFEShell* pFEShell = GetFEShell(); - if( (pFEShell != NULL) && (pFrm != NULL) && (pFrm->IsFlyFrm()) ) + if( pFEShell != NULL ) { - pFEShell->SelectFlyFrm( - *(static_cast<SwFlyFrm*>(const_cast<SwFrm*>(pFrm))), TRUE ); - bRet = sal_True; + const SdrObject *pObj = aChild.GetSdrObject(); + if( pObj ) + { + Point aDummy; + sal_uInt8 nFlags = aChild.GetSwFrm() ? 0 : SW_ADD_SELECT; + pFEShell->SelectObj( aDummy, nFlags, + const_cast< SdrObject *>( pObj ) ); + bRet = sal_True; + } } // no frame shell, or no frame, or no fly frame -> can't select @@ -188,8 +177,21 @@ sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( throw IndexOutOfBoundsException(); // ... and compare to the currently selected frame - const SwFlyFrm* pSelectedFrame = GetSelectedChildFlyFrame(); - return (pSelectedFrame == aChild.GetSwFrm()); + sal_Bool bRet = sal_False; + SwFEShell* pFEShell = GetFEShell(); + if( pFEShell ) + { + if( aChild.GetSwFrm() != 0 ) + { + bRet = (pFEShell->GetCurrFlyFrm() == aChild.GetSwFrm()); + } + else + { + bRet = pFEShell->IsObjSelected( *aChild.GetSdrObject() ); + } + } + + return bRet; } void SwAccessibleSelectionHelper::clearAccessibleSelection( ) @@ -207,35 +209,29 @@ void SwAccessibleSelectionHelper::selectAllAccessible( ) // the first we can select, and select it. sal_Int32 nIndex = 0; - const SwFlyFrm* pFirstSelectable = NULL; - sal_Bool bContinue = sal_True; - do + SwFEShell* pFEShell = GetFEShell(); + if( pFEShell ) { - const SwFrmOrObj aChild = rContext.GetChild( nIndex ); - if( aChild.IsValid() ) + ::std::list< SwFrmOrObj > aChildren; + rContext.GetChildren( aChildren ); + + ::std::list< SwFrmOrObj >::const_iterator aIter = aChildren.begin(); + ::std::list< SwFrmOrObj >::const_iterator aEndIter = aChildren.end(); + while( aIter != aEndIter ) { - const SwFrm* pFrm = aChild.GetSwFrm(); - if( (pFrm != NULL) && pFrm->IsFlyFrm() ) + const SwFrmOrObj& rChild = *aIter; + const SdrObject *pObj = rChild.GetSdrObject(); + const SwFrm* pFrm = rChild.GetSwFrm(); + if( pObj && !(pFrm != 0 && pFEShell->IsObjSelected()) ) { - pFirstSelectable = static_cast<const SwFlyFrm*>( pFrm ); - bContinue = sal_False; + Point aDummy; + sal_uInt8 nFlags = pFrm ? 0 : SW_ADD_SELECT; + pFEShell->SelectObj( aDummy, nFlags, + const_cast< SdrObject *>( pObj ) ); + if( pFrm ) + break; } - } - else - bContinue = sal_False; - - nIndex++; - } - while( bContinue ); - - // select frame (if we found any) - if( pFirstSelectable != NULL ) - { - SwFEShell* pFEShell = GetFEShell(); - if( pFEShell != NULL ) - { - pFEShell->SelectFlyFrm( *(const_cast<SwFlyFrm*>(pFirstSelectable)), - TRUE ); + ++aIter; } } } @@ -245,9 +241,45 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) { vos::OGuard aGuard(Application::GetSolarMutex()); + sal_Int32 nCount = 0; // Only one frame can be selected at a time, and we only frames // for selectable children. - return (GetSelectedChildFlyFrame() != NULL) ? 1 : 0; + SwFEShell* pFEShell = GetFEShell(); + if( pFEShell != 0 ) + { + const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); + if( pFlyFrm ) + { + if( rContext.GetParent(pFlyFrm) == rContext.GetFrm() ) + nCount = 1; + } + else + { + sal_uInt16 nSelObjs = pFEShell->IsObjSelected(); + if( nSelObjs > 0 ) + { + ::std::list< SwFrmOrObj > aChildren; + rContext.GetChildren( aChildren ); + + ::std::list< SwFrmOrObj >::const_iterator aIter = + aChildren.begin(); + ::std::list< SwFrmOrObj >::const_iterator aEndIter = + aChildren.end(); + while( aIter != aEndIter && nCount < nSelObjs ) + { + const SwFrmOrObj& rChild = *aIter; + if( rChild.GetSdrObject() && !rChild.GetSwFrm() && + rContext.GetParent(rChild) == rContext.GetFrm() && + pFEShell->IsObjSelected( *rChild.GetSdrObject() ) ) + { + nCount++; + } + ++aIter; + } + } + } + } + return nCount; } Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( @@ -257,18 +289,74 @@ Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( { vos::OGuard aGuard(Application::GetSolarMutex()); - const SwFlyFrm* pFlyFrm = GetSelectedChildFlyFrame(); - // Since the index is relative to the selected children, and since // there can be at most one selected frame child, the index must // be 0, and a selection must exist, otherwise we have to throw an // IndexOutOfBoundsException - - if( (pFlyFrm == NULL) || (nSelectedChildIndex != 0) ) + SwFEShell* pFEShell = GetFEShell(); + if( 0 == pFEShell ) throw IndexOutOfBoundsException(); - DBG_ASSERT( rContext.GetMap() != NULL, "We need the map." ) - return rContext.GetMap()->GetContext( pFlyFrm, sal_True ); + SwFrmOrObj aChild; + const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); + if( pFlyFrm ) + { + if( 0 == nSelectedChildIndex && + rContext.GetParent(pFlyFrm) == rContext.GetFrm() ) + aChild = pFlyFrm; + } + else + { + sal_uInt16 nSelObjs = pFEShell->IsObjSelected(); + if( 0 == nSelObjs || nSelectedChildIndex >= nSelObjs ) + throw IndexOutOfBoundsException(); + + ::std::list< SwFrmOrObj > aChildren; + rContext.GetChildren( aChildren ); + + ::std::list< SwFrmOrObj >::const_iterator aIter = aChildren.begin(); + ::std::list< SwFrmOrObj >::const_iterator aEndIter = aChildren.end(); + while( aIter != aEndIter && !aChild.IsValid() ) + { + const SwFrmOrObj& rChild = *aIter; + if( rChild.GetSdrObject() && !rChild.GetSwFrm() && + rContext.GetParent(rChild) == rContext.GetFrm() && + pFEShell->IsObjSelected( *rChild.GetSdrObject() ) ) + { + if( 0 == nSelectedChildIndex ) + aChild = rChild; + else + --nSelectedChildIndex; + } + ++aIter; + } + } + + if( !aChild.IsValid() ) + throw IndexOutOfBoundsException(); + + DBG_ASSERT( rContext.GetMap() != NULL, "We need the map." ); + Reference< XAccessible > xChild; + if( aChild.GetSwFrm() ) + { + ::vos::ORef < SwAccessibleContext > xChildImpl( + rContext.GetMap()->GetContextImpl( aChild.GetSwFrm(), + sal_True ) ); + if( xChildImpl.isValid() ) + { + xChildImpl->SetParent( &rContext ); + xChild = xChildImpl.getBodyPtr(); + } + } + else + { + ::vos::ORef < ::accessibility::AccessibleShape > xChildImpl( + rContext.GetMap()->GetContextImpl( aChild.GetSdrObject(), + &rContext, sal_True ) ); + if( xChildImpl.isValid() ) + xChild = xChildImpl.getBodyPtr(); + } + return xChild; } void SwAccessibleSelectionHelper::deselectSelectedAccessibleChild( diff --git a/sw/source/core/access/accselectionhelper.hxx b/sw/source/core/access/accselectionhelper.hxx index 43335aadfe31..e22f42091649 100644 --- a/sw/source/core/access/accselectionhelper.hxx +++ b/sw/source/core/access/accselectionhelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: accselectionhelper.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: dvo $ $Date: 2002-04-12 12:48:59 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,9 +79,6 @@ class SwAccessibleSelectionHelper /// get FE-Shell SwFEShell* GetFEShell(); - /// get current selected Fly-Frame, if it's a child of this frame - const SwFlyFrm* GetSelectedChildFlyFrame(); - public: SwAccessibleSelectionHelper( SwAccessibleContext& rContext ); diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index 49dcc0576f61..1621badfe860 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: acctable.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dvo $ $Date: 2002-05-06 14:03:40 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1180,11 +1180,13 @@ void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox ) SwAccessibleContext::InvalidatePosOrSize( rOldBox ); } -void SwAccessibleTable::DisposeChild( const SwFrm *pFrm, +void SwAccessibleTable::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, sal_Bool bRecursive ) { vos::OGuard aGuard(Application::GetSolarMutex()); + const SwFrm *pFrm = rChildFrmOrObj.GetSwFrm(); + ASSERT( pFrm, "frame expected" ); if( HasTableData() ) { FireTableChangeEvent( GetTableData() ); @@ -1198,10 +1200,10 @@ void SwAccessibleTable::DisposeChild( const SwFrm *pFrm, // about its change. We then must not call the superclass Reference< XAccessible > xAcc( GetMap()->GetContext( pFrm, sal_False ) ); if( !xAcc.is() ) - SwAccessibleContext::DisposeChild( pFrm, bRecursive ); + SwAccessibleContext::DisposeChild( rChildFrmOrObj, bRecursive ); } -void SwAccessibleTable::InvalidateChildPosOrSize( const SwFrm *pFrm, +void SwAccessibleTable::InvalidateChildPosOrSize( const SwFrmOrObj& rChildFrmOrObj, const SwRect& rOldBox ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1234,9 +1236,10 @@ void SwAccessibleTable::InvalidateChildPosOrSize( const SwFrm *pFrm, // the map, and we have to call our superclass. // The other situation is that we have been call by a call to get notified // about its change. We then must not call the superclass - Reference< XAccessible > xAcc( GetMap()->GetContext( pFrm, sal_False ) ); + ASSERT( rChildFrmOrObj.GetSwFrm(), "frame expected" ); + Reference< XAccessible > xAcc( GetMap()->GetContext( rChildFrmOrObj.GetSwFrm(), sal_False ) ); if( !xAcc.is() ) - SwAccessibleContext::InvalidateChildPosOrSize( pFrm, rOldBox ); + SwAccessibleContext::InvalidateChildPosOrSize( rChildFrmOrObj, rOldBox ); } @@ -1292,7 +1295,7 @@ void SAL_CALL SwAccessibleTable::selectAccessibleChild( pPaM->DeleteMark(); *(pPaM->GetPoint()) = SwPosition( *pStartNode ); pPaM->Move( fnMoveForward, fnGoNode ); - pCrsrShell->SelTblBox(); +// pCrsrShell->SelTblBox(); } else { @@ -1309,7 +1312,7 @@ void SAL_CALL SwAccessibleTable::selectAccessibleChild( if( aPaM.GetPoint()->nNode.GetNode().FindTableBoxStartNode() == aPaM.GetMark()->nNode.GetNode().FindTableBoxStartNode() ) { - pCrsrShell->SelTblBox(); +// pCrsrShell->SelTblBox(); } else { @@ -1455,7 +1458,7 @@ void SAL_CALL SwAccessibleTable::deselectSelectedAccessibleChild( // reduce selection to mark pCrsrShell->GetCrsr()->Exchange(); pCrsrShell->GetCrsr()->DeleteMark(); - pCrsrShell->SelTblBox(); +// pCrsrShell->SelTblBox(); } } // else: not selected -> ignore diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx index 067cd23aa0f0..88617f64cc06 100644 --- a/sw/source/core/access/acctable.hxx +++ b/sw/source/core/access/acctable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: acctable.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dvo $ $Date: 2002-05-06 14:03:40 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -238,8 +238,8 @@ public: // The object has been moved by the layout virtual void InvalidatePosOrSize( const SwRect& rOldBox ); - virtual void DisposeChild( const SwFrm *pFrm, sal_Bool bRecursive ); - virtual void InvalidateChildPosOrSize( const SwFrm *pFrm, + virtual void DisposeChild( const SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive ); + virtual void InvalidateChildPosOrSize( const SwFrmOrObj& rFrmOrObj, const SwRect& rFrm ); //===== XAccessibleSelection ============================================ diff --git a/sw/source/core/access/makefile.mk b/sw/source/core/access/makefile.mk index bb5690c632f3..cc27534d585c 100644 --- a/sw/source/core/access/makefile.mk +++ b/sw/source/core/access/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.7 $ +# $Revision: 1.8 $ # -# last change: $Author: dvo $ $Date: 2002-04-12 12:48:59 $ +# last change: $Author: mib $ $Date: 2002-05-15 13:17:31 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -95,6 +95,7 @@ SLOFILES = \ $(SLO)$/accframe.obj \ $(SLO)$/accframebase.obj \ $(SLO)$/accfrmobjmap.obj \ + $(SLO)$/accfrmobj.obj \ $(SLO)$/accfrmobjslist.obj \ $(SLO)$/accgraphic.obj \ $(SLO)$/accheaderfooter.obj \ @@ -114,6 +115,7 @@ EXCEPTIONSFILES= \ $(SLO)$/accfootnote.obj \ $(SLO)$/accframe.obj \ $(SLO)$/accframebase.obj \ + $(SLO)$/accfrmobj.obj \ $(SLO)$/accfrmobjmap.obj \ $(SLO)$/accfrmobjslist.obj \ $(SLO)$/accgraphic.obj \ diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 9dab47abb7dd..7164c77ceacd 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -2,9 +2,9 @@ * * $RCSfile: feshview.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: ama $ $Date: 2002-04-09 14:19:15 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:20:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -291,9 +291,14 @@ BOOL SwFEShell::SelectObj( const Point& rPt, BYTE nFlag, SdrObject *pObj ) } if ( pObj ) - pDView->MarkObj( pObj, Imp()->GetPageView(), bAddSelect, bEnterGroup ); + { + ASSERT( !bEnterGroup, "SW_ENTER_GROUP is not supported" ); + pDView->MarkObj( pObj, Imp()->GetPageView() ); + } else + { pDView->MarkObj( rPt, MINMOVE, bAddSelect, bEnterGroup ); + } const FASTBOOL bRet = 0 != rMrkList.GetMarkCount(); @@ -853,6 +858,17 @@ BOOL SwFEShell::IsFrmSelected() const (ViewShell*)this ); } +#ifdef ACCESSIBLE_LAYOUT +sal_Bool SwFEShell::IsObjSelected( const SdrObject& rObj ) const +{ + if ( IsFrmSelected() || !Imp()->HasDrawView() ) + return sal_False; + else + return Imp()->GetDrawView() + ->IsObjMarked( const_cast< SdrObject * >( &rObj ) ); +} +#endif + Rectangle *SwFEShell::IsAnchorAtPos( const Point &rPt ) const { if ( !Imp()->HasDrawView() ) diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index 798d23e002a5..b1f5039c1c12 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: viewimp.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: dvo $ $Date: 2002-04-26 13:22:00 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:21:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,6 +89,7 @@ class SdrPaintInfoRec; struct SdrPaintProcRec; #ifdef ACCESSIBLE_LAYOUT class SwAccessibleMap; +class SdrObject; #endif class SwViewImp @@ -255,15 +256,22 @@ public: void UpdateAccessible(); // Remove a frame from the accessible view - void DisposeAccessibleFrm( const SwFrm *pFrm, + void DisposeAccessible( const SwFrm *pFrm, const SdrObject *pObj, + sal_Bool bRecursive ); + inline void DisposeAccessibleFrm( const SwFrm *pFrm, sal_Bool bRecursive=sal_False ); + inline void DisposeAccessibleObj( const SdrObject *pObj ); // Move a frame's position in the accessible view - void MoveAccessibleFrm( const SwFrm *pFrm, const SwRect& rOldFrm ); + void MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj, + const SwRect& rOldFrm ); + inline void MoveAccessibleFrm( const SwFrm *pFrm, const SwRect& rOldFrm ); // Add a frame in the accessible view inline void AddAccessibleFrm( const SwFrm *pFrm ); + inline void AddAccessibleObj( const SdrObject *pObj ); + // Invalidate accessible frame's frame's content void InvalidateAccessibleFrmContent( const SwFrm *pFrm ); @@ -322,10 +330,33 @@ inline SwAccessibleMap& SwViewImp::GetAccessibleMap() return *pAccMap; } +inline void SwViewImp::DisposeAccessibleFrm( const SwFrm *pFrm, + sal_Bool bRecursive ) +{ + DisposeAccessible( pFrm, 0, bRecursive ); +} + +inline void SwViewImp::DisposeAccessibleObj( const SdrObject *pObj ) +{ + DisposeAccessible( 0, pObj, sal_False ); +} + +inline void SwViewImp::MoveAccessibleFrm( const SwFrm *pFrm, + const SwRect& rOldFrm ) +{ + MoveAccessible( pFrm, 0, rOldFrm ); +} + inline void SwViewImp::AddAccessibleFrm( const SwFrm *pFrm ) { SwRect aEmptyRect; - MoveAccessibleFrm( pFrm, aEmptyRect ); + MoveAccessible( pFrm, 0, aEmptyRect ); +} + +inline void SwViewImp::AddAccessibleObj( const SdrObject *pObj ) +{ + SwRect aEmptyRect; + MoveAccessible( 0, pObj, aEmptyRect ); } #endif diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 6434522b6e41..d18d48828768 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fly.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: mib $ $Date: 2002-05-03 12:36:42 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:20:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -518,7 +518,7 @@ void SwFlyFrm::ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow ) #ifdef ACCESSIBLE_LAYOUT // invalidate accessible relation set (accessibility wrapper) ViewShell* pSh = pMaster->GetShell(); - if( pSh ) + if( pSh && pSh->GetLayout()->IsAnyShellAccessible() ) pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow ); #endif @@ -565,7 +565,7 @@ void SwFlyFrm::UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow ) #ifdef ACCESSIBLE_LAYOUT // invalidate accessible relation set (accessibility wrapper) ViewShell* pSh = pMaster->GetShell(); - if( pSh ) + if( pSh && pSh->GetLayout()->IsAnyShellAccessible() ) pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow ); #endif } @@ -2409,12 +2409,25 @@ void SwFrm::AppendDrawObj( SwDrawContact *pNew ) SwPageFrm *pPage = FindPageFrm(); if ( pPage ) pPage->SwPageFrm::AppendDrawObj( pNew ); + +#ifdef ACCESSIBLE_LAYOUT + // Notify accessible layout. + ViewShell* pSh = GetShell(); + if( pSh && pSh->GetLayout()->IsAnyShellAccessible() ) + pSh->Imp()->AddAccessibleObj( pNew->GetMaster() ); +#endif } void SwFrm::RemoveDrawObj( SwDrawContact *pToRemove ) { //Bei der Seite Abmelden - kann schon passiert sein weil die Seite //bereits destruiert wurde. +#ifdef ACCESSIBLE_LAYOUT + // Notify accessible layout. + ViewShell* pSh = GetShell(); + if( pSh && pSh->GetLayout()->IsAnyShellAccessible() ) + pSh->Imp()->DisposeAccessibleObj( pToRemove->GetMaster() ); +#endif SwPageFrm *pPage = pToRemove->GetPage(); if ( pPage && pPage->GetSortedObjs() ) pPage->SwPageFrm::RemoveDrawObj( pToRemove ); diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index 333277d93c6d..1efd6d835c7c 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: viewimp.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: dvo $ $Date: 2002-04-24 15:23:09 $ + * last change: $Author: mib $ $Date: 2002-05-15 13:21:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -400,28 +400,31 @@ void SwViewImp::UpdateAccessible() GetAccessibleMap().GetDocumentView(); } -void SwViewImp::DisposeAccessibleFrm( const SwFrm *pFrm, sal_Bool bRecursive ) +void SwViewImp::DisposeAccessible( const SwFrm *pFrm, + const SdrObject *pObj, + sal_Bool bRecursive ) { - ASSERT( pFrm->IsAccessibleFrm(), "frame is not accessible" ); + ASSERT( !pFrm || pFrm->IsAccessibleFrm(), "frame is not accessible" ); ViewShell *pVSh = GetShell(); ViewShell *pTmp = pVSh; do { if( pTmp->Imp()->IsAccessible() ) - pTmp->Imp()->GetAccessibleMap().Dispose( pFrm, bRecursive ); + pTmp->Imp()->GetAccessibleMap().Dispose( pFrm, pObj, bRecursive ); pTmp = (ViewShell *)pTmp->GetNext(); } while ( pTmp != pVSh ); } -void SwViewImp::MoveAccessibleFrm( const SwFrm *pFrm, const SwRect& rOldFrm ) +void SwViewImp::MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj, + const SwRect& rOldFrm ) { - ASSERT( pFrm->IsAccessibleFrm(), "frame is not accessible" ); + ASSERT( !pFrm || pFrm->IsAccessibleFrm(), "frame is not accessible" ); ViewShell *pVSh = GetShell(); ViewShell *pTmp = pVSh; do { if( pTmp->Imp()->IsAccessible() ) - pTmp->Imp()->GetAccessibleMap().InvalidatePosOrSize( pFrm, + pTmp->Imp()->GetAccessibleMap().InvalidatePosOrSize( pFrm, pObj, rOldFrm ); pTmp = (ViewShell *)pTmp->GetNext(); } while ( pTmp != pVSh ); |