summaryrefslogtreecommitdiff
path: root/sd/source/ui
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-05-31 12:31:47 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2024-06-28 13:42:16 +0200
commitbc5ee63d4bbb73b2f574e7002da4aa4b142b03ac (patch)
treee4ec04d125f42e916280b127a5b35ce958414581 /sd/source/ui
parentde732c870f04921803343578f0601aede389f00d (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>
Diffstat (limited to 'sd/source/ui')
-rw-r--r--sd/source/ui/app/sdmod1.cxx39
-rw-r--r--sd/source/ui/dlg/LayerTabBar.cxx53
-rw-r--r--sd/source/ui/dlg/sdtreelb.cxx9
-rw-r--r--sd/source/ui/func/fuinsert.cxx6
-rw-r--r--sd/source/ui/slideshow/slideshow.cxx8
-rw-r--r--sd/source/ui/slidesorter/controller/SlsSlotManager.cxx26
-rw-r--r--sd/source/ui/table/tablefunction.cxx15
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx4
-rw-r--r--sd/source/ui/view/ViewShellImplementation.cxx11
-rw-r--r--sd/source/ui/view/drviews5.cxx4
-rw-r--r--sd/source/ui/view/drviews7.cxx6
-rw-r--r--sd/source/ui/view/grviewsh.cxx4
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 31b286c822e3..c25f6cf4004c 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -713,7 +713,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 9e8e7b1aa5d4..8b0aaf33a870 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -957,7 +957,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 8583ecc182c7..8a69b13bf472 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() );