From 75b2f6b241046d4467a7c0c9cbf49b4533b46045 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 28 Feb 2013 13:27:57 +0100 Subject: [PATCH] sw: remove CH_TXT_ATR_FORMELEMENT when CheckboxFieldmark is deleted Change-Id: I5f58b558b15f7d11b75554195e10a258d027bcfc --- sw/source/core/crsr/bookmrk.cxx | 7 +++++++ sw/source/core/doc/docbm.cxx | 20 +++++++------------- sw/source/core/inc/bookmrk.hxx | 5 ++++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 0cb1562a1770..c9e572e4e2b3 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -357,6 +357,13 @@ namespace sw { namespace mark // want this for checkboxes this->GetMarkEnd( ).nContent--; } + + void CheckboxFieldmark::ReleaseDoc(SwDoc* const pDoc) + { + lcl_RemoveFieldMarks(this, pDoc, + CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FORMELEMENT); + } + void CheckboxFieldmark::SetChecked(bool checked) { if ( IsChecked() != checked ) diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 4d06724e25d0..93c212d7b793 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -670,18 +670,17 @@ namespace sw { namespace mark #endif } - struct LazyTextFieldmarkDeleter : public IDocumentMarkAccess::ILazyDeleter + struct LazyFieldmarkDeleter : public IDocumentMarkAccess::ILazyDeleter { - ::boost::shared_ptr const m_pTextFieldmark; + ::boost::shared_ptr const m_pFieldmark; SwDoc *const m_pDoc; - LazyTextFieldmarkDeleter( + LazyFieldmarkDeleter( ::boost::shared_ptr const& pMark, SwDoc *const pDoc) - : m_pTextFieldmark(pMark), m_pDoc(pDoc) + : m_pFieldmark(pMark), m_pDoc(pDoc) { } - virtual ~LazyTextFieldmarkDeleter() + virtual ~LazyFieldmarkDeleter() { - dynamic_cast(m_pTextFieldmark.get()) - ->ReleaseDoc(m_pDoc); + dynamic_cast(m_pFieldmark.get())->ReleaseDoc(m_pDoc); } }; @@ -713,12 +712,7 @@ namespace sw { namespace mark "" " - Bookmark not found."); m_vFieldmarks.erase(ppFieldmark); - sw::mark::TextFieldmark* pTextFieldmark = dynamic_cast(ppMark->get()); - if (pTextFieldmark) - { - ret.reset( - new LazyTextFieldmarkDeleter(*ppMark, m_pDoc)); - } + ret.reset(new LazyFieldmarkDeleter(*ppMark, m_pDoc)); break; } case IDocumentMarkAccess::NAVIGATOR_REMINDER: diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index bab92bb31c7a..54dc9722d1ec 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -213,6 +213,8 @@ namespace sw { virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext) { m_aFieldHelptext = aFieldHelptext; } + virtual void ReleaseDoc(SwDoc* const) = 0; + virtual void Invalidate(); virtual rtl::OUString ToString() const; @@ -228,7 +230,7 @@ namespace sw { public: TextFieldmark(const SwPaM& rPaM); virtual void InitDoc(SwDoc* const io_pDoc); - void ReleaseDoc(SwDoc* const pDoc); + virtual void ReleaseDoc(SwDoc* const pDoc); }; class CheckboxFieldmark @@ -238,6 +240,7 @@ namespace sw { public: CheckboxFieldmark(const SwPaM& rPaM); virtual void InitDoc(SwDoc* const io_pDoc); + virtual void ReleaseDoc(SwDoc* const pDoc); bool IsChecked() const; void SetChecked(bool checked);