summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-06-29 10:38:19 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-06-30 17:57:18 +0200
commitd4b74188c87cdeb881aacbc053594a7c697ab1ca (patch)
tree2bbeaf366eaf4bd72429ca400392c6215991e7e6
parent20251fccc40bfaadf3651cc8d4b6bd321859da12 (diff)
fdo#36496, n#676858: background images shouldn't be selected before text
-rw-r--r--sw/source/core/layout/trvlfrm.cxx66
1 files changed, 46 insertions, 20 deletions
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 1193a2b26975..a508045378b6 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -58,6 +58,7 @@
#include <crstate.hxx>
#include <frmtool.hxx>
#include <ndtxt.hxx>
+#include <dcontact.hxx>
// OD 2004-05-24 #i28701#
#include <sortedobjs.hxx>
@@ -65,6 +66,44 @@
#include <cfloat>
#include <swselectionlist.hxx>
+namespace {
+ bool lcl_GetCrsrOfst_Objects( const SwPageFrm* pPageFrm, bool bSearchBackground,
+ SwPosition *pPos, Point& rPoint, SwCrsrMoveState* pCMS )
+ {
+ bool bRet = false;
+ Point aPoint( rPoint );
+ SwOrderIter aIter( pPageFrm );
+ aIter.Top();
+ while ( aIter() )
+ {
+ const SwVirtFlyDrawObj* pObj =
+ static_cast<const SwVirtFlyDrawObj*>(aIter());
+ const SwAnchoredObject* pAnchoredObj = GetUserCall( aIter() )->GetAnchoredObj( aIter() );
+ const SwFmtSurround& rSurround = pAnchoredObj->GetFrmFmt().GetSurround();
+ bool bInBackground = ( rSurround.GetSurround() == SURROUND_THROUGHT );
+
+ bool bBackgroundMatches = ( bInBackground && bSearchBackground ) ||
+ ( !bInBackground && !bSearchBackground );
+
+ const SwFlyFrm* pFly = pObj ? pObj->GetFlyFrm() : 0;
+ if ( pFly && bBackgroundMatches &&
+ ( ( pCMS ? pCMS->bSetInReadOnly : false ) ||
+ !pFly->IsProtected() ) &&
+ pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
+ {
+ bRet = true;
+ break;
+ }
+
+ if ( pCMS && pCMS->bStop )
+ return false;
+ aIter.Prev();
+ }
+ return bRet;
+ }
+}
+
+
//Fuer SwFlyFrm::GetCrsrOfst
class SwCrsrOszControl
{
@@ -166,26 +205,7 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
//hineinsetzen, dadurch sollten alle Aenderungen unmoeglich sein.
if ( GetSortedObjs() )
{
- SwOrderIter aIter( this );
- aIter.Top();
- while ( aIter() )
- {
- const SwVirtFlyDrawObj* pObj =
- static_cast<const SwVirtFlyDrawObj*>(aIter());
- const SwFlyFrm* pFly = pObj ? pObj->GetFlyFrm() : 0;
- if ( pFly &&
- ( ( pCMS ? pCMS->bSetInReadOnly : sal_False ) ||
- !pFly->IsProtected() ) &&
- pFly->GetCrsrOfst( pPos, aPoint, pCMS ) )
- {
- bRet = sal_True;
- break;
- }
-
- if ( pCMS && pCMS->bStop )
- return sal_False;
- aIter.Prev();
- }
+ bRet = lcl_GetCrsrOfst_Objects( this, false, pPos, rPoint, pCMS );
}
if ( !bRet )
@@ -222,6 +242,12 @@ sal_Bool SwPageFrm::GetCrsrOfst( SwPosition *pPos, Point &rPoint,
}
}
+ // Check objects in the background if nothing else matched
+ if ( !bRet && GetSortedObjs() )
+ {
+ bRet = lcl_GetCrsrOfst_Objects( this, true, pPos, rPoint, pCMS );
+ }
+
if ( bRet )
rPoint = aPoint;