sw/source/core/crsr/bookmark.cxx |   11 ++++++++---
 sw/source/core/doc/docbm.cxx     |    4 ++--
 sw/source/core/inc/bookmark.hxx  |    4 ++--
 3 files changed, 12 insertions(+), 7 deletions(-)

New commits:
commit cd8baac3c114fabeb593b59d3c8f4ee5243df36c
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Sat Oct 15 14:54:11 2022 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Oct 24 15:06:04 2022 +0200

    tdf#151548 sw: use provided name for formfields
    
    This was already aded for TextFieldmark in 2018 via tdf#120225.
    (A unique name is created if that mark already exists.)
    
    Added it to the other formfield items.
    This is needed for DOC/DOCX import,
    and is critical for connecting macros to the control.
    
    mstahl said that  DateFieldmark is not a valid MS formfield,
    and miklosv indicated  no likely value in preserving a name there.
    
    There is also NonTextFieldmark and FieldmarkWithDropDownButton,
    but they just look like implementation gadgets to me
    so I didn't give them the same treatment.
    
    No need for a unit test here. This is super foundational - anything
    else building on it will be the unit test.
    
    Cherry-pick of 8ad39b6f2aff3ca37aeaaaaff5373991e853c329
    
    Change-Id: Ide49d6efb8391fea17e7a61c9e99b30532bb2014
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141423
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141596
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx
index 417558aad130..ecbd5dab2d56 100644
--- a/sw/source/core/crsr/bookmark.cxx
+++ b/sw/source/core/crsr/bookmark.cxx
@@ -621,9 +621,12 @@ namespace sw::mark
     }
 
 
-    CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM)
+    CheckboxFieldmark::CheckboxFieldmark(const SwPaM& rPaM, const OUString& 
rName)
         : NonTextFieldmark(rPaM)
-    { }
+    {
+        if (!rName.isEmpty())
+            m_aName = rName;
+    }
 
     void CheckboxFieldmark::SetChecked(bool checked)
     {
@@ -662,9 +665,11 @@ namespace sw::mark
             m_pButton.disposeAndClear();
     }
 
-    DropDownFieldmark::DropDownFieldmark(const SwPaM& rPaM)
+    DropDownFieldmark::DropDownFieldmark(const SwPaM& rPaM, const OUString& 
rName)
         : FieldmarkWithDropDownButton(rPaM)
     {
+        if (!rName.isEmpty())
+            m_aName = rName;
     }
 
     DropDownFieldmark::~DropDownFieldmark()
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 0b8f5a39d158..bc9884c2829e 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -621,10 +621,10 @@ namespace sw::mark
                 pMark = std::make_unique<TextFieldmark>(rPaM, rName);
                 break;
             case IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK:
-                pMark = std::make_unique<CheckboxFieldmark>(rPaM);
+                pMark = std::make_unique<CheckboxFieldmark>(rPaM, rName);
                 break;
             case IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK:
-                pMark = std::make_unique<DropDownFieldmark>(rPaM);
+                pMark = std::make_unique<DropDownFieldmark>(rPaM, rName);
                 break;
             case IDocumentMarkAccess::MarkType::DATE_FIELDMARK:
                 pMark = std::make_unique<DateFieldmark>(rPaM);
diff --git a/sw/source/core/inc/bookmark.hxx b/sw/source/core/inc/bookmark.hxx
index ed7d5ad82180..39afc6e70271 100644
--- a/sw/source/core/inc/bookmark.hxx
+++ b/sw/source/core/inc/bookmark.hxx
@@ -259,7 +259,7 @@ namespace sw::mark {
             , public NonTextFieldmark
         {
         public:
-            CheckboxFieldmark(const SwPaM& rPaM);
+            CheckboxFieldmark(const SwPaM& rPaM, const OUString& rName);
             bool IsChecked() const override;
             void SetChecked(bool checked) override;
         };
@@ -284,7 +284,7 @@ namespace sw::mark {
             : public FieldmarkWithDropDownButton
         {
         public:
-            DropDownFieldmark(const SwPaM& rPaM);
+            DropDownFieldmark(const SwPaM& rPaM, const OUString& rName);
             virtual ~DropDownFieldmark() override;
 
             virtual void ShowButton(SwEditWin* pEditWin) override;

Reply via email to