sw/source/core/inc/unobookmark.hxx |    2 +-
 sw/source/core/unocore/unobkm.cxx  |   11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 2ec58f883bd4d7fe0ac1b716d1abc05cb2b16b4e
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri Oct 11 22:28:58 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Oct 12 08:18:03 2019 +0200

    Modify GetBookmark to get rid of const_cast (sw)
    
    Change-Id: Ib3c1d651b2bbfea807f02262b02bae6ecb6e3a58
    Reviewed-on: https://gerrit.libreoffice.org/80697
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/inc/unobookmark.hxx 
b/sw/source/core/inc/unobookmark.hxx
index 5c38402ba17c..20b984742b73 100644
--- a/sw/source/core/inc/unobookmark.hxx
+++ b/sw/source/core/inc/unobookmark.hxx
@@ -66,7 +66,7 @@ protected:
     virtual void attachToRange(
             const css::uno::Reference< css::text::XTextRange > & xTextRange);
 
-    const ::sw::mark::IMark* GetBookmark() const;
+    ::sw::mark::IMark* GetBookmark() const;
 
     IDocumentMarkAccess* GetIDocumentMarkAccess();
 
diff --git a/sw/source/core/unocore/unobkm.cxx 
b/sw/source/core/unocore/unobkm.cxx
index 51d303b43102..f81ca649384f 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -129,7 +129,7 @@ void SwXBookmark::registerInMark(SwXBookmark & rThis,
     m_pImpl->registerInMark( rThis, pBkmk );
 }
 
-const ::sw::mark::IMark* SwXBookmark::GetBookmark() const
+::sw::mark::IMark* SwXBookmark::GetBookmark() const
 {
     return m_pImpl->m_pRegisteredBookmark;
 }
@@ -616,8 +616,7 @@ OUString SwXFieldmark::getFieldType()
 void SwXFieldmark::setFieldType(const OUString & fieldType)
 {
     SolarMutexGuard aGuard;
-    IFieldmark *pBkm = const_cast<IFieldmark*>(
-        dynamic_cast<const IFieldmark*>(GetBookmark()));
+    IFieldmark *pBkm = dynamic_cast<IFieldmark*>(GetBookmark());
     if(!pBkm)
         throw uno::RuntimeException();
     if(fieldType != getFieldType())
@@ -640,8 +639,7 @@ void SwXFieldmark::setFieldType(const OUString & fieldType)
 uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
 {
     SolarMutexGuard aGuard;
-    IFieldmark *pBkm = const_cast<IFieldmark*>(
-        dynamic_cast<const IFieldmark*>(GetBookmark()));
+    IFieldmark *pBkm = dynamic_cast<IFieldmark*>(GetBookmark());
     if(!pBkm)
         throw uno::RuntimeException();
     return uno::Reference<container::XNameContainer>(new 
SwXFieldmarkParameters(pBkm));
@@ -687,8 +685,7 @@ SwXFieldmark::getCheckboxFieldmark()
     ::sw::mark::ICheckboxFieldmark* pCheckboxFm = nullptr;
     if ( getFieldType() == ODF_FORMCHECKBOX )
     {
-        // evil #TODO #FIXME casting away the const-ness
-        pCheckboxFm = const_cast<sw::mark::ICheckboxFieldmark*>(dynamic_cast< 
const ::sw::mark::ICheckboxFieldmark* >( GetBookmark()));
+        pCheckboxFm = dynamic_cast< ::sw::mark::ICheckboxFieldmark* >( 
GetBookmark());
         assert( GetBookmark() == nullptr || pCheckboxFm != nullptr );
             // unclear to me whether GetBookmark() can be null here
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to