diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2019-10-11 22:28:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-12 08:18:03 +0200 |
commit | 2ec58f883bd4d7fe0ac1b716d1abc05cb2b16b4e (patch) | |
tree | 3cb1d191f8bfab328b5b415040a83b42aa30f6c6 | |
parent | 1969094db0ebf3c6c296d5bc01184be9476c8c6c (diff) |
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.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/inc/unobookmark.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unobkm.cxx | 11 |
2 files changed, 5 insertions, 8 deletions
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 } |