forms/source/richtext/rtattributehandler.cxx                       |    8 
++++----
 oox/source/export/shapes.cxx                                       |    2 +-
 sc/source/core/data/table5.cxx                                     |    2 +-
 sc/source/ui/app/scmod.cxx                                         |    2 +-
 sc/source/ui/view/auditsh.cxx                                      |    2 +-
 sc/source/ui/view/cellsh3.cxx                                      |    2 +-
 sc/source/ui/view/tabvwshe.cxx                                     |    4 ++--
 sfx2/source/appl/appserv.cxx                                       |    2 +-
 svx/source/stbctrls/zoomsliderctrl.cxx                             |    2 +-
 sw/source/core/doc/doctxm.cxx                                      |    9 
++++-----
 sw/source/core/docnode/ndsect.cxx                                  |    2 +-
 sw/source/core/edit/edglbldc.cxx                                   |    2 +-
 sw/source/core/edit/edtox.cxx                                      |    6 
+++---
 sw/source/core/layout/fly.cxx                                      |    2 +-
 sw/source/core/layout/trvlfrm.cxx                                  |    2 +-
 sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx  |    6 
+++---
 sw/source/core/objectpositioning/environmentofanchoredobject.cxx   |    4 ++--
 sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx |    2 +-
 sw/source/core/txtnode/fmtatr2.cxx                                 |    3 +--
 sw/source/core/txtnode/ndtxt.cxx                                   |    3 +--
 sw/source/core/unocore/unorefmk.cxx                                |    3 +--
 sw/source/core/view/vprint.cxx                                     |    2 +-
 sw/source/uibase/app/docsh2.cxx                                    |    5 ++---
 sw/source/uibase/docvw/PostItMgr.cxx                               |    2 +-
 sw/source/uibase/uiview/srcview.cxx                                |    4 ++--
 sw/source/uibase/utlui/viewlayoutctrl.cxx                          |    2 +-
 26 files changed, 40 insertions(+), 45 deletions(-)

New commits:
commit e11386053d3c404fbeab8b66402d68f813f7dd58
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Sep 8 15:01:33 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 8 22:17:05 2021 +0200

    convert some OSL_ENSURE -> assert
    
    where we are just provide checking for a following static_cast.
    
    I'd rather have an explicit assert failure than a random crash
    
    Change-Id: Iab6c6b056341018deaa74b78b075e564f72c58d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121814
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/forms/source/richtext/rtattributehandler.cxx 
b/forms/source/richtext/rtattributehandler.cxx
index 804d6bb2d42d..653d42e46a5f 100644
--- a/forms/source/richtext/rtattributehandler.cxx
+++ b/forms/source/richtext/rtattributehandler.cxx
@@ -183,7 +183,7 @@ namespace frm
 
     AttributeCheckState ParaAlignmentHandler::implGetCheckState( const 
SfxPoolItem& _rItem ) const
     {
-        OSL_ENSURE( dynamic_cast<const SvxAdjustItem*>( &_rItem) !=  nullptr, 
"ParaAlignmentHandler::implGetCheckState: invalid pool item!" );
+        assert( dynamic_cast<const SvxAdjustItem*>( &_rItem) && 
"ParaAlignmentHandler::implGetCheckState: invalid pool item!" );
         SvxAdjust eAdjust = static_cast< const SvxAdjustItem& >( _rItem 
).GetAdjust();
         return ( eAdjust == m_eAdjust ) ? eChecked : eUnchecked;
     }
@@ -213,7 +213,7 @@ namespace frm
 
     AttributeCheckState LineSpacingHandler::implGetCheckState( const 
SfxPoolItem& _rItem ) const
     {
-        OSL_ENSURE( dynamic_cast<const SvxLineSpacingItem*>( &_rItem) !=  
nullptr, "LineSpacingHandler::implGetCheckState: invalid pool item!" );
+        assert( dynamic_cast<const SvxLineSpacingItem*>( &_rItem) && 
"LineSpacingHandler::implGetCheckState: invalid pool item!" );
         sal_uInt16 nLineSpace = static_cast< const SvxLineSpacingItem& >( 
_rItem ).GetPropLineSpace();
         return ( nLineSpace == m_nLineSpace ) ? eChecked : eUnchecked;
     }
@@ -250,7 +250,7 @@ namespace frm
 
     AttributeCheckState EscapementHandler::implGetCheckState( const 
SfxPoolItem& _rItem ) const
     {
-        OSL_ENSURE( dynamic_cast<const SvxEscapementItem*>( &_rItem) !=  
nullptr, "EscapementHandler::getState: invalid pool item!" );
+        assert( dynamic_cast<const SvxEscapementItem*>( &_rItem) && 
"EscapementHandler::getState: invalid pool item!" );
         SvxEscapement eEscapement = static_cast< const SvxEscapementItem& >( 
_rItem ).GetEscapement();
         return ( eEscapement == m_eEscapement ) ? eChecked : eUnchecked;
     }
@@ -389,7 +389,7 @@ namespace frm
 
     AttributeCheckState ParagraphDirectionHandler::implGetCheckState( const 
SfxPoolItem& _rItem ) const
     {
-        OSL_ENSURE( dynamic_cast<const SvxFrameDirectionItem*>( &_rItem) !=  
nullptr, "ParagraphDirectionHandler::implGetCheckState: invalid pool item!" );
+        assert( dynamic_cast<const SvxFrameDirectionItem*>( &_rItem) && 
"ParagraphDirectionHandler::implGetCheckState: invalid pool item!" );
         SvxFrameDirection eDirection = static_cast< const 
SvxFrameDirectionItem& >( _rItem ).GetValue();
         return ( eDirection == m_eParagraphDirection ) ? eChecked : eUnchecked;
     }
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index c7c47aa00059..5fc037029456 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -731,7 +731,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
 
     ShapeFlag nMirrorFlags = ShapeFlag::NONE;
     MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, 
nMirrorFlags, sShapeType );
-    OSL_ENSURE(nullptr != dynamic_cast< SdrObjCustomShape* 
>(SdrObject::getSdrObjectFromXShape(xShape)), "Not a SdrObjCustomShape (!)");
+    assert(dynamic_cast< SdrObjCustomShape* 
>(SdrObject::getSdrObjectFromXShape(xShape)) && "Not a SdrObjCustomShape (!)");
     SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& 
>(*SdrObject::getSdrObjectFromXShape(xShape)));
     const bool bIsDefaultObject(
         EscherPropertyContainer::IsDefaultObject(
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index 7af84bcd58dc..244ba04d53aa 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -126,7 +126,7 @@ void ScTable::UpdatePageBreaks(const ScRange* pUserArea)
     {
         if (pStyleSet->GetItemState(ATTR_PAGE_SCALETOPAGES, false, &pItem) == 
SfxItemState::SET)
         {
-            OSL_ENSURE(dynamic_cast<const SfxUInt16Item*>(pItem) != nullptr, 
"invalid Item");
+            assert(dynamic_cast<const SfxUInt16Item*>(pItem) && "invalid 
Item");
             bSkipColBreaks = bSkipRowBreaks
                 = static_cast<const SfxUInt16Item*>(pItem)->GetValue() > 0;
         }
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index fe7bf3b2bce9..b6917c58e9a9 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -420,7 +420,7 @@ void ScModule::Execute( SfxRequest& rReq )
             if (pReqArgs)
             {
                 auto const & p = pReqArgs->Get(SID_PSZ_FUNCTION);
-                OSL_ENSURE(dynamic_cast<const SfxUInt32Item*>(&p) !=  
nullptr,"wrong Parameter");
+                assert(dynamic_cast<const SfxUInt32Item*>(&p) && "wrong 
Parameter");
                 const SfxUInt32Item& rItem = static_cast<const 
SfxUInt32Item&>(p);
 
                 ScAppOptions aNewOpts( GetAppOptions() );
diff --git a/sc/source/ui/view/auditsh.cxx b/sc/source/ui/view/auditsh.cxx
index 42f01761bd25..a76267071bd5 100644
--- a/sc/source/ui/view/auditsh.cxx
+++ b/sc/source/ui/view/auditsh.cxx
@@ -91,7 +91,7 @@ void ScAuditingShell::Execute( const SfxRequest& rReq )
                     if ( pReqArgs->GetItemState( SID_RANGE_COL, true, &pXItem 
) == SfxItemState::SET
                       && pReqArgs->GetItemState( SID_RANGE_ROW, true, &pYItem 
) == SfxItemState::SET )
                     {
-                        OSL_ENSURE( dynamic_cast<const SfxInt16Item*>( pXItem) 
!= nullptr && dynamic_cast<const SfxInt32Item*>( pYItem) !=  nullptr,
+                        assert( dynamic_cast<const SfxInt16Item*>( pXItem) && 
dynamic_cast<const SfxInt32Item*>( pYItem) &&
                                         "wrong items" );
                         SCCOL nCol = static_cast<SCCOL>(static_cast<const 
SfxInt16Item*>(pXItem)->GetValue());
                         SCROW nRow = static_cast<SCROW>(static_cast<const 
SfxInt32Item*>(pYItem)->GetValue());
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 088c403168d6..960f8aa03381 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -908,7 +908,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
                     if ( pReqArgs &&
                         pReqArgs->GetItemState(nSlot, true, &pItem) == 
SfxItemState::SET )
                     {
-                        OSL_ENSURE(dynamic_cast<const SfxBoolItem*>( pItem), 
"wrong item");
+                        assert(dynamic_cast<const SfxBoolItem*>( pItem) && 
"wrong item");
                         bMoveContents = static_cast<const 
SfxBoolItem*>(pItem)->GetValue();
                     }
 
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index 418aa6e5da0d..ab3f0c2f18eb 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -261,7 +261,7 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
                 if ( pReqArgs &&
                      SfxItemState::SET == 
pReqArgs->GetItemState(SID_SEARCH_ITEM, false, &pItem) )
                 {
-                    OSL_ENSURE( dynamic_cast<const SvxSearchItem*>( pItem) !=  
nullptr, "wrong Item" );
+                    assert( dynamic_cast<const SvxSearchItem*>( pItem) && 
"wrong Item" );
                     const SvxSearchItem* pSearchItem = static_cast<const 
SvxSearchItem*>(pItem);
 
                     ScGlobal::SetSearchItem( *pSearchItem );
@@ -276,7 +276,7 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
                             pReqArgs->GetItemState(SID_SEARCH_ITEM, false, 
&pItem))
             {
                 // remember search item
-                OSL_ENSURE( dynamic_cast<const SvxSearchItem*>( pItem) !=  
nullptr, "wrong Item" );
+                assert( dynamic_cast<const SvxSearchItem*>( pItem) && "wrong 
Item" );
                 ScGlobal::SetSearchItem( *static_cast<const 
SvxSearchItem*>(pItem ));
             }
             else
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index d2db452e0815..c9bf73bd4394 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -245,7 +245,7 @@ namespace
         Reference <XFrame> xFrame;
         if (pArgs && pArgs->GetItemState(SID_FILLFRAME, false, &pItem) == 
SfxItemState::SET)
         {
-            OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) !=  
nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via 
SfxUnoFrameItem by now!" );
+            assert( dynamic_cast< const SfxUnoFrameItem *>( pItem ) && 
"SfxApplication::OfaExec_Impl: XFrames are to be transported via 
SfxUnoFrameItem by now!" );
             xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
         }
         return xFrame;
diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx 
b/svx/source/stbctrls/zoomsliderctrl.cxx
index d48b9ab8bd10..f85bb58a2ed5 100644
--- a/svx/source/stbctrls/zoomsliderctrl.cxx
+++ b/svx/source/stbctrls/zoomsliderctrl.cxx
@@ -167,7 +167,7 @@ void SvxZoomSliderControl::StateChangedAtStatusBarControl( 
sal_uInt16 /*nSID*/,
     }
     else
     {
-        OSL_ENSURE( dynamic_cast<const SvxZoomSliderItem*>( pState) !=  
nullptr, "invalid item type: should be a SvxZoomSliderItem" );
+        assert( dynamic_cast<const SvxZoomSliderItem*>( pState) && "invalid 
item type: should be a SvxZoomSliderItem" );
         mxImpl->mnCurrentZoom = static_cast<const SvxZoomSliderItem*>( pState 
)->GetValue();
         mxImpl->mnMinZoom     = static_cast<const SvxZoomSliderItem*>( pState 
)->GetMinZoom();
         mxImpl->mnMaxZoom     = static_cast<const SvxZoomSliderItem*>( pState 
)->GetMaxZoom();
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index a8916a113a05..ad9271d9ad28 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -453,7 +453,7 @@ SwTOXBase* SwDoc::GetCurTOX( const SwPosition& rPos )
         SectionType eT = pSectNd->GetSection().GetType();
         if( SectionType::ToxContent == eT )
         {
-            OSL_ENSURE( dynamic_cast< const SwTOXBaseSection *>( 
&pSectNd->GetSection()) !=  nullptr,
+            assert( dynamic_cast< const SwTOXBaseSection *>( 
&pSectNd->GetSection()) &&
                     "no TOXBaseSection!" );
             SwTOXBaseSection& rTOXSect = static_cast<SwTOXBaseSection&>(
                                                 pSectNd->GetSection());
@@ -466,7 +466,7 @@ SwTOXBase* SwDoc::GetCurTOX( const SwPosition& rPos )
 
 const SwAttrSet& SwDoc::GetTOXBaseAttrSet(const SwTOXBase& rTOXBase)
 {
-    OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) !=  nullptr, 
"no TOXBaseSection!" );
+    assert( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) && "no 
TOXBaseSection!" );
     const SwTOXBaseSection& rTOXSect = static_cast<const 
SwTOXBaseSection&>(rTOXBase);
     SwSectionFormat const * pFormat = rTOXSect.GetFormat();
     OSL_ENSURE( pFormat, "invalid TOXBaseSection!" );
@@ -524,7 +524,7 @@ bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool 
bDelNodes )
 {
     // We only delete the TOX, not the Nodes
     bool bRet = false;
-    OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) !=  nullptr, 
"no TOXBaseSection!" );
+    assert( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) && "no 
TOXBaseSection!" );
 
     const SwTOXBaseSection& rTOXSect = static_cast<const 
SwTOXBaseSection&>(rTOXBase);
     SwSectionFormat const * pFormat = rTOXSect.GetFormat();
@@ -703,8 +703,7 @@ OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& 
rType,
 
 bool SwDoc::SetTOXBaseName(const SwTOXBase& rTOXBase, const OUString& rName)
 {
-    OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) !=  nullptr,
-                    "no TOXBaseSection!" );
+    assert( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) && "no 
TOXBaseSection!" );
     SwTOXBaseSection* pTOX = const_cast<SwTOXBaseSection*>(static_cast<const 
SwTOXBaseSection*>(&rTOXBase));
 
     if (GetUniqueTOXBaseName(*rTOXBase.GetTOXType(), rName) == rName)
diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index d5c9db008116..5c28a2c82365 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -1233,7 +1233,7 @@ SwSectionNode* SwSectionNode::MakeCopy( SwDoc& rDoc, 
const SwNodeIndex& rIdx ) c
     std::unique_ptr<SwTOXBase> pTOXBase;
     if (SectionType::ToxContent == GetSection().GetType())
     {
-        OSL_ENSURE( dynamic_cast< const SwTOXBaseSection* >( &GetSection() ) 
!=  nullptr , "no TOXBaseSection!" );
+        assert( dynamic_cast< const SwTOXBaseSection* >( &GetSection() ) && 
"no TOXBaseSection!" );
         SwTOXBaseSection const& rTBS(
             dynamic_cast<SwTOXBaseSection const&>(GetSection()));
         pTOXBase.reset( new SwTOXBase(rTBS, &rDoc) );
diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx
index 7c30b156db0c..ece88ce9d74a 100644
--- a/sw/source/core/edit/edglbldc.cxx
+++ b/sw/source/core/edit/edglbldc.cxx
@@ -73,7 +73,7 @@ void SwEditShell::GetGlobalDocContent( SwGlblDocContents& 
rArr ) const
             case SectionType::ToxHeader:
                 break;      // ignore
             case SectionType::ToxContent:
-                OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( pSect) !=  
nullptr, "no TOXBaseSection!" );
+                assert( dynamic_cast<const SwTOXBaseSection*>( pSect) && "no 
TOXBaseSection!" );
                 pNew.reset(new SwGlblDocContent( static_cast<const 
SwTOXBaseSection*>(pSect) ));
                 break;
 
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index ebd201fd7efb..c10f36671cd4 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -91,14 +91,14 @@ void SwEditShell::GetCurTOXMarks(SwTOXMarks& rMarks) const
 
 bool SwEditShell::IsTOXBaseReadonly(const SwTOXBase& rTOXBase)
 {
-    OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) !=  nullptr, 
"no TOXBaseSection!" );
+    assert( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) && "no 
TOXBaseSection!" );
     const SwTOXBaseSection& rTOXSect = static_cast<const 
SwTOXBaseSection&>(rTOXBase);
     return  rTOXSect.IsProtect();
 }
 
 void SwEditShell::SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly)
 {
-    OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) !=  nullptr, 
"no TOXBaseSection!" );
+    assert( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) && "no 
TOXBaseSection!" );
     const SwTOXBaseSection& rTOXSect = static_cast<const 
SwTOXBaseSection&>(rTOXBase);
     const_cast<SwTOXBase&>(rTOXBase).SetProtected(bReadonly);
     OSL_ENSURE( rTOXSect.SwSection::GetType() == SectionType::ToxContent, "not 
a TOXContentSection" );
@@ -237,7 +237,7 @@ const SwTOXBase* SwEditShell::GetTOX( sal_uInt16 nPos ) 
const
             pSect->GetFormat()->GetSectionNode() &&
             nCnt++ == nPos )
         {
-            OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( pSect) !=  
nullptr, "no TOXBaseSection!" );
+            assert( dynamic_cast<const SwTOXBaseSection*>( pSect) && "no 
TOXBaseSection!" );
             return static_cast<const SwTOXBaseSection*>(pSect);
         }
     }
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 4f82c8e3b8af..ffe664b42898 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -2456,7 +2456,7 @@ void SwLayoutFrame::NotifyLowerObjs( const bool 
_bUnlockPosOfObjs )
         }
         else
         {
-            OSL_ENSURE( dynamic_cast<const SwAnchoredDrawObject*>( pObj) !=  
nullptr,
+            assert( dynamic_cast<const SwAnchoredDrawObject*>( pObj) &&
                     "<SwLayoutFrame::NotifyFlys() - anchored object of 
unexpected type" );
             // #i26945# - use <pAnchorFrame> to check, if
             // fly frame is lower of layout frame resp. if fly frame is
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index 377713b98178..d8eee05dc383 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -2595,7 +2595,7 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor)
                     const sal_uInt32 nPos = pObj->GetOrdNum();
                     for ( size_t k = 0; bSub && k < aSortObjs.size(); ++k )
                     {
-                        OSL_ENSURE( dynamic_cast< const SwFlyFrame *>( 
aSortObjs[k] ) !=  nullptr,
+                        assert( dynamic_cast< const SwFlyFrame *>( 
aSortObjs[k] ) &&
                             "<SwRootFrame::CalcFrameRects(..)> - object in 
<aSortObjs> of unexpected type" );
                         const SwFlyFrame* pTmp = 
static_cast<SwFlyFrame*>(aSortObjs[k]);
                         do
diff --git a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
index 012b575e6850..b78cadaf1549 100644
--- a/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/ascharanchoredobjectposition.cxx
@@ -61,7 +61,7 @@ 
SwAsCharAnchoredObjectPosition::~SwAsCharAnchoredObjectPosition()
 /** method to cast <SwAnchoredObjectPosition::GetAnchorFrame()> to needed type 
*/
 const SwTextFrame& SwAsCharAnchoredObjectPosition::GetAnchorTextFrame() const
 {
-    OSL_ENSURE( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame() ) !=  
nullptr,
+    assert( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame() ) &&
             "SwAsCharAnchoredObjectPosition::GetAnchorTextFrame() - wrong 
anchor frame type" );
 
     return static_cast<const SwTextFrame&>(GetAnchorFrame());
@@ -264,7 +264,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
             rAnchorFrame.SwitchHorizontalToVertical( aAnchorPos );
 
         // #i44347# - keep last object rectangle at anchored object
-        OSL_ENSURE( dynamic_cast<const SwAnchoredDrawObject*>( 
&GetAnchoredObj() ) !=  nullptr,
+        assert( dynamic_cast<const SwAnchoredDrawObject*>( &GetAnchoredObj() ) 
&&
                  "<SwAsCharAnchoredObjectPosition::CalcPosition()> - wrong 
type of anchored object." );
         SwAnchoredDrawObject& rAnchoredDrawObj =
                         static_cast<SwAnchoredDrawObject&>( GetAnchoredObj() );
@@ -291,7 +291,7 @@ void SwAsCharAnchoredObjectPosition::CalcPosition()
             aRelAttr = Point( 0, nRelPos );
 
         // OD 2004-03-23 #i26791#
-        OSL_ENSURE( dynamic_cast<const SwFlyInContentFrame*>( 
&GetAnchoredObj()) !=  nullptr,
+        assert( dynamic_cast<const SwFlyInContentFrame*>( &GetAnchoredObj()) &&
                 "<SwAsCharAnchoredObjectPosition::CalcPosition()> - wrong 
anchored object." );
         const SwFlyInContentFrame& rFlyInContentFrame =
                 static_cast<const SwFlyInContentFrame&>(GetAnchoredObj());
diff --git a/sw/source/core/objectpositioning/environmentofanchoredobject.cxx 
b/sw/source/core/objectpositioning/environmentofanchoredobject.cxx
index 8d197f464f02..79cb7b14eef3 100644
--- a/sw/source/core/objectpositioning/environmentofanchoredobject.cxx
+++ b/sw/source/core/objectpositioning/environmentofanchoredobject.cxx
@@ -56,7 +56,7 @@ const SwLayoutFrame& 
SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFram
         }
     }
 
-    OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame 
) !=  nullptr,
+    assert( dynamic_cast< const SwLayoutFrame *>( pHoriEnvironmentLayFrame ) &&
                 
"SwEnvironmentOfAnchoredObject::GetHoriEnvironmentLayoutFrame(..) - found frame 
isn't a layout frame" );
 
     return static_cast<const SwLayoutFrame&>(*pHoriEnvironmentLayFrame);
@@ -90,7 +90,7 @@ const SwLayoutFrame& 
SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFram
         }
     }
 
-    OSL_ENSURE( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame 
) !=  nullptr,
+    assert( dynamic_cast< const SwLayoutFrame *>( pVertEnvironmentLayFrame ) &&
                 
"SwEnvironmentOfAnchoredObject::GetVertEnvironmentLayoutFrame(..) - found frame 
isn't a layout frame" );
 
     return static_cast<const SwLayoutFrame&>(*pVertEnvironmentLayFrame);
diff --git a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx 
b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
index 08c768a88706..d6d17459fc2b 100644
--- a/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
+++ b/sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx
@@ -81,7 +81,7 @@ SwTwips SwToContentAnchoredObjectPosition::ToCharTopOfLine() 
const
 
 SwTextFrame& SwToContentAnchoredObjectPosition::GetAnchorTextFrame() const
 {
-    OSL_ENSURE( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame()) != 
nullptr ,
+    assert( dynamic_cast<const SwTextFrame*>( &GetAnchorFrame()) &&
             "SwToContentAnchoredObjectPosition::GetAnchorTextFrame() - wrong 
anchor frame type" );
 
     return static_cast<SwTextFrame&>(GetAnchorFrame());
diff --git a/sw/source/core/txtnode/fmtatr2.cxx 
b/sw/source/core/txtnode/fmtatr2.cxx
index 3ba9385f8ac4..67a55e28c9b5 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -737,8 +737,7 @@ void MetaField::GetPrefixAndSuffix(
     try
     {
         const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() );
-        OSL_ENSURE(dynamic_cast<SwXMetaField*>(xMetaField.get()),
-                "GetPrefixAndSuffix: no SwXMetaField?");
+        assert(dynamic_cast<SwXMetaField*>(xMetaField.get()) && 
"GetPrefixAndSuffix: no SwXMetaField?");
         if (xMetaField.is())
         {
             SwTextNode * const pTextNode( GetTextNode() );
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index b865687367e9..daa016423bb6 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3915,8 +3915,7 @@ namespace {
 SwFormatColl* SwTextNode::ChgFormatColl( SwFormatColl *pNewColl )
 {
     OSL_ENSURE( pNewColl,"ChgFormatColl: Collectionpointer has value 0." );
-    OSL_ENSURE( dynamic_cast<const SwTextFormatColl *>(pNewColl) != nullptr,
-                "ChgFormatColl: is not a Text Collection pointer." );
+    assert( dynamic_cast<const SwTextFormatColl *>(pNewColl) && 
"ChgFormatColl: is not a Text Collection pointer." );
 
     SwTextFormatColl *pOldColl = GetTextColl();
     if( pNewColl != pOldColl )
diff --git a/sw/source/core/unocore/unorefmk.cxx 
b/sw/source/core/unocore/unorefmk.cxx
index 3156ef10ed35..625a991a074a 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -1246,8 +1246,7 @@ SwXMetaField::SwXMetaField(SwDoc *const pDoc, ::sw::Meta 
*const pMeta,
         std::unique_ptr<TextRangeList_t const> pPortions)
     : SwXMetaField_Base(pDoc, pMeta, xParentText, std::move(pPortions))
 {
-    OSL_ENSURE(dynamic_cast< ::sw::MetaField* >(pMeta),
-        "SwXMetaField created for wrong hint!");
+    assert(dynamic_cast< ::sw::MetaField* >(pMeta) && "SwXMetaField created 
for wrong hint!");
 }
 
 SwXMetaField::SwXMetaField(SwDoc *const pDoc)
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 768ad00c8cd8..931928803722 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -304,7 +304,7 @@ void SwViewShell::CalcPagesForPrint( sal_uInt16 nMax )
 
 void SwViewShell::FillPrtDoc( SwDoc& rPrtDoc, const SfxPrinter* pPrt)
 {
-    OSL_ENSURE( dynamic_cast<const SwFEShell*>( this) !=  
nullptr,"SwViewShell::Prt for FEShell only");
+    assert( dynamic_cast<const SwFEShell*>( this) && "SwViewShell::Prt for 
FEShell only");
     SwFEShell* pFESh = static_cast<SwFEShell*>(this);
     rPrtDoc.getIDocumentFieldsAccess().LockExpFields();
 
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index c581f56b50e7..54ffca724071 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -689,8 +689,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
                     }
                 }
 
-                OSL_ENSURE(dynamic_cast<SwWebDocShell*>(this),
-                            "SourceView only in WebDocShell");
+                assert(dynamic_cast<SwWebDocShell*>(this) && "SourceView only 
in WebDocShell");
 
                 // the SourceView is not the 1 for SwWebDocShell
                 sal_uInt16 nSlot = SID_VIEWSHELL1;
@@ -1156,7 +1155,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
         case SID_ATTR_YEAR2000:
             if ( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich , 
false, &pItem ))
             {
-                OSL_ENSURE(dynamic_cast< const SfxUInt16Item *>( pItem ) !=  
nullptr, "wrong Item");
+                assert(dynamic_cast< const SfxUInt16Item *>( pItem ) && "wrong 
Item");
                 sal_uInt16 nYear2K = static_cast<const 
SfxUInt16Item*>(pItem)->GetValue();
                 // iterate over Views and put the State to FormShells
 
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx 
b/sw/source/uibase/docvw/PostItMgr.cxx
index a60b70b6cbef..1e6a2c801cbc 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -292,7 +292,7 @@ SwSidebarItem* SwPostItMgr::InsertItem(SfxBroadcaster* 
pItem, bool bCheckExisten
         
mvPostItFields.push_back(std::make_unique<SwAnnotationItem>(*pSwFormatField, 
bFocus));
         pAnnotationItem = mvPostItFields.back().get();
     }
-    OSL_ENSURE(dynamic_cast< const SwFormatField *>( pItem ) !=  
nullptr,"Mgr::InsertItem: seems like new stuff was added");
+    assert(dynamic_cast< const SwFormatField *>( pItem ) && "Mgr::InsertItem: 
seems like new stuff was added");
     StartListening(*pItem);
     return pAnnotationItem;
 }
diff --git a/sw/source/uibase/uiview/srcview.cxx 
b/sw/source/uibase/uiview/srcview.cxx
index e7b2059a1ec0..e453f7f43ce5 100644
--- a/sw/source/uibase/uiview/srcview.cxx
+++ b/sw/source/uibase/uiview/srcview.cxx
@@ -201,7 +201,7 @@ SwSrcView::SwSrcView(SfxViewFrame* pViewFrame, 
SfxViewShell*) :
 SwSrcView::~SwSrcView()
 {
     SwDocShell* pDocShell = GetDocShell();
-    OSL_ENSURE(dynamic_cast<SwWebDocShell*>( pDocShell), "Why no WebDocShell?" 
);
+    assert(dynamic_cast<SwWebDocShell*>( pDocShell) && "Why no WebDocShell?" );
     const TextSelection&  rSel = aEditWin->GetTextView()->GetSelection();
     static_cast<SwWebDocShell*>(pDocShell)->SetSourcePara( static_cast< 
sal_uInt16 >( rSel.GetStart().GetPara() ) );
 
@@ -833,7 +833,7 @@ void SwSrcView::Load(SwDocShell* pDocShell)
         pDocShell->SetModified();// The flag will be reset in between times.
     // Disable AutoLoad
     pDocShell->SetAutoLoad(INetURLObject(), 0, false);
-    OSL_ENSURE(dynamic_cast<SwWebDocShell*>( pDocShell), "Why no WebDocShell?" 
);
+    assert(dynamic_cast<SwWebDocShell*>( pDocShell) && "Why no WebDocShell?" );
     sal_uInt16 nLine = static_cast<SwWebDocShell*>(pDocShell)->GetSourcePara();
     aEditWin->SetStartLine(nLine);
     aEditWin->GetTextEngine()->ResetUndo();
diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx 
b/sw/source/uibase/utlui/viewlayoutctrl.cxx
index 22346de6b03b..b2f6ef4bea1c 100644
--- a/sw/source/uibase/utlui/viewlayoutctrl.cxx
+++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx
@@ -65,7 +65,7 @@ void SwViewLayoutControl::StateChangedAtStatusBarControl( 
sal_uInt16 /*nSID*/, S
         GetStatusBar().SetItemText( GetId(), OUString() );
     else
     {
-        OSL_ENSURE( dynamic_cast< const SvxViewLayoutItem *>( pState ) !=  
nullptr, "invalid item type" );
+        assert( dynamic_cast< const SvxViewLayoutItem *>( pState )  && 
"invalid item type" );
         const sal_uInt16 nColumns  = static_cast<const SvxViewLayoutItem*>( 
pState )->GetValue();
         const bool   bBookMode = static_cast<const SvxViewLayoutItem*>( pState 
)->IsBookMode();
 

Reply via email to