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-17 14:41:39 +0000 |
commit | 8e807647c266ea0ebf4c10ed61187690cfd65f52 (patch) | |
tree | 2c8b76be890f9746d6dfdf447113c24a9f343acb /svx | |
parent | 6aaf07b58253874c4e0c85d4d2c5399b3fa2a71d (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/+/144355
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/ClassificationDialog.cxx | 7 | ||||
-rw-r--r-- | svx/source/form/datanavi.cxx | 2 | ||||
-rw-r--r-- | svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 75 | ||||
-rw-r--r-- | svx/source/sidebar/nbdtmg.cxx | 8 | ||||
-rw-r--r-- | svx/source/tbxctrls/fillctrl.cxx | 27 | ||||
-rw-r--r-- | svx/source/tbxctrls/linectrl.cxx | 8 |
6 files changed, 71 insertions, 56 deletions
diff --git a/svx/source/dialog/ClassificationDialog.cxx b/svx/source/dialog/ClassificationDialog.cxx index e815f995aa56..8a6c26edda24 100644 --- a/svx/source/dialog/ClassificationDialog.cxx +++ b/svx/source/dialog/ClassificationDialog.cxx @@ -155,10 +155,11 @@ void writeResultToXml(tools::XmlWriter & rXmlWriter, } // end anonymous namespace -ClassificationDialog::ClassificationDialog(weld::Window* pParent, const bool bPerParagraph, std::function<void()> aParagraphSignHandler) +ClassificationDialog::ClassificationDialog(weld::Window* pParent, const css::uno::Reference<css::document::XDocumentProperties>& rDocProps, + const bool bPerParagraph, std::function<void()> aParagraphSignHandler) : GenericDialogController(pParent, "svx/ui/classificationdialog.ui", "AdvancedDocumentClassificationDialog") - , maHelper(SfxObjectShell::Current()->getDocProperties()) - , maInternationalHelper(SfxObjectShell::Current()->getDocProperties(), /*bUseLocalizedPolicy*/ false) + , maHelper(rDocProps) + , maInternationalHelper(rDocProps, /*bUseLocalizedPolicy*/ false) , m_bPerParagraph(bPerParagraph) , m_aParagraphSignHandler(std::move(aParagraphSignHandler)) , m_nCurrentSelectedCategory(-1) diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx index 5592ad8002a4..210ebdce3b22 100644 --- a/svx/source/form/datanavi.cxx +++ b/svx/source/form/datanavi.cxx @@ -1926,7 +1926,7 @@ namespace svxform { SfxObjectShell* pCurrentDoc = SfxObjectShell::Current(); DBG_ASSERT( pCurrentDoc, "DataNavigatorWindow::SetDocModified(): no objectshell" ); - if ( !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified() ) + if (pCurrentDoc && !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified()) pCurrentDoc->SetModified(); } diff --git a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx index b11f61d775eb..996026d1fa6c 100644 --- a/svx/source/sidebar/area/AreaPropertyPanelBase.cxx +++ b/svx/source/sidebar/area/AreaPropertyPanelBase.cxx @@ -203,31 +203,39 @@ IMPL_LINK_NOARG(AreaPropertyPanelBase, ClickImportBitmapHdl, weld::Button&, void if( nError != ERRCODE_NONE ) return; - XBitmapListRef pList = SfxObjectShell::Current()->GetItem(SID_BITMAP_LIST)->GetBitmapList(); - INetURLObject aURL( aDlg.GetPath() ); - OUString aFileName = aURL.GetLastName().getToken(0, '.'); - OUString aName = aFileName; - tools::Long j = 1; - bool bValidBitmapName = false; - while( !bValidBitmapName ) + mxLbFillAttr->clear(); + + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { - bValidBitmapName = true; - for( tools::Long i = 0; i < pList->Count() && bValidBitmapName; i++ ) + INetURLObject aURL(aDlg.GetPath()); + OUString aFileName = aURL.GetLastName().getToken(0, '.'); + OUString aName = aFileName; + + XBitmapListRef pList = pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList(); + + tools::Long j = 1; + bool bValidBitmapName = false; + while( !bValidBitmapName ) { - if( aName == pList->GetBitmap(i)->GetName() ) + bValidBitmapName = true; + for( tools::Long i = 0; i < pList->Count() && bValidBitmapName; i++ ) { - bValidBitmapName = false; - aName = aFileName + OUString::number(j++); + if( aName == pList->GetBitmap(i)->GetName() ) + { + bValidBitmapName = false; + aName = aFileName + OUString::number(j++); + } } } - } - pList->Insert(std::make_unique<XBitmapEntry>(aGraphic, aName)); - pList->Save(); - mxLbFillAttr->clear(); - SvxFillAttrBox::Fill(*mxLbFillAttr, pList); - mxLbFillAttr->set_active_text(aName); - SelectFillAttrHdl(*mxLbFillAttr); + pList->Insert(std::make_unique<XBitmapEntry>(aGraphic, aName)); + pList->Save(); + + SvxFillAttrBox::Fill(*mxLbFillAttr, pList); + + mxLbFillAttr->set_active_text(aName); + SelectFillAttrHdl(*mxLbFillAttr); + } } IMPL_LINK_NOARG(AreaPropertyPanelBase, SelectFillTypeHdl, weld::ComboBox&, void) @@ -285,7 +293,7 @@ void AreaPropertyPanelBase::SelectFillAttrHdl_Impl() case eFillStyle::GRADIENT: { - if(pSh && pSh->GetItem(SID_COLOR_TABLE)) + if (pSh && pSh->GetItem(SID_COLOR_TABLE)) { XGradient aGradient; aGradient.SetAngle(Degree10(mxMTRAngle->get_value(FieldUnit::DEGREE) * 10)); @@ -1097,10 +1105,12 @@ void AreaPropertyPanelBase::NotifyItemUpdate( { const OUString aString( mpFillGradientItem->GetName() ); const SfxObjectShell* pSh = SfxObjectShell::Current(); - mxLbFillAttr->clear(); - mxLbFillAttr->set_sensitive(true); - SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + if (pSh) + { + mxLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + } mxLbFillAttr->set_active_text(aString); } else @@ -1121,10 +1131,12 @@ void AreaPropertyPanelBase::NotifyItemUpdate( { const OUString aString( mpHatchItem->GetName() ); const SfxObjectShell* pSh = SfxObjectShell::Current(); - mxLbFillAttr->clear(); - mxLbFillAttr->set_sensitive(true); - SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + if (pSh) + { + mxLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + } mxLbFillAttr->set_active_text(aString); } else @@ -1148,13 +1160,12 @@ void AreaPropertyPanelBase::NotifyItemUpdate( const SfxObjectShell* pSh = SfxObjectShell::Current(); mxLbFillAttr->clear(); mxLbFillAttr->show(); - if(nSID == SID_BITMAP_LIST) - { - SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); - } - else if(nSID == SID_PATTERN_LIST) + if (pSh) { - SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_PATTERN_LIST)->GetPatternList()); + if(nSID == SID_BITMAP_LIST) + SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + else if(nSID == SID_PATTERN_LIST) + SvxFillAttrBox::Fill(*mxLbFillAttr, pSh->GetItem(SID_PATTERN_LIST)->GetPatternList()); } mxLbFillAttr->set_active_text(aString); } diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx index 55557eb0ff17..241b91673836 100644 --- a/svx/source/sidebar/nbdtmg.cxx +++ b/svx/source/sidebar/nbdtmg.cxx @@ -786,9 +786,11 @@ void OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1 //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 ) ) { diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx index 980c0f819e71..cfb7583be12c 100644 --- a/svx/source/tbxctrls/fillctrl.cxx +++ b/svx/source/tbxctrls/fillctrl.cxx @@ -275,11 +275,12 @@ void SvxFillToolBoxControl::StateChangedAtToolBoxControl( if(mpFillGradientItem) { const OUString aString( mpFillGradientItem->GetName() ); - const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->clear(); - mpLbFillAttr->set_sensitive(true); - SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + if (const SfxObjectShell* pSh = SfxObjectShell::Current()) + { + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_GRADIENT_LIST)->GetGradientList()); + } mpLbFillAttr->set_active_text(aString); } else @@ -299,11 +300,12 @@ void SvxFillToolBoxControl::StateChangedAtToolBoxControl( if(mpHatchItem) { const OUString aString( mpHatchItem->GetName() ); - const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->clear(); - mpLbFillAttr->set_sensitive(true); - SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + if (const SfxObjectShell* pSh = SfxObjectShell::Current()) + { + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_HATCH_LIST)->GetHatchList()); + } mpLbFillAttr->set_active_text(aString); } else @@ -323,11 +325,12 @@ void SvxFillToolBoxControl::StateChangedAtToolBoxControl( if(mpBitmapItem) { const OUString aString( mpBitmapItem->GetName() ); - const SfxObjectShell* pSh = SfxObjectShell::Current(); - mpLbFillAttr->clear(); - mpLbFillAttr->set_sensitive(true); - SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + if (const SfxObjectShell* pSh = SfxObjectShell::Current()) + { + mpLbFillAttr->set_sensitive(true); + SvxFillAttrBox::Fill(*mpLbFillAttr, pSh->GetItem(SID_BITMAP_LIST)->GetBitmapList()); + } mpLbFillAttr->set_active_text(aString); } else diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx index 81f064fc78f4..9fcaeb22b919 100644 --- a/svx/source/tbxctrls/linectrl.cxx +++ b/svx/source/tbxctrls/linectrl.cxx @@ -599,14 +599,12 @@ IMPL_LINK_NOARG(SvxLineBox, SelectHdl, ValueSet*, void) default: { eXLS = drawing::LineStyle_DASH; - - if ( nPos != -1 && - SfxObjectShell::Current() && - SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) + const SfxObjectShell* pObjSh = SfxObjectShell::Current(); + if (nPos != -1 && pObjSh && pObjSh->GetItem(SID_DASH_LIST)) { // LineDashItem will only be sent if it also has a dash. // Notify cares! - SvxDashListItem const * pItem = SfxObjectShell::Current()->GetItem( SID_DASH_LIST ); + SvxDashListItem const * pItem = pObjSh->GetItem( SID_DASH_LIST ); const XDashEntry* pEntry = pItem->GetDashList()->GetDash(nPos - 2); XLineDashItem aLineDashItem(pEntry->GetName(), pEntry->GetDash()); |