[PATCH libreoffice-4-0] sw: remove CH_TXT_ATR_FORMELEMENT when CheckboxFieldmark is ...

Michael Stahl (via Code Review) gerrit at gerrit.libreoffice.org
Thu Feb 28 05:21:49 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2467

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/67/2467/1

sw: remove CH_TXT_ATR_FORMELEMENT when CheckboxFieldmark is deleted

Change-Id: I5f58b558b15f7d11b75554195e10a258d027bcfc
(cherry picked from commit 75b2f6b241046d4467a7c0c9cbf49b4533b46045)
---
M sw/source/core/crsr/bookmrk.cxx
M sw/source/core/doc/docbm.cxx
M sw/source/core/inc/bookmrk.hxx
3 files changed, 18 insertions(+), 14 deletions(-)



diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 7e84482..a3c5217 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -355,6 +355,13 @@
         // 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 afd9fc2..8f785dd 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -670,18 +670,17 @@
 #endif
     }
 
-    struct LazyTextFieldmarkDeleter : public IDocumentMarkAccess::ILazyDeleter
+    struct LazyFieldmarkDeleter : public IDocumentMarkAccess::ILazyDeleter
     {
-        ::boost::shared_ptr<IMark> const m_pTextFieldmark;
+        ::boost::shared_ptr<IMark> const m_pFieldmark;
         SwDoc *const m_pDoc;
-        LazyTextFieldmarkDeleter(
+        LazyFieldmarkDeleter(
                 ::boost::shared_ptr<IMark> const& pMark, SwDoc *const pDoc)
-            : m_pTextFieldmark(pMark), m_pDoc(pDoc)
+            : m_pFieldmark(pMark), m_pDoc(pDoc)
         { }
-        virtual ~LazyTextFieldmarkDeleter()
+        virtual ~LazyFieldmarkDeleter()
         {
-            dynamic_cast<TextFieldmark*>(m_pTextFieldmark.get())
-                ->ReleaseDoc(m_pDoc);
+            dynamic_cast<Fieldmark *>(m_pFieldmark.get())->ReleaseDoc(m_pDoc);
         }
     };
 
@@ -713,12 +712,7 @@
                     "<MarkManager::deleteMark(..)>"
                     " - Bookmark not found.");
                 m_vFieldmarks.erase(ppFieldmark);
-                sw::mark::TextFieldmark* pTextFieldmark = dynamic_cast<sw::mark::TextFieldmark*>(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 6937a19..d4959b2 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -213,6 +213,8 @@
             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 @@
         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 @@
         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);
 

-- 
To view, visit https://gerrit.libreoffice.org/2467
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f58b558b15f7d11b75554195e10a258d027bcfc
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Michael Stahl <mstahl at redhat.com>



More information about the LibreOffice mailing list