sd/source/ui/app/sdmod1.cxx | 39 ++++++------ sd/source/ui/dlg/LayerTabBar.cxx | 53 +++++++++++------ sd/source/ui/dlg/sdtreelb.cxx | 9 +- sd/source/ui/func/fuinsert.cxx | 6 + sd/source/ui/inc/ViewShell.hxx | 2 sd/source/ui/slideshow/slideshow.cxx | 8 +- sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 26 +++++--- sd/source/ui/table/tablefunction.cxx | 15 ++-- sd/source/ui/view/ViewShellBase.cxx | 4 - sd/source/ui/view/ViewShellImplementation.cxx | 11 ++- sd/source/ui/view/drviews5.cxx | 4 - sd/source/ui/view/drviews7.cxx | 6 + sd/source/ui/view/grviewsh.cxx | 4 - 13 files changed, 118 insertions(+), 69 deletions(-)
New commits: commit d7311b4f1ff824c74e9cef6cf12454115e5ccc0b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri May 31 12:31:47 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Jun 3 13:23:22 2024 +0200 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 <xiscofa...@libreoffice.org> diff --git a/sd/source/ui/app/sdmod1.cxx b/sd/source/ui/app/sdmod1.cxx index 023e44a7c1e6..ea2b09e3f285 100644 --- a/sd/source/ui/app/sdmod1.cxx +++ b/sd/source/ui/app/sdmod1.cxx @@ -294,26 +294,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 324a9bd36ad9..aba77bd9501c 100644 --- a/sd/source/ui/dlg/LayerTabBar.cxx +++ b/sd/source/ui/dlg/LayerTabBar.cxx @@ -144,8 +144,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::MouseMove(const MouseEvent &rMEvt) @@ -244,10 +247,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()) { @@ -348,8 +354,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 ); + } } } @@ -400,8 +409,11 @@ void LayerTabBar::Command(const CommandEvent& rCEvt) if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) { BringLayerObjectsToAttention(); - SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher(); - pDispatcher->ExecutePopup(u"layertab"_ustr); + if (SfxViewFrame* pFrame = pDrViewSh->GetViewFrame()) + { + SfxDispatcher* pDispatcher = pFrame->GetDispatcher(); + pDispatcher->ExecutePopup(u"layertab"_ustr); + } } } @@ -442,12 +454,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) @@ -513,9 +528,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 f569febe0a2f..7eb476cfb48b 100644 --- a/sd/source/ui/dlg/sdtreelb.cxx +++ b/sd/source/ui/dlg/sdtreelb.cxx @@ -1122,9 +1122,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 55dfa5cf105d..693ae65f14c4 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/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index 9e5e8e068160..b848593458a6 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -148,7 +148,7 @@ public: SdDrawDocument* GetDoc() const; - SD_DLLPUBLIC SfxViewFrame* GetViewFrame() const; + SAL_RET_MAYBENULL SD_DLLPUBLIC SfxViewFrame* GetViewFrame() const; /** The active window is usually the mpContentWindow. When there is a show running then the active window is a ShowWindow. diff --git a/sd/source/ui/slideshow/slideshow.cxx b/sd/source/ui/slideshow/slideshow.cxx index f7c6cd0f0915..047fa95c27f9 100644 --- a/sd/source/ui/slideshow/slideshow.cxx +++ b/sd/source/ui/slideshow/slideshow.cxx @@ -638,10 +638,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 f71244c1baef..de8f18c8aac2 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -174,22 +174,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 9c2a0db99f51..6f886c1becec 100644 --- a/sd/source/ui/table/tablefunction.cxx +++ b/sd/source/ui/table/tablefunction.cxx @@ -229,13 +229,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 3672f5655bf6..efefb6287288 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -974,7 +974,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 b894d4e48ee8..b84ff8643ffc 100644 --- a/sd/source/ui/view/ViewShellImplementation.cxx +++ b/sd/source/ui/view/ViewShellImplementation.cxx @@ -107,10 +107,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 d1d9db893dc3..3488bc9bc6ff 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 2abe7214a794..9e1e676427a5 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -1648,9 +1648,11 @@ void DrawViewShell::GetModeSwitchingMenuState (SfxItemSet &rSet) const bool bIsRunning = SlideShow::IsRunning(GetViewShellBase()) && !SlideShow::IsInteractiveSlideshow(&GetViewShellBase()); // IASS - 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() );