summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2011-10-26 09:57:13 +0300
committerTor Lillqvist <tlillqvist@suse.com>2011-10-26 10:10:42 +0300
commit8c1c09dced2182701576b5dc2c9d309b1c780cb5 (patch)
tree1a40c87498a6080a7d8334f35ac4fefeacd6b8d7
parent2175576c120806f8415be7ab2051ba639a18f564 (diff)
WaE: reinterpret_cast used between related classes
MSVC warning C4946: reinterpret_cast used between related classes: 'sw::mark::IMark' and 'sw::mark::ICheckboxFieldmark'. This time changing the reinterpret_cast to static_cast didn't work, that caused compilation errors: cannot convert a 'sw::mark::IMark*' to a 'sw::mark::ICheckboxFieldmark*'; conversion from a virtual base class is implied 'const_cast' : cannot convert from 'const sw::mark::IMark *' to 'sw::mark::ICheckboxFieldmark *' Conversion from pointer to base class to pointer to derived class requires an explicit cast (other than const_cast) dynamic_cast is what we want here. Also added an OSL_ASSERT sanity check. Thanks to sberg and hub for discussing this on IRC.
-rw-r--r--sw/source/core/unocore/unobkm.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index aa92efdcf232..45b22f708ec9 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -685,8 +685,11 @@ SwXFieldmark::getCheckboxFieldmark()
{
::sw::mark::ICheckboxFieldmark* pCheckboxFm = NULL;
if ( getFieldType() == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(ODF_FORMCHECKBOX) ) )
+ {
// evil #TODO #FIXME casting away the const-ness
- pCheckboxFm = const_cast<sw::mark::ICheckboxFieldmark*>(reinterpret_cast< const ::sw::mark::ICheckboxFieldmark* >( GetBookmark()));
+ pCheckboxFm = const_cast<sw::mark::ICheckboxFieldmark*>(dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( GetBookmark()));
+ OSL_ASSERT( GetBookmark() == 0 || pCheckboxFm != 0 );
+ }
return pCheckboxFm;
}