diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-05 20:53:49 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-05-06 12:23:39 +0200 |
commit | 0cd07e1fb7afc0a6831eaafabcead7e0c5f7ac3b (patch) | |
tree | 8f145203ea1b9cf43d5e41b0c99c12b3e7465575 | |
parent | ef2066cdfe86019a3099b3530fb091ca2a4d2446 (diff) |
WaE: C6011 Dereferencing NULL pointer warnings
Change-Id: I71d20c4d35b5123216da55a8b314400c93cae6fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167173
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
41 files changed, 104 insertions, 51 deletions
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index f69585167c66..6ebc5d51ef77 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -281,7 +281,7 @@ void ScDocument::PutInFormulaTree( ScFormulaCell* pCell ) void ScDocument::RemoveFromFormulaTree( ScFormulaCell* pCell ) { ScMutationGuard aGuard(*this, ScMutationGuardFlags::CORE); - OSL_ENSURE( pCell, "RemoveFromFormulaTree: pCell Null" ); + assert(pCell && "RemoveFromFormulaTree: pCell Null"); ScFormulaCell* pPrev = pCell->GetPrevious(); assert(pPrev != pCell); // pointing to itself?!? // if the cell is first or somewhere in chain @@ -468,7 +468,7 @@ void ScDocument::AppendToFormulaTrack( ScFormulaCell* pCell ) void ScDocument::RemoveFromFormulaTrack( ScFormulaCell* pCell ) { - OSL_ENSURE( pCell, "RemoveFromFormulaTrack: pCell Null" ); + assert(pCell && "RemoveFromFormulaTrack: pCell Null"); ScFormulaCell* pPrev = pCell->GetPreviousTrack(); assert(pPrev != pCell); // pointing to itself?!? // if the cell is first or somewhere in chain diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index e584a9016626..5fb5eec14acc 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -593,6 +593,7 @@ bool ScDocument::IdleCalcTextWidth() // true = try next again if (!pDev) { pDev = GetPrinter(); + assert(pDev); aScope.setOldMapMode(pDev->GetMapMode()); pDev->SetMapMode(MapMode(MapUnit::MapPixel)); // Important for GetNeededSize diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 1a4020e56e91..e2e59d6987f2 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -3621,7 +3621,8 @@ void ScDPDataDimension::FillDataRow( FilterStack aFilterStack(rFilterCxt.maFilters); aFilterStack.pushDimName(aDimName, bDataLayout); - OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); + assert(pRefDim); + OSL_ENSURE( static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" ); const ScMemberSortOrder& rMemberOrder = pRefDim->GetMemberOrder(); @@ -3654,7 +3655,8 @@ void ScDPDataDimension::UpdateDataRow( const ScDPResultDimension* pRefDim, tools::Long nMeasure, bool bIsSubTotalRow, const ScDPSubTotalState& rSubState ) const { - OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); + assert(pRefDim); + OSL_ENSURE( static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" ); tools::Long nMemberMeasure = nMeasure; @@ -3719,7 +3721,8 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim ) // handle children first, before changing the visible state - OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); + assert(pRefDim); + OSL_ENSURE( static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" ); // for data layout, call only once - sorting measure is always taken from settings @@ -3808,7 +3811,8 @@ void ScDPDataDimension::UpdateRunningTotals( const ScDPResultDimension* pRefDim, const ScDPSubTotalState& rSubState, ScDPRunningTotalState& rRunning, ScDPRowTotals& rTotals, const ScDPResultMember& rRowParent ) const { - OSL_ENSURE( pRefDim && static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); + assert(pRefDim); + OSL_ENSURE( static_cast<size_t>(pRefDim->GetMemberCount()) == maMembers.size(), "dimensions don't match" ); OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" ); tools::Long nMemberMeasure = nMeasure; diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx index b9cfb51ae9c1..c9f128e49aa2 100644 --- a/sc/source/core/data/funcdesc.cxx +++ b/sc/source/core/data/funcdesc.cxx @@ -1037,7 +1037,7 @@ ScFunctionMgr::ScFunctionMgr() ScFunctionList* pFuncList /**< list of all calc functions */ = ScGlobal::GetStarCalcFunctionList(); - OSL_ENSURE( pFuncList, "Functionlist not found." ); + assert(pFuncList && "Functionlist not found."); sal_uInt32 catCount[MAX_FUNCCAT] = {0}; aCatLists[0].reserve(pFuncList->GetCount()); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index c9cad8641bce..4e0ab28a07c3 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -440,6 +440,7 @@ static bool StrCmp( const OUString* pStr1, const OUString* pStr2 ) return false; if (!pStr1 && pStr2) return false; + assert(pStr1 && pStr2); return *pStr1 == *pStr2; } diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 67f172a4f945..0118665d91b7 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -95,7 +95,7 @@ void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress { // pass true to ScDrawLayer::GetObjData() to create the object data entry ScDrawObjData* pObjData = ScDrawLayer::GetObjData( &rCaption, true ); - OSL_ENSURE( pObjData, "ScCaptionUtil::SetCaptionUserData - missing drawing object user data" ); + assert(pObjData && "ScCaptionUtil::SetCaptionUserData - missing drawing object user data"); pObjData->maStart = rPos; pObjData->meType = ScDrawObjData::CellNote; } diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index dc9e7715f6e2..1fd2f1ae8a42 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -225,6 +225,7 @@ SfxItemSet& ScStyleSheet::GetItemSet() case SfxStyleFamily::Frame: { SfxItemPool* pItemPool = &GetPool()->GetPool(); + assert(pItemPool); if (dynamic_cast<SdrItemPool*>(pItemPool) == nullptr) pItemPool = pItemPool->GetSecondaryPool(); assert(pItemPool); diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 59efb5ad6469..6f8648435aa4 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -582,7 +582,7 @@ void ScDetectiveFunc::DeleteArrowsAt( SCCOL nCol, SCROW nRow, bool bDestPnt ) ScDrawLayer* pModel = rDoc.GetDrawLayer(); SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); - OSL_ENSURE(pPage,"Page ?"); + assert(pPage && "Page ?"); pPage->RecalcObjOrdNums(); @@ -653,7 +653,7 @@ void ScDetectiveFunc::DeleteBox( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nR ScDrawLayer* pModel = rDoc.GetDrawLayer(); SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); - OSL_ENSURE(pPage,"Page ?"); + assert(pPage && "Page ?"); pPage->RecalcObjOrdNums(); @@ -1164,7 +1164,7 @@ bool ScDetectiveFunc::DeleteCirclesAt( SCCOL nCol, SCROW nRow ) return false; SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); - OSL_ENSURE(pPage, "Page ?"); + assert(pPage && "Page ?"); pPage->RecalcObjOrdNums(); @@ -1210,7 +1210,7 @@ bool ScDetectiveFunc::DeleteAll( ScDetectiveDelete eWhat ) return false; SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); - OSL_ENSURE(pPage,"Page ?"); + assert(pPage && "Page ?"); pPage->RecalcObjOrdNums(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 8c44ac179ad0..89601a7ca8b0 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3300,6 +3300,7 @@ void ScInterpreter::ScMacro() SbModule* pModule = pMethod->GetModule(); bool bUseVBAObjects = pModule->IsVBASupport(); SbxObject* pObject = pModule->GetParent(); + assert(pObject); OSL_ENSURE(dynamic_cast<const StarBASIC *>(pObject) != nullptr, "No Basic found!"); OUString aMacroStr = pObject->GetName() + "." + pModule->GetName() + "." + pMethod->GetName(); OUString aBasicStr; diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 8827b78afe64..c2eccb79d58f 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1954,6 +1954,7 @@ XclExpObjectManager::XclExpObjectManager( const XclExpRoot& rRoot ) : XclExpRoot( rRoot ) { InitStream( true ); + assert(mpDffStrm); mxEscherEx = std::make_shared<XclEscherEx>( GetRoot(), *this, *mpDffStrm ); } @@ -1961,6 +1962,7 @@ XclExpObjectManager::XclExpObjectManager( const XclExpObjectManager& rParent ) : XclExpRoot( rParent.GetRoot() ) { InitStream( false ); + assert(mpDffStrm); mxEscherEx = std::make_shared<XclEscherEx>( GetRoot(), *this, *mpDffStrm, rParent.mxEscherEx.get() ); } @@ -2046,6 +2048,8 @@ void XclExpObjectManager::InitStream( bool bTempFile ) mpDffStrm = mpBackupStrm.get(); } + assert(mpDffStrm); + mpDffStrm->SetEndian( SvStreamEndian::LITTLE ); } diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx index 71f5056beb93..1d0ce72e9c36 100644 --- a/sc/source/filter/excel/xeformula.cxx +++ b/sc/source/filter/excel/xeformula.cxx @@ -596,6 +596,7 @@ void XclExpFmlaCompImpl::Init( XclFormulaType eType, const ScTokenArray& rScTokA assert(mxData->mbOk && "XclExpFmlaCompImpl::Init - missing cell address"); if (mxData->mbOk) { + assert(pScBasePos); // clone the passed token array, convert references relative to current cell position mxData->mxOwnScTokArr = rScTokArr.Clone(); ScCompiler::MoveRelWrap( *mxData->mxOwnScTokArr, GetDoc(), *pScBasePos, GetDoc().MaxCol(), GetDoc().MaxRow() ); @@ -1403,6 +1404,8 @@ void XclExpFmlaCompImpl::ProcessFunction( const XclExpScToken& rTokData ) mxData->mbOk = pFuncInfo != nullptr; if( !mxData->mbOk ) return; + assert(pFuncInfo); + // internal functions equivalent to an existing add-in if( pFuncInfo->IsAddInEquivalent() ) aExtFuncData.Set( pFuncInfo->GetAddInEquivalentFuncName(), true, false ); diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 223eed9924f8..1e44f58f5ed6 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -1844,7 +1844,7 @@ void XclImpXFRangeColumn::Find( { nMidIndex = (nPrevIndex + rnNextIndex) / 2; pMidRange = maIndexList[nMidIndex].get(); - OSL_ENSURE( pMidRange, "XclImpXFRangeColumn::Find - missing XF index range" ); + assert(pMidRange && "XclImpXFRangeColumn::Find - missing XF index range"); if( nScRow < pMidRange->mnScRow1 ) // row is really before pMidRange { rpNextRange = pMidRange; diff --git a/sc/source/filter/ftools/fapihelper.cxx b/sc/source/filter/ftools/fapihelper.cxx index a8cb2f59d102..2d949877c232 100644 --- a/sc/source/filter/ftools/fapihelper.cxx +++ b/sc/source/filter/ftools/fapihelper.cxx @@ -271,7 +271,7 @@ void ScfPropertySet::SetProperties( const Sequence< OUString >& rPropNames, cons ScfPropSetHelper::ScfPropSetHelper( const char* const* ppcPropNames ) : mnNextIdx( 0 ) { - OSL_ENSURE( ppcPropNames, "ScfPropSetHelper::ScfPropSetHelper - no strings found" ); + assert(ppcPropNames && "ScfPropSetHelper::ScfPropSetHelper - no strings found"); // create OUStrings from ASCII property names typedef ::std::pair< OUString, size_t > IndexedOUString; diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 6e87e67fe2af..646791c668d4 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -434,7 +434,7 @@ void ScHTMLLayoutParser::NextRow( const HtmlImportInfo* pInfo ) bool ScHTMLLayoutParser::SeekOffset( const ScHTMLColOffset* pOffset, sal_uInt16 nOffset, SCCOL* pCol, sal_uInt16 nOffsetTol ) { - OSL_ENSURE( pOffset, "ScHTMLLayoutParser::SeekOffset - illegal call" ); + assert(pOffset && "ScHTMLLayoutParser::SeekOffset - illegal call"); ScHTMLColOffset::const_iterator it = pOffset->find( nOffset ); bool bFound = it != pOffset->end(); size_t nPos = it - pOffset->begin(); @@ -461,7 +461,7 @@ bool ScHTMLLayoutParser::SeekOffset( const ScHTMLColOffset* pOffset, sal_uInt16 void ScHTMLLayoutParser::MakeCol( ScHTMLColOffset* pOffset, sal_uInt16& nOffset, sal_uInt16& nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol ) { - OSL_ENSURE( pOffset, "ScHTMLLayoutParser::MakeCol - illegal call" ); + assert(pOffset && "ScHTMLLayoutParser::MakeCol - illegal call"); SCCOL nPos; if ( SeekOffset( pOffset, nOffset, &nPos, nOffsetTol ) ) nOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); @@ -479,7 +479,7 @@ void ScHTMLLayoutParser::MakeCol( ScHTMLColOffset* pOffset, sal_uInt16& nOffset, void ScHTMLLayoutParser::MakeColNoRef( ScHTMLColOffset* pOffset, sal_uInt16 nOffset, sal_uInt16 nWidth, sal_uInt16 nOffsetTol, sal_uInt16 nWidthTol ) { - OSL_ENSURE( pOffset, "ScHTMLLayoutParser::MakeColNoRef - illegal call" ); + assert(pOffset && "ScHTMLLayoutParser::MakeColNoRef - illegal call"); SCCOL nPos; if ( SeekOffset( pOffset, nOffset, &nPos, nOffsetTol ) ) nOffset = static_cast<sal_uInt16>((*pOffset)[nPos]); @@ -495,7 +495,7 @@ void ScHTMLLayoutParser::MakeColNoRef( ScHTMLColOffset* pOffset, sal_uInt16 nOff void ScHTMLLayoutParser::ModifyOffset( ScHTMLColOffset* pOffset, sal_uInt16& nOldOffset, sal_uInt16& nNewOffset, sal_uInt16 nOffsetTol ) { - OSL_ENSURE( pOffset, "ScHTMLLayoutParser::ModifyOffset - illegal call" ); + assert(pOffset && "ScHTMLLayoutParser::ModifyOffset - illegal call"); SCCOL nPos; if ( !SeekOffset( pOffset, nOldOffset, &nPos, nOffsetTol ) ) { diff --git a/sc/source/filter/inc/tool.h b/sc/source/filter/inc/tool.h index 786e7f669863..42de10b4607c 100644 --- a/sc/source/filter/inc/tool.h +++ b/sc/source/filter/inc/tool.h @@ -120,7 +120,7 @@ inline const SfxUInt32Item* FormCache::GetAttr( sal_uInt8 nFormat, sal_uInt8 nSt { // create new attribute pAttr = NewAttr( nFormat, nSt ); - OSL_ENSURE( pAttr, "FormCache::GetAttr(): Nothing to save" ); + assert(pAttr && "FormCache::GetAttr(): Nothing to save"); aIdents[ nIndex ] = FormIdent( nFormat, nSt, *pAttr ); bValid[ nIndex ] = true; diff --git a/sc/source/filter/lotus/filter.cxx b/sc/source/filter/lotus/filter.cxx index 3c89cf693128..0546c46d772a 100644 --- a/sc/source/filter/lotus/filter.cxx +++ b/sc/source/filter/lotus/filter.cxx @@ -91,7 +91,10 @@ generate_Opcodes(LotusContext &rContext, SvStream& aStream, break; } else if( nOpcode < nOps ) + { + assert(pOps); pOps[ nOpcode ] (rContext, aStream, nLength); + } else if (rContext.eTyp == eWK123 && nOpcode == LOTUS_PATTERN) { // This is really ugly - needs re-factoring ... diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index e85eb1f39c30..8f6f18f29796 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3307,6 +3307,8 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) { SvXMLElementExport aElemP(*this, sElemP, true, false); + assert(pDoc); + OUString aParaStr = ScCellFormat::GetOutputString(*pDoc, aCell.maCellAddress, aCell.maBaseCell); diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 65d85c499d55..f541ca27b679 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -227,8 +227,10 @@ void ScModule::ConfigurationChanged(utl::ConfigurationBroadcaster* p, Configurat const bool bUnchanged(aViewRenderingOptions == pViewShell->GetViewRenderingData()); if (!bUnchanged) pViewShell->SetViewRenderingData(aViewRenderingOptions); - ScModelObj* pScModelObj = comphelper::getFromUnoTunnel<ScModelObj>(SfxObjectShell::Current()->GetModel()); - SfxLokHelper::notifyViewRenderState(SfxViewShell::Current(), pScModelObj); + ScModelObj* pScModelObj = nullptr; + if (SfxObjectShell* pCurrentSh = SfxObjectShell::Current()) + pScModelObj = comphelper::getFromUnoTunnel<ScModelObj>(pCurrentSh->GetModel()); + SfxLokHelper::notifyViewRenderState(pViewShell, pScModelObj); // In Online, the document color is the one used for the background, contrary to // Writer and Draw that use the application background color. pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_APPLICATION_BACKGROUND_COLOR, diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 008113d0571e..cef7de276439 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -414,11 +414,17 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void ) RecalcAll(); } +static bool isLOKMobilePhone() +{ + SfxViewShell* pCurrent = SfxViewShell::Current(); + return pCurrent && pCurrent->isLOKMobilePhone(); +} + ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScViewData* pViewData, const std::shared_ptr<ScCondFormatDlgData>& rItem) : ScAnyRefDlgController(pB, pCW, pParent, - (SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui"), + isLOKMobilePhone()?OUString("modules/scalc/ui/conditionalformatdialogmobile.ui"):OUString("modules/scalc/ui/conditionalformatdialog.ui"), "ConditionalFormatDialog") , mpViewData(pViewData) // previous version based on SfxPoolItem used SfxPoolItem::Clone here, so make a copy diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 9798263d06c7..88de0f73a606 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -44,9 +44,15 @@ // force them to take a 1/3 of the available space #define CommonWidgetWidth 10 +static bool isLOKMobilePhone() +{ + SfxViewShell* pCurrent = SfxViewShell::Current(); + return pCurrent && pCurrent->isLOKMobilePhone(); +} + ScCondFrmtEntry::ScCondFrmtEntry(ScCondFormatList* pParent, ScDocument* pDoc, const ScAddress& rPos) : mpParent(pParent) - , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), (SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))) + , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), isLOKMobilePhone()?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui"))) , mxBorder(mxBuilder->weld_widget("border")) , mxGrid(mxBuilder->weld_container("grid")) , mxFtCondNr(mxBuilder->weld_label("number")) diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx index f8565e964354..e72951ce6027 100644 --- a/sc/source/ui/dbgui/validate.cxx +++ b/sc/source/ui/dbgui/validate.cxx @@ -45,9 +45,6 @@ #include <reffact.hxx> #include <comphelper/lok.hxx> - -#define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone()) - /* Position indexes for "Allow" list box. They do not map directly to ScValidationMode and can safely be modified to change the order of the list box entries. */ @@ -81,6 +78,14 @@ const WhichRangesContainer ScTPValidationValue::pValueRanges(svl::Items< FID_VALID_MODE, FID_VALID_ERRTEXT >); +static bool isLOKMobilePhone() +{ + if (!comphelper::LibreOfficeKit::isActive()) + return false; + SfxViewShell* pViewShell = SfxViewShell::Current(); + return pViewShell && pViewShell->isLOKMobilePhone(); +} + ScValidationDlg::ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell *pTabViewSh) : ScValidationDlgBase(pParent, @@ -95,7 +100,7 @@ ScValidationDlg::ScValidationDlg(weld::Window* pParent, const SfxItemSet* pArgSe AddTabPage("inputhelp", ScTPValidationHelp::Create, nullptr); AddTabPage("erroralert", ScTPValidationError::Create, nullptr); - if (IS_MOBILE) + if (isLOKMobilePhone()) { m_xBuilder->weld_button("cancel")->hide(); m_xBuilder->weld_button("help")->hide(); diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index fb9f7909f24a..92f5d55376a8 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -112,7 +112,7 @@ void ScDBDocFunc::DoImportUno( const ScAddress& rPos, // create database range ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, ScGetDBSelection::Keep ); - DBG_ASSERT(pDBData, "can't create DB data"); + assert(pDBData && "can't create DB data"); OUString sTarget = pDBData->GetName(); UpdateImport( sTarget, aDesc ); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 0348ce5174be..91d5ddc5836f 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -336,7 +336,7 @@ void ScDocShell::Execute( SfxRequest& rReq ) } ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, ScGetDBSelection::Keep ); - OSL_ENSURE(pDBData, "Cannot create DB data"); + assert(pDBData && "Cannot create DB data"); sTarget = pDBData->GetName(); } } @@ -2812,7 +2812,7 @@ ScDocShell* ScDocShell::GetShellByNum( sal_uInt16 nDocNo ) // static IMPL_LINK( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void ) { - OSL_ENSURE( _pFileDlg, "ScDocShell::DialogClosedHdl(): no file dialog" ); + assert( _pFileDlg && "ScDocShell::DialogClosedHdl(): no file dialog"); OSL_ENSURE( m_pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" ); if ( ERRCODE_NONE == _pFileDlg->GetError() ) diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 51c5a1a08cbc..0e7cc33f121d 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -520,6 +520,7 @@ bool ScDrawShell::AreAllObjectsOnLayer(SdrLayerID nLayerNo,const SdrMarkList& rM for (size_t i=0; i<nCount; ++i) { SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); + assert(pObj); if ( dynamic_cast<const SdrUnoObj*>( pObj) == nullptr ) { if(nLayerNo!=pObj->GetLayer()) diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx index 0baff09045cc..c2fe632c3bd5 100644 --- a/sc/source/ui/drawfunc/drawsh5.cxx +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -510,7 +510,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) { // #i68101# SdrObject* pSelected = pView->GetMarkedObjectByIndex(0); - OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); + assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); if(SC_LAYER_INTERN != pSelected->GetLayer()) { @@ -583,7 +583,7 @@ void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) if(1 == pView->GetMarkedObjectCount()) { SdrObject* pSelected = pView->GetMarkedObjectByIndex(0); - OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); + assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); if(SC_LAYER_INTERN != pSelected->GetLayer()) { diff --git a/sc/source/ui/drawfunc/fuconstr.cxx b/sc/source/ui/drawfunc/fuconstr.cxx index 5babb078d928..689f33d8fed8 100644 --- a/sc/source/ui/drawfunc/fuconstr.cxx +++ b/sc/source/ui/drawfunc/fuconstr.cxx @@ -147,6 +147,7 @@ bool FuConstruct::MouseButtonUp(const MouseEvent& rMEvt) // if Uno-Controls no text mode if ( DynCastSdrTextObj( pObj) != nullptr && dynamic_cast<const SdrUnoObj*>( pObj) == nullptr ) { + assert(pObj); OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); bool bVertical = ( pOPO && pOPO->IsEffectivelyVertical() ); sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT; diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx index 9076a75ada00..1d5be0692b4a 100644 --- a/sc/source/ui/drawfunc/fudraw.cxx +++ b/sc/source/ui/drawfunc/fudraw.cxx @@ -159,6 +159,7 @@ static bool lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell& rViewShell, const bool bReturn = false; if ( DynCastSdrTextObj( pObj) != nullptr && dynamic_cast<const SdrUnoObj*>( pObj) == nullptr ) { + assert(pObj); // start text edit - like FuSelection::MouseButtonUp, // but with bCursorToEnd instead of mouse position diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx index 10601676f75d..1fcc7a448750 100644 --- a/sc/source/ui/drawfunc/fusel.cxx +++ b/sc/source/ui/drawfunc/fusel.cxx @@ -478,6 +478,8 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt) SdrHitKind eHit = pView->PickAnything( rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt ); if (eHit != SdrHitKind::NONE && aVEvt.mpObj == pObj) { + assert(pObj); + SdrObjKind nSdrObjKind = pObj->GetObjIdentifier(); // OLE: activate diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index 0a26c7693bf5..8db495b0f467 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -217,6 +217,7 @@ bool FuText::MouseButtonDown(const MouseEvent& rMEvt) SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); if( ScDrawLayer::IsNoteCaption( pMarkedObj ) ) { + assert(pHdl); if(pHdl->GetKind() != SdrHdlKind::Poly && pHdl->GetKind() != SdrHdlKind::Circle) bDrag = true; } diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index 5707f8796526..61727c62919e 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -171,13 +171,13 @@ sal_uInt16 ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const { - OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" ); + assert(pCurData && "ScAutoFmtPreview::GetBoxItem - no format data found"); return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ); } const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const { - OSL_ENSURE( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" ); + assert(pCurData && "ScAutoFmtPreview::GetDiagItem - no format data found"); return * pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ); } diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index 7b76a2a5e5c6..b4c772e201f3 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -936,7 +936,7 @@ void ScContentTree::GetLinkNames() return; sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager(); - OSL_ENSURE(pLinkManager, "no LinkManager on document?"); + assert(pLinkManager && "no LinkManager on document?"); const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); sal_uInt16 nCount = rLinks.size(); for (sal_uInt16 i=0; i<nCount; i++) @@ -957,7 +957,7 @@ const ScAreaLink* ScContentTree::GetLink( sal_uLong nIndex ) sal_uLong nFound = 0; sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager(); - OSL_ENSURE(pLinkManager, "no LinkManager on document?"); + assert(pLinkManager && "no LinkManager on document?"); const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); sal_uInt16 nCount = rLinks.size(); for (sal_uInt16 i=0; i<nCount; i++) diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx index e38035b2fca9..41209f0945a9 100644 --- a/sc/source/ui/uitest/uiobject.cxx +++ b/sc/source/ui/uitest/uiobject.cxx @@ -316,7 +316,7 @@ void ScGridWinUIObject::execute(const OUString& rAction, else if (rAction == "SIDEBAR") { SfxViewFrame* pViewFrm = SfxViewFrame::Current(); - DBG_ASSERT(pViewFrm, "ScGridWinUIObject::execute: no viewframe"); + assert(pViewFrm && "ScGridWinUIObject::execute: no viewframe"); pViewFrm->ShowChildWindow(SID_SIDEBAR); auto itr = rParameters.find("PANEL"); diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 33fe76b5baaa..534415b6a7b3 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -2169,7 +2169,7 @@ ScUndoClearItems::ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& aMarkData( rMark ), pUndoDoc( std::move(pNewUndoDoc) ) { - OSL_ENSURE( pW, "ScUndoClearItems: Which-Pointer is Null" ); + assert(pW && "ScUndoClearItems: Which-Pointer is Null"); sal_uInt16 nCount = 0; while ( pW[nCount] ) diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx index fce07d2b9697..496e35684c47 100644 --- a/sc/source/ui/unoobj/afmtuno.cxx +++ b/sc/source/ui/unoobj/afmtuno.cxx @@ -433,7 +433,7 @@ void SAL_CALL ScAutoFormatObj::setName( const OUString& aNewName ) ScAutoFormat::iterator it = pFormats->begin(); std::advance(it, nFormatIndex); ScAutoFormatData *const pData = it->second.get(); - OSL_ENSURE(pData,"AutoFormat data not available"); + assert(pData && "AutoFormat data not available"); std::unique_ptr<ScAutoFormatData> pNew(new ScAutoFormatData(*pData)); pNew->SetName( aNewName ); @@ -504,7 +504,7 @@ uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const OUString& aPropertyNa if (IsInserted() && nFormatIndex < pFormats->size()) { ScAutoFormatData* pData = pFormats->findByIndex(nFormatIndex); - OSL_ENSURE(pData,"AutoFormat data not available"); + assert(pData && "AutoFormat data not available"); bool bValue; bool bError = false; diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 026c0ec5f260..6fc19a9497b9 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -4633,6 +4633,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const // e.g. can you have an Operator without a Criteria? In LibreOffice it if ( Operator.hasValue() && ( Operator >>= nOperator ) ) { + assert(pTabFilts); // if it's a bottom/top Ten(Percent/Value) and there // is no value specified for criteria1 set it to 10 if ( !bCritHasNumericValue && sCriteria1.isEmpty() && ( nOperator != excel::XlAutoFilterOperator::xlOr ) && ( nOperator != excel::XlAutoFilterOperator::xlAnd ) ) @@ -4669,6 +4670,7 @@ ScVbaRange::AutoFilter( const uno::Any& aField, const uno::Any& Criteria1, const } if ( !bAll && bAcceptCriteria2 ) { + assert(pTabFilts); pTabFilts[0].Connection = sheet::FilterConnection_AND; pTabFilts[0].Field = (nField - 1); diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 91ff6d7ac935..e06d794888c0 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -223,7 +223,8 @@ void ScDrawView::SetMarkedToLayer( SdrLayerID nLayerNo ) for (size_t i=0; i<nCount; ++i) { SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); - if ( dynamic_cast<const SdrUnoObj*>( pObj) == nullptr && (pObj->GetLayer() != SC_LAYER_INTERN) ) + assert(pObj); + if ( dynamic_cast<const SdrUnoObj*>( pObj) == nullptr && (pObj->GetLayer() != SC_LAYER_INTERN) ) { AddUndo( std::make_unique<SdrUndoObjectLayerChange>( *pObj, pObj->GetLayer(), nLayerNo) ); pObj->SetLayer( nLayerNo ); @@ -446,6 +447,7 @@ void ScDrawView::MarkListHasChanged() for ( size_t j = 0; j < nListCount; ++j ) { SdrObject *pSubObj = pLst->GetObj( j ); + assert(pSubObj); if (dynamic_cast<const SdrUnoObj*>( pSubObj) == nullptr) bOnlyControls = false; diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx index 206b53843ed6..27d91eba03d5 100644 --- a/sc/source/ui/view/gridwin5.cxx +++ b/sc/source/ui/view/gridwin5.cxx @@ -177,7 +177,7 @@ bool ScGridWindow::ShowNoteMarker( SCCOL nPosX, SCROW nPosY, bool bKeyboard ) vcl::Window* pRight = bHSplit ? mrViewData.GetView()->GetWindowByPos( bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ) : nullptr; vcl::Window* pBottom = bVSplit ? mrViewData.GetView()->GetWindowByPos( SC_SPLIT_BOTTOMLEFT ) : nullptr; vcl::Window* pDiagonal = (bHSplit && bVSplit) ? mrViewData.GetView()->GetWindowByPos( SC_SPLIT_BOTTOMRIGHT ) : nullptr; - OSL_ENSURE( pLeft, "ScGridWindow::ShowNoteMarker - missing top-left grid window" ); + assert(pLeft && "ScGridWindow::ShowNoteMarker - missing top-left grid window"); /* If caption is shown from right or bottom windows, adjust mapmode to include size of top-left window. */ diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index d286c9ce5959..1e9bb41a2716 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1021,7 +1021,7 @@ bool ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY, static bool StringDiffer( const ScPatternAttr*& rpOldPattern, const ScPatternAttr* pNewPattern ) { - OSL_ENSURE( pNewPattern, "pNewPattern" ); + assert(pNewPattern && "pNewPattern"); if ( ScPatternAttr::areSame( pNewPattern, rpOldPattern ) ) return false; diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx index 40f63d36bdb8..4404dbe3b44b 100644 --- a/sc/source/ui/view/tabview5.cxx +++ b/sc/source/ui/view/tabview5.cxx @@ -675,7 +675,12 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote) return; const SdrCaptionObj* pCaption = pNote->GetCaption(); - if (!pCaption) return; + if (!pCaption) + return; + + SfxViewShell* pCurrentViewShell = SfxViewShell::Current(); + if (!pCurrentViewShell) + return; tools::Rectangle aRect = pCaption->GetLogicRect(); basegfx::B2DRange aTailRange = pCaption->getTailPolygon().getB2DRange(); @@ -694,7 +699,6 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote) aInvalidRect.AdjustTop( -nBorderSize ); aInvalidRect.AdjustBottom( nBorderSize ); - SfxViewShell* pCurrentViewShell = SfxViewShell::Current(); SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) { diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index f704256756fe..ac447af17f0a 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -56,7 +56,7 @@ using namespace com::sun::star; static void lcl_AdjustInsertPos( ScViewData& rData, Point& rPos, const Size& rSize ) { SdrPage* pPage = rData.GetScDrawView()->GetModel().GetPage( static_cast<sal_uInt16>(rData.GetTabNo()) ); - OSL_ENSURE(pPage,"pPage ???"); + assert(pPage && "pPage ???"); Size aPgSize( pPage->GetSize() ); if (aPgSize.Width() < 0) aPgSize.setWidth( -aPgSize.Width() ); diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index 80a67380e5ca..e7f4bf6595f9 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -216,7 +216,7 @@ std::unique_ptr<weld::TreeIter> getReferenceEntry(const weld::TreeView& rTree, c while (bParent) { ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(rTree, *xParent); - OSL_ASSERT(pUserData); + assert(pUserData); if (pUserData->meType == ScOrcusXMLTreeParam::ElementRepeat) { // This is a repeat element - a potential reference entry. @@ -246,7 +246,7 @@ void ScXMLSourceDlg::TreeItemSelected() mxCurRefEntry = getReferenceEntry(*mxLbTree, *xEntry); ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *mxCurRefEntry); - OSL_ASSERT(pUserData); + assert(pUserData); const ScAddress& rPos = pUserData->maLinkedPos; if (rPos.IsValid()) @@ -284,7 +284,7 @@ void ScXMLSourceDlg::DefaultElementSelected(const weld::TreeIter& rEntry) do { ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xChild); - OSL_ASSERT(pUserData); + assert(pUserData); if (pUserData->meType != ScOrcusXMLTreeParam::Attribute) { // This child is not an attribute. Bail out. @@ -351,7 +351,7 @@ void ScXMLSourceDlg::AttributeSelected(const weld::TreeIter& rEntry) mxLbTree->iter_parent(*xParent); ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xParent); - OSL_ASSERT(pUserData); + assert(pUserData); if (pUserData->maLinkedPos.IsValid() && pUserData->mbRangeParent) { // Parent element is range-linked. Bail out. @@ -423,7 +423,7 @@ bool ScXMLSourceDlg::IsChildrenDirty(const weld::TreeIter* pEntry) const do { ScOrcusXMLTreeParam::EntryData* pUserData = ScOrcusXMLTreeParam::getUserData(*mxLbTree, *xChild); - OSL_ASSERT(pUserData); + assert(pUserData); if (pUserData->maLinkedPos.IsValid()) // Already linked. return true; |