diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2024-05-31 12:31:47 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-06-29 19:00:56 +0200 |
commit | e6558e247c98c23fcba4c9b522409e859ee182d6 (patch) | |
tree | 22198fb5cf9b06cdb1bedda9e193e1a34beca3e8 | |
parent | 870e157582430319c603d04db8ceeccc7a3368e8 (diff) |
sd: use SAL_RET_MAYBENULL in GetViewFrame()
Change-Id: If895a550fb2404f1a7cfcc4fb427674a3f6e5fc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168287
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168367
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | sd/source/ui/app/sdmod1.cxx | 39 | ||||
-rw-r--r-- | sd/source/ui/dlg/LayerTabBar.cxx | 53 | ||||
-rw-r--r-- | sd/source/ui/dlg/sdtreelb.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshow.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/table/tablefunction.cxx | 15 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellBase.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellImplementation.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/view/drviews5.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drviews7.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/view/grviewsh.cxx | 4 |
12 files changed, 117 insertions, 68 deletions
diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx index 0d9e82f27802..6a7e0e86902c 100644 --- a/sd/source/ui/app/sdmod1.cxx +++ b/sd/source/ui/app/sdmod1.cxx @@ -277,26 +277,27 @@ bool SdModule::OutlineToImpress(SfxRequest const & rRequest) // AutoLayouts have to be finished pDoc->StopWorkStartupDelay(); - SfxViewFrame* pViewFrame = pViewSh->GetViewFrame(); - - // When the view frame has not been just created we have - // to switch synchronously to the outline view. - // (Otherwise the request will be ignored anyway.) - ::sd::ViewShellBase* pBase - = dynamic_cast< ::sd::ViewShellBase*>(pViewFrame->GetViewShell()); - if (pBase != nullptr) + if (SfxViewFrame* pViewFrame = pViewSh->GetViewFrame()) { - std::shared_ptr<FrameworkHelper> pHelper ( - FrameworkHelper::Instance(*pBase)); - pHelper->RequestView( - FrameworkHelper::msOutlineViewURL, - FrameworkHelper::msCenterPaneURL); - - pHelper->RunOnResourceActivation( - FrameworkHelper::CreateResourceId( - FrameworkHelper::msOutlineViewURL, - FrameworkHelper::msCenterPaneURL), - OutlineToImpressFinalizer(*pBase, *pDoc, *pBytes)); + // When the view frame has not been just created we have + // to switch synchronously to the outline view. + // (Otherwise the request will be ignored anyway.) + ::sd::ViewShellBase* pBase + = dynamic_cast< ::sd::ViewShellBase*>(pViewFrame->GetViewShell()); + if (pBase != nullptr) + { + std::shared_ptr<FrameworkHelper> pHelper ( + FrameworkHelper::Instance(*pBase)); + pHelper->RequestView( + FrameworkHelper::msOutlineViewURL, + FrameworkHelper::msCenterPaneURL); + + pHelper->RunOnResourceActivation( + FrameworkHelper::CreateResourceId( + FrameworkHelper::msOutlineViewURL, + FrameworkHelper::msCenterPaneURL), + OutlineToImpressFinalizer(*pBase, *pDoc, *pBytes)); + } } } } diff --git a/sd/source/ui/dlg/LayerTabBar.cxx b/sd/source/ui/dlg/LayerTabBar.cxx index 96b96068f331..a2ef2001af43 100644 --- a/sd/source/ui/dlg/LayerTabBar.cxx +++ b/sd/source/ui/dlg/LayerTabBar.cxx @@ -133,8 +133,11 @@ bool LayerTabBar::IsRealNameOfStandardLayer(std::u16string_view rName) void LayerTabBar::Select() { - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->Execute(SID_SWITCHLAYER, SfxCallMode::SYNCHRON); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->Execute(SID_SWITCHLAYER, SfxCallMode::SYNCHRON); + } } void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt) @@ -147,10 +150,13 @@ void LayerTabBar::MouseButtonDown(const MouseEvent& rMEvt) sal_uInt16 aTabId = GetPageId( PixelToLogic(aPosPixel) ); if (aTabId == 0) { - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->Execute(SID_INSERTLAYER, SfxCallMode::SYNCHRON); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->Execute(SID_INSERTLAYER, SfxCallMode::SYNCHRON); - bSetPageID=true; + bSetPageID=true; + } } else if (rMEvt.IsMod2()) { @@ -251,8 +257,11 @@ void LayerTabBar::DoubleClick() { if (GetCurPageId() != 0) { - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->Execute( SID_MODIFYLAYER, SfxCallMode::SYNCHRON ); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->Execute( SID_MODIFYLAYER, SfxCallMode::SYNCHRON ); + } } } @@ -302,8 +311,11 @@ void LayerTabBar::Command(const CommandEvent& rCEvt) { if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) { - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->ExecutePopup("layertab"); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->ExecutePopup("layertab"); + } } } @@ -344,12 +356,15 @@ TabBarAllowRenamingReturnCode LayerTabBar::AllowRenaming() if (aNewName.isEmpty() || (rLayerAdmin.GetLayer( aNewName ) && aLayerName != aNewName) ) { - // Name already exists. - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pDrViewSh->GetViewFrame()->GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, - SdResId(STR_WARN_NAME_DUPLICATE))); - xWarn->run(); - bOK = false; + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + // Name already exists. + std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pFrame->GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, + SdResId(STR_WARN_NAME_DUPLICATE))); + xWarn->run(); + bOK = false; + } } if (bOK) @@ -415,9 +430,11 @@ void LayerTabBar::ActivatePage() { if (pDrViewSh!=nullptr) { - - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->Execute(SID_SWITCHLAYER, SfxCallMode::ASYNCHRON); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->Execute(SID_SWITCHLAYER, SfxCallMode::ASYNCHRON); + } } } diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx index bb631b06e546..ecf2e612051a 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -1099,9 +1099,12 @@ void SdPageObjsTLV::SetViewFrame(const SfxViewFrame* pViewFrame) { if (sd::ViewShellBase* pBase = sd::ViewShellBase::GetViewShellBase(pViewFrame)) { - std::shared_ptr<sd::ViewShell> xViewShell = pBase->GetMainViewShell(); - SAL_WARN_IF(!xViewShell, "sd", "null pBaseViewFrame"); - const css::uno::Reference< css::frame::XFrame > xFrame = xViewShell ? xViewShell->GetViewFrame()->GetFrame().GetFrameInterface() : nullptr; + css::uno::Reference< css::frame::XFrame > xFrame; + if (std::shared_ptr<sd::ViewShell> xViewShell = pBase->GetMainViewShell()) + { + if (SfxViewFrame* pFrame = xViewShell->GetViewFrame()) + xFrame = pFrame->GetFrame().GetFrameInterface(); + } m_xAccel->init(::comphelper::getProcessComponentContext(), xFrame); } } diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index e8409c815b25..eda51467a8f3 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -725,7 +725,11 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq ) if( mpWindow ) mpWindow->EnterWait(); - css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(mpViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY); + SfxViewFrame* pFrame = mpViewShell->GetViewFrame(); + if (!pFrame) + return; + + css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(pFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY); rtl::Reference<avmedia::PlayerListener> xPlayerListener(new avmedia::PlayerListener( [xDispatchProvider, aURL, bLink](const css::uno::Reference<css::media::XPlayer>& rPlayer){ diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index 1c21ef7ee08a..f45c374d4fe9 100644 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -615,10 +615,14 @@ WorkWindow *SlideShow::GetWorkWindow() PresentationViewShell* pShell = dynamic_cast<PresentationViewShell*>(mpFullScreenViewShellBase->GetMainViewShell().get()); - if( !pShell || !pShell->GetViewFrame() ) + if( !pShell) return nullptr; - return dynamic_cast<WorkWindow*>(pShell->GetViewFrame()->GetFrame().GetWindow().GetParent()); + SfxViewFrame* pFrame = pShell->GetViewFrame(); + if (!pFrame) + return nullptr; + + return dynamic_cast<WorkWindow*>(pFrame->GetFrame().GetWindow().GetParent()); } bool SlideShow::IsExitAfterPresenting() const diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 0a713c06da8f..3d1d822ee24d 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -175,22 +175,28 @@ void SlotManager::FuTemporary (SfxRequest& rRequest) case SID_SLIDE_TRANSITIONS_PANEL: { // First make sure that the sidebar is visible - pShell->GetViewFrame()->ShowChildWindow(SID_SIDEBAR); - ::sfx2::sidebar::Sidebar::ShowPanel( - u"SdSlideTransitionPanel", - pShell->GetViewFrame()->GetFrame().GetFrameInterface()); - rRequest.Ignore (); + if (SfxViewFrame* pFrame = pShell->GetViewFrame()) + { + pFrame->ShowChildWindow(SID_SIDEBAR); + ::sfx2::sidebar::Sidebar::ShowPanel( + u"SdSlideTransitionPanel", + pFrame->GetFrame().GetFrameInterface()); + rRequest.Ignore (); + } break; } case SID_MASTER_SLIDES_PANEL: { // First make sure that the sidebar is visible - pShell->GetViewFrame()->ShowChildWindow(SID_SIDEBAR); - ::sfx2::sidebar::Sidebar::ShowPanel( - u"SdAllMasterPagesPanel", - pShell->GetViewFrame()->GetFrame().GetFrameInterface()); - rRequest.Ignore (); + if (SfxViewFrame* pFrame = pShell->GetViewFrame()) + { + pFrame->ShowChildWindow(SID_SIDEBAR); + ::sfx2::sidebar::Sidebar::ShowPanel( + u"SdAllMasterPagesPanel", + pFrame->GetFrame().GetFrameInterface()); + rRequest.Ignore (); + } break; } diff --git a/sd/source/ui/table/tablefunction.cxx b/sd/source/ui/table/tablefunction.cxx index 67196e864b39..99552d149f50 100644 --- a/sd/source/ui/table/tablefunction.cxx +++ b/sd/source/ui/table/tablefunction.cxx @@ -234,13 +234,16 @@ void DrawViewShell::FuTable(SfxRequest& rReq) case SID_TABLEDESIGN: { // First make sure that the sidebar is visible - GetViewFrame()->ShowChildWindow(SID_SIDEBAR); - ::sfx2::sidebar::Sidebar::TogglePanel( - u"SdTableDesignPanel", - GetViewFrame()->GetFrame().GetFrameInterface()); + if (SfxViewFrame* pViewFrame = GetViewFrame()) + { + pViewFrame->ShowChildWindow(SID_SIDEBAR); + ::sfx2::sidebar::Sidebar::TogglePanel( + u"SdTableDesignPanel", + pViewFrame->GetFrame().GetFrameInterface()); - Cancel(); - rReq.Done (); + Cancel(); + rReq.Done (); + } break; } default: diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 5f7f3137cde9..f2ddb55b66d8 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -965,7 +965,9 @@ vcl::Window* ViewShellBase::GetViewWindow() OUString ViewShellBase::RetrieveLabelFromCommand( const OUString& aCmdURL ) const { - OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface())); + OUString aModuleName; + if (SfxViewFrame* pViewFrame = GetMainViewShell()->GetViewFrame()) + aModuleName = vcl::CommandInfoProvider::GetModuleIdentifier(pViewFrame->GetFrame().GetFrameInterface()); auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(aCmdURL, aModuleName); return vcl::CommandInfoProvider::GetLabelForCommand(aProperties); } diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx index c76de5a513b6..f97268dc7a5f 100644 --- a/sd/source/ui/view/ViewShellImplementation.cxx +++ b/sd/source/ui/view/ViewShellImplementation.cxx @@ -110,10 +110,13 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( // First make sure that the sidebar is visible mrViewShell.GetDrawView()->SdrEndTextEdit(); mrViewShell.GetDrawView()->UnmarkAll(); - mrViewShell.GetViewFrame()->ShowChildWindow(SID_SIDEBAR); - sfx2::sidebar::Sidebar::TogglePanel( - u"SdLayoutsPanel", - mrViewShell.GetViewFrame()->GetFrame().GetFrameInterface()); + if (SfxViewFrame* pViewFrame = mrViewShell.GetViewFrame()) + { + pViewFrame->ShowChildWindow(SID_SIDEBAR); + sfx2::sidebar::Sidebar::TogglePanel( + u"SdLayoutsPanel", + pViewFrame->GetFrame().GetFrameInterface()); + } break; } else if (pArgs->Count() == 4) diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx index fa744fe49bcd..7c6315926c77 100644 --- a/sd/source/ui/view/drviews5.cxx +++ b/sd/source/ui/view/drviews5.cxx @@ -114,7 +114,9 @@ void DrawViewShell::ArrangeGUIElements() if ( pIPClient && pIPClient->IsObjectInPlaceActive() ) bClientActive = true; - bool bInPlaceActive = GetViewFrame()->GetFrame().IsInPlace(); + bool bInPlaceActive = false; + if (SfxViewFrame* pViewFrame = GetViewFrame()) + bInPlaceActive = pViewFrame->GetFrame().IsInPlace(); if ( mbZoomOnPage && !bInPlaceActive && !bClientActive ) { diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index 845bc956ed1b..fe47f9095616 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1644,9 +1644,11 @@ void DrawViewShell::GetModeSwitchingMenuState (SfxItemSet &rSet) // view mode is allowed. const bool bIsRunning = SlideShow::IsRunning(GetViewShellBase()); - if (GetViewFrame()->GetFrame().IsInPlace() || bIsRunning) + SfxViewFrame* pViewFrame = GetViewFrame(); + const bool bIsInPlace = pViewFrame && pViewFrame->GetFrame().IsInPlace() ? true : false; + if (bIsInPlace || bIsRunning) { - if ( !GetViewFrame()->GetFrame().IsInPlace() ) + if (!bIsInPlace) { rSet.ClearItem( SID_DRAWINGMODE ); rSet.DisableItem( SID_DRAWINGMODE ); diff --git a/sd/source/ui/view/grviewsh.cxx b/sd/source/ui/view/grviewsh.cxx index b914b2da8cbd..92794299238c 100644 --- a/sd/source/ui/view/grviewsh.cxx +++ b/sd/source/ui/view/grviewsh.cxx @@ -70,7 +70,9 @@ void GraphicViewShell::ArrangeGUIElements() if (mpLayerTabBar && mpLayerTabBar->IsVisible()) { Size aSize = mpLayerTabBar->GetSizePixel(); - const Size aFrameSize (GetViewFrame()->GetWindow().GetOutputSizePixel()); + Size aFrameSize; + if (SfxViewFrame* pViewFrame = GetViewFrame()) + aFrameSize = pViewFrame->GetWindow().GetOutputSizePixel(); aSize.setHeight(GetParentWindow()->GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN); aSize.setWidth( aFrameSize.Width() ); |