sw/source/core/crsr/swcrsr.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
New commits: commit 1c94842e053a20a739a181d38a35c324df3e62a7 Author: Michael Stahl <[email protected]> AuthorDate: Wed Apr 15 16:58:55 2020 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Wed Apr 15 19:59:33 2020 +0200 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 <[email protected]> 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 _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
