diff options
author | Oliver-Rainer Wittmann <od@openoffice.org> | 2009-12-30 15:04:27 +0100 |
---|---|---|
committer | Oliver-Rainer Wittmann <od@openoffice.org> | 2009-12-30 15:04:27 +0100 |
commit | 5d57f18e6f0b14a1bf2c0f418a9cd6f64e06781b (patch) | |
tree | 64c33d79f4d680d25260f071a9d622dcc1c15124 | |
parent | d7d854b1c4f70f57f29261d6a942bdb29ebcee8c (diff) |
sw33bf02: #i89920# Improvement of selection of objects in background
-rw-r--r-- | sw/source/core/draw/dflyobj.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 86 | ||||
-rw-r--r-- | sw/source/core/inc/dflyobj.hxx | 1 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 23 |
4 files changed, 80 insertions, 35 deletions
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 15ca46ca2456..c97c0a079745 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -566,6 +566,11 @@ const Rectangle& __EXPORT SwVirtFlyDrawObj::GetCurrentBoundRect() const return aOutRect; } +const Rectangle& __EXPORT SwVirtFlyDrawObj::GetLastBoundRect() const +{ + return GetCurrentBoundRect(); +} + void __EXPORT SwVirtFlyDrawObj::RecalcBoundRect() { diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index d465abc4403e..80e150248c75 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1185,9 +1185,7 @@ bool SwFEShell::IsObjSelectable( const Point& rPt ) } // #107513# -// Test if there is a draw object at that position and if it should be selected. -// The 'should' is aimed at Writer text fly frames which may be in front of -// the draw object. +// Test if there is a object at that position and if it should be selected. sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt) { SET_CURR_SHELL(this); @@ -1204,39 +1202,79 @@ sal_Bool SwFEShell::ShouldObjectBeSelected(const Point& rPt) bRet = pDrawView->PickObj(rPt, pDrawView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMARKABLE); pDrawView->SetHitTolerancePixel(nOld); - if(bRet && pObj) + if ( bRet && pObj ) { const IDocumentDrawModelAccess* pIDDMA = getIDocumentDrawModelAccess(); - if( pObj->GetLayer() == pIDDMA->GetHellId() ) + // --> OD 2009-12-30 #i89920# + // Do not select object in background which is overlapping this text + // at the given position. + bool bObjInBackground( false ); { - const SwFrm *pPageFrm = GetLayout()->Lower(); - while( pPageFrm && !pPageFrm->Frm().IsInside( rPt ) ) + if ( pObj->GetLayer() == pIDDMA->GetHellId() ) { - if ( rPt.Y() < pPageFrm->Frm().Top() ) - pPageFrm = 0; - else - pPageFrm = pPageFrm->GetNext(); + const SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj ); + const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); + const SwFmtSurround& rSurround = rFmt.GetSurround(); + if ( rSurround.GetSurround() == SURROUND_THROUGHT ) + { + bObjInBackground = true; + } } + } + if ( bObjInBackground ) + { + const SwPageFrm* pPageFrm = GetLayout()->GetPageAtPos( rPt ); if( pPageFrm ) { - SwRect aTmp( pPageFrm->Prt() ); - aTmp += pPageFrm->Frm().Pos(); - if( aTmp.IsInside( rPt ) ) - return sal_False; + const SwCntntFrm* pCntntFrm( pPageFrm->ContainsCntnt() ); + while ( pCntntFrm ) + { + if ( pCntntFrm->UnionFrm().IsInside( rPt ) ) + { + const SwTxtFrm* pTxtFrm = + dynamic_cast<const SwTxtFrm*>(pCntntFrm); + if ( pTxtFrm ) + { + SwPosition* pPos = + new SwPosition( *(pTxtFrm->GetTxtNode()) ); + Point aTmpPt( rPt ); + if ( pTxtFrm->GetKeyCrsrOfst( pPos, aTmpPt ) ) + { + SwRect aCharRect; + if ( pTxtFrm->GetCharRect( aCharRect, *pPos ) ) + { + if ( aCharRect.IsOver( SwRect( pObj->GetLastBoundRect() ) ) ) + { + bRet = sal_False; + } + } + } + } + else + { + bRet = sal_False; + } + break; + } + + pCntntFrm = pCntntFrm->GetNextCntntFrm(); + } } } - - const SdrPage* pPage = pIDDMA->GetDrawModel()->GetPage(0); - // --> FME 2005-04-18 #i20965# Use GetOrdNum() instead of GetOrdNumDirect() - // because ordnums might be wrong - for(sal_uInt32 a(pObj->GetOrdNum() + 1); bRet && a < pPage->GetObjCount(); a++) - { // <-- - SdrObject *pCandidate = pPage->GetObj(a); - if(pCandidate->ISA(SwVirtFlyDrawObj) && ((SwVirtFlyDrawObj*)pCandidate)->GetCurrentBoundRect().IsInside(rPt)) + if ( bRet ) + { + const SdrPage* pPage = pIDDMA->GetDrawModel()->GetPage(0); + for(sal_uInt32 a(pObj->GetOrdNum() + 1); bRet && a < pPage->GetObjCount(); a++) { - bRet = sal_False; + SdrObject *pCandidate = pPage->GetObj(a); + + if (pCandidate->ISA(SwVirtFlyDrawObj) && + ( (SwVirtFlyDrawObj*)pCandidate)->GetCurrentBoundRect().IsInside(rPt) ) + { + bRet = sal_False; + } } } } diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 292be49df7b4..2d5f8299a229 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -100,6 +100,7 @@ public: //Wir nehemen die Groessenbehandlung vollstaendig selbst in die Hand. virtual const Rectangle& GetCurrentBoundRect() const; + virtual const Rectangle& GetLastBoundRect() const; virtual void RecalcBoundRect(); virtual void RecalcSnapRect(); virtual const Rectangle& GetSnapRect() const; diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 5bef2edb398f..6e7c393d8c6a 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -2882,7 +2882,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) !bExecDrawTextLink) { // #107513# - // Test if there is a draw object at that position and if it should be selected. + // Test if there is a object at that position and if it should be selected. sal_Bool bShould = rSh.ShouldObjectBeSelected(aDocPos); if(bShould) @@ -3153,7 +3153,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) if ( rSh.IsSelFrmMode() ) rSh.SelectObj(aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP); else - { if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) ) + { + if ( rSh.SelectObj( aDocPos, SW_ADD_SELECT | SW_ENTER_GROUP ) ) { rSh.EnterSelFrmMode( &aDocPos ); SwEditWin::nDDStartPosY = aDocPos.Y(); @@ -3366,11 +3367,16 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) bNoInterrupt = bTmpNoInterrupt; } - if( !bOverURLGrf && !bOnlyText ) + if ( !bOverURLGrf && !bOnlyText ) { - const int nSelType = rSh.GetSelectionType(); - if( nSelType == nsSelectionType::SEL_OLE || - nSelType == nsSelectionType::SEL_GRF ) + const SelectionType nSelType = rSh.GetSelectionType(); + // --> OD 2009-12-30 #i89920# + // Check in general, if an object is selectable at given position. + // Thus, also text fly frames in background become selectable via Ctrl-Click. + if ( nSelType & nsSelectionType::SEL_OLE || + nSelType & nsSelectionType::SEL_GRF || + rSh.IsObjSelectable( aDocPos ) ) + // <-- { MV_KONTEXT( &rSh ); if( !rSh.IsFrmSelected() ) @@ -3379,11 +3385,6 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) bCallBase = FALSE; } } - // nicht mehr hier zuruecksetzen, damit -- falls durch MouseMove - // bei gedrueckter Ctrl-Taste eine Mehrfachselektion erfolgen soll, - // im Drag nicht die vorherige Selektion aufgehoben wird. -// if(bModePushed) -// rSh.PopMode(FALSE); break; } } |