summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-04-14 13:58:14 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-04-14 14:14:36 +0200
commit0869895063bd528893707cb74c6cf4c461fef066 (patch)
treebf47ccc71145f3ee387a5dafbaab9bc86b47a008
parent4acae16f9252ada89fd530f1ca86edafc046bc07 (diff)
tdf#120703 PVS: Silence V522 warnings
V522 There might be dereferencing of a potential null pointer. Change-Id: Ie4bc74a734a6d5a73838a27e0d80cc8e51595839 Reviewed-on: https://gerrit.libreoffice.org/70730 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--codemaker/source/codemaker/typemanager.cxx3
-rw-r--r--cui/source/tabpages/tppattern.cxx4
-rw-r--r--dbaccess/source/ext/macromigration/macromigrationpages.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpcelllayout.cxx1
-rw-r--r--lotuswordpro/source/filter/lwpfribsection.cxx4
-rw-r--r--lotuswordpro/source/filter/lwprowlayout.cxx1
-rw-r--r--lotuswordpro/source/filter/lwptablelayout.cxx16
-rw-r--r--oox/source/ole/vbacontrol.cxx2
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx1
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx2
-rw-r--r--sc/source/ui/app/scmod.cxx3
-rw-r--r--sc/source/ui/vba/vbarange.cxx1
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx1
-rw-r--r--sdext/source/pdfimport/tree/writertreevisiting.cxx17
-rw-r--r--sfx2/source/dialog/templdlg.cxx2
-rw-r--r--sfx2/source/doc/Metadatable.cxx1
-rw-r--r--starmath/source/view.cxx7
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx5
-rw-r--r--sw/source/core/attr/swatrset.cxx5
-rw-r--r--sw/source/core/docnode/section.cxx4
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx1
-rw-r--r--sw/source/filter/xml/xmlimp.cxx8
-rw-r--r--sw/source/uibase/uiview/srcview.cxx35
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx3
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx1
-rw-r--r--vcl/source/gdi/print2.cxx2
-rw-r--r--vcl/source/graphic/UnoGraphicProvider.cxx2
-rw-r--r--vcl/workben/vcldemo.cxx8
-rw-r--r--xmloff/source/draw/ximpshap.cxx8
29 files changed, 103 insertions, 49 deletions
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
index cf638f0ca4eb..12a00495ee56 100644
--- a/codemaker/source/codemaker/typemanager.cxx
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -220,8 +220,7 @@ codemaker::UnoType::Sort TypeManager::decompose(
return s;
case codemaker::UnoType::Sort::PolymorphicStructTemplate:
if (args.size()
- != (dynamic_cast<
- unoidl::PolymorphicStructTypeTemplateEntity * >(ent.get())->
+ != (dynamic_cast<unoidl::PolymorphicStructTypeTemplateEntity&>(*ent).
getTypeParameters().size()))
{
throw CannotDumpException(
diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx
index 0bb433f00c65..0a73dfdf3e52 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -392,7 +392,9 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void)
if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem))
{
- pEntry.reset(new XBitmapEntry(dynamic_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject(), aName));
+ auto pFillBmpItem = dynamic_cast<const XFillBitmapItem*>(pPoolItem);
+ assert(pFillBmpItem);
+ pEntry.reset(new XBitmapEntry(pFillBmpItem->GetGraphicObject(), aName));
}
else
assert(!"SvxPatternTabPage::ClickAddHdl_Impl(), XBitmapEntry* pEntry == nullptr ?");
diff --git a/dbaccess/source/ext/macromigration/macromigrationpages.cxx b/dbaccess/source/ext/macromigration/macromigrationpages.cxx
index d4b84e5982e6..d2b19ed7608f 100644
--- a/dbaccess/source/ext/macromigration/macromigrationpages.cxx
+++ b/dbaccess/source/ext/macromigration/macromigrationpages.cxx
@@ -41,7 +41,9 @@ namespace dbmm
MacroMigrationDialog& MacroMigrationPage::getDialog()
{
- return *dynamic_cast< MacroMigrationDialog* >( GetParentDialog() );
+ auto pDialog = dynamic_cast<MacroMigrationDialog*>(GetParentDialog());
+ assert(pDialog);
+ return *pDialog;
}
// PreparationPage
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index 373656132adb..17f516a7897a 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -348,6 +348,7 @@ LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
if (pPreStoryID && !(pPreStoryID->IsNull()))
{
LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY).get());
+ assert(pPreStory);
return dynamic_cast<LwpPara*>(pPreStory->GetLastPara().obj(VO_PARA).get());
}
else
diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
index ccb7307b4fe7..de536253f24e 100644
--- a/lotuswordpro/source/filter/lwpfribsection.cxx
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -132,8 +132,8 @@ void LwpFribSection::SetSectionName()
*/
LwpPageLayout* LwpFribSection::GetPageLayout()
{
- if(GetSection())
- return GetSection()->GetPageLayout();
+ if (LwpSection* pSection = GetSection())
+ return pSection->GetPageLayout();
return nullptr;
}
diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
index a0a90a417c69..4140385bf8af 100644
--- a/lotuswordpro/source/filter/lwprowlayout.cxx
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -191,6 +191,7 @@ void LwpRowLayout::Read()
void LwpRowLayout::ConvertRow(rtl::Reference<XFTable> const & pXFTable,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
{
LwpTableLayout* pTableLayout = GetParentTableLayout();
+ assert(pTableLayout);
LwpTable* pTable = pTableLayout->GetTable();
//calculate the connected cell position
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index f14990156d01..48e4ee97837b 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -757,8 +757,8 @@ void LwpTableLayout::RegisterStyle()
// the old code doesn't check if the LwpFoundry pointer is NULL,
// so the NULL pointer cause sodc freeze. Add code to check the pointer.
- if (GetFoundry() && GetTable())
- PutCellVals(GetFoundry(), GetTable()->GetObjectID());
+ if (GetFoundry())
+ PutCellVals(GetFoundry(), pTable->GetObjectID());
}
/**
* @short read table layout
@@ -847,7 +847,9 @@ sal_uInt16 LwpTableLayout::ConvertHeadingRow(
rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartHeadRow, sal_uInt16 nEndHeadRow)
{
sal_uInt16 nContentRow;
- sal_uInt8 nCol = static_cast<sal_uInt8>(GetTable()->GetColumn());
+ LwpTable* pTable = GetTable();
+ assert(pTable);
+ sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
rtl::Reference<XFTable> pTmpTable( new XFTable );
ConvertTable(pTmpTable.get(),nStartHeadRow,nEndHeadRow,0,nCol);
@@ -888,7 +890,9 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
{
sal_uInt16 i;
sal_uInt16 nRowNum = pTmpTable->GetRowCount();
- sal_uInt8 nCol = static_cast<sal_uInt8>(GetTable()->GetColumn());
+ LwpTable* pTable = GetTable();
+ assert(pTable);
+ sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
rtl::Reference<XFRow> xXFRow(new XFRow);
@@ -1360,8 +1364,10 @@ void LwpTableLayout::ConvertDefaultRow(rtl::Reference<XFTable> const & pXFTable,
rtl::Reference<XFCell> xCell;
if (m_pDefaultCellLayout)
{
+ LwpTable* pTable = GetTable();
+ assert(pTable);
xCell = m_pDefaultCellLayout->DoConvertCell(
- GetTable()->GetObjectID(),nRowID,j+nStartCol);
+ pTable->GetObjectID(),nRowID,j+nStartCol);
}
else
{
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 0f3de9741094..da61e818c149 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -418,7 +418,7 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
if ( pContainerModel->getControlType() == API_CONTROL_MULTIPAGE )
{
AxMultiPageModel* pMultiPage = dynamic_cast< AxMultiPageModel* >( pContainerModel );
- if ( pMultiPage )
+ assert(pMultiPage);
{
BinaryXInputStream aXStrm( rStrg.openInputStream( "x" ), true );
pMultiPage->importPageAndMultiPageProperties( aXStrm, maControls.size() );
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index f08d86bf7bd1..90e8013b741e 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -409,6 +409,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage
//set comment chars for last comment on slide
SlideFragmentHandler* comment_handler =
dynamic_cast<SlideFragmentHandler*>(xCommentsFragmentHandler.get());
+ assert(comment_handler);
// some comments have no text -> set empty string as text to avoid
// crash (back() on empty vector is undefined) and losing other
// comment data that might be there (author, position, timestamp etc.)
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index d4c823561aa4..5e8e7e7d3b36 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -3470,6 +3470,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
{
pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i].get());
+ assert(pObjs[i]);
uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
@@ -3541,6 +3542,7 @@ void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
xShapePropLabel->setPosition(aPosLabel);
}
OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
+ assert(pObj);
uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
xShapeProp->setName(xShapeProp->getName() + sDefaultName );
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 09c7bbd63027..381c27501d07 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1050,7 +1050,8 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
aNewViewOpt.SetGridOptions( aNewGridOpt );
rViewData.SetOptions( aNewViewOpt );
rViewData.GetDocument()->SetViewOptions( aNewViewOpt );
- pDocSh->SetDocumentModified();
+ if (pDocSh)
+ pDocSh->SetDocumentModified();
bRepaint = true;
}
}
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index f1500352d4fd..747dbf4b24cd 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1777,6 +1777,7 @@ ScVbaRange::HasFormula()
{
uno::Reference<uno::XInterface> xRanges( pThisRanges->queryFormulaCells( sheet::FormulaResult::ERROR | sheet::FormulaResult::VALUE | sheet::FormulaResult::STRING ), uno::UNO_QUERY_THROW );
ScCellRangesBase* pFormulaRanges = dynamic_cast< ScCellRangesBase * > ( xRanges.get() );
+ assert(pFormulaRanges);
// check if there are no formula cell, return false
if ( pFormulaRanges->GetRangeList().empty() )
return uno::makeAny(false);
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 18bf7326a1b4..0c40536f534b 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1727,6 +1727,7 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
if (pViewShell2 && pViewShell2 == this)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
+ assert(pTabViewShell);
ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
if (pInputHdl && pInputHdl->IsFormulaMode())
{
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index 2e092503d757..dec4fd7b6f4c 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -111,23 +111,26 @@ void WriterXmlEmitter::fillFrameProps( DrawElement& rElem,
double rel_x = rElem.x, rel_y = rElem.y;
// find anchor type by recursing though parents
- Element* pAnchor = rElem.Parent;
- while( pAnchor &&
- ! dynamic_cast<ParagraphElement*>(pAnchor) &&
- ! dynamic_cast<PageElement*>(pAnchor) )
+ Element* pAnchor = &rElem;
+ ParagraphElement* pParaElt = nullptr;
+ PageElement* pPage = nullptr;
+ while ((pAnchor = pAnchor->Parent))
{
- pAnchor = pAnchor->Parent;
+ if ((pParaElt = dynamic_cast<ParagraphElement*>(pAnchor)))
+ break;
+ if ((pPage = dynamic_cast<PageElement*>(pAnchor)))
+ break;
}
if( pAnchor )
{
- if( dynamic_cast<ParagraphElement*>(pAnchor) )
+ if (pParaElt)
{
rProps[ "text:anchor-type" ] = rElem.isCharacter
? OUString("character") : OUString("paragraph");
}
else
{
- PageElement* pPage = dynamic_cast<PageElement*>(pAnchor);
+ assert(pPage); // guaranteed by the while loop above
rProps[ "text:anchor-type" ] = "page";
rProps[ "text:anchor-page-number" ] = OUString::number(pPage->PageNumber);
}
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index bcd013dda8be..772df9530ce5 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1570,7 +1570,7 @@ bool SfxCommonTemplateDialog_Impl::Execute_Impl(
if ( (nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId) && (pTreeBox->IsVisible() || aFmtLb->GetSelectionCount() <= 1) )
{
const SfxUInt16Item *pFilterItem = dynamic_cast< const SfxUInt16Item* >(pItem);
- OSL_ENSURE(pFilterItem, "SfxUINT16Item expected");
+ assert(pFilterItem);
SfxStyleSearchBits nFilterFlags = static_cast<SfxStyleSearchBits>(pFilterItem->GetValue()) & ~SfxStyleSearchBits::UserDefined;
if(nFilterFlags == SfxStyleSearchBits::Auto) // User Template?
nFilterFlags = static_cast<SfxStyleSearchBits>(pFilterItem->GetValue());
diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx
index 012bc5b92219..4570cec72cc2 100644
--- a/sfx2/source/doc/Metadatable.cxx
+++ b/sfx2/source/doc/Metadatable.cxx
@@ -1424,6 +1424,7 @@ std::shared_ptr<MetadatableUndo> Metadatable::CreateUndo() const
{
XmlIdRegistryDocument * pRegDoc(
dynamic_cast<XmlIdRegistryDocument*>( m_pReg ) );
+ assert(pRegDoc);
std::shared_ptr<MetadatableUndo> xUndo(
sfx2::XmlIdRegistryDocument::CreateUndo(*this) );
pRegDoc->RegisterCopy(*this, *xUndo, false);
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index d94e1a8e55f6..af2c1279c329 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -793,11 +793,14 @@ IMPL_LINK_NOARG( SmCmdBoxWindow, InitialFocusTimerHdl, Timer *, void )
aEdit->GrabFocus();
- bool bInPlace = GetView()->GetViewFrame()->GetFrame().IsInPlace();
+ SmViewShell* pView = GetView();
+ assert(pView);
+ bool bInPlace = pView->GetViewFrame()->GetFrame().IsInPlace();
uno::Reference< frame::XFrame > xFrame( GetBindings().GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface());
if ( bInPlace )
{
- uno::Reference< container::XChild > xModel( GetView()->GetDoc()->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference<container::XChild> xModel(pView->GetDoc()->GetModel(),
+ uno::UNO_QUERY_THROW);
uno::Reference< frame::XModel > xParent( xModel->getParent(), uno::UNO_QUERY_THROW );
uno::Reference< frame::XController > xParentCtrler( xParent->getCurrentController() );
uno::Reference< frame::XFramesSupplier > xParentFrame( xParentCtrler->getFrame(), uno::UNO_QUERY_THROW );
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 74fd2b147d76..693038a268dd 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -6411,8 +6411,9 @@ void SwUiWriterTest::testTdf115013()
// Save it as DOCX & load it again
reload("Office Open XML Text", "mm-field.docx");
- CPPUNIT_ASSERT(mxComponent.get());
- pDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get())->GetDocShell()->GetDoc();
+ auto pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+ pDoc = pXTextDocument->GetDocShell()->GetDoc();
CPPUNIT_ASSERT(pDoc);
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
CPPUNIT_ASSERT(pWrtShell);
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index d2f792ec4e74..dc7ef136561f 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -328,8 +328,9 @@ void SwAttrSet::CopyToModify( SwModify& rMod ) const
pCNd && pCNd->IsTextNode() &&
GetItemState( RES_PARATR_LIST_ID, false, &pItem ) == SfxItemState::SET )
{
- const OUString& sListId =
- dynamic_cast<const SfxStringItem*>(pItem)->GetValue();
+ auto pStrItem = dynamic_cast<const SfxStringItem*>(pItem);
+ assert(pStrItem);
+ const OUString& sListId = pStrItem->GetValue();
if ( !sListId.isEmpty() &&
!pDstDoc->getIDocumentListsAccess().getListByName( sListId ) )
{
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index d2474855d4ad..3d8704142ff1 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1108,7 +1108,9 @@ static void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd )
{
// break the link of the corresponding section.
// the link is also removed from the link manager
- pSectLnk->GetSectNode()->GetSection().BreakLink();
+ SwSectionNode* pSectNode = pSectLnk->GetSectNode();
+ assert(pSectNode);
+ pSectNode->GetSection().BreakLink();
// for robustness, because link is removed from the link manager
if ( n > rLnks.size() )
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 63b8971f55a8..c044b4903112 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -4746,6 +4746,7 @@ namespace {
const SwNumRuleItem* pNumRuleItem =
dynamic_cast<const SwNumRuleItem*>(pItem);
+ assert(pNumRuleItem);
if ( !pNumRuleItem->GetValue().isEmpty() )
{
mbAddTextNodeToList = true;
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 7742dd6bbb9b..cf6e4f86da07 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1065,8 +1065,12 @@ void SwXMLImport::MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
if (! pListId2)
return;
- const OUString& sListId1 = dynamic_cast<const SfxStringItem*>(pListId1)->GetValue();
- const OUString& sListId2 = dynamic_cast<const SfxStringItem*>(pListId2)->GetValue();
+ auto pStringListId1 = dynamic_cast<const SfxStringItem*>(pListId1);
+ assert(pStringListId1);
+ const OUString& sListId1 = pStringListId1->GetValue();
+ auto pStringListId2 = dynamic_cast<const SfxStringItem*>(pListId2);
+ assert(pStringListId2);
+ const OUString& sListId2 = pStringListId2->GetValue();
const SwList* pList1 = pDoc->getIDocumentListsAccess().getListByName( sListId1 );
const SwList* pList2 = pDoc->getIDocumentListsAccess().getListByName( sListId2 );
diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx
index d96b18fb6972..b361136fde6d 100644
--- a/sw/source/uibase/uiview/srcview.cxx
+++ b/sw/source/uibase/uiview/srcview.cxx
@@ -332,6 +332,7 @@ void SwSrcView::Execute(SfxRequest& rReq)
case SID_SAVEDOC:
{
SwDocShell* pDocShell = GetDocShell();
+ assert(pDocShell);
SfxMedium* pMed = nullptr;
if(pDocShell->HasName())
pMed = pDocShell->GetMedium();
@@ -366,7 +367,11 @@ void SwSrcView::Execute(SfxRequest& rReq)
SetSearchItem( static_cast<const SvxSearchItem&>(rItem));
StartSearchAndReplace( static_cast<const SvxSearchItem&>(rItem), rReq.IsAPI() );
if(aEditWin->IsModified())
- GetDocShell()->GetDoc()->getIDocumentState().SetModified();
+ {
+ SwDocShell* pDocShell = GetDocShell();
+ assert(pDocShell);
+ pDocShell->GetDoc()->getIDocumentState().SetModified();
+ }
}
break;
case FN_REPEAT_SEARCH:
@@ -433,6 +438,7 @@ void SwSrcView::GetState(SfxItemSet& rSet)
case SID_SAVEDOC:
{
SwDocShell* pDocShell = GetDocShell();
+ assert(pDocShell);
if(!pDocShell->IsModified())
rSet.DisableItem(nWhich);
}
@@ -455,7 +461,9 @@ void SwSrcView::GetState(SfxItemSet& rSet)
case SID_SEARCH_OPTIONS:
{
SearchOptionFlags nOpt = SRC_SEARCHOPTIONS;
- if(GetDocShell()->IsReadOnly())
+ SwDocShell* pDocShell = GetDocShell();
+ assert(pDocShell);
+ if (pDocShell->IsReadOnly())
nOpt &= ~SearchOptionFlags(SearchOptionFlags::REPLACE|SearchOptionFlags::REPLACE_ALL);
rSet.Put( SfxUInt16Item( SID_SEARCH_OPTIONS, static_cast<sal_uInt16>(nOpt) ) );
@@ -646,6 +654,7 @@ void SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem,
sal_uInt16 SwSrcView::SetPrinter(SfxPrinter* pNew, SfxPrinterChangeFlags nDiffFlags )
{
SwDocShell* pDocSh = GetDocShell();
+ assert(pDocSh);
if ( (SfxPrinterChangeFlags::JOBSETUP | SfxPrinterChangeFlags::PRINTER) & nDiffFlags )
{
pDocSh->GetDoc()->getIDocumentDeviceAccess().setPrinter( pNew, true, true );
@@ -666,7 +675,9 @@ sal_uInt16 SwSrcView::SetPrinter(SfxPrinter* pNew, SfxPrinterChangeFlags nDiffFl
SfxPrinter* SwSrcView::GetPrinter( bool bCreate )
{
- return GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( bCreate );
+ SwDocShell* pDocSh = GetDocShell();
+ assert(pDocSh);
+ return pDocSh->GetDoc()->getIDocumentDeviceAccess().getPrinter(bCreate);
}
sal_Int32 SwSrcView::PrintSource(
@@ -749,17 +760,17 @@ sal_Int32 SwSrcView::PrintSource(
void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if ( rHint.GetId() == SfxHintId::ModeChanged ||
- (
- rHint.GetId() == SfxHintId::TitleChanged &&
- !GetDocShell()->IsReadOnly() && aEditWin->IsReadonly()
- )
- )
+ if (rHint.GetId() == SfxHintId::ModeChanged || rHint.GetId() == SfxHintId::TitleChanged)
{
- // Broadcast only comes once!
const SwDocShell* pDocSh = GetDocShell();
- const bool bReadonly = pDocSh->IsReadOnly();
- aEditWin->SetReadonly(bReadonly);
+ assert(pDocSh);
+ if (!(rHint.GetId() == SfxHintId::TitleChanged
+ && (pDocSh->IsReadOnly() || !aEditWin->IsReadonly())))
+ {
+ // Broadcast only comes once!
+ const bool bReadonly = pDocSh->IsReadOnly();
+ aEditWin->SetReadonly(bReadonly);
+ }
}
SfxViewShell::Notify(rBC, rHint);
}
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 4a1c0b9da073..4a5dcee452aa 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3808,18 +3808,21 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
LanguageType nLang = LANGUAGE_DONTKNOW;
if (bLatin)
{
+ assert(pSet);
nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, false )).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bAsian)
{
+ assert(pSet);
nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, false )).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bComplex)
{
+ assert(pSet);
nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, false )).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index b950cefbf1cf..ae28379472e7 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -530,6 +530,7 @@ void PdfExportTest::testTdf109143()
// Make sure it's re-compressed.
auto pLength = dynamic_cast<vcl::filter::PDFNumberElement*>(pXObject->Lookup("Length"));
+ CPPUNIT_ASSERT(pLength);
int nLength = pLength->GetValue();
// This failed: cropped TIFF-in-JPEG wasn't re-compressed, so crop was
// lost. Size was 59416, now is 11827.
diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx
index 373acaba0700..a86a155ecfe3 100644
--- a/vcl/source/gdi/print2.cxx
+++ b/vcl/source/gdi/print2.cxx
@@ -744,6 +744,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
if( meOutDevType == OUTDEV_PRINTER )
{
Printer* pThis = dynamic_cast<Printer*>(this);
+ assert(pThis);
Point aPageOffset = pThis->GetPageOffsetPixel();
aPageOffset = Point( 0, 0 ) - aPageOffset;
Size aSize = pThis->GetPaperSizePixel();
@@ -1107,6 +1108,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf,
else if( meOutDevType == OUTDEV_PRINTER )
{
Printer* pThis = dynamic_cast<Printer*>(this);
+ assert(pThis);
aPageOffset = pThis->GetPageOffsetPixel();
aPageOffset = Point( 0, 0 ) - aPageOffset;
aTmpSize = pThis->GetPaperSizePixel();
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx
index 51d755b4515a..9e99cd89decd 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -660,6 +660,7 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal
if ( pAction->GetType() == MetaActionType::BMPSCALE )
{
MetaBmpScaleAction* pScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
+ assert(pScaleAction);
aBmpEx = pScaleAction->GetBitmap();
aPos = pScaleAction->GetPoint();
aSize = pScaleAction->GetSize();
@@ -667,6 +668,7 @@ void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyVal
else
{
MetaBmpExScaleAction* pScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
+ assert(pScaleAction);
aBmpEx = pScaleAction->GetBitmapEx();
aPos = pScaleAction->GetPoint();
aSize = pScaleAction->GetSize();
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 4a0fe21efc11..b9e4f26af815 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -2177,9 +2177,13 @@ public:
// get some other guys to leach off this context
VclPtrInstance<VirtualDevice> xVDev;
- rtl::Reference<OpenGLContext> pContext = getImpl(xVDev)->GetOpenGLContext();
+ OpenGLSalGraphicsImpl* pImpl = getImpl(xVDev);
+ assert(pImpl);
+ rtl::Reference<OpenGLContext> pContext = pImpl->GetOpenGLContext();
VclPtrInstance<VirtualDevice> xVDev2;
- rtl::Reference<OpenGLContext> pContext2 = getImpl(xVDev)->GetOpenGLContext();
+ OpenGLSalGraphicsImpl* pImpl2 = getImpl(xVDev2);
+ assert(pImpl2);
+ rtl::Reference<OpenGLContext> pContext2 = pImpl2->GetOpenGLContext();
// sharing the same off-screen context.
assert(pContext == pContext2);
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 29fd6f35c621..9f67a8225821 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -605,8 +605,6 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
do
{
- XMLPropStyleContext* pDocStyle = nullptr;
-
// set style on shape
if(maDrawStyleName.isEmpty())
break;
@@ -626,10 +624,10 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
OUString aStyleName = maDrawStyleName;
uno::Reference< style::XStyle > xStyle;
- if( dynamic_cast<const XMLShapeStyleContext*>( pStyle ) )
+ XMLPropStyleContext* pDocStyle
+ = dynamic_cast<XMLShapeStyleContext*>(const_cast<SvXMLStyleContext*>(pStyle));
+ if (pDocStyle)
{
- pDocStyle = const_cast<XMLShapeStyleContext*>(dynamic_cast<const XMLShapeStyleContext*>( pStyle ) );
-
if( pDocStyle->GetStyle().is() )
{
xStyle = pDocStyle->GetStyle();