From 84a72b88e50b60765fadd00c8caa73112a7e5830 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Tue, 2 Feb 2010 15:11:26 +0100 Subject: sw33a11y01: #i88070# - accessible Writer comments - part 1 --- sw/inc/AnnotationWin.hxx | 6 +- sw/inc/PostItMgr.hxx | 35 +- sw/inc/SidebarWin.hxx | 12 +- sw/inc/accmap.hxx | 91 +----- sw/inc/postithelper.hxx | 16 +- sw/inc/viewsh.hxx | 10 +- sw/source/core/access/acccell.cxx | 30 +- sw/source/core/access/acccell.hxx | 4 +- sw/source/core/access/acccontext.cxx | 285 +++++++++++----- sw/source/core/access/acccontext.hxx | 33 +- sw/source/core/access/accdoc.cxx | 4 +- sw/source/core/access/accfootnote.hxx | 10 +- sw/source/core/access/accframe.cxx | 266 ++++++++------- sw/source/core/access/accframe.hxx | 118 ++++--- sw/source/core/access/accframebase.hxx | 10 +- sw/source/core/access/accfrmobj.cxx | 380 +++++++++++++++++++++- sw/source/core/access/accfrmobj.hxx | 210 +++--------- sw/source/core/access/accfrmobjmap.cxx | 150 ++++++--- sw/source/core/access/accfrmobjmap.hxx | 92 +++--- sw/source/core/access/accfrmobjslist.cxx | 127 +++++--- sw/source/core/access/accfrmobjslist.hxx | 189 +++++------ sw/source/core/access/accmap.cxx | 446 +++++++++++++++----------- sw/source/core/access/accpara.cxx | 41 +-- sw/source/core/access/accpara.hxx | 20 +- sw/source/core/access/accselectionhelper.cxx | 75 ++--- sw/source/core/access/acctable.cxx | 106 +++--- sw/source/core/access/acctable.hxx | 16 +- sw/source/core/fields/postithelper.cxx | 58 +++- sw/source/core/inc/viewimp.hxx | 13 +- sw/source/core/view/viewsh.cxx | 9 + sw/source/ui/docvw/AnnotationWin.cxx | 7 +- sw/source/ui/docvw/PostItMgr.cxx | 126 ++++++-- sw/source/ui/docvw/SidebarTxtControl.cxx | 57 ++-- sw/source/ui/docvw/SidebarTxtControl.hxx | 10 +- sw/source/ui/docvw/SidebarTxtControlAcc.cxx | 88 ++++- sw/source/ui/docvw/SidebarWin.cxx | 72 ++++- sw/source/ui/docvw/SidebarWinAcc.cxx | 156 +++++++++ sw/source/ui/docvw/SidebarWinAcc.hxx | 67 ++++ sw/source/ui/docvw/edtwin.cxx | 2 +- sw/source/ui/docvw/frmsidebarwincontainer.cxx | 204 ++++++++++++ sw/source/ui/docvw/frmsidebarwincontainer.hxx | 73 +++++ sw/source/ui/docvw/makefile.mk | 2 + 42 files changed, 2444 insertions(+), 1282 deletions(-) create mode 100644 sw/source/ui/docvw/SidebarWinAcc.cxx create mode 100644 sw/source/ui/docvw/SidebarWinAcc.hxx create mode 100644 sw/source/ui/docvw/frmsidebarwincontainer.cxx create mode 100644 sw/source/ui/docvw/frmsidebarwincontainer.hxx diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 38388fd8e985..ef39ad6e4c8f 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -35,6 +35,7 @@ #include class PopupMenu; +class OutlinerParaObject; namespace sw { namespace annotation { @@ -43,9 +44,10 @@ class SwAnnotationWin : public sw::sidebarwindows::SwSidebarWin public: SwAnnotationWin( SwEditWin& rEditWin, WinBits nBits, - SwFmtFld* aField, SwPostItMgr& aMgr, - SwPostItBits aBits ); + SwPostItBits aBits, + SwSidebarItem& rSidebarItem, + SwFmtFld* aField ); virtual ~SwAnnotationWin(); virtual void UpdateData(); diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 8b2e85945989..48249b794f43 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -62,8 +62,11 @@ namespace sw { namespace annotation { }} namespace sw { namespace sidebarwindows { class SwSidebarWin; + class SwFrmSidebarWinContainer; }} class SwSidebarItem; +class SwFrm; +class Window; #define SORT_POS 1 #define SORT_AUTHOR 2 @@ -108,23 +111,23 @@ struct FieldShadowState class SwNoteProps: public utl::ConfigItem { private: - bool bIsShowAnkor; + bool bIsShowAnchor; public: SwNoteProps() : ConfigItem(::rtl::OUString::createFromAscii("Office.Writer/Notes")) - , bIsShowAnkor(false) + , bIsShowAnchor(false) { const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames = GetPropertyNames(); ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aValues = GetProperties(rNames); const ::com::sun::star::uno::Any* pValues = aValues.getConstArray(); DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); if (aValues.getLength()) - pValues[0]>>=bIsShowAnkor; + pValues[0]>>=bIsShowAnchor; } - bool IsShowAnkor() + bool IsShowAnchor() { - return bIsShowAnkor; + return bIsShowAnchor; } ::com::sun::star::uno::Sequence< ::rtl::OUString >& GetPropertyNames() { @@ -163,7 +166,10 @@ class SwPostItMgr: public SfxListener bool mbDeleteNote; FieldShadowState mShadowState; OutlinerParaObject* mpAnswer; - bool mpIsShowAnkor; + bool mbIsShowAnchor; + + // data structure to collect the instances for certain instances. + sw::sidebarwindows::SwFrmSidebarWinContainer* mpFrmSidebarWinContainer; typedef std::list::iterator SwSidebarWin_iterator; @@ -216,7 +222,7 @@ class SwPostItMgr: public SfxListener bool ShowScrollbar(const unsigned long aPage) const; bool HasNotes() const ; bool ShowNotes() const; - bool IsShowAnkor() { return mpIsShowAnkor;} + bool IsShowAnchor() { return mbIsShowAnchor;} unsigned long GetSidebarWidth(bool bPx = false) const; unsigned long GetSidebarBorderWidth(bool bPx = false) const; unsigned long GetNoteWidth(); @@ -265,7 +271,7 @@ class SwPostItMgr: public SfxListener Color GetColorDark(sal_uInt16 aAuthorIndex); Color GetColorLight(sal_uInt16 aAuthorIndex); - Color GetColorAnkor(sal_uInt16 aAuthorIndex); + Color GetColorAnchor(sal_uInt16 aAuthorIndex); bool ShowPreview(const SwField* pFld,SwFmtFld*& pFmtFld) const; @@ -278,7 +284,18 @@ class SwPostItMgr: public SfxListener sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); - void AssureStdModeAtShell(); + void AssureStdModeAtShell(); + + void ConnectSidebarWinToFrm( const SwFrm& rFrm, + const SwFmtFld& rFmtFld, + sw::sidebarwindows::SwSidebarWin& rSidebarWin ); + void DisconnectSidebarWinFromFrm( const SwFrm& rFrm, + sw::sidebarwindows::SwSidebarWin& rSidebarWin ); + bool HasFrmConnectedSidebarWins( const SwFrm& rFrm ); + Window* GetSidebarWinForFrmByIndex( const SwFrm& rFrm, + const sal_Int32 nIndex ); + void GetAllSidebarWinForFrm( const SwFrm& rFrm, + std::vector< Window* >* pChildren ); }; #endif diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index c7b81cf1d18f..abeba2e2c6aa 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -47,7 +47,6 @@ class SwPostItMgr; class SwPostItField; -class SwFmtFld; class OutlinerView; class Outliner; class ScrollBar; @@ -56,7 +55,8 @@ class SwView; class Edit; class MenuButton; //class SwRedline; -class OutlinerParaObject; +class SwFrm; + namespace sw { namespace sidebarwindows { @@ -75,7 +75,8 @@ class SwSidebarWin : public Window SwSidebarWin( SwEditWin& rEditWin, WinBits nBits, SwPostItMgr& aMgr, - SwPostItBits aBits ); + SwPostItBits aBits, + SwSidebarItem& rSidebarItem ); virtual ~SwSidebarWin(); void SetSize( const Size& rNewSize ); @@ -175,6 +176,9 @@ class SwSidebarWin : public Window void SetLanguage(const SvxLanguageItem aNewItem); + void ChangeSidebarItem( SwSidebarItem& rSidebarItem ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + protected: virtual void DataChanged( const DataChangedEvent& aEvent); virtual void LoseFocus(); @@ -232,6 +236,8 @@ class SwSidebarWin : public Window bool mbReadonly; bool mbIsFollow; + + SwSidebarItem& mrSidebarItem; }; } } // eof namespace sw::sidebarwindows diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx index ba18cf599872..ce8ffa4514bf 100644 --- a/sw/inc/accmap.hxx +++ b/sw/inc/accmap.hxx @@ -36,14 +36,15 @@ #include #include #include -#include "viewsh.hxx" #include #include #include +class ViewShell; class Rectangle; class SwFrm; +class SwTxtFrm; class SwPageFrm; class SwAccessibleContext; class SwAccessibleContextMap_Impl; @@ -51,85 +52,18 @@ class SwAccessibleEventList_Impl; class SwAccessibleEventMap_Impl; class SwShapeList_Impl; class SdrObject; -namespace accessibility { class AccessibleShape; } +namespace accessibility { + class AccessibleShape; +} class SwAccessibleShapeMap_Impl; struct SwAccessibleEvent_Impl; -// --> OD 2005-12-13 #i27301# class SwAccessibleSelectedParas_Impl; -// <-- class SwRect; class MapMode; class SwAccPreviewData; -// OD 14.01.2003 #103492# -#ifndef _PREVWPAGE_HXX -#include -#endif - -// helper class that stores preview data -class SwAccPreviewData -{ - typedef std::vector Rectangles; - Rectangles maPreviewRects; - Rectangles maLogicRects; - - SwRect maVisArea; - Fraction maScale; - - const SwPageFrm *mpSelPage; - - /** adjust logic page retangle to its visible part - - OD 17.01.2003 #103492# - - @author OD - - @param _iorLogicPgSwRect - input/output parameter - reference to the logic page rectangle, which - has to be adjusted. - - @param _rPrevwPgSwRect - input parameter - constant reference to the corresponding preview page - rectangle; needed to determine the visible part of the logic page rectangle. - - @param _rPrevwWinSize - input paramter - constant reference to the preview window size in TWIP; - needed to determine the visible part of the logic page rectangle - */ - void AdjustLogicPgRectToVisibleArea( SwRect& _iorLogicPgSwRect, - const SwRect& _rPrevwPgSwRect, - const Size& _rPrevwWinSize ); - -public: - SwAccPreviewData(); - ~SwAccPreviewData(); - - // OD 14.01.2003 #103492# - complete re-factoring of method due to new - // page/print preview functionality. - void Update( const std::vector& _rPrevwPages, - const Fraction& _rScale, - const SwPageFrm* _pSelectedPageFrm, - const Size& _rPrevwWinSize ); - - // OD 14.01.2003 #103492# - complete re-factoring of method due to new - // page/print preview functionality. - void InvalidateSelection( const SwPageFrm* _pSelectedPageFrm ); - - const SwRect& GetVisArea() const; - - MapMode GetMapModeForPreview( ) const; - - /** Adjust the MapMode so that the preview page appears at the - * proper position. rPoint identifies the page for which the - * MapMode should be adjusted. If bFromPreview is true, rPoint is - * a preview coordinate; else it's a document coordinate. */ - // OD 17.01.2003 #103492# - delete unused 3rd parameter. - void AdjustMapMode( MapMode& rMapMode, - const Point& rPoint ) const; - - inline const SwPageFrm *GetSelPage() const { return mpSelPage; } - - void DisposePage(const SwPageFrm *pPageFrm ); -}; +struct PrevwPage; +class Window; +class SwFmtFld; // real states for events #define ACC_STATE_EDITABLE 0x01 @@ -249,14 +183,7 @@ public: return mpVSh; } - inline const SwRect& GetVisArea() const - { - DBG_ASSERT( !GetShell()->IsPreView() || (mpPreview != NULL), - "preview without preview data?" ); - return GetShell()->IsPreView() - ? mpPreview->GetVisArea() - : GetShell()->VisArea(); - } + const SwRect& GetVisArea() const; /** get size of a dedicated preview page diff --git a/sw/inc/postithelper.hxx b/sw/inc/postithelper.hxx index 5d9d58ed75d7..4f9d04dc4ab7 100644 --- a/sw/inc/postithelper.hxx +++ b/sw/inc/postithelper.hxx @@ -54,7 +54,7 @@ typedef sal_Int64 SwPostItBits; struct SwLayoutInfo { - SwFrm* mpAssociatedFrm; + const SwFrm* mpAnchorFrm; SwRect mPosition; SwRect mPageFrame; SwRect mPagePrtArea; @@ -63,7 +63,7 @@ struct SwLayoutInfo USHORT mRedlineAuthor; SwLayoutInfo() - : mpAssociatedFrm(0) + : mpAnchorFrm(0) , mPosition() , mPageFrame() , mPagePrtArea() @@ -106,9 +106,9 @@ public: , maLayoutInfo() {} virtual ~SwSidebarItem(){} - virtual SwPosition GetPosition() = 0; + virtual SwPosition GetAnchorPosition() const = 0; virtual bool UseElement() = 0; - virtual SwFmtFld* GetFmtFld() = 0; + virtual SwFmtFld* GetFmtFld() const = 0; virtual SfxBroadcaster* GetBroadCaster() const = 0; virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin, WinBits nBits, @@ -126,9 +126,9 @@ public: : SwSidebarItem(aShow,aFocus), pRedline(pRed) {} virtual ~SwRedCommentItem() {} - virtual SwPosition GetPosition(); + virtual SwPosition GetAnchorPosition() const; virtual bool UseElement(); - virtual SwFmtFld* GetFmtFld() {return 0; } + virtual SwFmtFld* GetFmtFld() const {return 0; } virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast (pRedline); } virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin, WinBits nBits, @@ -150,9 +150,9 @@ class SwAnnotationItem: public SwSidebarItem , pFmtFld(p) {} virtual ~SwAnnotationItem() {} - virtual SwPosition GetPosition(); + virtual SwPosition GetAnchorPosition() const; virtual bool UseElement(); - virtual SwFmtFld* GetFmtFld() {return pFmtFld;} + virtual SwFmtFld* GetFmtFld() const {return pFmtFld;} virtual SfxBroadcaster* GetBroadCaster() const { return dynamic_cast (pFmtFld); } virtual sw::sidebarwindows::SwSidebarWin* GetSidebarWindow( SwEditWin& rEditWin, WinBits nBits, diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 7a8d0eb0c273..abf2111edc6b 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -78,19 +78,15 @@ struct ShellResource; class SwRegionRects; class SwFrm; class SvtAccessibilityOptions; -// OD 12.12.2002 #103492# class SwPagePreviewLayout; -// --> OD 2005-12-01 #i27138# class SwTxtFrm; -// <-- class BitmapEx; struct SwAccessibilityOptions; class Region; class SwPostItMgr; - -// #i74769# class SdrPaintWindow; +class SwAccessibleMap; //JP 19.07.98: - Bug 52312 // define fuer Flags, die im CTOR oder den darunter liegenden Schichten @@ -266,7 +262,7 @@ public: sal_Bool SmoothScroll( long lXDiff, long lYDiff, const Rectangle* );//Browser void EnableSmooth( sal_Bool b ) { bEnableSmooth = b; } - const SwRect &VisArea() const { return aVisArea; } + const SwRect& VisArea() const { return aVisArea; } //Es wird, wenn notwendig, soweit gescrollt, dass das //uebergebene Rect im sichtbaren Ausschnitt liegt. void MakeVisible( const SwRect & ); @@ -575,6 +571,8 @@ public: */ void InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm ); + SwAccessibleMap* GetAccessibleMap(); + ViewShell( ViewShell&, Window *pWin = 0, OutputDevice *pOut = 0, long nFlags = 0 ); ViewShell( SwDoc& rDoc, Window *pWin, diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index 98a603c8ccb4..5958adead0ea 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -44,6 +44,7 @@ #include #include "crsrsh.hxx" #include "viscrs.hxx" +#include #include #include "frmfmt.hxx" #include "cellatr.hxx" @@ -59,6 +60,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; +using namespace sw::access; const sal_Char sServiceName[] = "com.sun.star.table.AccessibleCellView"; const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleCellView"; @@ -86,8 +88,7 @@ sal_Bool SwAccessibleCell::IsSelected() return bRet; } -void SwAccessibleCell::GetStates( - ::utl::AccessibleStateSetHelper& rStateSet ) +void SwAccessibleCell::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) { SwAccessibleContext::GetStates( rStateSet ); @@ -107,11 +108,10 @@ void SwAccessibleCell::GetStates( } } -SwAccessibleCell::SwAccessibleCell( - SwAccessibleMap *pInitMap, - const SwCellFrm *pCellFrm ) : - SwAccessibleContext( pInitMap, AccessibleRole::TABLE_CELL, pCellFrm ), - bIsSelected( sal_False ) +SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap, + const SwCellFrm *pCellFrm ) + : SwAccessibleContext( pInitMap, AccessibleRole::TABLE_CELL, pCellFrm ) + , bIsSelected( sal_False ) { vos::OGuard aGuard(Application::GetSolarMutex()); OUString sBoxName( pCellFrm->GetTabBox()->GetName() ); @@ -148,11 +148,11 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) { sal_Bool bChanged = sal_False; - const SwFrmOrObjSList aVisList( GetVisArea(), pFrm ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + const SwAccessibleChildSList aVisList( GetVisArea(), *pFrm, *GetMap() ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; const SwFrm *pLower = rLower.GetSwFrm(); if( pLower ) { @@ -187,7 +187,7 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) void SwAccessibleCell::_InvalidateCursorPos() { - const SwFrm *pParent = GetParent( SwFrmOrObj(GetFrm()), IsInPagePreview() ); + const SwFrm *pParent = GetParent( SwAccessibleChild(GetFrm()), IsInPagePreview() ); ASSERT( pParent->IsTabFrm(), "parent is not a tab frame" ); const SwTabFrm *pTabFrm = static_cast< const SwTabFrm * >( pParent ); if( pTabFrm->IsFollow() ) @@ -256,21 +256,21 @@ uno::Sequence< OUString > SAL_CALL SwAccessibleCell::getSupportedServiceNames() void SwAccessibleCell::Dispose( sal_Bool bRecursive ) { - const SwFrm *pParent = GetParent( SwFrmOrObj(GetFrm()), IsInPagePreview() ); + const SwFrm *pParent = GetParent( SwAccessibleChild(GetFrm()), IsInPagePreview() ); ::vos::ORef< SwAccessibleContext > xAccImpl( GetMap()->GetContextImpl( pParent, sal_False ) ); if( xAccImpl.isValid() ) - xAccImpl->DisposeChild( SwFrmOrObj(GetFrm()), bRecursive ); + xAccImpl->DisposeChild( SwAccessibleChild(GetFrm()), bRecursive ); SwAccessibleContext::Dispose( bRecursive ); } void SwAccessibleCell::InvalidatePosOrSize( const SwRect& rOldBox ) { - const SwFrm *pParent = GetParent( SwFrmOrObj(GetFrm()), IsInPagePreview() ); + const SwFrm *pParent = GetParent( SwAccessibleChild(GetFrm()), IsInPagePreview() ); ::vos::ORef< SwAccessibleContext > xAccImpl( GetMap()->GetContextImpl( pParent, sal_False ) ); if( xAccImpl.isValid() ) - xAccImpl->InvalidateChildPosOrSize( SwFrmOrObj(GetFrm()), rOldBox ); + xAccImpl->InvalidateChildPosOrSize( SwAccessibleChild(GetFrm()), rOldBox ); SwAccessibleContext::InvalidatePosOrSize( rOldBox ); } diff --git a/sw/source/core/access/acccell.hxx b/sw/source/core/access/acccell.hxx index 147842fad54b..e1865bf6e0a2 100644 --- a/sw/source/core/access/acccell.hxx +++ b/sw/source/core/access/acccell.hxx @@ -29,12 +29,12 @@ ************************************************************************/ #ifndef _ACCCELL_HXX #define _ACCCELL_HXX -#ifndef _ACCCONTEXT_HXX + #include "acccontext.hxx" -#endif #include class SwCellFrm; +class SwFrmFmt; class SwAccessibleCell : public SwAccessibleContext, ::com::sun::star::accessibility::XAccessibleValue diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index 56a6fce1cf7c..e1400d050e3d 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -41,8 +41,8 @@ #endif // #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB #include #include -#include "errhdl.hxx" -#include "swtypes.hxx" +#include +#include #include #include @@ -54,9 +54,12 @@ #include #include #include -#include "fesh.hxx" +#include #include #include +#include +#include +#include #include #include #include @@ -64,7 +67,9 @@ #include #include #include +#include +using namespace sw::access; #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB #define DBG_MSG( _msg ) \ @@ -93,10 +98,10 @@ using ::rtl::OUString; void SwAccessibleContext::InitStates() { - bIsShowingState = IsShowing(); + bIsShowingState = GetMap() ? IsShowing( *(GetMap()) ) : sal_False; ViewShell *pVSh = GetMap()->GetShell(); - bIsEditableState = pVSh && IsEditable( pVSh ); + bIsEditableState = pVSh && IsEditable( pVSh ); bIsOpaqueState = pVSh && IsOpaque( pVSh ); bIsDefuncState = sal_False; } @@ -167,21 +172,20 @@ enum Action { NONE, SCROLLED, SCROLLED_WITHIN, SCROLLED_IN, SCROLLED_OUT }; void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, - const SwRect& rOldVisArea ) + const SwRect& rOldVisArea ) { const SwRect& rNewVisArea = GetVisArea(); - SwFrmOrObj aFrm( pFrm ); - sal_Bool bVisibleOnly = aFrm.IsVisibleChildrenOnly(); + SwAccessibleChild aFrm( pFrm ); + bool bVisibleOnly = aFrm.IsVisibleChildrenOnly(); uno::Reference < XAccessible > xAcc; - const SwFrmOrObjSList aList( pFrm ); - SwFrmOrObjSList::const_iterator aIter( aList.begin() ); + const SwAccessibleChildSList aList( *pFrm, *(GetMap()) ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); while( aIter != aList.end() ) { - const SwFrmOrObj& rLower = *aIter; - const SwFrm *pLower = rLower.GetSwFrm(); - SwRect aBox( rLower.GetBox() ); + const SwAccessibleChild& rLower = *aIter; + const SwRect aBox( rLower.GetBox( *(GetMap()) ) ); if( rLower.IsAccessible( GetShell()->IsPreView() ) ) { Action eAction = NONE; @@ -214,8 +218,9 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, } if( NONE != eAction ) { - if( pLower ) + if ( rLower.GetSwFrm() ) { + const SwFrm* pLower( rLower.GetSwFrm() ); ::vos::ORef< SwAccessibleContext > xAccImpl = GetMap()->GetContextImpl( pLower, SCROLLED_OUT == eAction || SCROLLED_IN == eAction ); @@ -244,10 +249,10 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, ChildrenScrolled( pLower, rOldVisArea ); } } - else + else if ( rLower.GetDrawObject() ) { ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl = - GetMap()->GetContextImpl( rLower.GetSdrObject(), + GetMap()->GetContextImpl( rLower.GetDrawObject(), this, SCROLLED_OUT == eAction || SCROLLED_IN == eAction ); @@ -262,7 +267,7 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, GetMap() ); break; case SCROLLED_IN: - ScrolledInShape( rLower.GetSdrObject(), + ScrolledInShape( rLower.GetDrawObject(), xAccImpl.getBodyPtr() ); break; case SCROLLED_OUT: @@ -270,7 +275,7 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, xAccImpl->ViewForwarderChanged( ::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, GetMap() ); - DisposeShape( rLower.GetSdrObject(), + DisposeShape( rLower.GetDrawObject(), xAccImpl.getBodyPtr() ); } break; @@ -279,14 +284,40 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm, } } } + else if ( rLower.GetWindow() ) + { + switch( eAction ) + { + case SCROLLED: + case SCROLLED_WITHIN: + // nothing to do + break; + case SCROLLED_IN: + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + uno::Reference< XAccessible > xAcc = + rLower.GetWindow()->GetAccessible(); + aEvent.NewValue <<= xAcc; + FireAccessibleEvent( aEvent ); + } + break; + case SCROLLED_OUT: + DisposeChild( rLower, sal_False ); + break; + case NONE: + break; + } + } } } - else if( pLower && (!bVisibleOnly || - aBox.IsOver( rOldVisArea ) || - aBox.IsOver( rNewVisArea )) ) + else if ( rLower.GetSwFrm() && + ( !bVisibleOnly || + aBox.IsOver( rOldVisArea ) || + aBox.IsOver( rNewVisArea ) ) ) { // There are no unaccessible SdrObjects that need to be notified - ChildrenScrolled( pLower, rOldVisArea ); + ChildrenScrolled( rLower.GetSwFrm(), rOldVisArea ); } ++aIter; } @@ -299,7 +330,7 @@ void SwAccessibleContext::Scrolled( const SwRect& rOldVisArea ) ChildrenScrolled( GetFrm(), rOldVisArea ); sal_Bool bIsOldShowingState; - sal_Bool bIsNewShowingState = IsShowing(); + sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) ); { vos::OGuard aGuard( aMutex ); bIsOldShowingState = bIsShowingState; @@ -329,7 +360,7 @@ void SwAccessibleContext::ScrolledIn() "Vis area of child is wrong. Did it exist already?" ); // Send child event at parent. That's all we have to do here. - const SwFrm *pParent = GetParent(); + const SwFrm* pParent = GetParent(); ::vos::ORef< SwAccessibleContext > xParentImpl( GetMap()->GetContextImpl( pParent, sal_False ) ); uno::Reference < XAccessibleContext > xThis( this ); @@ -381,13 +412,13 @@ void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea ) void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm, tAccessibleStates _nStates ) { - const SwFrmOrObjSList aVisList( GetVisArea(), _pFrm ); + const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrm, *(GetMap()) ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; - const SwFrm *pLower = rLower.GetSwFrm(); + const SwAccessibleChild& rLower = *aIter; + const SwFrm* pLower = rLower.GetSwFrm(); if( pLower ) { ::vos::ORef< SwAccessibleContext > xAccImpl; @@ -398,10 +429,15 @@ void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm, else InvalidateChildrenStates( pLower, _nStates ); } - else + else if ( rLower.GetDrawObject() ) { // TODO: SdrObjects } + else if ( rLower.GetWindow() ) + { + // nothing to do ? + } + ++aIter; } } @@ -410,12 +446,12 @@ void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm, void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm, sal_Bool bRecursive ) { - const SwFrmOrObjSList aVisList( GetVisArea(), pFrm ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + const SwAccessibleChildSList aVisList( GetVisArea(), *pFrm, *(GetMap()) ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; - const SwFrm *pLower = rLower.GetSwFrm(); + const SwAccessibleChild& rLower = *aIter; + const SwFrm* pLower = rLower.GetSwFrm(); if( pLower ) { ::vos::ORef< SwAccessibleContext > xAccImpl; @@ -426,13 +462,17 @@ void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm, else if( bRecursive ) DisposeChildren( pLower, bRecursive ); } - else + else if ( rLower.GetDrawObject() ) { ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl( - GetMap()->GetContextImpl( rLower.GetSdrObject(), + GetMap()->GetContextImpl( rLower.GetDrawObject(), this, sal_False ) ); if( xAccImpl.isValid() ) - DisposeShape( rLower.GetSdrObject(), xAccImpl.getBodyPtr() ); + DisposeShape( rLower.GetDrawObject(), xAccImpl.getBodyPtr() ); + } + else if ( rLower.GetWindow() ) + { + DisposeChild( rLower, sal_False ); } ++aIter; } @@ -530,16 +570,14 @@ sal_Bool SwAccessibleContext::IsEditableState() SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM, sal_Int16 nR, - const SwFrm *pF ) : - SwAccessibleFrame( pM->GetVisArea().SVRect(), pF, - pM->GetShell()->IsPreView() ), - pMap( pM ), - nClientId(0), - nRole( nR ), - bDisposing( sal_False ), - // --> OD 2008-03-10 #i85634# - bRegisteredAtAccessibleMap( true ) - // <-- + const SwFrm *pF ) + : SwAccessibleFrame( pM->GetVisArea().SVRect(), pF, + pM->GetShell()->IsPreView() ) + , pMap( pM ) + , nClientId(0) + , nRole( nR ) + , bDisposing( sal_False ) + , bRegisteredAtAccessibleMap( true ) { InitStates(); DBG_MSG_CD( "constructed" ) @@ -550,11 +588,7 @@ SwAccessibleContext::~SwAccessibleContext() vos::OGuard aGuard(Application::GetSolarMutex()); DBG_MSG_CD( "destructed" ) - // --> OD 2008-03-10 #i85634# -// if( GetFrm() && GetMap() ) -// GetMap()->RemoveContext( GetFrm() ); RemoveFrmFromAccessibleMap(); - // <-- } uno::Reference< XAccessibleContext > SAL_CALL @@ -572,7 +606,7 @@ sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleChildCount( void ) CHECK_FOR_DEFUNC( XAccessibleContext ) - return bDisposing ? 0 : GetChildCount(); + return bDisposing ? 0 : GetChildCount( *(GetMap()) ); } uno::Reference< XAccessible> SAL_CALL @@ -583,7 +617,7 @@ uno::Reference< XAccessible> SAL_CALL CHECK_FOR_DEFUNC( XAccessibleContext ) - const SwFrmOrObj aChild( GetChild( nIndex ) ); + const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) ); if( !aChild.IsValid() ) { uno::Reference < XAccessibleContext > xThis( this ); @@ -604,14 +638,18 @@ uno::Reference< XAccessible> SAL_CALL xChild = xChildImpl.getBodyPtr(); } } - else + else if ( aChild.GetDrawObject() ) { ::vos::ORef < ::accessibility::AccessibleShape > xChildImpl( - GetMap()->GetContextImpl( aChild.GetSdrObject(), + GetMap()->GetContextImpl( aChild.GetDrawObject(), this, !bDisposing ) ); if( xChildImpl.isValid() ) xChild = xChildImpl.getBodyPtr(); } + else if ( aChild.GetWindow() ) + { + xChild = aChild.GetWindow()->GetAccessible(); + } return xChild; } @@ -658,7 +696,7 @@ sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleIndexInParent (void) GetMap()->GetContextImpl( pUpper, !bDisposing ) ); ASSERT( xAccImpl.isValid() || bDisposing, "no parent found" ); if( xAccImpl.isValid() ) - nIndex = xAccImpl->GetChildIndex( SwFrmOrObj(GetFrm()) ); + nIndex = xAccImpl->GetChildIndex( *(GetMap()), SwAccessibleChild(GetFrm()) ); } return nIndex; @@ -794,20 +832,24 @@ uno::Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAtPoint Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to parent if( !GetFrm()->IsRootFrm() ) { - SwRect aLogBounds( GetBounds( GetFrm() ) ); // twip rel to doc root + SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root Point aPixPos( GetMap()->CoreToPixel( aLogBounds.SVRect() ).TopLeft() ); aPixPoint.X() += aPixPos.X(); aPixPoint.Y() += aPixPos.Y(); } - const SwFrmOrObj aChild( GetChildAtPixel( aPixPoint, GetMap() ) ); + const SwAccessibleChild aChild( GetChildAtPixel( aPixPoint, *(GetMap()) ) ); if( aChild.GetSwFrm() ) { xAcc = GetMap()->GetContext( aChild.GetSwFrm() ); } - else if( aChild.GetSdrObject() ) + else if( aChild.GetDrawObject() ) + { + xAcc = GetMap()->GetContext( aChild.GetDrawObject(), this ); + } + else if ( aChild.GetWindow() ) { - xAcc = GetMap()->GetContext( aChild.GetSdrObject(), this ); + xAcc = aChild.GetWindow()->GetAccessible(); } return xAcc; @@ -845,7 +887,7 @@ awt::Rectangle SAL_CALL SwAccessibleContext::getBoundsImpl(sal_Bool bRelative) CHECK_FOR_WINDOW( XAccessibleComponent, pWin && pParent ) - SwRect aLogBounds( GetBounds( GetFrm() ) ); // twip rel to doc root + SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root Rectangle aPixBounds( 0, 0, 0, 0 ); if( GetFrm()->IsPageFrm() && static_cast < const SwPageFrm * >( GetFrm() )->IsEmptyPage() ) @@ -864,7 +906,7 @@ awt::Rectangle SAL_CALL SwAccessibleContext::getBoundsImpl(sal_Bool bRelative) aPixBounds = GetMap()->CoreToPixel( aLogBounds.SVRect() ); if( !pParent->IsRootFrm() && bRelative) { - SwRect aParentLogBounds( GetBounds( pParent ) ); // twip rel to doc root + SwRect aParentLogBounds( GetBounds( *(GetMap()), pParent ) ); // twip rel to doc root Point aParentPixPos( GetMap()->CoreToPixel( aParentLogBounds.SVRect() ).TopLeft() ); aPixBounds.Move( -aParentPixPos.X(), -aParentPixPos.Y() ); } @@ -1089,24 +1131,20 @@ void SwAccessibleContext::Dispose( sal_Bool bRecursive ) DBG_MSG_CD( "dispose" ) } - // --> OD 2008-03-10 #i85634# -// if( GetFrm() && GetMap() ) -// GetMap()->RemoveContext( GetFrm() ); RemoveFrmFromAccessibleMap(); - // <-- ClearFrm(); pMap = 0; bDisposing = sal_False; } -void SwAccessibleContext::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, +void SwAccessibleContext::DisposeChild( const SwAccessibleChild& rChildFrmOrObj, sal_Bool bRecursive ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwFrmOrObj aFrmOrObj( GetFrm() ); - if( IsShowing( rChildFrmOrObj ) || !aFrmOrObj.IsVisibleChildrenOnly() ) + if( IsShowing( *(GetMap()), rChildFrmOrObj ) || + !SwAccessibleChild( GetFrm() ).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 @@ -1118,14 +1156,23 @@ void SwAccessibleContext::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, sal_True ); xAccImpl->Dispose( bRecursive ); } - else + else if ( rChildFrmOrObj.GetDrawObject() ) { ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl = - GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(), this, sal_True ); - DisposeShape( rChildFrmOrObj.GetSdrObject(), + DisposeShape( rChildFrmOrObj.GetDrawObject(), xAccImpl.getBodyPtr() ); } + else if ( rChildFrmOrObj.GetWindow() ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + uno::Reference< XAccessible > xAcc = + rChildFrmOrObj.GetWindow()->GetAccessible(); + aEvent.NewValue <<= xAcc; + FireAccessibleEvent( aEvent ); + } } else if( bRecursive && rChildFrmOrObj.GetSwFrm() ) DisposeChildren( rChildFrmOrObj.GetSwFrm(), bRecursive ); @@ -1138,7 +1185,7 @@ void SwAccessibleContext::InvalidatePosOrSize( const SwRect& ) ASSERT( GetFrm() && !GetFrm()->Frm().IsEmpty(), "context should have a size" ); sal_Bool bIsOldShowingState; - sal_Bool bIsNewShowingState = IsShowing(); + sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) ); { vos::OGuard aShowingStateGuard( aMutex ); bIsOldShowingState = bIsShowingState; @@ -1156,7 +1203,7 @@ void SwAccessibleContext::InvalidatePosOrSize( const SwRect& ) FireVisibleDataEvent(); } - SwFrmOrObj aParent( GetParent() ); + SwAccessibleChild aParent( GetParent() ); if( !bIsNewShowingState && aParent.IsVisibleChildrenOnly() ) { // The frame is now invisible -> dispose it @@ -1169,7 +1216,7 @@ void SwAccessibleContext::InvalidatePosOrSize( const SwRect& ) } void SwAccessibleContext::InvalidateChildPosOrSize( - const SwFrmOrObj& rChildFrmOrObj, + const SwAccessibleChild& rChildFrmOrObj, const SwRect& rOldFrm ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1178,10 +1225,10 @@ void SwAccessibleContext::InvalidateChildPosOrSize( !rChildFrmOrObj.GetSwFrm()->Frm().IsEmpty(), "child context should have a size" ); - SwFrmOrObj aFrm( GetFrm() ); - sal_Bool bNew = rOldFrm.IsEmpty() || - (rOldFrm.Left() == 0 && rOldFrm.Top() == 0); - if( IsShowing( rChildFrmOrObj ) ) + SwAccessibleChild aFrm( GetFrm() ); + const bool bNew = rOldFrm.IsEmpty() || + ( rOldFrm.Left() == 0 && rOldFrm.Top() == 0 ); + if( IsShowing( *(GetMap()), 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 @@ -1196,15 +1243,15 @@ void SwAccessibleContext::InvalidateChildPosOrSize( sal_True ); xAccImpl->ScrolledIn(); } - else + else if ( rChildFrmOrObj.GetDrawObject() ) { ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl = - GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(), this, sal_True ); // --> OD 2004-11-29 #i37790# if ( xAccImpl.isValid() ) { - ScrolledInShape( rChildFrmOrObj.GetSdrObject(), + ScrolledInShape( rChildFrmOrObj.GetDrawObject(), xAccImpl.getBodyPtr() ); } else @@ -1214,6 +1261,13 @@ void SwAccessibleContext::InvalidateChildPosOrSize( } // <-- } + else if ( rChildFrmOrObj.GetWindow() ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.NewValue <<= (rChildFrmOrObj.GetWindow()->GetAccessible()); + FireAccessibleEvent( aEvent ); + } } } else @@ -1233,14 +1287,19 @@ void SwAccessibleContext::InvalidateChildPosOrSize( xAccImpl->SetParent( this ); xAccImpl->Dispose( sal_True ); } - else + else if ( rChildFrmOrObj.GetDrawObject() ) { ::vos::ORef< ::accessibility::AccessibleShape > xAccImpl = - GetMap()->GetContextImpl( rChildFrmOrObj.GetSdrObject(), + GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(), this, sal_True ); - DisposeShape( rChildFrmOrObj.GetSdrObject(), + DisposeShape( rChildFrmOrObj.GetDrawObject(), xAccImpl.getBodyPtr() ); } + else if ( rChildFrmOrObj.GetWindow() ) + { + ASSERT( false, + " - not expected to handle dispose of child of type ." ); + } } } } @@ -1424,13 +1483,67 @@ OUString SwAccessibleContext::GetResource( sal_uInt16 nResId, return OUString( sStr ); } -// --> OD 2008-03-10 #i85634# void SwAccessibleContext::RemoveFrmFromAccessibleMap() { if( bRegisteredAtAccessibleMap && GetFrm() && GetMap() ) GetMap()->RemoveContext( GetFrm() ); } -// <-- + +bool SwAccessibleContext::HasAdditionalAccessibleChildren() +{ + bool bRet( false ); + + if ( GetFrm()->IsTxtFrm() ) + { + SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) + { + bRet = pPostItMgr->HasFrmConnectedSidebarWins( *(GetFrm()) ); + } + } + + return bRet; +} +/** get additional accessible child by index + + OD 2010-01-27 #i88070# + + @author OD +*/ +Window* SwAccessibleContext::GetAdditionalAccessibleChild( const sal_Int32 nIndex ) +{ + Window* pAdditionalAccessibleChild( 0 ); + + if ( GetFrm()->IsTxtFrm() ) + { + SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) + { + pAdditionalAccessibleChild = + pPostItMgr->GetSidebarWinForFrmByIndex( *(GetFrm()), nIndex ); + } + } + + return pAdditionalAccessibleChild; +} + +/** get all additional accessible children + + OD 2010-01-27 #i88070# + + @author OD +*/ +void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< Window* >* pChildren ) +{ + if ( GetFrm()->IsTxtFrm() ) + { + SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) + { + pPostItMgr->GetAllSidebarWinForFrm( *(GetFrm()), pChildren ); + } + } +} #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc, diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index d35f026968b0..050b29b46109 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -43,8 +43,14 @@ class SwAccessibleMap; class SwCrsrShell; class SdrObject; class SwPaM; -namespace utl { class AccessibleStateSetHelper; } -namespace accessibility { class AccessibleShape; } +namespace utl { + class AccessibleStateSetHelper; +} +namespace accessibility { + class AccessibleShape; +} +class SwFmtFld; +class SwAccessibleChildContainer; const sal_Char sAccessibleServiceName[] = "com.sun.star.accessibility.Accessible"; @@ -342,13 +348,13 @@ 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 SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive ); + virtual void DisposeChild( const sw::access::SwAccessibleChild& 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 SwFrmOrObj& rFrmOrObj, + virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrmOrObj, const SwRect& rFrm ); // The content may have changed (but it hasn't tohave changed) @@ -384,6 +390,25 @@ public: */ void InvalidateAttr(); + bool HasAdditionalAccessibleChildren(); + + /** get additional child by index + + OD 2010-01-27 #i88070# + + @author OD + */ + Window* GetAdditionalAccessibleChild( const sal_Int32 nIndex ); + + /** get all additional accessible children + + OD 2010-01-27 #i88070# + + @author OD + */ + void GetAdditionalAccessibleChildren( std::vector< Window* >* pChildren ); + + const ::rtl::OUString& GetName() const { return sName; } virtual sal_Bool HasCursor(); // required by map to remember that object diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index e0ca45c902c2..b101bd641fa1 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -158,8 +158,10 @@ uno::Reference< XAccessible> SAL_CALL if( mpChildWin ) { CHECK_FOR_DEFUNC( XAccessibleContext ) - if( nIndex == GetChildCount() ) + if ( nIndex == GetChildCount( *(GetMap()) ) ) + { return mpChildWin->GetAccessible(); + } } return SwAccessibleContext::getAccessibleChild( nIndex ); diff --git a/sw/source/core/access/accfootnote.hxx b/sw/source/core/access/accfootnote.hxx index eb47ba82a446..ea2f0f0ab4bd 100644 --- a/sw/source/core/access/accfootnote.hxx +++ b/sw/source/core/access/accfootnote.hxx @@ -29,9 +29,13 @@ ************************************************************************/ #ifndef _ACCFOOTNOTE_HXX #define _ACCFOOTNOTE_HXX -#ifndef _ACCCONTEXT_HXX -#include "acccontext.hxx" -#endif + +#include + +#include + +class SwAccessibleMap; +class SwFtnFrm; class SwAccessibleFootnote : public SwAccessibleContext { diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index a62afc11e551..ad243c8cfbc3 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -55,22 +55,24 @@ #include #include +using namespace sw::access; // Regarding visibilily (or in terms of accessibility: regarding the showing // state): A frame is visible and therfor contained in the tree if its frame // size overlaps with the visible area. The bounding box however is the // frame's paint area. -sal_Int32 SwAccessibleFrame::GetChildCount( const SwRect& rVisArea, - const SwFrm *pFrm, - sal_Bool bInPagePreview ) +/* static */ sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm *pFrm, + sal_Bool bInPagePreview ) { sal_Int32 nCount = 0; - const SwFrmOrObjSList aVisList( rVisArea, pFrm ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + const SwAccessibleChildSList aVisList( rVisArea, *pFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; if( rLower.IsAccessible( bInPagePreview ) ) { nCount++; @@ -78,7 +80,8 @@ sal_Int32 SwAccessibleFrame::GetChildCount( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - nCount += GetChildCount( rVisArea, rLower.GetSwFrm(), + nCount += GetChildCount( rAccMap, + rVisArea, rLower.GetSwFrm(), bInPagePreview ); } ++aIter; @@ -87,23 +90,25 @@ sal_Int32 SwAccessibleFrame::GetChildCount( const SwRect& rVisArea, return nCount; } -SwFrmOrObj SwAccessibleFrame::GetChild( const SwRect& rVisArea, - const SwFrm *pFrm, - sal_Int32& rPos, - sal_Bool bInPagePreview ) +/* static */ SwAccessibleChild SwAccessibleFrame::GetChild( + SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + sal_Int32& rPos, + sal_Bool bInPagePreview ) { - SwFrmOrObj aRet; + SwAccessibleChild aRet; if( rPos >= 0 ) { - if( SwFrmOrObjMap::IsSortingRequired( pFrm ) ) + if( SwAccessibleChildMap::IsSortingRequired( rFrm ) ) { // We need a sorted list here - const SwFrmOrObjMap aVisMap( rVisArea, pFrm ); - SwFrmOrObjMap::const_iterator aIter( aVisMap.begin() ); + const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() ); while( aIter != aVisMap.end() && !aRet.IsValid() ) { - const SwFrmOrObj& rLower = (*aIter).second; + const SwAccessibleChild& rLower = (*aIter).second; if( rLower.IsAccessible( bInPagePreview ) ) { if( 0 == rPos ) @@ -114,7 +119,8 @@ SwFrmOrObj SwAccessibleFrame::GetChild( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - aRet = GetChild( rVisArea, rLower.GetSwFrm(), rPos, + aRet = GetChild( rAccMap, + rVisArea, *(rLower.GetSwFrm()), rPos, bInPagePreview ); } ++aIter; @@ -124,11 +130,11 @@ SwFrmOrObj SwAccessibleFrame::GetChild( const SwRect& rVisArea, { // 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() ); + const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() && !aRet.IsValid() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; if( rLower.IsAccessible( bInPagePreview ) ) { if( 0 == rPos ) @@ -139,7 +145,8 @@ SwFrmOrObj SwAccessibleFrame::GetChild( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - aRet = GetChild( rVisArea, rLower.GetSwFrm(), rPos, + aRet = GetChild( rAccMap, + rVisArea, *(rLower.GetSwFrm()), rPos, bInPagePreview ); } ++aIter; @@ -150,22 +157,24 @@ SwFrmOrObj SwAccessibleFrame::GetChild( const SwRect& rVisArea, return aRet; } -sal_Bool SwAccessibleFrame::GetChildIndex( const SwRect& rVisArea, - const SwFrm *pFrm, - const SwFrmOrObj& rChild, - sal_Int32& rPos, - sal_Bool bInPagePreview ) +/* static */ sal_Bool SwAccessibleFrame::GetChildIndex( + SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + const SwAccessibleChild& rChild, + sal_Int32& rPos, + sal_Bool bInPagePreview ) { sal_Bool bFound = sal_False; - if( SwFrmOrObjMap::IsSortingRequired( pFrm ) ) + if( SwAccessibleChildMap::IsSortingRequired( rFrm ) ) { // We need a sorted list here - const SwFrmOrObjMap aVisMap( rVisArea, pFrm ); - SwFrmOrObjMap::const_iterator aIter( aVisMap.begin() ); + const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() ); while( aIter != aVisMap.end() && !bFound ) { - const SwFrmOrObj& rLower = (*aIter).second; + const SwAccessibleChild& rLower = (*aIter).second; if( rLower.IsAccessible( bInPagePreview ) ) { if( rChild == rLower ) @@ -176,7 +185,8 @@ sal_Bool SwAccessibleFrame::GetChildIndex( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - bFound = GetChildIndex( rVisArea, rLower.GetSwFrm(), rChild, + bFound = GetChildIndex( rAccMap, + rVisArea, *(rLower.GetSwFrm()), rChild, rPos, bInPagePreview ); } ++aIter; @@ -186,11 +196,11 @@ sal_Bool SwAccessibleFrame::GetChildIndex( const SwRect& rVisArea, { // 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() ); + const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() && !bFound ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; if( rLower.IsAccessible( bInPagePreview ) ) { if( rChild == rLower ) @@ -201,7 +211,8 @@ sal_Bool SwAccessibleFrame::GetChildIndex( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - bFound = GetChildIndex( rVisArea, rLower.GetSwFrm(), rChild, + bFound = GetChildIndex( rAccMap, + rVisArea, *(rLower.GetSwFrm()), rChild, rPos, bInPagePreview ); } ++aIter; @@ -211,31 +222,31 @@ sal_Bool SwAccessibleFrame::GetChildIndex( const SwRect& rVisArea, return bFound; } -SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, - const SwFrm *pFrm, +SwAccessibleChild SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, + const SwFrm& rFrm, const Point& rPixPos, sal_Bool bInPagePreview, - const SwAccessibleMap *pMap ) + SwAccessibleMap& rAccMap ) { - SwFrmOrObj aRet; + SwAccessibleChild aRet; - if( SwFrmOrObjMap::IsSortingRequired( pFrm ) ) + if( SwAccessibleChildMap::IsSortingRequired( rFrm ) ) { // We need a sorted list here, and we have to reverse iterate, // because objects in front should be returned. - const SwFrmOrObjMap aVisMap( rVisArea, pFrm ); - SwFrmOrObjMap::const_reverse_iterator aRIter( aVisMap.rbegin() ); + const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + SwAccessibleChildMap::const_reverse_iterator aRIter( aVisMap.rbegin() ); while( aRIter != aVisMap.rend() && !aRet.IsValid() ) { - const SwFrmOrObj& rLower = (*aRIter).second; + const SwAccessibleChild& rLower = (*aRIter).second; // A frame is returned if it's frame size is inside the visarea // and the positiion is inside the frame's paint area. if( rLower.IsAccessible( bInPagePreview ) ) { - SwRect aLogBounds( rLower.GetBounds( ) ); + SwRect aLogBounds( rLower.GetBounds( rAccMap ) ); if( !aLogBounds.IsEmpty() ) { - Rectangle aPixBounds( pMap->CoreToPixel( aLogBounds.SVRect() ) ); + Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) ); if( aPixBounds.IsInside( rPixPos ) ) aRet = rLower; } @@ -243,8 +254,8 @@ SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - aRet = GetChildAtPixel( rVisArea, rLower.GetSwFrm(), rPixPos, - bInPagePreview, pMap ); + aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos, + bInPagePreview, rAccMap ); } aRIter++; } @@ -254,19 +265,19 @@ SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, // The unsorted list is sorted enough, because it returns lower // frames in the correct order. Morover, we can iterate forward, // because the lowers don't overlap! - const SwFrmOrObjSList aVisList( rVisArea, pFrm ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() && !aRet.IsValid() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; // A frame is returned if it's frame size is inside the visarea // and the positiion is inside the frame's paint area. if( rLower.IsAccessible( bInPagePreview ) ) { - SwRect aLogBounds( rLower.GetBounds( ) ); + SwRect aLogBounds( rLower.GetBounds( rAccMap ) ); if( !aLogBounds.IsEmpty() ) { - Rectangle aPixBounds( pMap->CoreToPixel( aLogBounds.SVRect() ) ); + Rectangle aPixBounds( rAccMap.CoreToPixel( aLogBounds.SVRect() ) ); if( aPixBounds.IsInside( rPixPos ) ) aRet = rLower; } @@ -274,8 +285,8 @@ SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - aRet = GetChildAtPixel( rVisArea, rLower.GetSwFrm(), rPixPos, - bInPagePreview, pMap ); + aRet = GetChildAtPixel( rVisArea, *(rLower.GetSwFrm()), rPixPos, + bInPagePreview, rAccMap ); } ++aIter; } @@ -284,18 +295,20 @@ SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const SwRect& rVisArea, return aRet; } -void SwAccessibleFrame::GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, - ::std::list< SwFrmOrObj >& rChildren, - sal_Bool bInPagePreview ) +/* static */ void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + ::std::list< SwAccessibleChild >& rChildren, + sal_Bool bInPagePreview ) { - if( SwFrmOrObjMap::IsSortingRequired( pFrm ) ) + if( SwAccessibleChildMap::IsSortingRequired( rFrm ) ) { // We need a sorted list here - const SwFrmOrObjMap aVisMap( rVisArea, pFrm ); - SwFrmOrObjMap::const_iterator aIter( aVisMap.begin() ); + const SwAccessibleChildMap aVisMap( rVisArea, rFrm, rAccMap ); + SwAccessibleChildMap::const_iterator aIter( aVisMap.begin() ); while( aIter != aVisMap.end() ) { - const SwFrmOrObj& rLower = (*aIter).second; + const SwAccessibleChild& rLower = (*aIter).second; if( rLower.IsAccessible( bInPagePreview ) ) { rChildren.push_back( rLower ); @@ -303,8 +316,8 @@ void SwAccessibleFrame::GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - GetChildren( rVisArea, rLower.GetSwFrm(), rChildren, - bInPagePreview ); + GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()), + rChildren, bInPagePreview ); } ++aIter; } @@ -313,11 +326,11 @@ void SwAccessibleFrame::GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, { // 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() ); + const SwAccessibleChildSList aVisList( rVisArea, rFrm, rAccMap ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; if( rLower.IsAccessible( bInPagePreview ) ) { rChildren.push_back( rLower ); @@ -325,21 +338,22 @@ void SwAccessibleFrame::GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, else if( rLower.GetSwFrm() ) { // There are no unaccessible SdrObjects that count - GetChildren( rVisArea, rLower.GetSwFrm(), rChildren, - bInPagePreview ); + GetChildren( rAccMap, rVisArea, *(rLower.GetSwFrm()), + rChildren, bInPagePreview ); } ++aIter; } } } -SwRect SwAccessibleFrame::GetBounds( const SwFrm *pFrm ) +SwRect SwAccessibleFrame::GetBounds( const SwAccessibleMap& rAccMap, + const SwFrm *pFrm ) { if( !pFrm ) pFrm = GetFrm(); - SwFrmOrObj aFrm( pFrm ); - SwRect aBounds( aFrm.GetBounds().Intersection( maVisArea ) ); + SwAccessibleChild aFrm( pFrm ); + SwRect aBounds( aFrm.GetBounds( rAccMap ).Intersection( maVisArea ) ); return aBounds; } @@ -362,7 +376,7 @@ sal_Bool SwAccessibleFrame::IsEditable( ViewShell *pVSh ) const sal_Bool SwAccessibleFrame::IsOpaque( ViewShell *pVSh ) const { - SwFrmOrObj aFrm( GetFrm() ); + SwAccessibleChild aFrm( GetFrm() ); if( !aFrm.GetSwFrm() ) return sal_False; @@ -426,71 +440,10 @@ SwAccessibleFrame::~SwAccessibleFrame() { } -const SwFrm *SwAccessibleFrame::GetParent( const SwFrmOrObj& rFrmOrObj, - sal_Bool bInPagePreview ) +/* static */ const SwFrm* SwAccessibleFrame::GetParent( const SwAccessibleChild& rFrmOrObj, + sal_Bool bInPagePreview ) { - SwFrmOrObj aParent; - const SwFrm *pFrm = rFrmOrObj.GetSwFrm(); - if( pFrm ) - { - if( pFrm->IsFlyFrm() ) - { - const SwFlyFrm *pFly = static_cast< const SwFlyFrm *>( pFrm ); - if( pFly->IsFlyInCntFrm() ) - { - // For FLY_IN_CNTNT the parent is the anchor - aParent = pFly->GetAnchorFrm(); - ASSERT( aParent.IsAccessible( bInPagePreview ), - "parent is not accessible" ); - } - else - { - // In any other case the parent is the root frm - // (in page preview, the page frame) - if( bInPagePreview ) - aParent = pFly->FindPageFrm(); - else - aParent = pFly->FindRootFrm(); - } - } - else - { - SwFrmOrObj aUpper( pFrm->GetUpper() ); - while( aUpper.GetSwFrm() && !aUpper.IsAccessible(bInPagePreview) ) - aUpper = aUpper.GetSwFrm()->GetUpper(); - aParent = aUpper; - } - } - else if( rFrmOrObj.GetSdrObject() ) - { - 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->GetAnchorFrm(); - ASSERT( aParent.IsAccessible( bInPagePreview ), - "parent is not accessible" ); - - } - else - { - // In any other case the parent is the root frm - if( bInPagePreview ) - aParent = pContact->GetAnchorFrm()->FindPageFrm(); - else - aParent = pContact->GetAnchorFrm()->FindRootFrm(); - } - } - } - - return aParent.GetSwFrm(); + return rFrmOrObj.GetParent( bInPagePreview ); } String SwAccessibleFrame::GetFormattedPageNumber() const @@ -504,3 +457,44 @@ String SwAccessibleFrame::GetFormattedPageNumber() const String sRet( FormatNumber( nPageNum, nFmt ) ); return sRet; } + +sal_Int32 SwAccessibleFrame::GetChildCount( SwAccessibleMap& rAccMap ) const +{ + return GetChildCount( rAccMap, maVisArea, mpFrm, IsInPagePreview() ); +} + +sw::access::SwAccessibleChild SwAccessibleFrame::GetChild( + SwAccessibleMap& rAccMap, + sal_Int32 nPos ) const +{ + return SwAccessibleFrame::GetChild( rAccMap, maVisArea, *mpFrm, nPos, IsInPagePreview() ); +} + +sal_Int32 SwAccessibleFrame::GetChildIndex( SwAccessibleMap& rAccMap, + const sw::access::SwAccessibleChild& rChild ) const +{ + sal_Int32 nPos = 0; + return GetChildIndex( rAccMap, maVisArea, *mpFrm, rChild, nPos, IsInPagePreview() ) + ? nPos + : -1L; +} + +sw::access::SwAccessibleChild SwAccessibleFrame::GetChildAtPixel( + const Point& rPos, + SwAccessibleMap& rAccMap ) const +{ + return GetChildAtPixel( maVisArea, *mpFrm, rPos, IsInPagePreview(), rAccMap ); +} + +void SwAccessibleFrame::GetChildren( SwAccessibleMap& rAccMap, + ::std::list< sw::access::SwAccessibleChild >& rChildren ) const +{ + GetChildren( rAccMap, maVisArea, *mpFrm, rChildren, IsInPagePreview() ); +} + +sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap, + const sw::access::SwAccessibleChild& rFrmOrObj ) const +{ + return IsShowing( rFrmOrObj.GetBox( rAccMap ) ); +} + diff --git a/sw/source/core/access/accframe.hxx b/sw/source/core/access/accframe.hxx index c1c385cdcf4d..316932335a91 100644 --- a/sw/source/core/access/accframe.hxx +++ b/sw/source/core/access/accframe.hxx @@ -30,14 +30,22 @@ #ifndef _ACCFRAME_HXX #define _ACCFRAME_HXX +#include + #include +#include #include #include -// Any method of this class must be called with an acquired solar mutex! - class SwAccessibleMap; +class SwFrm; +class ViewShell; +namespace sw { namespace access { + class SwAccessibleChild; +}} + +// Any method of this class must be called with an acquired solar mutex! class SwAccessibleFrame { @@ -48,26 +56,34 @@ class SwAccessibleFrame protected: // --> OD 2007-06-29 #i77106# // method needs to be called by new class - static sal_Int32 GetChildCount( const SwRect& rVisArea, + static sal_Int32 GetChildCount( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, const SwFrm *pFrm, sal_Bool bInPagePreview ); private: - static SwFrmOrObj GetChild( const SwRect& rVisArea, - const SwFrm *pFrm, - sal_Int32& rPos, - sal_Bool bInPagePreview); - static sal_Bool GetChildIndex( const SwRect& rVisArea, - const SwFrm *pFrm, - const SwFrmOrObj& rChild, - sal_Int32& rPos, - sal_Bool bInPagePreview ); - static SwFrmOrObj GetChildAtPixel( const SwRect& rVisArea, - const SwFrm *pFrm, - const Point& rPos, - sal_Bool bInPagePreview, - const SwAccessibleMap *pMap ); - static void GetChildren( const SwRect& rVisArea, const SwFrm *pFrm, - ::std::list< SwFrmOrObj >& rChildren, + static sw::access::SwAccessibleChild GetChild( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + sal_Int32& rPos, + sal_Bool bInPagePreview); + + static sal_Bool GetChildIndex( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + const sw::access::SwAccessibleChild& rChild, + sal_Int32& rPos, + sal_Bool bInPagePreview ); + + static sw::access::SwAccessibleChild GetChildAtPixel( const SwRect& rVisArea, + const SwFrm& rFrm, + const Point& rPos, + sal_Bool bInPagePreview, + SwAccessibleMap& rAccMap ); + + static void GetChildren( SwAccessibleMap& rAccMap, + const SwRect& rVisArea, + const SwFrm& rFrm, + ::std::list< sw::access::SwAccessibleChild >& rChildren, sal_Bool bInPagePreview ); protected: @@ -76,9 +92,10 @@ protected: sal_Bool IsOpaque( ViewShell *pVSh ) const; + sal_Bool IsShowing( const SwAccessibleMap& rAccMap, + const sw::access::SwAccessibleChild& rFrmOrObj ) const; inline sal_Bool IsShowing( const SwRect& rFrm ) const; - inline sal_Bool IsShowing( const SwFrmOrObj& rFrmOrObj ) const; - inline sal_Bool IsShowing() const; + inline sal_Bool IsShowing( const SwAccessibleMap& rAccMap ) const; inline sal_Bool IsInPagePreview() const { @@ -100,14 +117,15 @@ public: const SwFrm *GetFrm() const { return mpFrm; }; - static const SwFrm *GetParent( const SwFrmOrObj& rFrmOrObj, + static const SwFrm* GetParent( const sw::access::SwAccessibleChild& rFrmOrObj, sal_Bool bInPagePreview ); protected: // Return the bounding box of the frame clipped to the vis area. If // no frame is specified, use this' frame. - SwRect GetBounds( const SwFrm *pFrm=0 ); + SwRect GetBounds( const SwAccessibleMap& rAccMap, + const SwFrm *pFrm = 0 ); // Return the upper that has a context attached. This might be // another one than the immediate upper. @@ -115,12 +133,15 @@ protected: // Return the lower count or the nth lower, there the lowers have a // not be same one as the SwFrm's lowers - inline sal_Int32 GetChildCount() const; - inline SwFrmOrObj GetChild( sal_Int32 nPos ) const; - inline sal_Int32 GetChildIndex( const SwFrmOrObj& rChild ) const; - inline SwFrmOrObj GetChildAtPixel( const Point& rPos, - const SwAccessibleMap *pMap ) const; - inline void GetChildren( ::std::list< SwFrmOrObj >& rChildren ) const; + 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, + ::std::list< sw::access::SwAccessibleChild >& rChildren ) const; inline void SetVisArea( const SwRect& rNewVisArea ) { @@ -141,48 +162,17 @@ inline sal_Bool SwAccessibleFrame::IsShowing( const SwRect& rFrm ) const return rFrm.IsOver( maVisArea ); } -inline sal_Bool SwAccessibleFrame::IsShowing( const SwFrmOrObj& rFrmOrObj ) const -{ - return IsShowing( rFrmOrObj.GetBox() ); -} - -inline sal_Bool SwAccessibleFrame::IsShowing() const +inline sal_Bool SwAccessibleFrame::IsShowing( const SwAccessibleMap& rAccMap ) const { - SwFrmOrObj aFrmOrObj( GetFrm() ); - return IsShowing( aFrmOrObj ); + sw::access::SwAccessibleChild aFrmOrObj( GetFrm() ); + return IsShowing( rAccMap, aFrmOrObj ); } inline const SwFrm *SwAccessibleFrame::GetParent() const { - SwFrmOrObj aFrmOrObj( GetFrm() ); + sw::access::SwAccessibleChild aFrmOrObj( GetFrm() ); return GetParent( aFrmOrObj, IsInPagePreview() ); } -inline sal_Int32 SwAccessibleFrame::GetChildCount() const -{ - return GetChildCount( maVisArea, mpFrm, IsInPagePreview() ); -} - -inline SwFrmOrObj SwAccessibleFrame::GetChild( sal_Int32 nPos ) const -{ - return GetChild( maVisArea, mpFrm, nPos, IsInPagePreview() ); -} - -inline sal_Int32 SwAccessibleFrame::GetChildIndex( const SwFrmOrObj& rChild ) const -{ - sal_Int32 nPos = 0; - return GetChildIndex( maVisArea, mpFrm, rChild, nPos, IsInPagePreview() ) ? nPos : -1L; -} - -inline SwFrmOrObj SwAccessibleFrame::GetChildAtPixel( const Point& rPos, - const SwAccessibleMap *pMap ) const -{ - return GetChildAtPixel( maVisArea, mpFrm, rPos, IsInPagePreview(), pMap ); -} - -inline void SwAccessibleFrame::GetChildren( ::std::list< SwFrmOrObj >& rChildren ) const -{ - GetChildren( maVisArea, mpFrm, rChildren, IsInPagePreview() ); -} #endif diff --git a/sw/source/core/access/accframebase.hxx b/sw/source/core/access/accframebase.hxx index 0b667996e066..c70c364458a1 100644 --- a/sw/source/core/access/accframebase.hxx +++ b/sw/source/core/access/accframebase.hxx @@ -29,13 +29,15 @@ ************************************************************************/ #ifndef _ACCFRAMEBASE_HXX #define _ACCFRAMEBASE_HXX -#ifndef _ACCCONTEXT_HXX -#include "acccontext.hxx" -#endif + +#include + +#include class SwFlyFrm; -class SwAccessibleFrameBase : public SwAccessibleContext, public SwClient +class SwAccessibleFrameBase : public SwAccessibleContext, + public SwClient { sal_Bool bIsSelected; // protected by base class mutex diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index f16d11692c9c..a620b95ddc20 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -31,36 +31,382 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include -#include -sal_Bool SwFrmOrObj::IsAccessible( sal_Bool bPagePreview ) const +#include + +namespace css = ::com::sun::star; + +namespace sw { namespace access { + +SwAccessibleChild::SwAccessibleChild() + : mpDrawObj( 0 ) + , mpFrm( 0 ) + , mpWindow( 0 ) +{} + +SwAccessibleChild::SwAccessibleChild( const SdrObject* pDrawObj ) + : mpFrm( 0 ) + , mpDrawObj( 0 ) + , mpWindow( 0 ) +{ + Init( pDrawObj ); +} + +SwAccessibleChild::SwAccessibleChild( const SwFrm* pFrm ) + : mpFrm( 0 ) + , mpDrawObj( 0 ) + , mpWindow( 0 ) +{ + Init( pFrm ); +} + +SwAccessibleChild::SwAccessibleChild( Window* pWindow ) + : mpFrm( 0 ) + , mpDrawObj( 0 ) + , mpWindow( 0 ) +{ + Init( pWindow ); +} + + +SwAccessibleChild::SwAccessibleChild( const SwFrm* pFrm, + const SdrObject* pDrawObj ) +{ + if ( pFrm ) + { + Init( pFrm ); + } + else + { + Init( pDrawObj ); + } + ASSERT( (!pFrm || pFrm == mpFrm) && (!pDrawObj || pDrawObj == mpDrawObj), + "invalid frame/object combination" ); + +} + +void SwAccessibleChild::Init( const SdrObject* pDrawObj ) +{ + mpDrawObj = pDrawObj; + mpFrm = mpDrawObj && mpDrawObj->ISA(SwVirtFlyDrawObj) + ? static_cast < const SwVirtFlyDrawObj * >( mpDrawObj )->GetFlyFrm() + : 0; + mpWindow = 0; +} + +void SwAccessibleChild::Init( const SwFrm* pFrm ) +{ + mpFrm = pFrm; + mpDrawObj = mpFrm && mpFrm->IsFlyFrm() + ? static_cast < const SwFlyFrm * >( mpFrm )->GetVirtDrawObj() + : 0; + mpWindow = 0; +} + +void SwAccessibleChild::Init( Window* pWindow ) +{ + mpWindow = pWindow; + mpFrm = 0; + mpDrawObj = 0; +} + +bool SwAccessibleChild::IsAccessible( sal_Bool bPagePreview ) const +{ + bool bRet( false ); + + if ( mpFrm ) + { + bRet = mpFrm->IsAccessibleFrm() && + ( !mpFrm->IsCellFrm() || + static_cast( mpFrm )->GetTabBox()->GetSttNd() != 0 ) && + !mpFrm->IsInCoveredCell() && + ( bPagePreview || + !mpFrm->IsPageFrm() ); + } + else if ( mpDrawObj ) + { + bRet = true; + } + else if ( mpWindow ) + { + bRet = true; + } + + return bRet; +} + +bool SwAccessibleChild::IsBoundAsChar() const +{ + bool bRet( false ); + + if ( mpFrm ) + { + bRet = mpFrm->IsFlyFrm() && + static_cast< const SwFlyFrm *>(mpFrm)->IsFlyInCntFrm(); + } + else if ( mpDrawObj ) + { + const SwFrmFmt* mpFrmFmt = ::FindFrmFmt( mpDrawObj ); + bRet = mpFrmFmt + ? (FLY_IN_CNTNT == mpFrmFmt->GetAnchor().GetAnchorId()) + : false; + } + else if ( mpWindow ) + { + bRet = false; + } + + return bRet; +} + +SwAccessibleChild::SwAccessibleChild( const SwAccessibleChild& r ) + : mpFrm( r.mpFrm ) + , mpDrawObj( r.mpDrawObj ) + , mpWindow( r.mpWindow ) +{} + +SwAccessibleChild& SwAccessibleChild::operator=( const SwAccessibleChild& r ) +{ + mpDrawObj = r.mpDrawObj; + mpFrm = r.mpFrm; + mpWindow = r.mpWindow; + + return *this; +} + +SwAccessibleChild& SwAccessibleChild::operator=( const SdrObject* pDrawObj ) +{ + Init( pDrawObj ); + return *this; +} + +SwAccessibleChild& SwAccessibleChild::operator=( const SwFrm* pFrm ) +{ + Init( pFrm ); + return *this; +} + +SwAccessibleChild& SwAccessibleChild::operator=( Window* pWindow ) +{ + Init( pWindow ); + return *this; +} + +bool SwAccessibleChild::operator==( const SwAccessibleChild& r ) const { - return ( pFrm && pFrm->IsAccessibleFrm() && - ( !pFrm->IsCellFrm() || - static_cast( pFrm )->GetTabBox()->GetSttNd() != 0 ) && - !pFrm->IsInCoveredCell() && - ( bPagePreview || !pFrm->IsPageFrm() ) ) || - pObj; + return mpFrm == r.mpFrm && + mpDrawObj == r.mpDrawObj && + mpWindow == r.mpWindow; } -sal_Bool SwFrmOrObj::IsBoundAsChar() const +bool SwAccessibleChild::IsValid() const { - // currently only SwFrms are accessible - if( pFrm ) + return mpFrm != 0 || + mpDrawObj != 0 || + mpWindow != 0; +} + +const SdrObject* SwAccessibleChild::GetDrawObject() const +{ + return mpDrawObj; +} + +const SwFrm *SwAccessibleChild::GetSwFrm() const +{ + return mpFrm; +} + +Window* SwAccessibleChild::GetWindow() const +{ + return mpWindow; +} + +bool SwAccessibleChild::IsVisibleChildrenOnly() const +{ + bool bRet( false ); + + if ( !mpFrm ) { - return pFrm->IsFlyFrm() && - static_cast< const SwFlyFrm *>(pFrm)->IsFlyInCntFrm(); + bRet = true; } else { - const SwFrmFmt *pFrmFmt = pObj ? ::FindFrmFmt( pObj ) : 0; - return pFrmFmt ? static_cast(FLY_IN_CNTNT == pFrmFmt->GetAnchor().GetAnchorId()) - : sal_False; + bRet = mpFrm->IsRootFrm() || + !( mpFrm->IsTabFrm() || + mpFrm->IsInTab() || + ( IsBoundAsChar() && + static_cast(mpFrm)->GetAnchorFrm()->IsInTab() ) ); } + + return bRet; } +SwRect SwAccessibleChild::GetBox( const SwAccessibleMap& rAccMap ) const +{ + SwRect aBox; + + if ( mpFrm ) + { + if ( mpFrm->IsPageFrm() && + static_cast< const SwPageFrm * >( mpFrm )->IsEmptyPage() ) + { + aBox = SwRect( mpFrm->Frm().Left(), mpFrm->Frm().Top()-1, 1, 1 ); + } + else if ( mpFrm->IsTabFrm() ) + { + aBox = SwRect( mpFrm->Frm() ); + aBox.Intersection( mpFrm->GetUpper()->Frm() ); + } + else + { + aBox = mpFrm->Frm(); + } + } + else if( mpDrawObj ) + { + aBox = SwRect( mpDrawObj->GetCurrentBoundRect() ); + } + else if ( mpWindow ) + { + MapMode aDest( MAP_TWIP ); + aBox = SwRect( rAccMap.GetShell()->GetWin()->PixelToLogic( mpWindow->GetPosPixel(), aDest ), + rAccMap.GetShell()->GetWin()->PixelToLogic( mpWindow->GetSizePixel(), aDest ) ); + } + + return aBox; +} + +SwRect SwAccessibleChild::GetBounds( const SwAccessibleMap& rAccMap ) const +{ + SwRect aBound; + + if( mpFrm ) + { + if( mpFrm->IsPageFrm() && + static_cast< const SwPageFrm * >( mpFrm )->IsEmptyPage() ) + { + aBound = SwRect( mpFrm->Frm().Left(), mpFrm->Frm().Top()-1, 0, 0 ); + } + else + aBound = mpFrm->PaintArea(); + } + else if( mpDrawObj ) + { + aBound = GetBox( rAccMap ); + } + else if ( mpWindow ) + { + aBound = GetBox( rAccMap ); + } + + return aBound; +} + +const SwFrm* SwAccessibleChild::GetParent( const sal_Bool bInPagePreview ) const +{ + const SwFrm* pParent( 0 ); + + if ( mpFrm ) + { + if( mpFrm->IsFlyFrm() ) + { + const SwFlyFrm* pFly = static_cast< const SwFlyFrm *>( mpFrm ); + if( pFly->IsFlyInCntFrm() ) + { + // For FLY_IN_CNTNT the parent is the anchor + pParent = pFly->GetAnchorFrm(); + ASSERT( SwAccessibleChild( pParent ).IsAccessible( bInPagePreview ), + "parent is not accessible" ); + } + else + { + // In any other case the parent is the root frm + // (in page preview, the page frame) + if( bInPagePreview ) + pParent = pFly->FindPageFrm(); + else + pParent = pFly->FindRootFrm(); + } + } + else + { + SwAccessibleChild aUpper( mpFrm->GetUpper() ); + while( aUpper.GetSwFrm() && !aUpper.IsAccessible(bInPagePreview) ) + { + aUpper = aUpper.GetSwFrm()->GetUpper(); + } + pParent = aUpper.GetSwFrm(); + } + } + else if( mpDrawObj ) + { + const SwDrawContact *pContact = + static_cast< const SwDrawContact* >( GetUserCall( mpDrawObj ) ); + 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 + pParent = pContact->GetAnchorFrm(); + ASSERT( SwAccessibleChild( pParent ).IsAccessible( bInPagePreview ), + "parent is not accessible" ); + + } + else + { + // In any other case the parent is the root frm + if( bInPagePreview ) + pParent = pContact->GetAnchorFrm()->FindPageFrm(); + else + pParent = pContact->GetAnchorFrm()->FindRootFrm(); + } + } + } + else if ( mpWindow ) + { + css::uno::Reference < css::accessibility::XAccessible > xAcc = + mpWindow->GetAccessible(); + if ( xAcc.is() ) + { + css::uno::Reference < css::accessibility::XAccessibleContext > xAccContext = + xAcc->getAccessibleContext(); + if ( xAccContext.is() ) + { + css::uno::Reference < css::accessibility::XAccessible > xAccParent = + xAccContext->getAccessibleParent(); + if ( xAccParent.is() ) + { + SwAccessibleContext* pAccParentImpl = + dynamic_cast< SwAccessibleContext *>( xAccParent.get() ); + if ( pAccParentImpl ) + { + pParent = pAccParentImpl->GetFrm(); + } + } + } + } + } + + return pParent; +} + +} } // eof of namespace sw::access + diff --git a/sw/source/core/access/accfrmobj.hxx b/sw/source/core/access/accfrmobj.hxx index c1c1e919f840..9cdff0be34ec 100644 --- a/sw/source/core/access/accfrmobj.hxx +++ b/sw/source/core/access/accfrmobj.hxx @@ -29,192 +29,62 @@ ************************************************************************/ #ifndef _ACCFRMOBJ_HXX #define _ACCFRMOBJ_HXX -#include -#include -#include -#include -class SwFrmOrObj -{ - const SdrObject *pObj; - const SwFrm *pFrm; - - inline void Init( const SdrObject *pO ); - inline void Init( const SwFrm *pF ); - -public: - - inline SwFrmOrObj(); - inline explicit SwFrmOrObj( const SdrObject *pO ); - inline explicit SwFrmOrObj( const SwFrm *pF ); - inline SwFrmOrObj( const SwFrm *pF, const SdrObject *pO ); - inline SwFrmOrObj( const SwFrmOrObj& r ); +#include - inline SwFrmOrObj& operator=( const SwFrmOrObj& r ); - inline SwFrmOrObj& operator=( const SdrObject *pO ); - inline SwFrmOrObj& operator=( const SwFrm *pF ); +class SwAccessibleMap; +class SwFrm; +class SdrObject; +class Window; +class SwRect; - inline sal_Bool operator==( const SwFrmOrObj& r ) const; - inline sal_Bool operator==( const SdrObject *pO ) const; - inline sal_Bool operator==( const SwFrm *pF ) const; - - inline sal_Bool IsValid() const; - - inline const SdrObject *GetSdrObject() const; - inline const SwFrm *GetSwFrm() const; - - sal_Bool IsAccessible( sal_Bool bPagePreview ) const; - sal_Bool IsBoundAsChar() const; - inline sal_Bool IsVisibleChildrenOnly() const; - inline SwRect GetBox() const; - inline SwRect GetBounds() const; -}; +namespace sw { namespace access { -inline void SwFrmOrObj::Init( const SdrObject *pO ) +class SwAccessibleChild { - pObj = pO; - // #110094#-1 - pFrm = pObj && pObj->ISA(SwVirtFlyDrawObj) - ? static_cast < const SwVirtFlyDrawObj * >( pObj )->GetFlyFrm() - : 0; -} - -inline void SwFrmOrObj::Init( const SwFrm *pF ) -{ - pFrm = pF; - pObj = pFrm && pFrm->IsFlyFrm() - ? static_cast < const SwFlyFrm * >( pFrm )->GetVirtDrawObj() - : 0; -} + public: + SwAccessibleChild(); + explicit SwAccessibleChild( const SdrObject* pDrawObj ); + explicit SwAccessibleChild( const SwFrm* pFrm ); + explicit SwAccessibleChild( Window* pWindow ); + SwAccessibleChild( const SwFrm* pFrm, + const SdrObject* pDrawObj ); -inline SwFrmOrObj::SwFrmOrObj() : - pObj( 0 ), pFrm( 0 ) -{} + SwAccessibleChild( const SwAccessibleChild& r ); + SwAccessibleChild& operator=( const SwAccessibleChild& r ); -inline SwFrmOrObj::SwFrmOrObj( const SdrObject *pO ) -{ - Init( pO ); -} + SwAccessibleChild& operator=( const SdrObject* pDrawObj ); + SwAccessibleChild& operator=( const SwFrm* pFrm ); + SwAccessibleChild& operator=( Window* pWindow ); -inline SwFrmOrObj::SwFrmOrObj( const SwFrm *pF ) -{ - Init( pF ); -} + bool operator==( const SwAccessibleChild& r ) const; -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" ); + bool IsValid() const; -} + const SwFrm* GetSwFrm() const; + const SdrObject* GetDrawObject() const; + Window* GetWindow() const; -inline SwFrmOrObj::SwFrmOrObj( const SwFrmOrObj& r ) : - pObj( r.pObj ), pFrm( r.pFrm ) -{} + const SwFrm* GetParent( const sal_Bool bInPagePreview ) const; -inline SwFrmOrObj& SwFrmOrObj::operator=( const SwFrmOrObj& r ) -{ - pObj = r.pObj; - pFrm = r.pFrm; - return *this; -} + bool IsAccessible( sal_Bool bPagePreview ) const; + bool IsBoundAsChar() const; -inline SwFrmOrObj& SwFrmOrObj::operator=( const SdrObject *pO ) -{ - Init( pO ); - return *this; -} + bool IsVisibleChildrenOnly() const; + SwRect GetBox( const SwAccessibleMap& rAccMap ) const; + SwRect GetBounds( const SwAccessibleMap& rAccMap ) const; -inline SwFrmOrObj& SwFrmOrObj::operator=( const SwFrm *pF ) -{ - Init( pF ); - return *this; -} + private: + const SwFrm* mpFrm; + const SdrObject* mpDrawObj; + Window* mpWindow; -inline sal_Bool SwFrmOrObj::operator==( const SwFrmOrObj& r ) const -{ - return pObj == r.pObj && pFrm == r.pFrm; -} - -inline sal_Bool SwFrmOrObj::operator==( const SdrObject *pO ) const -{ - return pObj == pO; -} - -inline sal_Bool SwFrmOrObj::operator==( const SwFrm *pF ) const -{ - return pFrm == pF; -} - -inline sal_Bool SwFrmOrObj::IsValid() const -{ - return pObj != 0 || pFrm != 0; -} - -inline const SdrObject *SwFrmOrObj::GetSdrObject() const -{ - return pObj; -} - -inline const SwFrm *SwFrmOrObj::GetSwFrm() const -{ - return pFrm; -} - -inline sal_Bool SwFrmOrObj::IsVisibleChildrenOnly() const -{ - return !pFrm || pFrm->IsRootFrm() || - !( pFrm->IsTabFrm() || pFrm->IsInTab() || - ( IsBoundAsChar() && - static_cast(pFrm)->GetAnchorFrm()->IsInTab()) ); -} + void Init( const SdrObject* pDrawObj ); + void Init( const SwFrm* pFrm ); + void Init( Window* pWindow ); +}; -inline SwRect SwFrmOrObj::GetBox() const -{ - if( pFrm ) - { - if( pFrm->IsPageFrm() && - static_cast< const SwPageFrm * >( pFrm )->IsEmptyPage() ) - { - SwRect aBox( pFrm->Frm().Left(), pFrm->Frm().Top()-1, 1, 1 ); - return aBox; - } - else if ( pFrm->IsTabFrm() ) - { - SwRect aBox( pFrm->Frm() ); - aBox.Intersection( pFrm->GetUpper()->Frm() ); - return aBox; - } - else - return pFrm->Frm(); - } - else if( pObj ) - return SwRect( pObj->GetCurrentBoundRect() ); - else - return SwRect(); -} - -inline SwRect SwFrmOrObj::GetBounds() const -{ - if( pFrm ) - { - if( pFrm->IsPageFrm() && - static_cast< const SwPageFrm * >( pFrm )->IsEmptyPage() ) - { - SwRect aBox( pFrm->Frm().Left(), pFrm->Frm().Top()-1, 0, 0 ); - return aBox; - } - else - return pFrm->PaintArea(); - } - else if( pObj ) - return SwRect( pObj->GetCurrentBoundRect() ); - return SwRect(); -} +} } // eof of namespace sw::access #endif diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx index cc016f5e5b52..a28084324f23 100644 --- a/sw/source/core/access/accfrmobjmap.cxx +++ b/sw/source/core/access/accfrmobjmap.cxx @@ -31,95 +31,139 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include +#include +#include #include #include #include #include #include -// OD 2004-05-24 #i28701# #include +#include -#ifndef _ACCFFRMOBJMAP_HXX -#include -#endif - -::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( - sal_uInt32 nPos, const SwFrmOrObj& rLower ) -{ - SwFrmOrObjMapKey aKey( SwFrmOrObjMapKey::TEXT, nPos ); - value_type aEntry( aKey, rLower ); - return _SwFrmOrObjMap::insert( aEntry ); -} - -::std::pair< SwFrmOrObjMap::iterator, bool > SwFrmOrObjMap::insert( - const SdrObject *pObj, const SwFrmOrObj& rLower, const SwDoc *pDoc ) -{ - if( !bLayerIdsValid ) - { - nHellId = pDoc->GetHellId(); - nControlsId = pDoc->GetControlsId(); - bLayerIdsValid = sal_True; - } +#include - SdrLayerID nLayer = pObj->GetLayer(); - SwFrmOrObjMapKey::LayerId eLayerId = (nHellId == nLayer) - ? SwFrmOrObjMapKey::HELL - : ((nControlsId == nLayer) ? SwFrmOrObjMapKey::CONTROLS - : SwFrmOrObjMapKey::HEAVEN); - SwFrmOrObjMapKey aKey( eLayerId, pObj->GetOrdNum() ); - value_type aEntry( aKey, rLower ); - return _SwFrmOrObjMap::insert( aEntry ); -} +using namespace sw::access; -SwFrmOrObjMap::SwFrmOrObjMap( - const SwRect& rVisArea, const SwFrm *pFrm ) : - bLayerIdsValid( sal_False ) +SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea, + const SwFrm& rFrm, + SwAccessibleMap& rAccMap ) + : nHellId( rAccMap.GetShell()->GetDoc()->GetHellId() ) + , nControlsId( rAccMap.GetShell()->GetDoc()->GetControlsId() ) { - SwFrmOrObj aFrm( pFrm ); - sal_Bool bVisibleOnly = aFrm.IsVisibleChildrenOnly(); + const bool bVisibleOnly = SwAccessibleChild( &rFrm ).IsVisibleChildrenOnly(); sal_uInt32 nPos = 0; - SwFrmOrObj aLower( pFrm->GetLower() ); + SwAccessibleChild aLower( rFrm.GetLower() ); while( aLower.GetSwFrm() ) { - if( !bVisibleOnly || aLower.GetBox().IsOver( rVisArea ) ) - insert( nPos++, aLower ); + if ( !bVisibleOnly || + aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) + { + insert( nPos++, SwAccessibleChildMapKey::TEXT, aLower ); + } aLower = aLower.GetSwFrm()->GetNext(); } - if( pFrm->IsPageFrm() ) + if ( rFrm.IsPageFrm() ) { ASSERT( bVisibleOnly, "page frame within tab frame???" ); const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( pFrm ); + static_cast< const SwPageFrm * >( &rFrm ); const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs(); - if( pObjs ) + if ( pObjs ) { - const SwDoc *pDoc = pPgFrm->GetFmt()->GetDoc(); for( sal_uInt16 i=0; iCount(); i++ ) { aLower = (*pObjs)[i]->GetDrawObj(); - if( aLower.GetBox().IsOver( rVisArea ) ) - insert( aLower.GetSdrObject(), aLower, pDoc ); + if ( aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) + { + insert( aLower.GetDrawObject(), aLower ); + } } } } - else if( pFrm->IsTxtFrm() ) + else if( rFrm.IsTxtFrm() ) { - const SwDoc *pDoc = static_cast< const SwTxtFrm * >( pFrm )->GetNode() - ->GetDoc(); - const SwSortedObjs *pObjs = pFrm->GetDrawObjs(); - if( pObjs ) + const SwSortedObjs *pObjs = rFrm.GetDrawObjs(); + if ( pObjs ) { for( sal_uInt16 i=0; iCount(); i++ ) { aLower = (*pObjs)[i]->GetDrawObj(); - if( aLower.IsBoundAsChar() && - (!bVisibleOnly || aLower.GetBox().IsOver( rVisArea )) ) - insert( aLower.GetSdrObject(), aLower, pDoc ); + if ( aLower.IsBoundAsChar() && + ( !bVisibleOnly || + aLower.GetBox( rAccMap ).IsOver( rVisArea ) ) ) + { + insert( aLower.GetDrawObject(), aLower ); + } + } + } + + { + ::vos::ORef < SwAccessibleContext > xAccImpl = + rAccMap.GetContextImpl( &rFrm, sal_False ); + if( xAccImpl.isValid() ) + { + SwAccessibleContext* pAccImpl = xAccImpl.getBodyPtr(); + if ( pAccImpl && + pAccImpl->HasAdditionalAccessibleChildren() ) + { + std::vector< Window* >* pAdditionalChildren = + new std::vector< Window* >(); + pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren ); + + sal_Int32 nCounter( 0 ); + for ( std::vector< Window* >::iterator aIter = pAdditionalChildren->begin(); + aIter != pAdditionalChildren->end(); + ++aIter ) + { + aLower = (*aIter); + insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower ); + } + + delete pAdditionalChildren; + } } } } } + +::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert( + const sal_uInt32 nPos, + const SwAccessibleChildMapKey::LayerId eLayerId, + const SwAccessibleChild& rLower ) +{ + SwAccessibleChildMapKey aKey( eLayerId, nPos ); + value_type aEntry( aKey, rLower ); + return _SwAccessibleChildMap::insert( aEntry ); +} + +::std::pair< SwAccessibleChildMap::iterator, bool > SwAccessibleChildMap::insert( + const SdrObject *pObj, + const SwAccessibleChild& rLower ) +{ + const SdrLayerID nLayer = pObj->GetLayer(); + SwAccessibleChildMapKey::LayerId eLayerId = + (nHellId == nLayer) + ? SwAccessibleChildMapKey::HELL + : ( (nControlsId == nLayer) + ? SwAccessibleChildMapKey::CONTROLS + : SwAccessibleChildMapKey::HEAVEN ); + SwAccessibleChildMapKey aKey( eLayerId, pObj->GetOrdNum() ); + value_type aEntry( aKey, rLower ); + return _SwAccessibleChildMap::insert( aEntry ); +} + +/* static */ sal_Bool SwAccessibleChildMap::IsSortingRequired( const SwFrm& rFrm ) +{ + return ( rFrm.IsPageFrm() && + static_cast< const SwPageFrm& >( rFrm ).GetSortedObjs() ) || + ( rFrm.IsTxtFrm() && + rFrm.GetDrawObjs() ); +} diff --git a/sw/source/core/access/accfrmobjmap.hxx b/sw/source/core/access/accfrmobjmap.hxx index 47c995e48507..be83922c6556 100644 --- a/sw/source/core/access/accfrmobjmap.hxx +++ b/sw/source/core/access/accfrmobjmap.hxx @@ -29,79 +29,71 @@ ************************************************************************/ #ifndef _ACCFRMOBJMAP_HXX #define _ACCFRMOBJMAP_HXX + #include +#include + #include +class SwAccessibleMap; class SwDoc; +class SwRect; +class SwFrm; +class SdrObject; -class SwFrmOrObjMapKey +class SwAccessibleChildMapKey { public: - enum LayerId { INVALID, HELL, TEXT, HEAVEN, CONTROLS }; + enum LayerId { INVALID, HELL, TEXT, HEAVEN, CONTROLS, XWINDOW }; + + inline SwAccessibleChildMapKey() + : eLayerId( INVALID ) + , nOrdNum( 0 ) + {} + + inline SwAccessibleChildMapKey( LayerId eId, sal_uInt32 nOrd ) + : eLayerId( eId ) + , nOrdNum( nOrd ) + {} + + inline bool operator()( const SwAccessibleChildMapKey& r1, + const SwAccessibleChildMapKey& r2 ) const + { + return (r1.eLayerId == r2.eLayerId) + ? (r1.nOrdNum < r2.nOrdNum) + : (r1.eLayerId < r2.eLayerId); + } + private: LayerId eLayerId; sal_uInt32 nOrdNum; -public: - - inline SwFrmOrObjMapKey(); - inline SwFrmOrObjMapKey( LayerId eId, sal_uInt32 nOrd ); - - inline sal_Bool operator()( const SwFrmOrObjMapKey& r1, - const SwFrmOrObjMapKey& r2 ) const; }; -typedef ::std::map < SwFrmOrObjMapKey, SwFrmOrObj, SwFrmOrObjMapKey > - _SwFrmOrObjMap; +typedef ::std::map < SwAccessibleChildMapKey, sw::access::SwAccessibleChild, SwAccessibleChildMapKey > + _SwAccessibleChildMap; -class SwFrmOrObjMap : public _SwFrmOrObjMap +class SwAccessibleChildMap : public _SwAccessibleChildMap { - SdrLayerID nHellId; - SdrLayerID nControlsId; - sal_Bool bLayerIdsValid; + const SdrLayerID nHellId; + const SdrLayerID nControlsId; - ::std::pair< iterator, bool > insert( sal_uInt32 nPos, - const SwFrmOrObj& rLower ); - ::std::pair< iterator, bool > insert( const SdrObject *pObj, - const SwFrmOrObj& rLower, - const SwDoc *pDoc ); + ::std::pair< iterator, bool > insert( const sal_uInt32 nPos, + const SwAccessibleChildMapKey::LayerId eLayerId, + const sw::access::SwAccessibleChild& rLower ); + ::std::pair< iterator, bool > insert( const SdrObject* pObj, + const sw::access::SwAccessibleChild& rLower ); public: - SwFrmOrObjMap( const SwRect& rVisArea, const SwFrm *pFrm ); + SwAccessibleChildMap( const SwRect& rVisArea, + const SwFrm& rFrm, + SwAccessibleMap& rAccMap ); - inline static sal_Bool IsSortingRequired( const SwFrm *pFrm ); + static sal_Bool IsSortingRequired( const SwFrm& rFrm ); }; -inline SwFrmOrObjMapKey::SwFrmOrObjMapKey() : - eLayerId( INVALID ), - nOrdNum( 0 ) -{ -} - -inline SwFrmOrObjMapKey::SwFrmOrObjMapKey( - LayerId eId, sal_uInt32 nOrd ) : - eLayerId( eId ), - nOrdNum( nOrd ) -{ -} - -inline sal_Bool SwFrmOrObjMapKey::operator()( - const SwFrmOrObjMapKey& r1, - const SwFrmOrObjMapKey& r2 ) const -{ - return (r1.eLayerId == r2.eLayerId) ? (r1.nOrdNum < r2.nOrdNum) : - (r1.eLayerId < r2.eLayerId); -} - -inline sal_Bool SwFrmOrObjMap::IsSortingRequired( const SwFrm *pFrm ) -{ - return ( pFrm->IsPageFrm() && - static_cast< const SwPageFrm * >( pFrm )->GetSortedObjs() ) || - (pFrm->IsTxtFrm() && pFrm->GetDrawObjs() ); -} - #endif diff --git a/sw/source/core/access/accfrmobjslist.cxx b/sw/source/core/access/accfrmobjslist.cxx index 97e3a46663e8..74c4cc1ae27f 100644 --- a/sw/source/core/access/accfrmobjslist.cxx +++ b/sw/source/core/access/accfrmobjslist.cxx @@ -31,97 +31,144 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include +#include +#include #include -// OD 2004-05-24 #i28701# #include -#include +#include +using namespace ::sw::access; -SwFrmOrObjSList_const_iterator::SwFrmOrObjSList_const_iterator( - const SwFrmOrObjSList& rLst, sal_Bool ) : - rList( rLst ), aCurr( rList.pFrm->GetLower() ), nNextObj( 0 ) +SwAccessibleChildSList_const_iterator::SwAccessibleChildSList_const_iterator( + const SwAccessibleChildSList& rLst, + SwAccessibleMap& rAccMap ) + : rList( rLst ), + aCurr( rList.GetFrm().GetLower() ), + nNextObj( 0 ) { if( !aCurr.GetSwFrm() ) { - if( rList.pFrm->IsPageFrm() ) + const SwFrm& rFrm = rList.GetFrm(); + if( rFrm.IsPageFrm() ) { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( rList.pFrm ); - const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs(); + const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm ); + const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs(); if( pObjs && pObjs->Count() ) + { aCurr = (*pObjs)[nNextObj++]->GetDrawObj(); + } } - else if( rList.pFrm->IsTxtFrm() ) + else if( rFrm.IsTxtFrm() ) { - const SwSortedObjs *pObjs = rList.pFrm->GetDrawObjs(); - if( pObjs && pObjs->Count() ) + const SwSortedObjs *pObjs = rFrm.GetDrawObjs(); + if ( pObjs && pObjs->Count() ) { aCurr = (*pObjs)[nNextObj++]->GetDrawObj(); while( aCurr.IsValid() && !aCurr.IsBoundAsChar() ) + { aCurr = (nNextObj < pObjs->Count()) - ? (*pObjs)[nNextObj++]->GetDrawObj() - : static_cast< const SdrObject *>( 0 ); - + ? (*pObjs)[nNextObj++]->GetDrawObj() + : static_cast< const SdrObject *>( 0 ); + } + } + if ( !aCurr.IsValid() ) + { + ::vos::ORef < SwAccessibleContext > xAccImpl = + rAccMap.GetContextImpl( &rFrm, sal_False ); + if( xAccImpl.isValid() ) + { + SwAccessibleContext* pAccImpl = xAccImpl.getBodyPtr(); + aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( 0 ) ); + ++nNextObj; + } } } } - if( rList.bVisibleOnly ) + + if( rList.IsVisibleOnly() ) { // Find the first visible while( aCurr.IsValid() && - !aCurr.GetBox().IsOver( rList.aVisArea ) ) + !aCurr.GetBox( rAccMap ).IsOver( rList.GetVisArea() ) ) + { next(); + } } } -SwFrmOrObjSList_const_iterator& SwFrmOrObjSList_const_iterator::next() +SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next() { - sal_Bool bGetSdrObject = sal_False; - if( aCurr.GetSdrObject() ) + bool bNextTaken( true ); + if( aCurr.GetDrawObject() || aCurr.GetWindow() ) { - bGetSdrObject = sal_True; + bNextTaken = false; } else if( aCurr.GetSwFrm() ) { aCurr = aCurr.GetSwFrm()->GetNext(); if( !aCurr.GetSwFrm() ) - bGetSdrObject = sal_True; + { + bNextTaken = false; + } } - if( bGetSdrObject ) + if( !bNextTaken ) { - if( rList.pFrm->IsPageFrm() ) + const SwFrm& rFrm = rList.GetFrm(); + if( rFrm.IsPageFrm() ) { - const SwPageFrm *pPgFrm = - static_cast< const SwPageFrm * >( rList.pFrm ); - const SwSortedObjs *pObjs = pPgFrm->GetSortedObjs(); - aCurr = (pObjs && nNextObj < pObjs->Count()) - ? (*pObjs)[nNextObj++]->GetDrawObj() - : static_cast< const SdrObject *>( 0 ); + const SwPageFrm& rPgFrm = static_cast< const SwPageFrm& >( rFrm ); + const SwSortedObjs *pObjs = rPgFrm.GetSortedObjs(); + aCurr = ( pObjs && nNextObj < pObjs->Count() ) + ? (*pObjs)[nNextObj++]->GetDrawObj() + : static_cast< const SdrObject *>( 0 ); } - else if( rList.pFrm->IsTxtFrm() ) + else if( rFrm.IsTxtFrm() ) { - const SwSortedObjs *pObjs = rList.pFrm->GetDrawObjs(); - aCurr = (pObjs && nNextObj < pObjs->Count()) - ? (*pObjs)[nNextObj++]->GetDrawObj() - : static_cast< const SdrObject *>( 0 ); + const SwSortedObjs* pObjs = rFrm.GetDrawObjs(); + const sal_uInt32 nObjsCount = pObjs ? pObjs->Count() : 0; + aCurr = ( pObjs && nNextObj < nObjsCount ) + ? (*pObjs)[nNextObj++]->GetDrawObj() + : static_cast< const SdrObject *>( 0 ); while( aCurr.IsValid() && !aCurr.IsBoundAsChar() ) - aCurr = (nNextObj < pObjs->Count()) - ? (*pObjs)[nNextObj++]->GetDrawObj() - : static_cast< const SdrObject *>( 0 ); + { + aCurr = ( nNextObj < nObjsCount ) + ? (*pObjs)[nNextObj++]->GetDrawObj() + : static_cast< const SdrObject *>( 0 ); + } + if ( !aCurr.IsValid() ) + { + ::vos::ORef < SwAccessibleContext > xAccImpl = + rList.GetAccMap().GetContextImpl( &rFrm, sal_False ); + if( xAccImpl.isValid() ) + { + SwAccessibleContext* pAccImpl = xAccImpl.getBodyPtr(); + aCurr = SwAccessibleChild( pAccImpl->GetAdditionalAccessibleChild( nNextObj - nObjsCount ) ); + ++nNextObj; + } + } } } return *this; } -SwFrmOrObjSList_const_iterator& SwFrmOrObjSList_const_iterator::next_visible() +SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::next_visible() { next(); while( aCurr.IsValid() && - !aCurr.GetBox().IsOver( rList.aVisArea ) ) + !aCurr.GetBox( rList.GetAccMap() ).IsOver( rList.GetVisArea() ) ) + { next(); + } return *this; } + +SwAccessibleChildSList_const_iterator& SwAccessibleChildSList_const_iterator::operator++() +{ + return rList.IsVisibleOnly() ? next_visible() : next(); +} + diff --git a/sw/source/core/access/accfrmobjslist.hxx b/sw/source/core/access/accfrmobjslist.hxx index 2a310b44f2bd..df4192ef1867 100644 --- a/sw/source/core/access/accfrmobjslist.hxx +++ b/sw/source/core/access/accfrmobjslist.hxx @@ -31,117 +31,118 @@ #define _ACCFRMOBJSLIST_HXX #include +#include -class SwFrmOrObjSList; +class SwAccessibleMap; -class SwFrmOrObjSList_const_iterator -{ - friend class SwFrmOrObjSList; - const SwFrmOrObjSList& rList; // The frame we are iterating over - SwFrmOrObj aCurr; // The current object - sal_uInt16 nNextObj; // The index of the current sdr object - - inline SwFrmOrObjSList_const_iterator( const SwFrmOrObjSList& rLst ); - SwFrmOrObjSList_const_iterator( const SwFrmOrObjSList& rLst, sal_Bool ); - -// SwFrmOrObjSList_const_iterator& begin(); - SwFrmOrObjSList_const_iterator& next(); - SwFrmOrObjSList_const_iterator& next_visible(); - -public: - - inline SwFrmOrObjSList_const_iterator( - const SwFrmOrObjSList_const_iterator& rIter ); - inline sal_Bool operator==( - const SwFrmOrObjSList_const_iterator& r ) const; - inline sal_Bool operator!=( - const SwFrmOrObjSList_const_iterator& r ) const; - inline SwFrmOrObjSList_const_iterator& operator++(); - inline const SwFrmOrObj& operator*() const; -}; +class SwAccessibleChildSList; -// An iterator to iterate over a frame's child in any order -class SwFrmOrObjSList +class SwAccessibleChildSList_const_iterator { - friend class SwFrmOrObjSList_const_iterator; +private: + friend class SwAccessibleChildSList; - SwRect aVisArea; - const SwFrm *pFrm; // The frame we are iterating over - sal_Bool bVisibleOnly; - -public: + const SwAccessibleChildSList& rList; // The frame we are iterating over + sw::access::SwAccessibleChild aCurr; // The current object + sal_uInt16 nNextObj; // The index of the current sdr object - typedef SwFrmOrObjSList_const_iterator const_iterator; + inline SwAccessibleChildSList_const_iterator( const SwAccessibleChildSList& rLst ) + : rList( rLst ) + , nNextObj( 0 ) + {} - inline SwFrmOrObjSList( const SwFrm *pF ); - inline SwFrmOrObjSList( const SwRect& rVisArea, const SwFrm *pF ); + SwAccessibleChildSList_const_iterator( const SwAccessibleChildSList& rLst, + SwAccessibleMap& rAccMap ); - inline const_iterator begin() const; - inline const_iterator end() const; -}; - -inline SwFrmOrObjSList_const_iterator::SwFrmOrObjSList_const_iterator( - const SwFrmOrObjSList& rLst ) : - rList( rLst ), nNextObj( 0 ) -{ -} + SwAccessibleChildSList_const_iterator& next(); + SwAccessibleChildSList_const_iterator& next_visible(); -inline SwFrmOrObjSList_const_iterator::SwFrmOrObjSList_const_iterator( - const SwFrmOrObjSList_const_iterator& rIter ) : - rList( rIter.rList ), - aCurr( rIter.aCurr ), - nNextObj( rIter.nNextObj ) -{ -} +public: -inline sal_Bool SwFrmOrObjSList_const_iterator::operator==( - const SwFrmOrObjSList_const_iterator& r ) const -{ - return aCurr == r.aCurr; -} + inline SwAccessibleChildSList_const_iterator( const SwAccessibleChildSList_const_iterator& rIter ) + : rList( rIter.rList ) + , aCurr( rIter.aCurr ) + , nNextObj( rIter.nNextObj ) + {} -inline sal_Bool SwFrmOrObjSList_const_iterator::operator!=( - const SwFrmOrObjSList_const_iterator& r ) const -{ - return !(aCurr == r.aCurr); -} + inline sal_Bool operator==( const SwAccessibleChildSList_const_iterator& r ) const + { + return aCurr == r.aCurr; + } -inline SwFrmOrObjSList_const_iterator& SwFrmOrObjSList_const_iterator::operator++() -{ - return rList.bVisibleOnly ? next_visible() : next(); -} + inline sal_Bool operator!=( + const SwAccessibleChildSList_const_iterator& r ) const + { + return !(*this == r); + } -inline const SwFrmOrObj& SwFrmOrObjSList_const_iterator::operator*() const -{ - return aCurr; -} + SwAccessibleChildSList_const_iterator& operator++(); -inline SwFrmOrObjSList::SwFrmOrObjSList( const SwFrm *pF ) : - pFrm( pF ), - bVisibleOnly( sal_False ) -{ -} + inline const sw::access::SwAccessibleChild& operator*() const + { + return aCurr; + } +}; -inline SwFrmOrObjSList::SwFrmOrObjSList( const SwRect& rVisArea, - const SwFrm *pF ) : - aVisArea( rVisArea ), - pFrm( pF ) +// An iterator to iterate over a frame's child in any order +class SwAccessibleChildSList { - SwFrmOrObj aFrm( pFrm ); - bVisibleOnly = aFrm.IsVisibleChildrenOnly(); -} + const SwRect maVisArea; + const SwFrm& mrFrm; + const sal_Bool mbVisibleOnly; + SwAccessibleMap& mrAccMap; -inline SwFrmOrObjSList_const_iterator SwFrmOrObjSList::begin() const -{ -// SwFrmOrObjSList_const_iterator aIter2( *this ); -// aIter2.begin(); -// return aIter2; - return SwFrmOrObjSList_const_iterator( *this, sal_True ); -} +public: -inline SwFrmOrObjSList_const_iterator SwFrmOrObjSList::end() const -{ - return SwFrmOrObjSList_const_iterator( *this ); -} + typedef SwAccessibleChildSList_const_iterator const_iterator; + + inline SwAccessibleChildSList( const SwFrm& rFrm, + SwAccessibleMap& rAccMap ) + : maVisArea() + , mrFrm( rFrm ) + , mbVisibleOnly( sal_False ) + , mrAccMap( rAccMap ) + {} + + inline SwAccessibleChildSList( const SwRect& rVisArea, + const SwFrm& rFrm, + SwAccessibleMap& rAccMap ) + : maVisArea( rVisArea ) + , mrFrm( rFrm ) + , mbVisibleOnly( sw::access::SwAccessibleChild( &rFrm ).IsVisibleChildrenOnly() ) + , mrAccMap( rAccMap ) + { + } + + inline const_iterator begin() const + { + return SwAccessibleChildSList_const_iterator( *this, mrAccMap ); + } + + inline const_iterator end() const + { + return SwAccessibleChildSList_const_iterator( *this ); + } + + inline const SwFrm& GetFrm() const + { + return mrFrm; + } + + inline sal_Bool IsVisibleOnly() const + { + return mbVisibleOnly; + } + + inline const SwRect& GetVisArea() const + { + return maVisArea; + } + + inline SwAccessibleMap& GetAccMap() const + { + return mrAccMap; + } +}; #endif diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index d030f8d61561..d498800ec670 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -42,9 +42,7 @@ #include #include #include -#ifndef _ACCCONTEXT_HXX #include -#endif #include #include #include @@ -56,7 +54,7 @@ #include #include #include -#include "fesh.hxx" +#include #include #include #include @@ -64,10 +62,9 @@ #include #include #include +#include #include -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include -#endif #include #include #include @@ -80,10 +77,13 @@ #include #include // <-- +#include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; +using namespace ::sw::access; struct SwFrmFunc { @@ -332,7 +332,7 @@ private: SwRect maOldBox; // the old bounds for CHILD_POS_CHANGED // and POS_CHANGED uno::WeakReference < XAccessible > mxAcc; // The object that fires the event - SwFrmOrObj maFrmOrObj; // the child for CHILD_POS_CHANGED and + SwAccessibleChild maFrmOrObj; // the child for CHILD_POS_CHANGED and // the same as xAcc for any other // event type EventType meType; // The event type @@ -345,7 +345,7 @@ private: public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, - const SwFrmOrObj& rFrmOrObj ) + const SwAccessibleChild& rFrmOrObj ) : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), @@ -353,7 +353,7 @@ public: {} SwAccessibleEvent_Impl( EventType eT, - const SwFrmOrObj& rFrmOrObj ) + const SwAccessibleChild& rFrmOrObj ) : maFrmOrObj( rFrmOrObj ), meType( eT ), mnStates( 0 ) @@ -372,7 +372,7 @@ public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, - const SwFrmOrObj& rFrmOrObj, + const SwAccessibleChild& rFrmOrObj, const SwRect& rR ) : maOldBox( rR ), mxAcc( pA ), @@ -388,7 +388,7 @@ public: // --> OD 2005-12-12 #i27301# - use new type definition for parameter <_nStates> SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, - const SwFrmOrObj& rFrmOrObj, + const SwAccessibleChild& rFrmOrObj, const tAccessibleStates _nStates ) : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), @@ -428,7 +428,7 @@ public: maOldBox = rOldBox; } - inline const SwFrmOrObj& GetFrmOrObj() const + inline const SwAccessibleChild& GetFrmOrObj() const { return maFrmOrObj; } @@ -527,22 +527,26 @@ public: //------------------------------------------------------------------------------ -struct SwFrmOrObjFunc +struct SwAccessibleChildFunc { - sal_Bool operator()( const SwFrmOrObj& r1, - const SwFrmOrObj& r2 ) const + sal_Bool operator()( const SwAccessibleChild& r1, + const SwAccessibleChild& r2 ) const { const void *p1 = r1.GetSwFrm() - ? static_cast < const void * >( r1.GetSwFrm()) - : static_cast < const void * >( r1.GetSdrObject() ); + ? static_cast < const void * >( r1.GetSwFrm()) + : ( r1.GetDrawObject() + ? static_cast < const void * >( r1.GetDrawObject() ) + : static_cast < const void * >( r1.GetWindow() ) ); const void *p2 = r2.GetSwFrm() - ? static_cast < const void * >( r2.GetSwFrm()) - : static_cast < const void * >( r2.GetSdrObject() ); + ? static_cast < const void * >( r2.GetSwFrm()) + : ( r2.GetDrawObject() + ? static_cast < const void * >( r2.GetDrawObject() ) + : static_cast < const void * >( r2.GetWindow() ) ); return p1 < p2; } }; -typedef ::std::map < SwFrmOrObj, SwAccessibleEventList_Impl::iterator, - SwFrmOrObjFunc > _SwAccessibleEventMap_Impl; +typedef ::std::map < SwAccessibleChild, SwAccessibleEventList_Impl::iterator, + SwAccessibleChildFunc > _SwAccessibleEventMap_Impl; class SwAccessibleEventMap_Impl: public _SwAccessibleEventMap_Impl { @@ -580,6 +584,222 @@ typedef ::std::map< uno::WeakReference < XAccessible >, class SwAccessibleSelectedParas_Impl: public _SwAccessibleSelectedParas_Impl {}; // <-- + +// helper class that stores preview data +class SwAccPreviewData +{ + typedef std::vector Rectangles; + Rectangles maPreviewRects; + Rectangles maLogicRects; + + SwRect maVisArea; + Fraction maScale; + + const SwPageFrm *mpSelPage; + + /** adjust logic page retangle to its visible part + + OD 17.01.2003 #103492# + + @author OD + + @param _iorLogicPgSwRect + input/output parameter - reference to the logic page rectangle, which + has to be adjusted. + + @param _rPrevwPgSwRect + input parameter - constant reference to the corresponding preview page + rectangle; needed to determine the visible part of the logic page rectangle. + + @param _rPrevwWinSize + input paramter - constant reference to the preview window size in TWIP; + needed to determine the visible part of the logic page rectangle + */ + void AdjustLogicPgRectToVisibleArea( SwRect& _iorLogicPgSwRect, + const SwRect& _rPrevwPgSwRect, + const Size& _rPrevwWinSize ); + +public: + SwAccPreviewData(); + ~SwAccPreviewData(); + + // OD 14.01.2003 #103492# - complete re-factoring of method due to new + // page/print preview functionality. + void Update( const SwAccessibleMap& rAccMap, + const std::vector& _rPrevwPages, + const Fraction& _rScale, + const SwPageFrm* _pSelectedPageFrm, + const Size& _rPrevwWinSize ); + + // OD 14.01.2003 #103492# - complete re-factoring of method due to new + // page/print preview functionality. + void InvalidateSelection( const SwPageFrm* _pSelectedPageFrm ); + + const SwRect& GetVisArea() const; + + MapMode GetMapModeForPreview( ) const; + + /** Adjust the MapMode so that the preview page appears at the + * proper position. rPoint identifies the page for which the + * MapMode should be adjusted. If bFromPreview is true, rPoint is + * a preview coordinate; else it's a document coordinate. */ + // OD 17.01.2003 #103492# - delete unused 3rd parameter. + void AdjustMapMode( MapMode& rMapMode, + const Point& rPoint ) const; + + inline const SwPageFrm *GetSelPage() const { return mpSelPage; } + + void DisposePage(const SwPageFrm *pPageFrm ); +}; + +SwAccPreviewData::SwAccPreviewData() : + mpSelPage( 0 ) +{ +} + +SwAccPreviewData::~SwAccPreviewData() +{ +} + +// OD 13.01.2003 #103492# - complete re-factoring of method due to new page/print +// preview functionality. +void SwAccPreviewData::Update( const SwAccessibleMap& rAccMap, + const std::vector& _rPrevwPages, + const Fraction& _rScale, + const SwPageFrm* _pSelectedPageFrm, + const Size& _rPrevwWinSize ) +{ + // store preview scaling, maximal preview page size and selected page + maScale = _rScale; + mpSelPage = _pSelectedPageFrm; + + // prepare loop on preview pages + maPreviewRects.clear(); + maLogicRects.clear(); + SwAccessibleChild aPage; + maVisArea.Clear(); + + // loop on preview pages to calculate , and + // + for ( std::vector::const_iterator aPageIter = _rPrevwPages.begin(); + aPageIter != _rPrevwPages.end(); + ++aPageIter ) + { + aPage = (*aPageIter)->pPage; + + // add preview page rectangle to + Rectangle aPrevwPgRect( (*aPageIter)->aPrevwWinPos, (*aPageIter)->aPageSize ); + maPreviewRects.push_back( aPrevwPgRect ); + + // add logic page rectangle to + SwRect aLogicPgSwRect( aPage.GetBox( rAccMap ) ); + Rectangle aLogicPgRect( aLogicPgSwRect.SVRect() ); + maLogicRects.push_back( aLogicPgRect ); + // union visible area with visible part of logic page rectangle + if ( (*aPageIter)->bVisible ) + { + if ( !(*aPageIter)->pPage->IsEmptyPage() ) + { + AdjustLogicPgRectToVisibleArea( aLogicPgSwRect, + SwRect( aPrevwPgRect ), + _rPrevwWinSize ); + } + if ( maVisArea.IsEmpty() ) + maVisArea = aLogicPgSwRect; + else + maVisArea.Union( aLogicPgSwRect ); + } + } +} + +// OD 16.01.2003 #103492# - complete re-factoring of method due to new page/print +// preview functionality. +void SwAccPreviewData::InvalidateSelection( const SwPageFrm* _pSelectedPageFrm ) +{ + mpSelPage = _pSelectedPageFrm; + ASSERT( mpSelPage, "selected page not found" ); +} + +struct ContainsPredicate +{ + const Point& mrPoint; + ContainsPredicate( const Point& rPoint ) : mrPoint(rPoint) {} + bool operator() ( const Rectangle& rRect ) const + { + return rRect.IsInside( mrPoint ) ? true : false; + } +}; + +const SwRect& SwAccPreviewData::GetVisArea() const +{ + return maVisArea; +} + +void SwAccPreviewData::AdjustMapMode( MapMode& rMapMode, + const Point& rPoint ) const +{ + // adjust scale + rMapMode.SetScaleX( maScale ); + rMapMode.SetScaleY( maScale ); + + // find proper rectangle + Rectangles::const_iterator aBegin = maLogicRects.begin(); + Rectangles::const_iterator aEnd = maLogicRects.end(); + Rectangles::const_iterator aFound = ::std::find_if( aBegin, aEnd, + ContainsPredicate( rPoint ) ); + + if( aFound != aEnd ) + { + // found! set new origin + Point aPoint = (maPreviewRects.begin() + (aFound - aBegin))->TopLeft(); + aPoint -= (maLogicRects.begin() + (aFound-aBegin))->TopLeft(); + rMapMode.SetOrigin( aPoint ); + } + // else: don't adjust MapMode +} + +void SwAccPreviewData::DisposePage(const SwPageFrm *pPageFrm ) +{ + if( mpSelPage == pPageFrm ) + mpSelPage = 0; +} + +/** adjust logic page retangle to its visible part + + OD 17.01.2003 #103492# + + @author OD +*/ +void SwAccPreviewData::AdjustLogicPgRectToVisibleArea( + SwRect& _iorLogicPgSwRect, + const SwRect& _rPrevwPgSwRect, + const Size& _rPrevwWinSize ) +{ + // determine preview window rectangle + const SwRect aPrevwWinSwRect( Point( 0, 0 ), _rPrevwWinSize ); + // calculate visible preview page rectangle + SwRect aVisPrevwPgSwRect( _rPrevwPgSwRect ); + aVisPrevwPgSwRect.Intersection( aPrevwWinSwRect ); + // adjust logic page rectangle + SwTwips nTmpDiff; + // left + nTmpDiff = aVisPrevwPgSwRect.Left() - _rPrevwPgSwRect.Left(); + if ( nTmpDiff > 0 ) + _iorLogicPgSwRect.Left( _iorLogicPgSwRect.Left() + nTmpDiff ); + // top + nTmpDiff = aVisPrevwPgSwRect.Top() - _rPrevwPgSwRect.Top(); + if ( nTmpDiff > 0 ) + _iorLogicPgSwRect.Top( _iorLogicPgSwRect.Top() + nTmpDiff ); + // right + nTmpDiff = _rPrevwPgSwRect.Right() - aVisPrevwPgSwRect.Right(); + if ( nTmpDiff > 0 ) + _iorLogicPgSwRect.Right( _iorLogicPgSwRect.Right() - nTmpDiff ); + // bottom + nTmpDiff = _rPrevwPgSwRect.Bottom() - aVisPrevwPgSwRect.Bottom(); + if ( nTmpDiff > 0 ) + _iorLogicPgSwRect.Bottom( _iorLogicPgSwRect.Bottom() - nTmpDiff ); +} + //------------------------------------------------------------------------------ static sal_Bool AreInSameTable( const uno::Reference< XAccessible >& rAcc, const SwFrm *pFrm ) @@ -801,7 +1021,7 @@ void SwAccessibleMap::InvalidateCursorPosition( { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, - SwFrmOrObj(pAccImpl->GetFrm()), + SwAccessibleChild(pAccImpl->GetFrm()), ACC_STATE_CARET ); AppendEvent( aEvent ); } @@ -878,7 +1098,7 @@ void SwAccessibleMap::DoInvalidateShapeSelection() if( bChanged ) { const SwFrm* pParent = SwAccessibleFrame::GetParent( - SwFrmOrObj( pShape->first ), + SwAccessibleChild( pShape->first ), GetShell()->IsPreView() ); aParents.push_back( pParent ); } @@ -1169,7 +1389,7 @@ uno::Reference SwAccessibleMap::GetDocumentPreview( // create & update preview data object if( mpPreview == NULL ) mpPreview = new SwAccPreviewData(); - mpPreview->Update( _rPrevwPages, _rScale, _pSelectedPageFrm, _rPrevwWinSize ); + mpPreview->Update( *this, _rPrevwPages, _rScale, _pSelectedPageFrm, _rPrevwWinSize ); uno::Reference xAcc = _GetDocumentView( sal_True ); return xAcc; @@ -1464,7 +1684,7 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj ) void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, sal_Bool bRecursive ) { - SwFrmOrObj aFrmOrObj( pFrm, pObj ); + SwAccessibleChild 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 @@ -1517,7 +1737,7 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, mpShapeMap ) { SwAccessibleShapeMap_Impl::iterator aIter = - mpShapeMap->find( aFrmOrObj.GetSdrObject() ); + mpShapeMap->find( aFrmOrObj.GetDrawObject() ); if( aIter != mpShapeMap->end() ) { uno::Reference < XAccessible > xAcc( (*aIter).second ); @@ -1577,7 +1797,7 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, } else if( xShapeAccImpl.isValid() ) { - RemoveContext( aFrmOrObj.GetSdrObject() ); + RemoveContext( aFrmOrObj.GetDrawObject() ); xShapeAccImpl->dispose(); } @@ -1590,7 +1810,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, const SdrObject *pObj, const SwRect& rOldBox ) { - SwFrmOrObj aFrmOrObj( pFrm, pObj ); + SwAccessibleChild aFrmOrObj( pFrm, pObj ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { ::vos::ORef< SwAccessibleContext > xAccImpl; @@ -1672,7 +1892,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, void SwAccessibleMap::InvalidateContent( const SwFrm *pFrm ) { - SwFrmOrObj aFrmOrObj( pFrm ); + SwAccessibleChild aFrmOrObj( pFrm ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { uno::Reference < XAccessible > xAcc; @@ -1711,7 +1931,7 @@ void SwAccessibleMap::InvalidateContent( const SwFrm *pFrm ) // --> OD 2009-01-06 #i88069# void SwAccessibleMap::InvalidateAttr( const SwTxtFrm& rTxtFrm ) { - SwFrmOrObj aFrmOrObj( &rTxtFrm ); + SwAccessibleChild aFrmOrObj( &rTxtFrm ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { uno::Reference < XAccessible > xAcc; @@ -1750,7 +1970,7 @@ void SwAccessibleMap::InvalidateAttr( const SwTxtFrm& rTxtFrm ) void SwAccessibleMap::InvalidateCursorPosition( const SwFrm *pFrm ) { - SwFrmOrObj aFrmOrObj( pFrm ); + SwAccessibleChild aFrmOrObj( pFrm ); sal_Bool bShapeSelected = sal_False; const ViewShell *pVSh = GetShell(); if( pVSh->ISA( SwCrsrShell ) ) @@ -1876,7 +2096,7 @@ void SwAccessibleMap::InvalidateStates( tAccessibleStates _nStates, const SwFrm* _pFrm ) { // Start with the frame or the first upper that is accessible - SwFrmOrObj aFrmOrObj( _pFrm ); + SwAccessibleChild aFrmOrObj( _pFrm ); while( aFrmOrObj.GetSwFrm() && !aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) aFrmOrObj = aFrmOrObj.GetSwFrm()->GetUpper(); @@ -1890,7 +2110,7 @@ void SwAccessibleMap::InvalidateStates( tAccessibleStates _nStates, { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, - SwFrmOrObj(pAccImpl->GetFrm()), + SwAccessibleChild(pAccImpl->GetFrm()), _nStates ); AppendEvent( aEvent ); } @@ -1906,7 +2126,7 @@ void SwAccessibleMap::_InvalidateRelationSet( const SwFrm* pFrm, sal_Bool bFrom ) { // first, see if this frame is accessible, and if so, get the respective - SwFrmOrObj aFrmOrObj( pFrm ); + SwAccessibleChild aFrmOrObj( pFrm ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { uno::Reference < XAccessible > xAcc; @@ -1932,7 +2152,7 @@ void SwAccessibleMap::_InvalidateRelationSet( const SwFrm* pFrm, if( GetShell()->ActionPend() ) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, - pAccImpl, SwFrmOrObj(pFrm), + pAccImpl, SwAccessibleChild(pFrm), ( bFrom ? ACC_STATE_RELATION_FROM : ACC_STATE_RELATION_TO ) ); @@ -1977,7 +2197,7 @@ void SwAccessibleMap::InvalidateParaFlowRelation( const SwTxtFrm& _rTxtFrm, void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) { // first, see if this frame is accessible, and if so, get the respective - SwFrmOrObj aFrmOrObj( &_rTxtFrm ); + SwAccessibleChild aFrmOrObj( &_rTxtFrm ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { uno::Reference < XAccessible > xAcc; @@ -2005,7 +2225,7 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, - SwFrmOrObj( &_rTxtFrm ), + SwAccessibleChild( &_rTxtFrm ), ACC_STATE_TEXT_SELECTION_CHANGED ); AppendEvent( aEvent ); } @@ -2029,7 +2249,7 @@ void SwAccessibleMap::UpdatePreview( const std::vector& _rPrevwPages DBG_ASSERT( mpPreview != NULL, "no preview data?" ); // OD 15.01.2003 #103492# - adjustments for changed method signature - mpPreview->Update( _rPrevwPages, _rScale, _pSelectedPageFrm, _rPrevwWinSize ); + mpPreview->Update( *this, _rPrevwPages, _rScale, _pSelectedPageFrm, _rPrevwWinSize ); // propagate change of VisArea through the document's // accessibility tree; this will also send appropriate scroll @@ -2619,153 +2839,13 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas() } } -// -// SwAccPreviewData -// - -SwAccPreviewData::SwAccPreviewData() : - mpSelPage( 0 ) +const SwRect& SwAccessibleMap::GetVisArea() const { -} + DBG_ASSERT( !GetShell()->IsPreView() || (mpPreview != NULL), + "preview without preview data?" ); -SwAccPreviewData::~SwAccPreviewData() -{ + return GetShell()->IsPreView() + ? mpPreview->GetVisArea() + : GetShell()->VisArea(); } -// OD 13.01.2003 #103492# - complete re-factoring of method due to new page/print -// preview functionality. -void SwAccPreviewData::Update( const std::vector& _rPrevwPages, - const Fraction& _rScale, - const SwPageFrm* _pSelectedPageFrm, - const Size& _rPrevwWinSize ) -{ - // store preview scaling, maximal preview page size and selected page - maScale = _rScale; - mpSelPage = _pSelectedPageFrm; - - // prepare loop on preview pages - maPreviewRects.clear(); - maLogicRects.clear(); - SwFrmOrObj aPage; - maVisArea.Clear(); - - // loop on preview pages to calculate , and - // - for ( std::vector::const_iterator aPageIter = _rPrevwPages.begin(); - aPageIter != _rPrevwPages.end(); - ++aPageIter ) - { - aPage = (*aPageIter)->pPage; - - // add preview page rectangle to - Rectangle aPrevwPgRect( (*aPageIter)->aPrevwWinPos, (*aPageIter)->aPageSize ); - maPreviewRects.push_back( aPrevwPgRect ); - - // add logic page rectangle to - SwRect aLogicPgSwRect( aPage.GetBox() ); - Rectangle aLogicPgRect( aLogicPgSwRect.SVRect() ); - maLogicRects.push_back( aLogicPgRect ); - // union visible area with visible part of logic page rectangle - if ( (*aPageIter)->bVisible ) - { - if ( !(*aPageIter)->pPage->IsEmptyPage() ) - { - AdjustLogicPgRectToVisibleArea( aLogicPgSwRect, - SwRect( aPrevwPgRect ), - _rPrevwWinSize ); - } - if ( maVisArea.IsEmpty() ) - maVisArea = aLogicPgSwRect; - else - maVisArea.Union( aLogicPgSwRect ); - } - } -} - -// OD 16.01.2003 #103492# - complete re-factoring of method due to new page/print -// preview functionality. -void SwAccPreviewData::InvalidateSelection( const SwPageFrm* _pSelectedPageFrm ) -{ - mpSelPage = _pSelectedPageFrm; - ASSERT( mpSelPage, "selected page not found" ); -} - -struct ContainsPredicate -{ - const Point& mrPoint; - ContainsPredicate( const Point& rPoint ) : mrPoint(rPoint) {} - bool operator() ( const Rectangle& rRect ) const - { - return rRect.IsInside( mrPoint ) ? true : false; - } -}; - -const SwRect& SwAccPreviewData::GetVisArea() const -{ - return maVisArea; -} - -void SwAccPreviewData::AdjustMapMode( MapMode& rMapMode, - const Point& rPoint ) const -{ - // adjust scale - rMapMode.SetScaleX( maScale ); - rMapMode.SetScaleY( maScale ); - - // find proper rectangle - Rectangles::const_iterator aBegin = maLogicRects.begin(); - Rectangles::const_iterator aEnd = maLogicRects.end(); - Rectangles::const_iterator aFound = ::std::find_if( aBegin, aEnd, - ContainsPredicate( rPoint ) ); - - if( aFound != aEnd ) - { - // found! set new origin - Point aPoint = (maPreviewRects.begin() + (aFound - aBegin))->TopLeft(); - aPoint -= (maLogicRects.begin() + (aFound-aBegin))->TopLeft(); - rMapMode.SetOrigin( aPoint ); - } - // else: don't adjust MapMode -} - -void SwAccPreviewData::DisposePage(const SwPageFrm *pPageFrm ) -{ - if( mpSelPage == pPageFrm ) - mpSelPage = 0; -} - -/** adjust logic page retangle to its visible part - - OD 17.01.2003 #103492# - - @author OD -*/ -void SwAccPreviewData::AdjustLogicPgRectToVisibleArea( - SwRect& _iorLogicPgSwRect, - const SwRect& _rPrevwPgSwRect, - const Size& _rPrevwWinSize ) -{ - // determine preview window rectangle - const SwRect aPrevwWinSwRect( Point( 0, 0 ), _rPrevwWinSize ); - // calculate visible preview page rectangle - SwRect aVisPrevwPgSwRect( _rPrevwPgSwRect ); - aVisPrevwPgSwRect.Intersection( aPrevwWinSwRect ); - // adjust logic page rectangle - SwTwips nTmpDiff; - // left - nTmpDiff = aVisPrevwPgSwRect.Left() - _rPrevwPgSwRect.Left(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Left( _iorLogicPgSwRect.Left() + nTmpDiff ); - // top - nTmpDiff = aVisPrevwPgSwRect.Top() - _rPrevwPgSwRect.Top(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Top( _iorLogicPgSwRect.Top() + nTmpDiff ); - // right - nTmpDiff = _rPrevwPgSwRect.Right() - aVisPrevwPgSwRect.Right(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Right( _iorLogicPgSwRect.Right() - nTmpDiff ); - // bottom - nTmpDiff = _rPrevwPgSwRect.Bottom() - aVisPrevwPgSwRect.Bottom(); - if ( nTmpDiff > 0 ) - _iorLogicPgSwRect.Bottom( _iorLogicPgSwRect.Bottom() - nTmpDiff ); -} diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index ced1e6261c7b..d9ccda18c68f 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -31,12 +31,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" #include +#include #include #include #include #include #include -#include "fesh.hxx" +#include #include #include #include @@ -52,48 +53,32 @@ #include #include #include -#include "accpara.hxx" -#ifndef _ACCESS_HRC -#include "access.hrc" -#endif -#include "accportions.hxx" +#include +#include +#include #include // for ExecuteAtViewShell(...) #include // for ExecuteAtViewShell(...) #include // for ExecuteAtViewShell(...) #include // for GetWordBoundary // for get/setCharacterAttribute(...) -#include "unocrsr.hxx" -#include "unoobj.hxx" -#include "unoport.hxx" -#include "doc.hxx" -#include "crsskip.hxx" +#include +#include +#include +#include +#include #include #include #include -// --> OD 2005-12-02 #i27138# #include #include -// <-- #include -// --> OD 2006-07-12 #i63870# #include -// <-- -// --> OD 2007-01-15 #i72800# #include -// <-- -// --> OD 2007-01-15 #i73371# #include -// <-- -// --> OD 2007-01-17 #i71385# #include #include -// <-- -// --> OD 2007-11-12 #i82637# #include -// <-- -// --> OD 2008-05-26 #i71360# #include -// <-- #include @@ -1691,7 +1676,7 @@ awt::Rectangle SwAccessibleParagraph::getCharacterBounds( CHECK_FOR_WINDOW( XAccessibleComponent, pWin ); Rectangle aScreenRect( GetMap()->CoreToPixel( aCoreRect.SVRect() )); - SwRect aFrmLogBounds( GetBounds() ); // twip rel to doc root + SwRect aFrmLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root Point aFrmPixPos( GetMap()->CoreToPixel( aFrmLogBounds.SVRect() ).TopLeft() ); aScreenRect.Move( -aFrmPixPos.X(), -aFrmPixPos.Y() ); @@ -1729,7 +1714,7 @@ sal_Int32 SwAccessibleParagraph::getIndexAtPoint( const awt::Point& rPoint ) Window *pWin = GetWindow(); CHECK_FOR_WINDOW( XAccessibleComponent, pWin ); Point aPoint( rPoint.X, rPoint.Y ); - SwRect aLogBounds( GetBounds( GetFrm() ) ); // twip rel to doc root + SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root Point aPixPos( GetMap()->CoreToPixel( aLogBounds.SVRect() ).TopLeft() ); aPoint.X() += aPixPos.X(); aPoint.Y() += aPixPos.Y(); @@ -2557,7 +2542,7 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getNumberOfLineWithCaret() Rectangle aScreenRect( GetMap()->CoreToPixel( aCursorCoreRect.SVRect() )); - SwRect aFrmLogBounds( GetBounds() ); // twip rel to doc root + SwRect aFrmLogBounds( GetBounds( *(GetMap()) ) ); // twip rel to doc root Point aFrmPixPos( GetMap()->CoreToPixel( aFrmLogBounds.SVRect() ).TopLeft() ); aScreenRect.Move( -aFrmPixPos.X(), -aFrmPixPos.Y() ); diff --git a/sw/source/core/access/accpara.hxx b/sw/source/core/access/accpara.hxx index 43efd8efa866..d06235196dbb 100644 --- a/sw/source/core/access/accpara.hxx +++ b/sw/source/core/access/accpara.hxx @@ -29,24 +29,16 @@ ************************************************************************/ #ifndef _ACCPARA_HXX #define _ACCPARA_HXX -#ifndef _ACCCONTEXT_HXX -#include "acccontext.hxx" -#endif + +#include #include #include #include -// --> OD 2008-05-19 #i71360# #include -// <-- -// --> OD 2008-05-29 #i89175# #include -// <-- - -// --> OD 2006-07-11 #i63870# #include #include -// <-- -#include "accselectionhelper.hxx" +#include class SwTxtFrm; class SwTxtNode; @@ -70,15 +62,9 @@ class SwAccessibleParagraph : public ::com::sun::star::accessibility::XAccessibleEditableText, public com::sun::star::accessibility::XAccessibleSelection, public com::sun::star::accessibility::XAccessibleHypertext, - // --> OD 2008-05-19 #i71360# public com::sun::star::accessibility::XAccessibleTextMarkup, - // <-- - // --> OD 2008-05-29 #i89175# public com::sun::star::accessibility::XAccessibleMultiLineText, - // <-- - // --> OD 2006-07-11 #i63870# public ::com::sun::star::accessibility::XAccessibleTextAttributes - // <-- { friend class SwAccessibleHyperlink; diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 3f0acc53a2cf..33301b28ee17 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -35,15 +35,14 @@ #include #include -#ifndef _ACCCONTEXT_HXX #include -#endif #include #include #include -#include "fesh.hxx" +#include #include // for SolarMutex #include +#include using namespace ::com::sun::star; @@ -53,7 +52,7 @@ using ::com::sun::star::accessibility::XAccessible; using ::com::sun::star::accessibility::XAccessibleContext; using ::com::sun::star::accessibility::XAccessibleSelection; - +using namespace ::sw::access; SwAccessibleSelectionHelper::SwAccessibleSelectionHelper( SwAccessibleContext& rCtxt ) : @@ -103,7 +102,8 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( vos::OGuard aGuard(Application::GetSolarMutex()); // Get the respective child as SwFrm (also do index checking), ... - const SwFrmOrObj aChild = rContext.GetChild( nChildIndex ); + const SwAccessibleChild aChild = rContext.GetChild( *(rContext.GetMap()), + nChildIndex ); if( !aChild.IsValid() ) throwIndexOutOfBoundsException(); @@ -113,7 +113,7 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( SwFEShell* pFEShell = GetFEShell(); if( pFEShell != NULL ) { - const SdrObject *pObj = aChild.GetSdrObject(); + const SdrObject *pObj = aChild.GetDrawObject(); if( pObj ) { bRet = rContext.Select( const_cast< SdrObject *>( pObj ), 0==aChild.GetSwFrm()); @@ -132,7 +132,8 @@ sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( vos::OGuard aGuard(Application::GetSolarMutex()); // Get the respective child as SwFrm (also do index checking), ... - const SwFrmOrObj aChild = rContext.GetChild( nChildIndex ); + const SwAccessibleChild aChild = rContext.GetChild( *(rContext.GetMap()), + nChildIndex ); if( !aChild.IsValid() ) throwIndexOutOfBoundsException(); @@ -141,13 +142,13 @@ sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( SwFEShell* pFEShell = GetFEShell(); if( pFEShell ) { - if( aChild.GetSwFrm() != 0 ) + if ( aChild.GetSwFrm() != 0 ) { bRet = (pFEShell->GetCurrFlyFrm() == aChild.GetSwFrm()); } - else + else if ( aChild.GetDrawObject() ) { - bRet = pFEShell->IsObjSelected( *aChild.GetSdrObject() ); + bRet = pFEShell->IsObjSelected( *aChild.GetDrawObject() ); } } @@ -171,15 +172,15 @@ void SwAccessibleSelectionHelper::selectAllAccessibleChildren( ) SwFEShell* pFEShell = GetFEShell(); if( pFEShell ) { - ::std::list< SwFrmOrObj > aChildren; - rContext.GetChildren( aChildren ); + ::std::list< SwAccessibleChild > aChildren; + rContext.GetChildren( *(rContext.GetMap()), aChildren ); - ::std::list< SwFrmOrObj >::const_iterator aIter = aChildren.begin(); - ::std::list< SwFrmOrObj >::const_iterator aEndIter = aChildren.end(); + ::std::list< SwAccessibleChild >::const_iterator aIter = aChildren.begin(); + ::std::list< SwAccessibleChild >::const_iterator aEndIter = aChildren.end(); while( aIter != aEndIter ) { - const SwFrmOrObj& rChild = *aIter; - const SdrObject *pObj = rChild.GetSdrObject(); + const SwAccessibleChild& rChild = *aIter; + const SdrObject* pObj = rChild.GetDrawObject(); const SwFrm* pFrm = rChild.GetSwFrm(); if( pObj && !(pFrm != 0 && pFEShell->IsObjSelected()) ) { @@ -203,10 +204,10 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) SwFEShell* pFEShell = GetFEShell(); if( pFEShell != 0 ) { - const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); + const SwFlyFrm* pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { - if( rContext.GetParent( SwFrmOrObj(pFlyFrm), rContext.IsInPagePreview()) == + if( rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == rContext.GetFrm() ) { nCount = 1; @@ -217,20 +218,20 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) sal_uInt16 nSelObjs = pFEShell->IsObjSelected(); if( nSelObjs > 0 ) { - ::std::list< SwFrmOrObj > aChildren; - rContext.GetChildren( aChildren ); + ::std::list< SwAccessibleChild > aChildren; + rContext.GetChildren( *(rContext.GetMap()), aChildren ); - ::std::list< SwFrmOrObj >::const_iterator aIter = + ::std::list< SwAccessibleChild >::const_iterator aIter = aChildren.begin(); - ::std::list< SwFrmOrObj >::const_iterator aEndIter = + ::std::list< SwAccessibleChild >::const_iterator aEndIter = aChildren.end(); while( aIter != aEndIter && nCount < nSelObjs ) { - const SwFrmOrObj& rChild = *aIter; - if( rChild.GetSdrObject() && !rChild.GetSwFrm() && + const SwAccessibleChild& rChild = *aIter; + if( rChild.GetDrawObject() && !rChild.GetSwFrm() && rContext.GetParent(rChild, rContext.IsInPagePreview()) == rContext.GetFrm() && - pFEShell->IsObjSelected( *rChild.GetSdrObject() ) ) + pFEShell->IsObjSelected( *rChild.GetDrawObject() ) ) { nCount++; } @@ -257,12 +258,12 @@ Reference SwAccessibleSelectionHelper::getSelectedAccessibleChild( if( 0 == pFEShell ) throwIndexOutOfBoundsException(); - SwFrmOrObj aChild; + SwAccessibleChild aChild; const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { if( 0 == nSelectedChildIndex && - rContext.GetParent( SwFrmOrObj(pFlyFrm), rContext.IsInPagePreview()) == + rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == rContext.GetFrm() ) { aChild = pFlyFrm; @@ -274,18 +275,18 @@ Reference SwAccessibleSelectionHelper::getSelectedAccessibleChild( if( 0 == nSelObjs || nSelectedChildIndex >= nSelObjs ) throwIndexOutOfBoundsException(); - ::std::list< SwFrmOrObj > aChildren; - rContext.GetChildren( aChildren ); + ::std::list< SwAccessibleChild > aChildren; + rContext.GetChildren( *(rContext.GetMap()), aChildren ); - ::std::list< SwFrmOrObj >::const_iterator aIter = aChildren.begin(); - ::std::list< SwFrmOrObj >::const_iterator aEndIter = aChildren.end(); + ::std::list< SwAccessibleChild >::const_iterator aIter = aChildren.begin(); + ::std::list< SwAccessibleChild >::const_iterator aEndIter = aChildren.end(); while( aIter != aEndIter && !aChild.IsValid() ) { - const SwFrmOrObj& rChild = *aIter; - if( rChild.GetSdrObject() && !rChild.GetSwFrm() && + const SwAccessibleChild& rChild = *aIter; + if( rChild.GetDrawObject() && !rChild.GetSwFrm() && rContext.GetParent(rChild, rContext.IsInPagePreview()) == rContext.GetFrm() && - pFEShell->IsObjSelected( *rChild.GetSdrObject() ) ) + pFEShell->IsObjSelected( *rChild.GetDrawObject() ) ) { if( 0 == nSelectedChildIndex ) aChild = rChild; @@ -312,10 +313,10 @@ Reference SwAccessibleSelectionHelper::getSelectedAccessibleChild( xChild = xChildImpl.getBodyPtr(); } } - else + else if ( aChild.GetDrawObject() ) { ::vos::ORef < ::accessibility::AccessibleShape > xChildImpl( - rContext.GetMap()->GetContextImpl( aChild.GetSdrObject(), + rContext.GetMap()->GetContextImpl( aChild.GetDrawObject(), &rContext, sal_True ) ); if( xChildImpl.isValid() ) xChild = xChildImpl.getBodyPtr(); @@ -331,6 +332,6 @@ void SwAccessibleSelectionHelper::deselectAccessibleChild( { // return sal_False // we can't deselect if( nChildIndex < 0 || - nChildIndex >= rContext.GetChildCount() ) + nChildIndex >= rContext.GetChildCount( *(rContext.GetMap()) ) ) throwIndexOutOfBoundsException(); } diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx index 6ec66caf6c64..b43a86b96a8c 100644 --- a/sw/source/core/access/acctable.cxx +++ b/sw/source/core/access/acctable.cxx @@ -45,26 +45,23 @@ #include #include #include -// --> OD 2007-06-27 #i77106# #include -// <-- #include #include -#include "crsrsh.hxx" -#include "viscrs.hxx" +#include +#include #include -#include "fesh.hxx" +#include #include -#include "accmap.hxx" -#ifndef _ACCESS_HRC -#include "access.hrc" -#endif +#include +#include #include using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; using ::rtl::OUStringBuffer; +using namespace ::sw::access; const sal_Char sServiceName[] = "com.sun.star.table.AccessibleTableView"; const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleTableView"; @@ -86,15 +83,14 @@ public: class SwAccessibleTableData_Impl { + SwAccessibleMap& mrAccMap; Int32Set_Impl maRows; Int32Set_Impl maColumns; Int32PairList_Impl maExtents; // cell extends for event processing only Point maTabFrmPos; const SwTabFrm *mpTabFrm; sal_Bool mbIsInPagePreview; - // --> OD 2007-06-27 #i77106# bool mbOnlyTableColumnHeader; - // <-- void CollectData( const SwFrm *pFrm ); void CollectExtents( const SwFrm *pFrm ); @@ -117,7 +113,8 @@ class SwAccessibleTableData_Impl public: // --> OD 2007-06-27 #i77106# // add third optional parameter , default value - SwAccessibleTableData_Impl( const SwTabFrm *pTabFrm, + SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap, + const SwTabFrm *pTabFrm, sal_Bool bIsInPagePreview, bool bOnlyTableColumnHeader = false ); // <-- @@ -157,12 +154,12 @@ public: void SwAccessibleTableData_Impl::CollectData( const SwFrm *pFrm ) { - const SwFrmOrObjSList aList( pFrm ); - SwFrmOrObjSList::const_iterator aIter( aList.begin() ); - SwFrmOrObjSList::const_iterator aEndIter( aList.end() ); + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); while( aIter != aEndIter ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; const SwFrm *pLower = rLower.GetSwFrm(); if( pLower ) { @@ -192,12 +189,12 @@ void SwAccessibleTableData_Impl::CollectData( const SwFrm *pFrm ) void SwAccessibleTableData_Impl::CollectExtents( const SwFrm *pFrm ) { - const SwFrmOrObjSList aList( pFrm ); - SwFrmOrObjSList::const_iterator aIter( aList.begin() ); - SwFrmOrObjSList::const_iterator aEndIter( aList.end() ); + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); while( aIter != aEndIter ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; const SwFrm *pLower = rLower.GetSwFrm(); if( pLower ) { @@ -233,12 +230,12 @@ sal_Bool SwAccessibleTableData_Impl::FindCell( { sal_Bool bFound = sal_False; - const SwFrmOrObjSList aList( pFrm ); - SwFrmOrObjSList::const_iterator aIter( aList.begin() ); - SwFrmOrObjSList::const_iterator aEndIter( aList.end() ); + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); while( !bFound && aIter != aEndIter ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; const SwFrm *pLower = rLower.GetSwFrm(); ASSERT( pLower, "child should be a frame" ); if( pLower ) @@ -285,15 +282,15 @@ void SwAccessibleTableData_Impl::GetSelection( SwAccTableSelHander_Impl& rSelHdl, sal_Bool bColumns ) const { - const SwFrmOrObjSList aList( pFrm ); - SwFrmOrObjSList::const_iterator aIter( aList.begin() ); - SwFrmOrObjSList::const_iterator aEndIter( aList.end() ); + const SwAccessibleChildSList aList( *pFrm, mrAccMap ); + SwAccessibleChildSList::const_iterator aIter( aList.begin() ); + SwAccessibleChildSList::const_iterator aEndIter( aList.end() ); while( aIter != aEndIter ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; const SwFrm *pLower = rLower.GetSwFrm(); ASSERT( pLower, "child should be a frame" ); - const SwRect& rBox = rLower.GetBox(); + const SwRect& rBox = rLower.GetBox( mrAccMap ); if( pLower && rBox.IsOver( rArea ) ) { if( rLower.IsAccessible( mbIsInPagePreview ) ) @@ -433,15 +430,15 @@ sal_Bool SwAccessibleTableData_Impl::CompareExtents( return sal_True; } -SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( const SwTabFrm *pTabFrm, +SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap, + const SwTabFrm *pTabFrm, sal_Bool bIsInPagePreview, bool bOnlyTableColumnHeader ) - : maTabFrmPos( pTabFrm->Frm().Pos() ), - mpTabFrm( pTabFrm ), - mbIsInPagePreview( bIsInPagePreview ), - // --> OD 2007-06-27 #i77106# - mbOnlyTableColumnHeader( bOnlyTableColumnHeader ) - // <-- + : mrAccMap( rAccMap ) + , maTabFrmPos( pTabFrm->Frm().Pos() ) + , mpTabFrm( pTabFrm ) + , mbIsInPagePreview( bIsInPagePreview ) + , mbOnlyTableColumnHeader( bOnlyTableColumnHeader ) { CollectData( mpTabFrm ); CollectExtents( mpTabFrm ); @@ -644,7 +641,7 @@ const SwTableBox* SwAccessibleTable::GetTableBox( sal_Int32 nChildIndex ) const const SwTableBox* pBox = NULL; // get table box for 'our' table cell - SwFrmOrObj aCell( GetChild( nChildIndex ) ); + SwAccessibleChild aCell( GetChild( *(const_cast(GetMap())), nChildIndex ) ); if( aCell.GetSwFrm() ) { const SwFrm* pChildFrm = aCell.GetSwFrm(); @@ -858,7 +855,7 @@ uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTable::getImplementationId() SwAccessibleTableData_Impl* SwAccessibleTable::CreateNewTableData() { const SwTabFrm* pTabFrm = static_cast( GetFrm() ); - return new SwAccessibleTableData_Impl( pTabFrm, IsInPagePreview() ); + return new SwAccessibleTableData_Impl( *GetMap(), pTabFrm, IsInPagePreview() ); } // <-- @@ -1179,9 +1176,11 @@ sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleIndex( CHECK_FOR_DEFUNC( XAccessibleTable ) - SwFrmOrObj aCell( GetTableData().GetCell( nRow, nColumn, sal_False, this )); - if( aCell.IsValid() ) - nRet = GetChildIndex( aCell ); + SwAccessibleChild aCell( GetTableData().GetCell( nRow, nColumn, sal_False, this )); + if ( aCell.IsValid() ) + { + nRet = GetChildIndex( *(GetMap()), aCell ); + } return nRet; } @@ -1203,8 +1202,8 @@ sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRow( sal_Int32 nChildIndex ) } // <-- - SwFrmOrObj aCell( GetChild( nChildIndex ) ); - if( aCell.GetSwFrm() ) + SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) ); + if ( aCell.GetSwFrm() ) { sal_Int32 nTop = aCell.GetSwFrm()->Frm().Top(); nTop -= GetFrm()->Frm().Top(); @@ -1242,8 +1241,8 @@ sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumn( } // <-- - SwFrmOrObj aCell( GetChild( nChildIndex ) ); - if( aCell.GetSwFrm() ) + SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) ); + if ( aCell.GetSwFrm() ) { sal_Int32 nLeft = aCell.GetSwFrm()->Frm().Left(); nLeft -= GetFrm()->Frm().Left(); @@ -1310,8 +1309,8 @@ void SwAccessibleTable::Dispose( sal_Bool bRecursive ) SwAccessibleContext::Dispose( bRecursive ); } -void SwAccessibleTable::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, - sal_Bool bRecursive ) +void SwAccessibleTable::DisposeChild( const SwAccessibleChild& rChildFrmOrObj, + sal_Bool bRecursive ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1333,7 +1332,7 @@ void SwAccessibleTable::DisposeChild( const SwFrmOrObj& rChildFrmOrObj, SwAccessibleContext::DisposeChild( rChildFrmOrObj, bRecursive ); } -void SwAccessibleTable::InvalidateChildPosOrSize( const SwFrmOrObj& rChildFrmOrObj, +void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChildFrmOrObj, const SwRect& rOldBox ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -1664,7 +1663,7 @@ SwAccessibleTableColHeaders::SwAccessibleTableColHeaders( SwAccessibleMap *pMap2 SwAccessibleTableData_Impl* SwAccessibleTableColHeaders::CreateNewTableData() { const SwTabFrm* pTabFrm = static_cast( GetFrm() ); - return new SwAccessibleTableData_Impl( pTabFrm, IsInPagePreview(), true ); + return new SwAccessibleTableData_Impl( *(GetMap()), pTabFrm, IsInPagePreview(), true ); } @@ -1690,11 +1689,11 @@ sal_Int32 SAL_CALL SwAccessibleTableColHeaders::getAccessibleChildCount(void) sal_Int32 nCount = 0; const SwTabFrm* pTabFrm = static_cast( GetFrm() ); - const SwFrmOrObjSList aVisList( GetVisArea(), pTabFrm ); - SwFrmOrObjSList::const_iterator aIter( aVisList.begin() ); + const SwAccessibleChildSList aVisList( GetVisArea(), *pTabFrm, *(GetMap()) ); + SwAccessibleChildSList::const_iterator aIter( aVisList.begin() ); while( aIter != aVisList.end() ) { - const SwFrmOrObj& rLower = *aIter; + const SwAccessibleChild& rLower = *aIter; if( rLower.IsAccessible( IsInPagePreview() ) ) { nCount++; @@ -1705,7 +1704,8 @@ sal_Int32 SAL_CALL SwAccessibleTableColHeaders::getAccessibleChildCount(void) if ( !rLower.GetSwFrm()->IsRowFrm() || pTabFrm->IsInHeadline( *(rLower.GetSwFrm()) ) ) { - nCount += SwAccessibleFrame::GetChildCount( GetVisArea(), + nCount += SwAccessibleFrame::GetChildCount( *(GetMap()), + GetVisArea(), rLower.GetSwFrm(), IsInPagePreview() ); } diff --git a/sw/source/core/access/acctable.hxx b/sw/source/core/access/acctable.hxx index ce63090caca1..6c340460c2a1 100644 --- a/sw/source/core/access/acctable.hxx +++ b/sw/source/core/access/acctable.hxx @@ -32,13 +32,16 @@ #include #include -#ifndef _ACCCONTEXT_HXX -#include "acccontext.hxx" -#endif +#include class SwTabFrm; class SwAccessibleTableData_Impl; class SwTableBox; +class SwSelBoxes; + +namespace sw { namespace access { + class SwAccessibleChild; +} } class SwAccessibleTable : public SwAccessibleContext, @@ -221,9 +224,10 @@ public: // The object is not visible an longer and should be destroyed virtual void Dispose( sal_Bool bRecursive = sal_False ); - virtual void DisposeChild( const SwFrmOrObj& rFrmOrObj, sal_Bool bRecursive ); - virtual void InvalidateChildPosOrSize( const SwFrmOrObj& rFrmOrObj, - const SwRect& rFrm ); + virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrmOrObj, + sal_Bool bRecursive ); + virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrmOrObj, + const SwRect& rFrm ); //===== XAccessibleSelection ============================================ diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx index aada9ea05397..a6a7b9903a92 100644 --- a/sw/source/core/fields/postithelper.cxx +++ b/sw/source/core/fields/postithelper.cxx @@ -45,12 +45,50 @@ #include #include #include +#include #include #include #include #include +namespace { + +struct LayoutInfoOrder +{ + bool operator()( const SwLayoutInfo& rLayoutInfo, + const SwLayoutInfo& rNewLayoutInfo ) + { + if ( rLayoutInfo.mnPageNumber != rNewLayoutInfo.mnPageNumber ) + { + // corresponding instances are on different pages + return rLayoutInfo.mnPageNumber < rNewLayoutInfo.mnPageNumber; + } + else + { + // corresponding instances are in different repeating table header rows + ASSERT( rLayoutInfo.mpAnchorFrm->FindTabFrm(), + " - table frame not found" ); + ASSERT( rNewLayoutInfo.mpAnchorFrm->FindTabFrm(), + " - table frame not found" ); + const SwTabFrm* pLayoutInfoTabFrm( rLayoutInfo.mpAnchorFrm->FindTabFrm() ); + const SwTabFrm* pNewLayoutInfoTabFrm( rNewLayoutInfo.mpAnchorFrm->FindTabFrm() ); + const SwTabFrm* pTmpTabFrm( pNewLayoutInfoTabFrm ); + while ( pTmpTabFrm && pTmpTabFrm->GetFollow() ) + { + pTmpTabFrm = static_cast(pTmpTabFrm->GetFollow()->GetFrm()); + if ( pTmpTabFrm == pLayoutInfoTabFrm ) + { + return false; + } + } + return true; + } + } +}; + +} // eof anonymous namespace + SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLayoutInfo >& rInfo, SwPosition& rPos ) { SwLayoutStatus aRet = INVISIBLE; @@ -71,7 +109,7 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa { SwLayoutInfo aInfo; pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 ); - aInfo.mpAssociatedFrm = pTxtFrm; + aInfo.mpAnchorFrm = pTxtFrm; aInfo.mPageFrame = pPage->Frm(); aInfo.mPagePrtArea = pPage->Prt(); aInfo.mPagePrtArea.Pos() += aInfo.mPageFrame.Pos(); @@ -96,7 +134,14 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa } } } - rInfo.push_back( aInfo ); + + { + std::vector< SwLayoutInfo >::iterator aInsPosIter = + std::lower_bound( rInfo.begin(), rInfo.end(), + aInfo, LayoutInfoOrder() ); + + rInfo.insert( aInsPosIter, aInfo ); + } } } } @@ -147,7 +192,7 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa return aRet; } -SwPosition SwAnnotationItem::GetPosition() +SwPosition SwAnnotationItem::GetAnchorPosition() const { SwTxtFld* pFld = pFmtFld->GetTxtFld(); //if( pFld ) @@ -173,11 +218,14 @@ sw::sidebarwindows::SwSidebarWin* SwAnnotationItem::GetSidebarWindow( SwPostItMgr& aMgr, SwPostItBits aBits) { - return new sw::annotation::SwAnnotationWin( rEditWin, nBits, pFmtFld, aMgr, aBits ); + return new sw::annotation::SwAnnotationWin( rEditWin, nBits, + aMgr, aBits, + *this, + pFmtFld ); } /* -SwPosition SwRedCommentItem::GetPosition() +SwPosition SwRedCommentItem::GetAnchorPosition() { return *pRedline->Start(); } diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index eba323bd52a2..6a22116af951 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -38,8 +38,8 @@ #include -#include "swtypes.hxx" -#include "swrect.hxx" +#include +#include class ViewShell; class SwFlyFrm; @@ -57,17 +57,10 @@ struct SdrPaintProcRec; class SwAccessibleMap; class SdrObject; class Fraction; -// OD 12.12.2002 #103492# class SwPagePreviewLayout; -// OD 15.01.2003 #103492# -#ifndef _PREVWPAGE_HXX -#include -#endif -// OD 15.01.2003 #103492# +struct PrevwPage; #include -// --> OD 2005-12-01 #i27138# class SwTxtFrm; -// <-- class SwViewImp { diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index c29b61fbed95..1ae6599a02cb 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2606,6 +2606,15 @@ void ViewShell::InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm ) } } +SwAccessibleMap* ViewShell::GetAccessibleMap() +{ + if ( Imp()->IsAccessible() ) + { + return &(Imp()->GetAccessibleMap()); + } + + return 0; +} /* -----------------------------06.05.2002 13:23------------------------------ ---------------------------------------------------------------------------*/ diff --git a/sw/source/ui/docvw/AnnotationWin.cxx b/sw/source/ui/docvw/AnnotationWin.cxx index b27843209162..492cf1600298 100644 --- a/sw/source/ui/docvw/AnnotationWin.cxx +++ b/sw/source/ui/docvw/AnnotationWin.cxx @@ -68,10 +68,11 @@ namespace sw { namespace annotation { SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin, WinBits nBits, - SwFmtFld* aField, SwPostItMgr& aMgr, - SwPostItBits aBits) - : SwSidebarWin( rEditWin, nBits, aMgr, aBits ) + SwPostItBits aBits, + SwSidebarItem& rSidebarItem, + SwFmtFld* aField ) + : SwSidebarWin( rEditWin, nBits, aMgr, aBits, rSidebarItem ) , mpFmtFld(aField) , mpFld( static_cast(aField->GetFld())) , mpButtonPopup(0) diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index a20d2daaf5c6..936fa8d2368e 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -90,8 +91,8 @@ #include "swevent.hxx" -// distance between ankor Y and initial note position -#define POSTIT_INITIAL_ANKOR_DISTANCE 20 +// distance between Anchor Y and initial note position +#define POSTIT_INITIAL_ANCHOR_DISTANCE 20 //distance between two postits #define POSTIT_SPACE_BETWEEN 8 #define POSTIT_MINIMUMSIZE_WITH_META 60 @@ -114,17 +115,22 @@ bool comp_date( const SwPostItItem* a, const SwPostItItem* b) } */ -// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position -// if two notes are at the same position, sort by logical node position -bool comp_pos(const SwSidebarItem *a, const SwSidebarItem *b) +// +bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b) { - return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom()) - ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) && - (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) - ? *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < - *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) - : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() ) - : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom(); + // --> OD 2010-01-19 #i88070# + // sort by anchor position +//// if position is on the same line, sort by x (Left) position, otherwise by y(Bottom) position +//// if two notes are at the same position, sort by logical node position +// return (a->maLayoutInfo.mPosition.Bottom() == b->maLayoutInfo.mPosition.Bottom()) +// ? ( ( (a->maLayoutInfo.mPosition.Left() == b->maLayoutInfo.mPosition.Left()) && +// (a->GetBroadCaster()->ISA(SwFmtFld) && b->GetBroadCaster()->ISA(SwFmtFld)) ) +// ? *(static_cast(a->GetBroadCaster())->GetTxtFld()->GetStart()) < +// *(static_cast(b->GetBroadCaster())->GetTxtFld()->GetStart()) +// : a->maLayoutInfo.mPosition.Left() < b->maLayoutInfo.mPosition.Left() ) +// : a->maLayoutInfo.mPosition.Bottom() < b->maLayoutInfo.mPosition.Bottom(); + return a->GetAnchorPosition() < b->GetAnchorPosition(); + // <-- } SwPostItMgr::SwPostItMgr(SwView* pView) @@ -140,12 +146,14 @@ SwPostItMgr::SwPostItMgr(SwView* pView) , mbReadOnly(mpView->GetDocShell()->IsReadOnly()) , mbDeleteNote(true) , mpAnswer(0) + , mbIsShowAnchor( false ) + , mpFrmSidebarWinContainer( 0 ) { if(!mpView->GetDrawView() ) mpView->GetWrtShell().MakeDrawView(); SwNoteProps aProps; - mpIsShowAnkor = aProps.IsShowAnkor(); + mbIsShowAnchor = aProps.IsShowAnchor(); //make sure we get the colour yellow always, even if not the first one of comments or redlining SW_MOD()->GetRedlineAuthor(); @@ -167,6 +175,8 @@ SwPostItMgr::SwPostItMgr(SwView* pView) SwPostItMgr::~SwPostItMgr() { + delete mpFrmSidebarWinContainer; + if ( mnEventId ) Application::RemoveUserEvent( mnEventId ); // forget about all our Sidebar windows @@ -491,8 +501,10 @@ bool SwPostItMgr::CalcRects() SwRect aOldRect(pItem->maLayoutInfo.mPosition); SwPostItHelper::SwLayoutStatus eOldStatus = pItem->mLayoutStatus; std::vector< SwLayoutInfo > aInfo; - SwPosition aPosition = pItem->GetPosition(); - pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + { + SwPosition aPosition = pItem->GetAnchorPosition(); + pItem->mLayoutStatus = SwPostItHelper::getLayoutInfos( aInfo, aPosition ); + } if( aInfo.size() ) { pItem->maLayoutInfo = aInfo[0]; @@ -503,7 +515,7 @@ bool SwPostItMgr::CalcRects() } // show notes in right order in navigator - //prevent ankors during layout to overlap, e.g. when moving a frame + //prevent Anchors during layout to overlap, e.g. when moving a frame Sort(SORT_POS); // sort the items into the right page vector, so layout can be done by page @@ -674,7 +686,7 @@ void SwPostItMgr::LayoutPostIts() pPostIt->SetChangeTracking( pItem->mLayoutStatus, - GetColorAnkor(pItem->maLayoutInfo.mRedlineAuthor)); + GetColorAnchor(pItem->maLayoutInfo.mRedlineAuthor)); pPostIt->SetSidebarPosition(mPages[n]->eSidebarPosition); pPostIt->SetFollow(pPostIt->CalcFollow()); aPostItHeight = ( pPostIt->GetPostItTextHeight() < pPostIt->GetMinimumSizeWithoutMeta() @@ -687,6 +699,7 @@ void SwPostItMgr::LayoutPostIts() aPostItHeight, pItem->maLayoutInfo.mPosition, mlPageEnd ); + pPostIt->ChangeSidebarItem( *pItem ); if (pItem->bFocus) { @@ -1659,23 +1672,23 @@ void SwPostItMgr::CorrectPositions() return; // yeah, I know, if this is a left page it could be wrong, but finding the page and the note is probably not even faster than just doing it - const long aAnkorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); - const long aAnkorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; - if (Point(aAnkorX,aAnkorY) != pFirstPostIt->GetPosPixel()) + const long aAnchorX = mpEditWin->LogicToPixel( Point((long)(pFirstPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); + const long aAnchorY = mpEditWin->LogicToPixel( Point(0,(long)(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; + if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel()) { - long aAnkorPosX = 0; - long aAnkorPosY = 0; + long aAnchorPosX = 0; + long aAnchorPosY = 0; for (unsigned long n=0;nmList->begin(); i!= mPages[n]->mList->end(); i++) { if ((*i)->bShow && (*i)->pPostIt) { - aAnkorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT + aAnchorPosX = mPages[n]->eSidebarPosition == sw::sidebarwindows::SIDEBAR_LEFT ? mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() : mpEditWin->LogicToPixel( Point((long)((*i)->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); - aAnkorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; - (*i)->pPostIt->SetPosPixel(Point(aAnkorPosX,aAnkorPosY)); + aAnchorPosY = mpEditWin->LogicToPixel( Point(0,(long)((*i)->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; + (*i)->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY)); } } } @@ -1746,16 +1759,16 @@ Color SwPostItMgr::GetColorLight(sal_uInt16 aAuthorIndex) return Color(COL_WHITE); } -Color SwPostItMgr::GetColorAnkor(sal_uInt16 aAuthorIndex) +Color SwPostItMgr::GetColorAnchor(sal_uInt16 aAuthorIndex) { if (!Application::GetSettings().GetStyleSettings().GetHighContrastMode()) { - static const Color aArrayAnkor[] = { + static const Color aArrayAnchor[] = { COL_AUTHOR1_DARK, COL_AUTHOR2_DARK, COL_AUTHOR3_DARK, COL_AUTHOR4_DARK, COL_AUTHOR5_DARK, COL_AUTHOR6_DARK, COL_AUTHOR7_DARK, COL_AUTHOR8_DARK, COL_AUTHOR9_DARK }; - return Color( aArrayAnkor[ aAuthorIndex % (sizeof( aArrayAnkor ) / sizeof( aArrayAnkor[0] ))]); + return Color( aArrayAnchor[ aAuthorIndex % (sizeof( aArrayAnchor ) / sizeof( aArrayAnchor[0] ))]); } else return Color(COL_WHITE); @@ -1813,7 +1826,7 @@ void SwPostItMgr::Rescale() sal_Int32 SwPostItMgr::GetInitialAnchorDistance() const { const Fraction& f( mpEditWin->GetMapMode().GetScaleY() ); - return POSTIT_INITIAL_ANKOR_DISTANCE * f.GetNumerator() / f.GetDenominator(); + return POSTIT_INITIAL_ANCHOR_DISTANCE * f.GetNumerator() / f.GetDenominator(); } sal_Int32 SwPostItMgr::GetSpaceBetween() const @@ -1984,3 +1997,58 @@ void SwPostItMgr::ToggleInsModeOnActiveSidebarWin() mpActivePostIt->ToggleInsMode(); } } + +void SwPostItMgr::ConnectSidebarWinToFrm( const SwFrm& rFrm, + const SwFmtFld& rFmtFld, + SwSidebarWin& rSidebarWin ) +{ + if ( mpFrmSidebarWinContainer == 0 ) + { + mpFrmSidebarWinContainer = new SwFrmSidebarWinContainer(); + } + + mpFrmSidebarWinContainer->insert( rFrm, rFmtFld, rSidebarWin ); +} + +void SwPostItMgr::DisconnectSidebarWinFromFrm( const SwFrm& rFrm, + SwSidebarWin& rSidebarWin ) +{ + if ( mpFrmSidebarWinContainer != 0 ) + { + mpFrmSidebarWinContainer->remove( rFrm, rSidebarWin ); + } +} + +bool SwPostItMgr::HasFrmConnectedSidebarWins( const SwFrm& rFrm ) +{ + bool bRet( false ); + + if ( mpFrmSidebarWinContainer != 0 ) + { + bRet = !mpFrmSidebarWinContainer->empty( rFrm ); + } + + return bRet; +} + +Window* SwPostItMgr::GetSidebarWinForFrmByIndex( const SwFrm& rFrm, + const sal_Int32 nIndex ) +{ + Window* pSidebarWin( 0 ); + + if ( mpFrmSidebarWinContainer != 0 ) + { + pSidebarWin = mpFrmSidebarWinContainer->get( rFrm, nIndex ); + } + + return pSidebarWin; +} + +void SwPostItMgr::GetAllSidebarWinForFrm( const SwFrm& rFrm, + std::vector< Window* >* pChildren ) +{ + if ( mpFrmSidebarWinContainer != 0 ) + { + mpFrmSidebarWinContainer->getAll( rFrm, pChildren ); + } +} diff --git a/sw/source/ui/docvw/SidebarTxtControl.cxx b/sw/source/ui/docvw/SidebarTxtControl.cxx index 7b421327e40d..8cd3503136ff 100644 --- a/sw/source/ui/docvw/SidebarTxtControl.cxx +++ b/sw/source/ui/docvw/SidebarTxtControl.cxx @@ -75,7 +75,6 @@ SidebarTxtControl::SidebarTxtControl( SwSidebarWin& rSidebarWin, SwView& rDocView, SwPostItMgr& rPostItMgr ) : Control( &rSidebarWin, nBits ) - , mpOutlinerView(0) , mrSidebarWin( rSidebarWin ) , mrDocView( rDocView ) , mrPostItMgr( rPostItMgr ) @@ -89,6 +88,11 @@ SidebarTxtControl::~SidebarTxtControl() RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) ); } +OutlinerView* SidebarTxtControl::GetTextView() const +{ + return mrSidebarWin.GetOutlinerView(); +} + void SidebarTxtControl::GetFocus() { Window::GetFocus(); @@ -155,7 +159,10 @@ void SidebarTxtControl::Paint( const Rectangle& rRect) } } - mpOutlinerView->Paint( rRect ); + if ( GetTextView() ) + { + GetTextView()->Paint( rRect ); + } if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED ) { @@ -210,7 +217,7 @@ void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt ) ( bIsProtected && !mrSidebarWin.GetOutlinerView()->GetOutliner()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) { - bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); + bDone = GetTextView() && GetTextView()->PostKeyEvent( rKeyEvt ); } else { @@ -234,14 +241,15 @@ void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt ) void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt ) { - if ( mpOutlinerView ) + if ( GetTextView() ) { - mpOutlinerView->MouseMove( rMEvt ); + OutlinerView* pOutlinerView( GetTextView() ); + pOutlinerView->MouseMove( rMEvt ); // mba: why does OutlinerView not handle the modifier setting?! // this forces the postit to handle *all* pointer types - SetPointer( mpOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); + SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); - const EditView& aEV = mpOutlinerView->GetEditView(); + const EditView& aEV = pOutlinerView->GetEditView(); const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); if ( pItem ) { @@ -264,14 +272,14 @@ void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt ) void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt ) { - if (mpOutlinerView ) + if ( GetTextView() ) { SvtSecurityOptions aSecOpts; bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK); if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1)) { - const EditView& aEV = mpOutlinerView->GetEditView(); + const EditView& aEV = GetTextView()->GetEditView(); const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); if ( pItem ) { @@ -279,7 +287,7 @@ void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt ) const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld ); if ( pURL ) { - mpOutlinerView->MouseButtonDown( rMEvt ); + GetTextView()->MouseButtonDown( rMEvt ); SwWrtShell &rSh = mrDocView.GetWrtShell(); String sURL( pURL->GetURL() ); String sTarget( pURL->GetTargetFrame() ); @@ -291,15 +299,17 @@ void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt ) } GrabFocus(); - if ( mpOutlinerView ) - mpOutlinerView->MouseButtonDown( rMEvt ); + if ( GetTextView() ) + { + GetTextView()->MouseButtonDown( rMEvt ); + } mrDocView.GetViewFrame()->GetBindings().InvalidateAll(FALSE); } void SidebarTxtControl::MouseButtonUp( const MouseEvent& rMEvt ) { - if ( mpOutlinerView ) - mpOutlinerView->MouseButtonUp( rMEvt ); + if ( GetTextView() ) + GetTextView()->MouseButtonUp( rMEvt ); } IMPL_LINK( SidebarTxtControl, OnlineSpellCallback, SpellCallbackInfo*, pInfo ) @@ -321,11 +331,12 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) { if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) { - if (!mrSidebarWin.IsProtected() && - mpOutlinerView->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE )) + if ( !mrSidebarWin.IsProtected() && + GetTextView() && + GetTextView()->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),TRUE )) { Link aLink = LINK(this, SidebarTxtControl, OnlineSpellCallback); - mpOutlinerView->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink); + GetTextView()->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink); } else { @@ -373,8 +384,8 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) } else { - if ( mpOutlinerView ) - mpOutlinerView->Command( rCEvt ); + if ( GetTextView() ) + GetTextView()->Command( rCEvt ); else Window::Command(rCEvt); } @@ -382,16 +393,16 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) XubString SidebarTxtControl::GetSurroundingText() const { - if( mpOutlinerView ) - return mpOutlinerView->GetSurroundingText(); + if( GetTextView() ) + return GetTextView()->GetSurroundingText(); else return XubString::EmptyString(); } Selection SidebarTxtControl::GetSurroundingTextSelection() const { - if( mpOutlinerView ) - return mpOutlinerView->GetSurroundingTextSelection(); + if( GetTextView() ) + return GetTextView()->GetSurroundingTextSelection(); else return Selection( 0, 0 ); } diff --git a/sw/source/ui/docvw/SidebarTxtControl.hxx b/sw/source/ui/docvw/SidebarTxtControl.hxx index 850342967602..08a5de0003c4 100644 --- a/sw/source/ui/docvw/SidebarTxtControl.hxx +++ b/sw/source/ui/docvw/SidebarTxtControl.hxx @@ -46,7 +46,6 @@ class SwSidebarWin; class SidebarTxtControl : public Control { private: - OutlinerView* mpOutlinerView; SwSidebarWin& mrSidebarWin; SwView& mrDocView; SwPostItMgr& mrPostItMgr; @@ -76,14 +75,7 @@ class SidebarTxtControl : public Control virtual void GetFocus(); - inline void SetTextView( OutlinerView* aEditView ) - { - mpOutlinerView = aEditView; - } - inline OutlinerView* GetTextView() const - { - return mpOutlinerView; - } + OutlinerView* GetTextView() const; DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*); diff --git a/sw/source/ui/docvw/SidebarTxtControlAcc.cxx b/sw/source/ui/docvw/SidebarTxtControlAcc.cxx index e01041d79fe6..82049b954ef7 100644 --- a/sw/source/ui/docvw/SidebarTxtControlAcc.cxx +++ b/sw/source/ui/docvw/SidebarTxtControlAcc.cxx @@ -44,6 +44,7 @@ #include #include + namespace css = ::com::sun::star; namespace sw { namespace sidebarwindows { @@ -82,12 +83,18 @@ SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtCont , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), NULL ) , mViewForwarder( *(rSidebarTxtControl.GetTextView()) ) { - mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) ); + if ( mrSidebarTxtControl.GetTextView() ) + { + mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) ); + } } SidebarTextEditSource::~SidebarTextEditSource() { - mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() ); + if ( mrSidebarTxtControl.GetTextView() ) + { + mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() ); + } } SvxEditSource* SidebarTextEditSource::Clone() const @@ -172,12 +179,17 @@ class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent private: SidebarTxtControl& mrSidebarTxtControl; ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper; + + ::vos::OMutex maMutex; + + void defunc(); }; SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl ) : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() ) , mrSidebarTxtControl( rSidebarTxtControl ) , mpAccessibleTextHelper( 0 ) + , maMutex() { ::std::auto_ptr pEditSource( new SidebarTextEditSource( mrSidebarTxtControl ) ); @@ -186,52 +198,94 @@ SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarT } SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext() +{ + defunc(); +} + +void SidebarTxtControlAccessibleContext::defunc() { delete mpAccessibleTextHelper; + mpAccessibleTextHelper = 0; } sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException) { - return mpAccessibleTextHelper->GetChildCount(); + vos::OGuard aGuard( maMutex ); + + sal_Int32 nChildCount( 0 ); + + if ( mpAccessibleTextHelper ) + { + nChildCount = mpAccessibleTextHelper->GetChildCount(); + } + + return nChildCount; } css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i ) throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException ) { - return mpAccessibleTextHelper->GetChild( i ); + vos::OGuard aGuard( maMutex ); + + css::uno::Reference< css::accessibility::XAccessible > xChild; + + if ( mpAccessibleTextHelper ) + { + xChild = mpAccessibleTextHelper->GetChild( i ); + } + + return xChild; } void SAL_CALL SidebarTxtControlAccessibleContext::addEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { - mpAccessibleTextHelper->AddEventListener(xListener); + vos::OGuard aGuard( maMutex ); + + if ( mpAccessibleTextHelper ) + { + mpAccessibleTextHelper->AddEventListener(xListener); + } } void SAL_CALL SidebarTxtControlAccessibleContext::removeEventListener ( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener) throw (css::uno::RuntimeException) { - mpAccessibleTextHelper->RemoveEventListener(xListener); + vos::OGuard aGuard( maMutex ); + + if ( mpAccessibleTextHelper ) + { + mpAccessibleTextHelper->RemoveEventListener(xListener); + } } void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { - switch ( rVclWindowEvent.GetId() ) + if ( mpAccessibleTextHelper ) { - case VCLEVENT_WINDOW_GETFOCUS: - case VCLEVENT_CONTROL_GETFOCUS: - { - mpAccessibleTextHelper->SetFocus( sal_True ); - } - break; - case VCLEVENT_WINDOW_LOSEFOCUS: - case VCLEVENT_CONTROL_LOSEFOCUS: + switch ( rVclWindowEvent.GetId() ) { - mpAccessibleTextHelper->SetFocus( sal_False ); + case VCLEVENT_OBJECT_DYING: + { + defunc(); + } + break; + case VCLEVENT_WINDOW_GETFOCUS: + case VCLEVENT_CONTROL_GETFOCUS: + { + mpAccessibleTextHelper->SetFocus( sal_True ); + } + break; + case VCLEVENT_WINDOW_LOSEFOCUS: + case VCLEVENT_CONTROL_LOSEFOCUS: + { + mpAccessibleTextHelper->SetFocus( sal_False ); + } + break; } - break; } VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx index 1dc845f292b8..683d51325547 100644 --- a/sw/source/ui/docvw/SidebarWin.cxx +++ b/sw/source/ui/docvw/SidebarWin.cxx @@ -31,6 +31,7 @@ #include "precompiled_sw.hxx" #include +#include #include #include @@ -92,7 +93,8 @@ namespace sw { namespace sidebarwindows { SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, WinBits nBits, SwPostItMgr& aMgr, - SwPostItBits aBits) + SwPostItBits aBits, + SwSidebarItem& rSidebarItem ) : Window(&rEditWin, nBits) , mrMgr(aMgr) , mrView( rEditWin.GetView() ) @@ -119,24 +121,34 @@ SwSidebarWin::SwSidebarWin( SwEditWin& rEditWin, , mLayoutStatus( SwPostItHelper::INVISIBLE ) , mbReadonly( false ) , mbIsFollow( false ) + , mrSidebarItem( rSidebarItem ) { mpShadow = ShadowOverlayObject::CreateShadowOverlayObject( mrView ); if ( mpShadow ) { mpShadow->setVisible(false); } + + mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm), + *(mrSidebarItem.GetFmtFld()), + *this ); } SwSidebarWin::~SwSidebarWin() { - if (mpOutlinerView) + if ( mpSidebarTxtControl ) { - delete mpOutlinerView; + if ( mpOutlinerView ) + { + mpOutlinerView->SetWindow( 0 ); + } + delete mpSidebarTxtControl; } - if (mpSidebarTxtControl) + if ( mpOutlinerView ) { - delete mpSidebarTxtControl; + delete mpOutlinerView; + mpOutlinerView = 0; } if (mpOutliner) @@ -160,11 +172,14 @@ SwSidebarWin::~SwSidebarWin() { mpVScrollbar->RemoveEventListener( LINK( this, SwSidebarWin, WindowEventListener ) ); delete mpVScrollbar; + mpVScrollbar = 0; } AnchorOverlayObject::DestroyAnchorOverlayObject( mpAnchor ); + mpAnchor = 0; ShadowOverlayObject::DestroyShadowOverlayObject( mpShadow ); + mpShadow = 0; delete mpMenuButton; @@ -189,10 +204,12 @@ void SwSidebarWin::Paint( const Rectangle& rRect) } SetLineColor(); DrawRect( PixelToLogic( - Rectangle( Point( mpMetadataAuthor->GetPosPixel().X()+mpMetadataAuthor->GetSizePixel().Width(), + Rectangle( Point( mpMetadataAuthor->GetPosPixel().X() + + mpMetadataAuthor->GetSizePixel().Width(), mpMetadataAuthor->GetPosPixel().Y() ), - Size( GetMetaButtonAreaWidth(), - GetSizePixel().Height() - mpMetadataAuthor->GetPosPixel().Y() ) ) ) ); + Size( GetMetaButtonAreaWidth(), + mpMetadataAuthor->GetSizePixel().Height() + + mpMetadataDate->GetSizePixel().Height() ) ) ) ); } } @@ -308,7 +325,6 @@ void SwSidebarWin::InitControls() mpOutlinerView = new OutlinerView ( mpOutliner, mpSidebarTxtControl ); mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT); mpOutliner->InsertView(mpOutlinerView ); - mpSidebarTxtControl->SetTextView(mpOutlinerView); mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) ); mpOutlinerView->SetAttribs(DefaultItem()); @@ -342,7 +358,7 @@ void SwSidebarWin::InitControls() sal_uInt16 aIndex = SW_MOD()->InsertRedlineAuthor(GetAuthor()); SetColor( mrMgr.GetColorDark(aIndex), mrMgr.GetColorLight(aIndex), - mrMgr.GetColorAnkor(aIndex)); + mrMgr.GetColorAnchor(aIndex)); CheckMetaText(); @@ -800,7 +816,7 @@ void SwSidebarWin::HideNote() Window::Hide(); if (mpAnchor) { - if (mrMgr.IsShowAnkor()) + if (mrMgr.IsShowAnchor()) mpAnchor->SetAnchorState(AS_TRI); else mpAnchor->setVisible(false); @@ -1188,7 +1204,39 @@ bool SwSidebarWin::IsScrollbarVisible() const return HasScrollbar() && mpVScrollbar->IsVisible(); } -} } // eof of namespace sw::sidebarwindows:: +void SwSidebarWin::ChangeSidebarItem( SwSidebarItem& rSidebarItem ) +{ + const bool bAnchorChanged = mrSidebarItem.maLayoutInfo.mpAnchorFrm != + rSidebarItem.maLayoutInfo.mpAnchorFrm; + if ( bAnchorChanged ) + { + mrMgr.DisconnectSidebarWinFromFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm), + *this ); + } + + mrSidebarItem = rSidebarItem; + + if ( bAnchorChanged ) + { + mrMgr.ConnectSidebarWinToFrm( *(mrSidebarItem.maLayoutInfo.mpAnchorFrm), + *(mrSidebarItem.GetFmtFld()), + *this ); + } +} + +css::uno::Reference< css::accessibility::XAccessible > SwSidebarWin::CreateAccessible() +{ + SidebarWinAccessible* pAcc( new SidebarWinAccessible( *this, + mrView.GetWrtShell(), + mrSidebarItem ) ); + css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc ); + SetWindowPeer( xWinPeer, pAcc ); + + css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY ); + return xAcc; +} + +} } // eof of namespace sw::sidebarwindows /********** SwRedComment**************/ /* diff --git a/sw/source/ui/docvw/SidebarWinAcc.cxx b/sw/source/ui/docvw/SidebarWinAcc.cxx new file mode 100644 index 000000000000..a484f2068c67 --- /dev/null +++ b/sw/source/ui/docvw/SidebarWinAcc.cxx @@ -0,0 +1,156 @@ +/************************************************************************* * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "precompiled_sw.hxx" + +#include + +#include +#include +#include +#include + +namespace css = ::com::sun::star; + +namespace sw { namespace sidebarwindows { + +// ============================================================================= +// declaration and implementation of accessible context for instance +// ============================================================================= +class SidebarWinAccessibleContext : public VCLXAccessibleComponent +{ + public: + explicit SidebarWinAccessibleContext( SwSidebarWin& rSidebarWin, + ViewShell& rViewShell, + const SwFrm* pAnchorFrm ) + : VCLXAccessibleComponent( rSidebarWin.GetWindowPeer() ) + , mrViewShell( rViewShell ) + , mpAnchorFrm( pAnchorFrm ) + , maMutex() + {} + + virtual ~SidebarWinAccessibleContext() + {} + + void ChangeAnchor( const SwFrm* pAnchorFrm ) + { + vos::OGuard aGuard(maMutex); + + mpAnchorFrm = pAnchorFrm; + } + + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleParent() throw (css::uno::RuntimeException) + { + vos::OGuard aGuard(maMutex); + + css::uno::Reference< css::accessibility::XAccessible > xAccParent; + + if ( mpAnchorFrm && + mrViewShell.GetAccessibleMap() ) + { + xAccParent = mrViewShell.GetAccessibleMap()->GetContext( mpAnchorFrm, sal_False ); + } + + return xAccParent; + } + + sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (css::uno::RuntimeException) + { + vos::OGuard aGuard(maMutex); + + if ( mpAnchorFrm && + mrViewShell.GetAccessibleMap() ) + { + // ODsTODO + + } + + return -1; + } + + private: + ViewShell& mrViewShell; + const SwFrm* mpAnchorFrm; + + ::vos::OMutex maMutex; +}; + +// ============================================================================= +// implementaion of accessible for instance +// ============================================================================= +SidebarWinAccessible::SidebarWinAccessible( SwSidebarWin& rSidebarWin, + ViewShell& rViewShell, + const SwSidebarItem& rSidebarItem ) + : VCLXWindow() + , mrSidebarWin( rSidebarWin ) + , mrViewShell( rViewShell ) + , mpAnchorFrm( rSidebarItem.maLayoutInfo.mpAnchorFrm ) + , bAccContextCreated( false ) +{ + SetWindow( &mrSidebarWin ); +} + +SidebarWinAccessible::~SidebarWinAccessible() +{ +} + +void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& rSidebarItem ) +{ + if ( bAccContextCreated ) + { + css::uno::Reference< css::accessibility::XAccessibleContext > xAcc + = getAccessibleContext(); + if ( xAcc.is() ) + { + SidebarWinAccessibleContext* pAccContext = + dynamic_cast(xAcc.get()); + if ( pAccContext ) + { + pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrm ); + } + } + } +} + +css::uno::Reference< css::accessibility::XAccessibleContext > SidebarWinAccessible::CreateAccessibleContext() +{ + SidebarWinAccessibleContext* pAccContext = + new SidebarWinAccessibleContext( mrSidebarWin, + mrViewShell, + mpAnchorFrm ); + css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext ); + bAccContextCreated = true; + return xAcc; +} + +} } // end of namespace sw::sidebarwindows + diff --git a/sw/source/ui/docvw/SidebarWinAcc.hxx b/sw/source/ui/docvw/SidebarWinAcc.hxx new file mode 100644 index 000000000000..0abe1acbfaf5 --- /dev/null +++ b/sw/source/ui/docvw/SidebarWinAcc.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SIDEBARWINACC_HXX +#define _SIDEBARWINACC_HXX + +#include + +class ViewShell; +class SwSidebarItem; +class SwFrm; + +namespace sw { namespace sidebarwindows { + +class SwSidebarWin; + +class SidebarWinAccessible : public VCLXWindow +{ + public: + explicit SidebarWinAccessible( SwSidebarWin& rSidebarWin, + ViewShell& rViewShell, + const SwSidebarItem& rSidebarItem ); + virtual ~SidebarWinAccessible(); + + virtual com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext > + CreateAccessibleContext(); + + void ChangeSidebarItem( const SwSidebarItem& rSidebarItem ); + + private: + SwSidebarWin& mrSidebarWin; + ViewShell& mrViewShell; + const SwFrm* mpAnchorFrm; + bool bAccContextCreated; +}; + +} } // end of namespace sw::sidebarwindows + +#endif diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 16634dc89a5d..aef04fe6d01a 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -1354,7 +1354,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) const KeyCode& rKeyCode = aKeyEvent.GetKeyCode(); sal_Unicode aCh = aKeyEvent.GetCharCode(); - // enable switching to notes ankor with Ctrl - Alt - Page Up/Down + // enable switching to notes anchor with Ctrl - Alt - Page Up/Down // pressing this inside a note will switch to next/previous note if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((rKeyCode.GetCode() == KEY_PAGEUP) || (rKeyCode.GetCode() == KEY_PAGEDOWN))) { diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.cxx b/sw/source/ui/docvw/frmsidebarwincontainer.cxx new file mode 100644 index 000000000000..4fe9f55a1421 --- /dev/null +++ b/sw/source/ui/docvw/frmsidebarwincontainer.cxx @@ -0,0 +1,204 @@ + /************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include + +#include +#include +#include +#include + +namespace { + struct SidebarWinKey + { + const xub_StrLen mnIndex; + + explicit SidebarWinKey( const xub_StrLen nIndex ) + : mnIndex( nIndex ) + {} + + bool operator < ( const SidebarWinKey& SidebarWinKey ) const + { + return mnIndex < SidebarWinKey.mnIndex; + } + }; + + struct SidebarWinOrder + { + sal_Bool operator()( const SidebarWinKey& rSidebarWinKeyA, + const SidebarWinKey& rSidebarWinKeyB ) const + { + return rSidebarWinKeyA < rSidebarWinKeyB; + } + }; + + typedef ::std::map < SidebarWinKey, sw::sidebarwindows::SwSidebarWin*, SidebarWinOrder > SidebarWinContainer; + + struct FrmKey + { + const SwFrm* mpFrm; + + explicit FrmKey( const SwFrm* pFrm ) + : mpFrm( pFrm ) + {} + + bool operator < ( const FrmKey& rFrmKey ) const + { + return mpFrm < rFrmKey.mpFrm; + } + }; + + struct FrmOrder + { + sal_Bool operator()( const FrmKey& rFrmKeyA, + const FrmKey& rFrmKeyB ) const + { + return rFrmKeyA < rFrmKeyB; + } + }; + + typedef ::std::map < FrmKey, SidebarWinContainer, FrmOrder > _FrmSidebarWinContainer; +} + +namespace sw { namespace sidebarwindows { + +class FrmSidebarWinContainer : public _FrmSidebarWinContainer +{ +}; + +SwFrmSidebarWinContainer::SwFrmSidebarWinContainer() + : mpFrmSidebarWinContainer( new FrmSidebarWinContainer() ) +{} + +SwFrmSidebarWinContainer::~SwFrmSidebarWinContainer() +{ + mpFrmSidebarWinContainer->clear(); + delete mpFrmSidebarWinContainer; +} + +void SwFrmSidebarWinContainer::insert( const SwFrm& rFrm, + const SwFmtFld& rFmtFld, + SwSidebarWin& rSidebarWin ) +{ + FrmKey aFrmKey( &rFrm ); + SidebarWinContainer& rSidebarWinContainer = (*mpFrmSidebarWinContainer)[ aFrmKey ]; + + SidebarWinKey aSidebarWinKey( *(rFmtFld.GetTxtFld()->GetStart()) ); + if ( rSidebarWinContainer.empty() || + rSidebarWinContainer.find( aSidebarWinKey) != rSidebarWinContainer.end() ) + { + rSidebarWinContainer[ aSidebarWinKey ] = &rSidebarWin; + } +} + +void SwFrmSidebarWinContainer::remove( const SwFrm& rFrm, + const SwSidebarWin& rSidebarWin ) +{ + FrmKey aFrmKey( &rFrm ); + FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey ); + if ( aFrmIter != mpFrmSidebarWinContainer->end() ) + { + SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second; + for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin(); + aIter != rSidebarWinContainer.end(); + ++aIter ) + { + if ( (*aIter).second == &rSidebarWin ) + { + rSidebarWinContainer.erase( aIter ); + break; + } + } + } +} + +bool SwFrmSidebarWinContainer::empty( const SwFrm& rFrm ) +{ + bool bEmpty( true ); + + FrmKey aFrmKey( &rFrm ); + FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey ); + if ( aFrmIter != mpFrmSidebarWinContainer->end() ) + { + bEmpty = (*aFrmIter).second.empty(); + } + + return bEmpty; +} + +SwSidebarWin* SwFrmSidebarWinContainer::get( const SwFrm& rFrm, + const sal_Int32 nIndex ) +{ + SwSidebarWin* pRet( 0 ); + + FrmKey aFrmKey( &rFrm ); + FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey ); + if ( aFrmIter != mpFrmSidebarWinContainer->end() ) + { + SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second; + sal_Int32 nCounter( nIndex ); + for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin(); + nCounter >= 0 && aIter != rSidebarWinContainer.end(); + ++aIter ) + { + if ( nCounter == 0 ) + { + pRet = (*aIter).second; + break; + } + } + } + + return pRet; +} + +void SwFrmSidebarWinContainer::getAll( const SwFrm& rFrm, + std::vector< Window* >* pSidebarWins ) +{ + pSidebarWins->clear(); + + FrmKey aFrmKey( &rFrm ); + FrmSidebarWinContainer::iterator aFrmIter = mpFrmSidebarWinContainer->find( aFrmKey ); + if ( aFrmIter != mpFrmSidebarWinContainer->end() ) + { + SidebarWinContainer& rSidebarWinContainer = (*aFrmIter).second; + for ( SidebarWinContainer::iterator aIter = rSidebarWinContainer.begin(); + aIter != rSidebarWinContainer.end(); + ++aIter ) + { + pSidebarWins->push_back( (*aIter).second ); + } + } +} + +} } // eof of namespace sw::sidebarwindows:: diff --git a/sw/source/ui/docvw/frmsidebarwincontainer.hxx b/sw/source/ui/docvw/frmsidebarwincontainer.hxx new file mode 100644 index 000000000000..6144d955b38b --- /dev/null +++ b/sw/source/ui/docvw/frmsidebarwincontainer.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _FRMSIDEBARWINCONTAINER_HXX +#define _FRMSIDEBARWINCONTAINER_HXX + +#include +#include + +class SwFrm; +class SwFmtFld; +class Window; + +namespace sw { namespace sidebarwindows { + +class SwSidebarWin; +class FrmSidebarWinContainer; + +class SwFrmSidebarWinContainer +{ + public: + SwFrmSidebarWinContainer(); + ~SwFrmSidebarWinContainer(); + + void insert( const SwFrm& rFrm, + const SwFmtFld& rFmtFld, + SwSidebarWin& rSidebarWin ); + + void remove( const SwFrm& rFrm, + const SwSidebarWin& rSidebarWin ); + + bool empty( const SwFrm& rFrm ); + + SwSidebarWin* get( const SwFrm& rFrm, + const sal_Int32 nIndex ); + + void getAll( const SwFrm& rFrm, + std::vector< Window* >* pSidebarWins ); + + private: + FrmSidebarWinContainer* mpFrmSidebarWinContainer; +}; + +} } // eof of namespace sw::sidebarwindows:: + +#endif + diff --git a/sw/source/ui/docvw/makefile.mk b/sw/source/ui/docvw/makefile.mk index d2d15811d49c..d55b4f4d808c 100644 --- a/sw/source/ui/docvw/makefile.mk +++ b/sw/source/ui/docvw/makefile.mk @@ -57,9 +57,11 @@ SLOFILES = \ $(SLO)$/romenu.obj \ $(SLO)$/srcedtw.obj \ $(SLO)$/PostItMgr.obj \ + $(SLO)$/frmsidebarwincontainer.obj \ $(SLO)$/AnchorOverlayObject.obj \ $(SLO)$/ShadowOverlayObject.obj \ $(SLO)$/SidebarWin.obj \ + $(SLO)$/SidebarWinAcc.obj \ $(SLO)$/AnnotationWin.obj \ $(SLO)$/AnnotationMenuButton.obj \ $(SLO)$/SidebarTxtControl.obj \ -- cgit