diff options
Diffstat (limited to 'sw/source/core/access/accmap.cxx')
-rw-r--r-- | sw/source/core/access/accmap.cxx | 526 |
1 files changed, 325 insertions, 201 deletions
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 367db154a30a..0d7ab98d3b03 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -39,9 +39,7 @@ #include <map> #include <list> #include <accmap.hxx> -#ifndef _ACCCONTEXT_HXX #include <acccontext.hxx> -#endif #include <accdoc.hxx> #include <accpreview.hxx> #include <accpage.hxx> @@ -53,7 +51,7 @@ #include <accembedded.hxx> #include <acccell.hxx> #include <acctable.hxx> -#include "fesh.hxx" +#include <fesh.hxx> #include <rootfrm.hxx> #include <txtfrm.hxx> #include <hffrm.hxx> @@ -61,10 +59,9 @@ #include <cellfrm.hxx> #include <tabfrm.hxx> #include <pagefrm.hxx> +#include <flyfrm.hxx> #include <ndtyp.hxx> -#ifndef IDOCUMENTDRAWMODELACCESS_HXX_INCLUDED #include <IDocumentDrawModelAccess.hxx> -#endif #include <svx/ShapeTypeHandler.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> @@ -77,10 +74,13 @@ #include <pam.hxx> #include <ndtxt.hxx> // <-- +#include <dflyobj.hxx> +#include <prevwpage.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; +using namespace ::sw::access; struct SwFrmFunc { @@ -329,7 +329,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 @@ -342,7 +342,7 @@ private: public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, - const SwFrmOrObj& rFrmOrObj ) + const SwAccessibleChild& rFrmOrObj ) : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), @@ -350,7 +350,7 @@ public: {} SwAccessibleEvent_Impl( EventType eT, - const SwFrmOrObj& rFrmOrObj ) + const SwAccessibleChild& rFrmOrObj ) : maFrmOrObj( rFrmOrObj ), meType( eT ), mnStates( 0 ) @@ -369,7 +369,7 @@ public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, - const SwFrmOrObj& rFrmOrObj, + const SwAccessibleChild& rFrmOrObj, const SwRect& rR ) : maOldBox( rR ), mxAcc( pA ), @@ -385,7 +385,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 ), @@ -425,7 +425,7 @@ public: maOldBox = rOldBox; } - inline const SwFrmOrObj& GetFrmOrObj() const + inline const SwAccessibleChild& GetFrmOrObj() const { return maFrmOrObj; } @@ -524,22 +524,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 { @@ -577,6 +581,222 @@ typedef ::std::map< uno::WeakReference < XAccessible >, class SwAccessibleSelectedParas_Impl: public _SwAccessibleSelectedParas_Impl {}; // <-- + +// helper class that stores preview data +class SwAccPreviewData +{ + typedef std::vector<Rectangle> 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<PrevwPage*>& _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<PrevwPage*>& _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 <maPreviewRects>, <maLogicRects> and + // <maVisArea> + for ( std::vector<PrevwPage*>::const_iterator aPageIter = _rPrevwPages.begin(); + aPageIter != _rPrevwPages.end(); + ++aPageIter ) + { + aPage = (*aPageIter)->pPage; + + // add preview page rectangle to <maPreviewRects> + Rectangle aPrevwPgRect( (*aPageIter)->aPrevwWinPos, (*aPageIter)->aPageSize ); + maPreviewRects.push_back( aPrevwPgRect ); + + // add logic page rectangle to <maLogicRects> + 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 ) @@ -796,9 +1016,10 @@ void SwAccessibleMap::InvalidateCursorPosition( ASSERT( pAccImpl->GetFrm(), "caret context is disposed" ); if( GetShell()->ActionPend() ) { - SwAccessibleEvent_Impl aEvent( - SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, - pAccImpl->GetFrm(), ACC_STATE_CARET ); + SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, + pAccImpl, + SwAccessibleChild(pAccImpl->GetFrm()), + ACC_STATE_CARET ); AppendEvent( aEvent ); } else @@ -873,11 +1094,10 @@ void SwAccessibleMap::DoInvalidateShapeSelection() } if( bChanged ) { - SwFrmOrObj aFrmOrObj( pShape->first ); - SwFrmOrObj aParent = - SwAccessibleFrame::GetParent( aFrmOrObj, - GetShell()->IsPreView() ); - aParents.push_back( aParent.GetSwFrm() ); + const SwFrm* pParent = SwAccessibleFrame::GetParent( + SwAccessibleChild( pShape->first ), + GetShell()->IsPreView() ); + aParents.push_back( pParent ); } } @@ -1166,7 +1386,7 @@ uno::Reference<XAccessible> 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<XAccessible> xAcc = _GetDocumentView( sal_True ); return xAcc; @@ -1197,8 +1417,8 @@ uno::Reference< XAccessible> SwAccessibleMap::GetContext( const SwFrm *pFrm, { case FRM_TXT: mnPara++; - pAcc = new SwAccessibleParagraph( this, - static_cast< const SwTxtFrm * >( pFrm ) ); + pAcc = new SwAccessibleParagraph( *this, + static_cast< const SwTxtFrm& >( *pFrm ) ); break; case FRM_HEADER: pAcc = new SwAccessibleHeaderFooter( this, @@ -1458,10 +1678,12 @@ void SwAccessibleMap::RemoveContext( const SdrObject *pObj ) } -void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, +void SwAccessibleMap::Dispose( const SwFrm *pFrm, + const SdrObject *pObj, + Window* pWindow, sal_Bool bRecursive ) { - SwFrmOrObj aFrmOrObj( pFrm, pObj ); + SwAccessibleChild aFrmOrObj( pFrm, pObj, pWindow ); // Indeed, the following assert checks the frame's accessible flag, // because that's the one that is evaluated in the layout. The frame @@ -1470,11 +1692,11 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, ASSERT( !aFrmOrObj.GetSwFrm() || aFrmOrObj.GetSwFrm()->IsAccessibleFrm(), "non accessible frame should be disposed" ); - ::vos::ORef< SwAccessibleContext > xAccImpl; - ::vos::ORef< SwAccessibleContext > xParentAccImpl; - ::vos::ORef< ::accessibility::AccessibleShape > xShapeAccImpl; if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { + ::vos::ORef< SwAccessibleContext > xAccImpl; + ::vos::ORef< SwAccessibleContext > xParentAccImpl; + ::vos::ORef< ::accessibility::AccessibleShape > xShapeAccImpl; // get accessible context for frame { vos::OGuard aGuard( maMutex ); @@ -1514,7 +1736,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 ); @@ -1574,7 +1796,7 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, } else if( xShapeAccImpl.isValid() ) { - RemoveContext( aFrmOrObj.GetSdrObject() ); + RemoveContext( aFrmOrObj.GetDrawObject() ); xShapeAccImpl->dispose(); } @@ -1585,9 +1807,10 @@ void SwAccessibleMap::Dispose( const SwFrm *pFrm, const SdrObject *pObj, void SwAccessibleMap::InvalidatePosOrSize( const SwFrm *pFrm, const SdrObject *pObj, + Window* pWindow, const SwRect& rOldBox ) { - SwFrmOrObj aFrmOrObj( pFrm, pObj ); + SwAccessibleChild aFrmOrObj( pFrm, pObj, pWindow ); if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) { ::vos::ORef< SwAccessibleContext > xAccImpl; @@ -1669,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; @@ -1708,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; @@ -1747,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 ) ) @@ -1873,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(); @@ -1885,9 +2108,10 @@ void SwAccessibleMap::InvalidateStates( tAccessibleStates _nStates, static_cast< SwAccessibleContext *>( xAcc.get() ); if( GetShell()->ActionPend() ) { - SwAccessibleEvent_Impl aEvent( - SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, - pAccImpl->GetFrm(), _nStates ); + SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, + pAccImpl, + SwAccessibleChild(pAccImpl->GetFrm()), + _nStates ); AppendEvent( aEvent ); } else @@ -1902,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; @@ -1927,9 +2151,11 @@ void SwAccessibleMap::_InvalidateRelationSet( const SwFrm* pFrm, static_cast< SwAccessibleContext *>( xAcc.get() ); if( GetShell()->ActionPend() ) { - SwAccessibleEvent_Impl aEvent( - SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, pFrm, - bFrom ? ACC_STATE_RELATION_FROM : ACC_STATE_RELATION_TO ); + SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, + pAccImpl, SwAccessibleChild(pFrm), + ( bFrom + ? ACC_STATE_RELATION_FROM + : ACC_STATE_RELATION_TO ) ); AppendEvent( aEvent ); } else @@ -1971,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; @@ -1998,7 +2224,8 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, - pAccImpl, &_rTxtFrm, + pAccImpl, + SwAccessibleChild( &_rTxtFrm ), ACC_STATE_TEXT_SELECTION_CHANGED ); AppendEvent( aEvent ); } @@ -2011,6 +2238,43 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) } } +sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrm& rParentFrm, + Window& rChild ) const +{ + sal_Int32 nIndex( -1 ); + + SwAccessibleChild aFrmOrObj( &rParentFrm ); + if( aFrmOrObj.IsAccessible( GetShell()->IsPreView() ) ) + { + uno::Reference < XAccessible > xAcc; + { + vos::OGuard aGuard( maMutex ); + + if( mpFrmMap ) + { + SwAccessibleContextMap_Impl::iterator aIter = + mpFrmMap->find( aFrmOrObj.GetSwFrm() ); + if( aIter != mpFrmMap->end() ) + { + xAcc = (*aIter).second; + } + } + } + + if( xAcc.is() ) + { + SwAccessibleContext *pAccImpl = + static_cast< SwAccessibleContext *>( xAcc.get() ); + + nIndex = pAccImpl->GetChildIndex( const_cast<SwAccessibleMap&>(*this), + SwAccessibleChild( &rChild ) ); + } + } + + return nIndex; +} + + // OD 15.01.2003 #103492# - complete re-factoring of method due to new page/print // preview functionality. void SwAccessibleMap::UpdatePreview( const std::vector<PrevwPage*>& _rPrevwPages, @@ -2022,7 +2286,7 @@ void SwAccessibleMap::UpdatePreview( const std::vector<PrevwPage*>& _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 @@ -2247,7 +2511,7 @@ sal_Bool SwAccessibleMap::ReplaceChild ( // Also get keep parent. uno::Reference < XAccessible > xParent( pCurrentChild->getAccessibleParent() ); pCurrentChild = 0; // well be realease by dispose - Dispose( 0, pObj ); + Dispose( 0, pObj, 0 ); { vos::OGuard aGuard( maMutex ); @@ -2284,7 +2548,7 @@ sal_Bool SwAccessibleMap::ReplaceChild ( } SwRect aEmptyRect; - InvalidatePosOrSize( 0, pObj, aEmptyRect ); + InvalidatePosOrSize( 0, pObj, 0, aEmptyRect ); return sal_True; } @@ -2612,153 +2876,13 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas() } } -// -// SwAccPreviewData -// - -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 std::vector<PrevwPage*>& _rPrevwPages, - const Fraction& _rScale, - const SwPageFrm* _pSelectedPageFrm, - const Size& _rPrevwWinSize ) +const SwRect& SwAccessibleMap::GetVisArea() const { - // 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(); + DBG_ASSERT( !GetShell()->IsPreView() || (mpPreview != NULL), + "preview without preview data?" ); - // loop on preview pages to calculate <maPreviewRects>, <maLogicRects> and - // <maVisArea> - for ( std::vector<PrevwPage*>::const_iterator aPageIter = _rPrevwPages.begin(); - aPageIter != _rPrevwPages.end(); - ++aPageIter ) - { - aPage = (*aPageIter)->pPage; - - // add preview page rectangle to <maPreviewRects> - Rectangle aPrevwPgRect( (*aPageIter)->aPrevwWinPos, (*aPageIter)->aPageSize ); - maPreviewRects.push_back( aPrevwPgRect ); - - // add logic page rectangle to <maLogicRects> - 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 ); - } - } + return GetShell()->IsPreView() + ? mpPreview->GetVisArea() + : GetShell()->VisArea(); } -// 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 ); -} |