diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-04-15 16:58:55 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-04-15 19:59:33 +0200 |
commit | 1c94842e053a20a739a181d38a35c324df3e62a7 (patch) | |
tree | 0c584b905158f3b3d8032735b01a377d17462f1a | |
parent | 54c94ddff2664bc378a4298ee4d6948b7f32e595 (diff) |
tdf#132091 sw: fix fieldmark mess in SwCursor::SelectWordWT()
The problem is that it selects both the field instruction and the field
result; in the typical case where the instruction is empty, the
separator won't be deleted (due to CalcBreaks) but the problem is
that the cursor ends up before the separator, not after it.
Also remove some silly defensive programming.
(regression from ffb26b81e1c7ff1d64959200247bb2edd5a569da)
Change-Id: I80b6cb1790b7102828f12b680631f928734ffa7b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92284
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r-- | sw/source/core/crsr/swcrsr.cxx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index d4bfe66b05d9..9881a260f382 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -28,6 +28,7 @@ #include <swtblfmt.hxx> #include <swcrsr.hxx> #include <unocrsr.hxx> +#include <bookmrk.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentRedlineAccess.hxx> @@ -1407,23 +1408,20 @@ bool SwCursor::SelectWordWT( SwViewShell const * pViewShell, sal_Int16 nWordType { // Should we select the whole fieldmark? const IDocumentMarkAccess* pMarksAccess = GetDoc()->getIDocumentMarkAccess( ); - sw::mark::IMark* pMark = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : nullptr; + sw::mark::IFieldmark const*const pMark(pMarksAccess->getFieldmarkFor(*GetPoint())); if ( pMark ) { - const SwPosition& rStart = pMark->GetMarkStart(); - GetPoint()->nNode = rStart.nNode; - GetPoint()->nContent = rStart.nContent; - ++GetPoint()->nContent; // Don't select the start delimiter + *GetPoint() = sw::mark::FindFieldSep(*pMark); + ++GetPoint()->nContent; // Don't select the separator const SwPosition& rEnd = pMark->GetMarkEnd(); - if ( rStart != rEnd ) - { - SetMark(); - GetMark()->nNode = rEnd.nNode; - GetMark()->nContent = rEnd.nContent; - --GetMark()->nContent; //Don't select the end delimiter - } + assert(pMark->GetMarkEnd() != *GetPoint()); + SetMark(); + GetMark()->nNode = rEnd.nNode; + GetMark()->nContent = rEnd.nContent; + --GetMark()->nContent; // Don't select the end delimiter + bRet = true; } else |