sw/inc/IMark.hxx                  |    1 +
 sw/source/core/crsr/bookmark.cxx  |   21 +++++++++++++++++++++
 sw/source/core/inc/bookmark.hxx   |    5 +++++
 sw/source/uibase/docvw/edtwin.cxx |    6 ++++++
 4 files changed, 33 insertions(+)

New commits:
commit 7ea8523e068160b933a4a0611d7b0a1307925d0d
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Mon Sep 23 11:38:56 2024 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Tue Nov 5 09:44:07 2024 +0100

    tdf#159286 FORMTEXT selection changed
    
    As long as FORMTEXT has default content of 5 en spaces a click
    selects the content. If the content has changed then the cursor is
    placed at the mouse position.
    
    Change-Id: If0e7717d04d29887b63ec20ed6b82c625400421a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173812
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175770
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sw/inc/IMark.hxx b/sw/inc/IMark.hxx
index 04b7efa22141..ae0098058635 100644
--- a/sw/inc/IMark.hxx
+++ b/sw/inc/IMark.hxx
@@ -106,6 +106,7 @@ namespace sw::mark
             virtual OUString GetContent() const { return OUString(); }
             virtual void ReplaceContent(const OUString& /*sNewContent*/) {}
 
+            virtual bool HasDefaultContent() const = 0;
         private:
             IFieldmark(IFieldmark const &) = delete;
             IFieldmark &operator =(IFieldmark const&) = delete;
diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx
index 60aee0b19197..2e02b9298be6 100644
--- a/sw/source/core/crsr/bookmark.cxx
+++ b/sw/source/core/crsr/bookmark.cxx
@@ -672,6 +672,11 @@ namespace sw::mark
         }
         Invalidate();
     }
+    bool TextFieldmark::HasDefaultContent() const
+    {
+        return GetContent() == vEnSpaces;
+    }
+
 
     NonTextFieldmark::NonTextFieldmark(const SwPaM& rPaM)
         : Fieldmark(rPaM)
@@ -704,6 +709,11 @@ namespace sw::mark
     }
 
 
+    bool NonTextFieldmark::HasDefaultContent() const
+    {
+        return false;
+    }
+
     CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM, const OUString& 
rName)
         : NonTextFieldmark(rPaM)
     {
@@ -1033,6 +1043,11 @@ namespace sw::mark
             "{\"action\": \"hide\", \"type\": \"drop-down\"}"_ostr);
     }
 
+    bool DropDownFieldmark::HasDefaultContent() const
+    {
+        return false;
+    }
+
     DateFieldmark::DateFieldmark(const SwPaM& rPaM)
         : FieldmarkWithDropDownButton(rPaM)
         , m_pNumberFormatter(nullptr)
@@ -1324,6 +1339,12 @@ namespace sw::mark
             (*pParameters)[ODF_FORMDATE_CURRENTDATE] <<= OUString();
         }
     }
+
+    bool DateFieldmark::HasDefaultContent() const
+    {
+        return false;
+    }
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/bookmark.hxx b/sw/source/core/inc/bookmark.hxx
index 8a3fc98f260c..29344910ec5a 100644
--- a/sw/source/core/inc/bookmark.hxx
+++ b/sw/source/core/inc/bookmark.hxx
@@ -246,6 +246,7 @@ namespace sw::mark {
 
             OUString GetContent() const override;
             void ReplaceContent(const OUString& sNewContent) override;
+            bool HasDefaultContent() const override;
 
         private:
             sw::DocumentContentOperationsManager* 
m_pDocumentContentOperationsManager;
@@ -259,6 +260,8 @@ namespace sw::mark {
             NonTextFieldmark(const SwPaM& rPaM);
             void InitDoc(SwDoc& io_rDoc, sw::mark::InsertMode eMode, 
SwPosition const* pSepPos) override;
             void ReleaseDoc(SwDoc& rDoc) override;
+
+            bool HasDefaultContent() const override;
         };
 
         /// Fieldmark representing a checkbox form field.
@@ -307,6 +310,7 @@ namespace sw::mark {
             void DelContent(sal_Int32 nDelIndex = -1) override;
             void ReplaceContent(const OUString* pText, sal_Int32* pIndex) 
override;
             void ReplaceContent(const OUString& sNewContent) override;
+            bool HasDefaultContent() const override;
 
             // This method should be called only by the portion so we can now 
the portion's painting area
             void SetPortionPaintArea(const SwRect& rPortionPaintArea);
@@ -345,6 +349,7 @@ namespace sw::mark {
             std::pair<bool, double> GetCurrentDate() const override;
             void SetCurrentDate(double fDate) override;
             OUString GetDateInStandardDateFormat(double fDate) const override;
+            bool HasDefaultContent() const override;
 
         private:
             OUString GetDateInCurrentDateFormat(double fDate) const;
diff --git a/sw/source/uibase/docvw/edtwin.cxx 
b/sw/source/uibase/docvw/edtwin.cxx
index 28339dde0d42..7055517bcdef 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -5105,6 +5105,12 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                                         rCheckboxFm.Invalidate();
                                         rSh.InvalidateWindows( 
SwRect(m_rView.GetVisArea()) );
                                     }
+                                    else if ( fieldBM->GetFieldname( ) == 
ODF_FORMTEXT &&
+                                        
aContentAtPos.aFnd.pFieldmark->HasDefaultContent() )
+                                    {
+                                        rSh.GotoFieldmark( 
aContentAtPos.aFnd.pFieldmark );
+                                    }
+
                                 }
                             }
                             else if ( IsAttrAtPos::InetAttr == 
aContentAtPos.eContentAtPos )

Reply via email to