diff options
author | Justin Luth <justin.luth@collabora.com> | 2022-10-15 14:54:11 -0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-18 11:37:26 +0200 |
commit | 8ad39b6f2aff3ca37aeaaaaff5373991e853c329 (patch) | |
tree | eb19ee42802af88e7e2b2f8e916735ff973d05c2 /sw | |
parent | 2aacaa2231298e8a38d5964a13b285f7c5a3d8be (diff) |
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.
Change-Id: Ide49d6efb8391fea17e7a61c9e99b30532bb2014
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141423
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/bookmark.cxx | 11 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/inc/bookmark.hxx | 4 |
3 files changed, 12 insertions, 7 deletions
diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx index 95b545102bc1..0d61d684914c 100644 --- a/sw/source/core/crsr/bookmark.cxx +++ b/sw/source/core/crsr/bookmark.cxx @@ -617,9 +617,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) { @@ -658,9 +661,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 c19d182c3f7a..65b9de1ebc13 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -619,10 +619,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 bf2e98488f3e..bc77ccd8ab91 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; |