summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-08-12 20:15:02 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-08-12 20:23:16 +0200
commit78131b6bfc16d739e28024407de253c84cb68a8a (patch)
treeeb7a7d13fd942f8c04b1a584f36e2c2cd710a2c4 /sw
parent2903d85d6197829633d7f96c95cd55821c2c20ff (diff)
show fly anchored inside selection as selected too
If part (or whole) document is selected and then the selection is e.g. deleted, flys anchored there will be deleted too, so it makes sense to show them as part of the selection. Change-Id: I17bfccebc0cd305c19616159471f0f113c7e71d9
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/swregion.hxx1
-rw-r--r--sw/source/core/bastyp/swregion.cxx6
-rw-r--r--sw/source/core/layout/trvlfrm.cxx26
3 files changed, 32 insertions, 1 deletions
diff --git a/sw/inc/swregion.hxx b/sw/inc/swregion.hxx
index 5602c127637e..b290e2191aef 100644
--- a/sw/inc/swregion.hxx
+++ b/sw/inc/swregion.hxx
@@ -36,6 +36,7 @@ public:
// For punching from aOrigin.
void operator-=( const SwRect& rRect );
+ void operator+=( const SwRect& rRect );
// From holes to areas, from areas to holes.
void Invert();
diff --git a/sw/source/core/bastyp/swregion.cxx b/sw/source/core/bastyp/swregion.cxx
index d7cef1506554..dcd2eb342814 100644
--- a/sw/source/core/bastyp/swregion.cxx
+++ b/sw/source/core/bastyp/swregion.cxx
@@ -45,6 +45,12 @@ inline void SwRegionRects::InsertRect( const SwRect &rRect,
}
}
+void SwRegionRects::operator+=( const SwRect &rRect )
+{
+ bool f = false;
+ InsertRect( rRect, 0, f );
+}
+
/** Delete all overlaps of the Rects in array with the given <rRect>
To do so, all existing rectangles have to be either split or deleted.
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index f98aee6be4a8..7f63987ad39e 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1973,6 +1973,12 @@ inline void Sub( SwRegionRects& rRegion, const SwRect& rRect )
rRegion -= rRect;
}
+inline void Add( SwRegionRects& rRegion, const SwRect& rRect )
+{
+ if( rRect.Width() > 1 && rRect.Height() > 1 )
+ rRegion += rRect;
+}
+
/*
* The following situations can happen:
* 1. Start and end lie in one screen-row and in the same node
@@ -1990,6 +1996,7 @@ inline void Sub( SwRegionRects& rRegion, const SwRect& rRect )
* Exceptions: - The Fly in which the selection took place (if it took place
* in a Fly)
* - The Flys which are underrun by the text
+ * - The Flys which are anchored to somewhere inside the selection.
* Functioning: First a SwRegion with a root gets initialized.
* Out of the region the inverted sections are cut out. The
* section gets compressed and finally inverted and thereby the
@@ -2549,6 +2556,7 @@ void SwRootFrm::CalcFrmRects(SwShellCrsr &rCrsr)
// sit in it)
// - if in the Z-order we have Flys above those in which the StartFrm is
// placed
+ // - if they are anchored to inside the selection and thus part of it
const SwPageFrm *pPage = pStartFrm->FindPageFrm();
const SwPageFrm *pEndPage = pEndFrm->FindPageFrm();
@@ -2565,7 +2573,23 @@ void SwRootFrm::CalcFrmRects(SwShellCrsr &rCrsr)
const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pAnchoredObj);
const SwVirtFlyDrawObj* pObj = pFly->GetVirtDrawObj();
const SwFmtSurround &rSur = pFly->GetFmt()->GetSurround();
- if ( !pFly->IsAnLower( pStartFrm ) &&
+ SwPosition anchoredAt = *pAnchoredObj->GetFrmFmt().GetAnchor().GetCntntAnchor();
+ bool inSelection = ( *pStartPos <= anchoredAt && anchoredAt < *pEndPos );
+ if( anchoredAt == *pEndPos )
+ {
+ const SwNodes& nodes = anchoredAt.GetDoc()->GetNodes();
+ if( *pEndPos == SwPosition( nodes.GetEndOfContent()))
+ inSelection = true;
+ else
+ {
+ SwNodeIndex idx( nodes.GetEndOfContent());
+ if( SwCntntNode* last = nodes.GoPrevious( &idx ))
+ inSelection = *pEndPos == SwPosition( *last, last->Len());
+ }
+ }
+ if( inSelection )
+ Add( aRegion, pFly->Frm() );
+ else if ( !pFly->IsAnLower( pStartFrm ) &&
(rSur.GetSurround() != SURROUND_THROUGHT &&
!rSur.IsContour()) )
{