diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-16 12:11:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-16 21:17:15 +0000 |
commit | 1726c27e0d633ab04843834d2bf987bc7645807f (patch) | |
tree | 7810a18cd5bc3bf5aa345b816b372d93bd323974 /cui/source/dialogs | |
parent | 1ae71d8f09771ba7180be6ebdf89d36a31eb8625 (diff) |
check SfxObjectShell::Current()
SfxObjectShell::Current() can return null, it's based on the equally
vile SfxViewFrame::Current()
Change-Id: Ia5c7783680e9d8e5d3075078f16a2c15cb6f7a47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144339
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui/source/dialogs')
-rw-r--r-- | cui/source/dialogs/SignSignatureLineDialog.cxx | 8 | ||||
-rw-r--r-- | cui/source/dialogs/srchxtra.cxx | 62 | ||||
-rw-r--r-- | cui/source/dialogs/zoom.cxx | 8 |
3 files changed, 40 insertions, 38 deletions
diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 1f1bd4551080..94306764b201 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -156,7 +156,7 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, chooseCertificate, weld::Button&, void) { // Document needs to be saved before selecting a certificate SfxObjectShell* pShell = SfxObjectShell::Current(); - if (!pShell->PrepareForSigning(m_xDialog.get())) + if (!pShell || !pShell->PrepareForSigning(m_xDialog.get())) return; Reference<XCertificate> xSignCertificate @@ -193,6 +193,12 @@ void SignSignatureLineDialog::Apply() } SfxObjectShell* pShell = SfxObjectShell::Current(); + if (!pShell) + { + SAL_WARN("cui.dialogs", "No SfxObjectShell!"); + return; + } + Reference<XGraphic> xValidGraphic = getSignedGraphic(true); Reference<XGraphic> xInvalidGraphic = getSignedGraphic(false); pShell->SignSignatureLine(m_xDialog.get(), m_aSignatureLineId, m_xSelectedCertifate, diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index d857f77c42df..40c2e369ab6b 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -64,9 +64,7 @@ void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) if (rId == "font") { const FontList* pApm_pFontList = nullptr; - SfxObjectShell* pSh = SfxObjectShell::Current(); - - if ( pSh ) + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>( pSh->GetItem( SID_ATTR_CHAR_FONTLIST )); @@ -119,42 +117,44 @@ SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent, SfxObjectShell* pSh = SfxObjectShell::Current(); DBG_ASSERT( pSh, "No DocShell" ); - - SfxItemPool& rPool = pSh->GetPool(); - SfxItemSet aSet( rPool, pWhRanges ); - SfxWhichIter aIter( aSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); - - while ( nWhich ) + if (pSh) { - sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); - if ( nSlot >= SID_SVX_START ) + SfxItemPool& rPool = pSh->GetPool(); + SfxItemSet aSet( rPool, pWhRanges ); + SfxWhichIter aIter( aSet ); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while ( nWhich ) { - bool bChecked = false, bFound = false; - for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) + sal_uInt16 nSlot = rPool.GetSlotId( nWhich ); + if ( nSlot >= SID_SVX_START ) { - if ( nSlot == rList[i].nSlot ) + bool bChecked = false, bFound = false; + for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i ) { - bFound = true; - if ( IsInvalidItem( rList[i].pItem ) ) - bChecked = true; + if ( nSlot == rList[i].nSlot ) + { + bFound = true; + if ( IsInvalidItem( rList[i].pItem ) ) + bChecked = true; + } } - } - // item resources are in svx - sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); - if (RESARRAY_INDEX_NOTFOUND != nId) - { - m_xAttrLB->append(); - const int nRow = m_xAttrLB->n_children() - 1; - m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); - m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + // item resources are in svx + sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); + if (RESARRAY_INDEX_NOTFOUND != nId) + { + m_xAttrLB->append(); + const int nRow = m_xAttrLB->n_children() - 1; + m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0); + m_xAttrLB->set_id(nRow, OUString::number(nSlot)); + } + else + SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); } - else - SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); + nWhich = aIter.NextWhich(); } - nWhich = aIter.NextWhich(); } m_xAttrLB->make_sorted(); diff --git a/cui/source/dialogs/zoom.cxx b/cui/source/dialogs/zoom.cxx index 0c9b189dd0f1..0d6f44e405fd 100644 --- a/cui/source/dialogs/zoom.cxx +++ b/cui/source/dialogs/zoom.cxx @@ -168,9 +168,7 @@ SvxZoomDialog::SvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) // maybe get the old value first const SfxUInt16Item* pOldUserItem = nullptr; - SfxObjectShell* pShell = SfxObjectShell::Current(); - - if (pShell) + if (SfxObjectShell* pShell = SfxObjectShell::Current()) pOldUserItem = pShell->GetItem(SID_ATTR_ZOOM_USER); if (pOldUserItem) @@ -384,9 +382,7 @@ IMPL_LINK_NOARG(SvxZoomDialog, OKHdl, weld::Button&, void) m_pOutSet->Put(aViewLayoutItem); // memorize value from the UserEdit beyond the dialog - SfxObjectShell* pShell = SfxObjectShell::Current(); - - if (pShell) + if (SfxObjectShell* pShell = SfxObjectShell::Current()) { sal_uInt16 nZoomValue = static_cast<sal_uInt16>(m_xUserEdit->get_value(FieldUnit::PERCENT)); |