sw/source/uibase/shells/basesh.cxx |   23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

New commits:
commit 7303a0375bb3ae087fb4ff77d0efc9182c60a372
Author:     Juergen Funk <juergen.funk...@cib.de>
AuthorDate: Tue Oct 15 10:57:15 2024 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Oct 17 13:53:28 2024 +0200

    tdf#160163 improvment when reset placeholder in Text field
    
     - this patch improve e8a271dd53d605a835c493eef5c34e4fb077f16d
       when replace the empty-placholder, it was missing the selection
       of the whole placeholders.
     - with this change have solved a other problem, when select with
       the field with mouse or tab, and press backspace, then the cursor
       has the wrong position, after tip text the view was wrong.
     - reduce code
    
    Change-Id: I6c2c7b2849298552770ea2d257ab844d250a97a1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174965
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index 1a7fc5b6c197..25a4465f30b0 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -292,29 +292,24 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq)
     //#i42732# - notify the edit window that from now on we do not use the 
input language
     rTmpEditWin.SetUseInputLanguage( false );
 
-    std::function<void(SwPosition* sp, const IDocumentMarkAccess* 
pMarksAccess)>
-        NoEmptyTextField = [](SwPosition* sp, const IDocumentMarkAccess* 
pMarksAccess)
+    // Test Fieldmark when empty reset the Placeholders
+    const IDocumentMarkAccess* pMarksAccess = 
rSh.GetDoc()->getIDocumentMarkAccess();
+    for (SwPaM &rPaM : rSh.GetCursor()->GetRingContainer())
     {
+        const SwPosition* sp = rPaM.Start();
         // Legacy text/combo/checkbox: never return read-only when inside 
these form fields.
         sw::mark::Fieldmark* pA = pMarksAccess->getInnerFieldmarkFor(*sp);
         if (pA != nullptr)
         {
-            bool fm = IDocumentMarkAccess::GetType(*pA) == 
IDocumentMarkAccess::MarkType::TEXT_FIELDMARK;
-            if ((pA->GetContent().getLength() == 0) && fm)
+            if ((IDocumentMarkAccess::GetType(*pA) == 
IDocumentMarkAccess::MarkType::TEXT_FIELDMARK) &&
+                (pA->GetContent().getLength() == 0)
+               )
             {
                 pA->ReplaceContent(vEnSpaces);
-            };
+                rSh.GotoFieldmark(pA);
+            }
         }
-    };
-
-    const IDocumentMarkAccess* pMarksAccess = 
rSh.GetDoc()->getIDocumentMarkAccess();
-    for (SwPaM& rPaM : rSh.GetCursor()->GetRingContainer())
-    {
-        auto [pStt, pEnd] = rPaM.StartEnd(); // SwPosition*
-        NoEmptyTextField(pStt, pMarksAccess);
-        NoEmptyTextField(pEnd, pMarksAccess);
     }
-
 }
 
 void SwBaseShell::ExecClpbrd(SfxRequest &rReq)

Reply via email to