summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-12-16 12:11:38 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-12-16 21:17:15 +0000
commit1726c27e0d633ab04843834d2bf987bc7645807f (patch)
tree7810a18cd5bc3bf5aa345b816b372d93bd323974 /cui
parent1ae71d8f09771ba7180be6ebdf89d36a31eb8625 (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')
-rw-r--r--cui/source/dialogs/SignSignatureLineDialog.cxx8
-rw-r--r--cui/source/dialogs/srchxtra.cxx62
-rw-r--r--cui/source/dialogs/zoom.cxx8
-rw-r--r--cui/source/tabpages/autocdlg.cxx3
-rw-r--r--cui/source/tabpages/border.cxx3
-rw-r--r--cui/source/tabpages/chardlg.cxx7
-rw-r--r--cui/source/tabpages/numfmt.cxx8
-rw-r--r--cui/source/tabpages/numpages.cxx15
-rw-r--r--cui/source/tabpages/page.cxx3
-rw-r--r--cui/source/tabpages/paragrph.cxx6
10 files changed, 58 insertions, 65 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));
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index 2947c16e3730..2c978a835922 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -769,7 +769,8 @@ bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet* )
bool bKeepSourceFormatting = newEntry.pUserData == &bHasSelectionText;
if (bKeepSourceFormatting)
{
- pAutoCorrect->PutText(newEntry.sShort, *SfxObjectShell::Current(), eCurrentLang);
+ if (SfxObjectShell* pSh = SfxObjectShell::Current())
+ pAutoCorrect->PutText(newEntry.sShort, *pSh, eCurrentLang);
continue;
}
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 336e3f57bb26..9b94bc0eb28a 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -574,8 +574,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle
// checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
m_xMergeAdjacentBordersCB->hide();
- SfxObjectShell* pDocSh = SfxObjectShell::Current();
- if (pDocSh)
+ if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
if ( xSI.is() )
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 3d77e2a338fb..3fff1a62352a 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -344,10 +344,8 @@ const FontList* SvxCharNamePage::GetFontList() const
{
if ( !m_pImpl->m_pFontList )
{
- SfxObjectShell* pDocSh = SfxObjectShell::Current();
-
/* #110771# SvxFontListItem::GetFontList can return NULL */
- if ( pDocSh )
+ if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
if ( pItem != nullptr )
@@ -1366,8 +1364,7 @@ void SvxCharEffectsPage::Initialize()
const SfxUInt16Item* pHtmlModeItem = GetItemSet().GetItemIfSet( SID_HTML_MODE, false );
if ( !pHtmlModeItem)
{
- SfxObjectShell* pShell = SfxObjectShell::Current();
- if (pShell)
+ if (SfxObjectShell* pShell = SfxObjectShell::Current())
pHtmlModeItem = pShell->GetItem( SID_HTML_MODE );
}
if (pHtmlModeItem)
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 54b5b53d9aac..f48a3b60c95e 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -475,8 +475,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
bool bUseStarFormat = false;
- SfxObjectShell* pDocSh = SfxObjectShell::Current();
- if ( pDocSh )
+ if (SfxObjectShell* pDocSh = SfxObjectShell::Current())
{
// is this a calc document
Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY );
@@ -714,11 +713,8 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
else
{
SfxObjectShell* pDocSh = SfxObjectShell::Current();
-
DBG_ASSERT( pDocSh, "DocShell not found!" );
-
-
- if ( pDocSh )
+ if (pDocSh)
pDocSh->PutItem( *pNumItem );
}
}
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 57648fa612db..0c66f69ee637 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -645,11 +645,13 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void)
//search for the font
if(!pList)
{
- SfxObjectShell* pCurDocShell = SfxObjectShell::Current();
- const SvxFontListItem* pFontListItem =
- static_cast<const SvxFontListItem*>( pCurDocShell
- ->GetItem( SID_ATTR_CHAR_FONTLIST ));
- pList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
+ if (SfxObjectShell* pCurDocShell = SfxObjectShell::Current())
+ {
+ const SvxFontListItem* pFontListItem =
+ static_cast<const SvxFontListItem*>( pCurDocShell
+ ->GetItem( SID_ATTR_CHAR_FONTLIST ));
+ pList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
+ }
}
if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) )
{
@@ -1243,8 +1245,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
rSet->GetItemIfSet( SID_HTML_MODE, false );
if (!pHtmlModeItem)
{
- SfxObjectShell* pShell = SfxObjectShell::Current();
- if (pShell)
+ if (SfxObjectShell* pShell = SfxObjectShell::Current())
pHtmlModeItem = pShell->GetItem( SID_HTML_MODE );
}
if ( pHtmlModeItem )
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index bf57c645bd74..7af647f02d9b 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -199,8 +199,7 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController*
const SfxUInt16Item* pHtmlModeItem = rAttr.GetItemIfSet(SID_HTML_MODE, false);
if (!pHtmlModeItem)
{
- SfxObjectShell* pShell = SfxObjectShell::Current();
- if (pShell)
+ if (SfxObjectShell* pShell = SfxObjectShell::Current())
pHtmlModeItem = pShell->GetItem(SID_HTML_MODE);
}
if (pHtmlModeItem)
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index e9171a62dd04..ff6426b499aa 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -148,8 +148,7 @@ static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet)
const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
if (!pItem)
{
- SfxObjectShell* pShell = SfxObjectShell::Current();
- if (pShell)
+ if (SfxObjectShell* pShell = SfxObjectShell::Current())
pItem = pShell->GetItem(SID_HTML_MODE);
}
if(pItem)
@@ -1999,8 +1998,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia
m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl));
m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl));
- SfxObjectShell* pSh = SfxObjectShell::Current();
- if ( pSh )
+ if (SfxObjectShell* pSh = SfxObjectShell::Current())
{
SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool();
SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page);