summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-08-12 18:39:02 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-08-12 20:23:16 +0200
commit2903d85d6197829633d7f96c95cd55821c2c20ff (patch)
treec73b28cb073885647e4e9274735bc7e4ed93fa10
parent95f0811c093680e6258f3bc973a3f7a3731a28f4 (diff)
fix deleting an image anchored to last paragraph in document
It only compared nodes instead of SwPositions, thus refusing to delete anything anchored at the last content node. Also, select-all makes rEnd point to the last content node, after its content. So if an anchor-to-char image is anchored at the end of the paragraph, it points to this place, too, so that must be checked. Change-Id: Ie0ba6ed59f47e59492ad88577392884cadb52106
-rw-r--r--sw/inc/undobj.hxx2
-rw-r--r--sw/source/core/undo/undobj.cxx20
-rw-r--r--sw/source/filter/basflt/shellio.cxx3
3 files changed, 19 insertions, 6 deletions
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 9c0ff35df8ab..a1febc4e5e2b 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -134,7 +134,7 @@ namespace nsDelCntntType
/// will DelCntntIndex destroy a frame anchored at character at rAnchorPos?
bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
- SwPosition const & rStart, SwPosition const & rEnd,
+ SwPosition const & rStart, SwPosition const & rEnd, const SwDoc* doc,
DelCntntType const nDelCntntType = nsDelCntntType::DELCNT_ALL);
// This class has to be inherited into an Undo-object if it saves content
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 7124511f8795..ff2a30b72e54 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -645,7 +645,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark,
if( !pHistory )
pHistory = new SwHistory;
if (IsDestroyFrameAnchoredAtChar(
- *pAPos, *pStt, *pEnd, nDelCntntType))
+ *pAPos, *pStt, *pEnd, pDoc, nDelCntntType))
{
pHistory->Add( *pFmt, nChainInsPos );
n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
@@ -1145,15 +1145,27 @@ OUString ShortenString(const OUString & rStr, sal_Int32 nLength, const OUString
}
bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
- SwPosition const & rStart, SwPosition const & rEnd,
+ SwPosition const & rStart, SwPosition const & rEnd, const SwDoc* doc,
DelCntntType const nDelCntntType)
{
-
+ bool inSelection = rAnchorPos < rEnd;
+ if( rAnchorPos == rEnd )
+ {
+ const SwNodes& nodes = doc->GetNodes();
+ if( rEnd == SwPosition( nodes.GetEndOfContent()))
+ inSelection = true;
+ else
+ {
+ SwNodeIndex idx( nodes.GetEndOfContent());
+ if( SwCntntNode* last = nodes.GoPrevious( &idx ))
+ inSelection = rEnd == SwPosition( *last, last->Len());
+ }
+ }
// Here we identified the objects to destroy:
// - anchored between start and end of the selection
// - anchored in start of the selection with "CheckNoContent"
// - anchored in start of sel. and the selection start at pos 0
- return (rAnchorPos.nNode < rEnd.nNode)
+ return inSelection
&& ( (nsDelCntntType::DELCNT_CHKNOCNTNT & nDelCntntType)
|| (rStart.nNode < rAnchorPos.nNode)
|| !rStart.nContent.GetIndex()
diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx
index 6505ccf525c9..8a1bb01991f5 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -237,7 +237,8 @@ sal_uLong SwReader::Read( const Reader& rOptions )
&& !IsDestroyFrameAnchoredAtChar(
*pFrameAnchor,
*pUndoPam->GetPoint(),
- *pUndoPam->GetMark())
+ *pUndoPam->GetMark(),
+ pDoc)
)
)
)