sw/source/core/view/viewsh.cxx | 50 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-)
New commits: commit 3da41647552c21fcc61f5b5dd9f63d64f23f1cf6 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Fri Nov 6 14:11:05 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Thu Nov 19 11:20:22 2020 +0100 sw_fieldmarkhide: move cursor outside of hidden fieldmark when toggling Change-Id: If76331fa5a65376fd210171b967736f4d356462e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105988 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 12e67ef4e901..1ef26c9e126f 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -51,6 +51,7 @@ #include <ptqueue.hxx> #include <docsh.hxx> #include <pagedesc.hxx> +#include <bookmrk.hxx> #include <ndole.hxx> #include <ndindex.hxx> #include <accmap.hxx> @@ -2143,6 +2144,45 @@ void SwViewShell::ApplyViewOptions( const SwViewOption &rOpt ) rSh.EndAction(); } +static bool +IsCursorInFieldmarkHidden(SwPaM const& rCursor, sw::FieldmarkMode const eMode) +{ + if (eMode == sw::FieldmarkMode::ShowBoth) + { + return false; + } + IDocumentMarkAccess const& rIDMA(*rCursor.GetDoc().getIDocumentMarkAccess()); + // iterate, for nested fieldmarks + for (auto iter = rIDMA.getFieldmarksBegin(); iter != rIDMA.getFieldmarksEnd(); ++iter) + { + if (*rCursor.GetPoint() <= (**iter).GetMarkStart()) + { + return false; + } + if (*rCursor.GetPoint() < (**iter).GetMarkEnd()) + { + SwPosition const sepPos(sw::mark::FindFieldSep( + *dynamic_cast<sw::mark::IFieldmark*>(*iter))); + if (eMode == sw::FieldmarkMode::ShowResult) + { + if (*rCursor.GetPoint() <= sepPos + && *rCursor.GetPoint() != (**iter).GetMarkStart()) + { + return true; + } + } + else + { + if (sepPos < *rCursor.GetPoint()) + { + return true; + } + } + } + } + return false; +} + void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt ) { if (*mpOpt == rOpt) @@ -2183,7 +2223,7 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt ) // ( - SwEndPortion must _no_ longer be generated. ) // - Of course, the screen is something completely different than the printer ... bReformat = bReformat || mpOpt->IsFieldName() != rOpt.IsFieldName(); - bool const isEnableFieldNames(mpOpt->IsFieldName() != rOpt.IsFieldName() && rOpt.IsFieldName()); + bool const isToggleFieldNames(mpOpt->IsFieldName() != rOpt.IsFieldName()); // The map mode is changed, minima/maxima will be attended by UI if( mpOpt->GetZoom() != rOpt.GetZoom() && !IsPreview() ) @@ -2271,14 +2311,16 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt ) EndAction(); } - if (isEnableFieldNames) + if (isToggleFieldNames) { for(SwViewShell& rSh : GetRingContainer()) { if (SwCursorShell *const pSh = dynamic_cast<SwCursorShell *>(&rSh)) { - if (pSh->CursorInsideInputField()) - { // move cursor out of input field + if ((mpOpt->IsFieldName() && pSh->CursorInsideInputField()) + || IsCursorInFieldmarkHidden(*pSh->GetCursor(), + pSh->GetLayout()->GetFieldmarkMode())) + { // move cursor out of field pSh->Left(1, CRSR_SKIP_CHARS); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits