diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-02-16 10:42:06 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-02-16 15:13:21 +0000 |
commit | 0908c7c1184ab7acb7b6f6740a82c2f12c296fae (patch) | |
tree | 7bfe09dce871f6f2bc59a81b689d7ab5a3a6f3ea /desktop | |
parent | e71080e19365aa074c56d1136dad2b09783949a2 (diff) |
SfxViewShell::GetViewFrame never returns null, change to a reference
various null checks can be seen to be redundant and removed
Change-Id: Icf49c1de4b0302795d2769a370af3abceaad0221
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147147
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 22 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 6 |
2 files changed, 13 insertions, 15 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index a5560dd6be8d..6be2de622b1d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1216,7 +1216,7 @@ void DesktopLOKTest::testSheetDragDrop() Scheduler::ProcessEventsToIdle(); { SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); OUString sValue; css::uno::Any aValue; @@ -1228,7 +1228,7 @@ void DesktopLOKTest::testSheetDragDrop() aURL.Path = "Address"; aURL.Main = ".uno:Address"; - pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState); + rViewFrame.GetBindings().QueryState(rViewFrame.GetBindings().QuerySlotId(aURL), pState); pState->QueryValue(aValue); aValue >>= sValue; CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.A1:E1"), sValue); @@ -1272,7 +1272,7 @@ void DesktopLOKTest::testSheetDragDrop() Scheduler::ProcessEventsToIdle(); { SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); OUString sValue; css::uno::Any aValue; @@ -1284,7 +1284,7 @@ void DesktopLOKTest::testSheetDragDrop() aURL.Path = "Address"; aURL.Main = ".uno:Address"; - pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState); + rViewFrame.GetBindings().QueryState(rViewFrame.GetBindings().QuerySlotId(aURL), pState); pState->QueryValue(aValue); aValue >>= sValue; CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.D1:H1"), sValue); @@ -2040,7 +2040,7 @@ void DesktopLOKTest::testDialogInput() Scheduler::ProcessEventsToIdle(); SfxViewShell* pViewShell = SfxViewShell::Current(); - pViewShell->GetViewFrame()->GetBindings().Update(); + pViewShell->GetViewFrame().GetBindings().Update(); VclPtr<vcl::Window> pWindow(Application::GetActiveTopWindow()); CPPUNIT_ASSERT(pWindow); @@ -2970,7 +2970,7 @@ void DesktopLOKTest::testDialogPaste() Scheduler::ProcessEventsToIdle(); SfxViewShell* pViewShell = SfxViewShell::Current(); - pViewShell->GetViewFrame()->GetBindings().Update(); + pViewShell->GetViewFrame().GetBindings().Update(); VclPtr<vcl::Window> pWindow(Application::GetActiveTopWindow()); CPPUNIT_ASSERT(pWindow); @@ -3249,10 +3249,8 @@ namespace SfxViewShell* pViewShell = SfxViewShell::Current(); CPPUNIT_ASSERT(pViewShell); - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); - CPPUNIT_ASSERT(pViewFrame); - - SfxChildWindow* pSideBar = pViewFrame->GetChildWindow(SID_SIDEBAR); + SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); + SfxChildWindow* pSideBar = rViewFrame.GetChildWindow(SID_SIDEBAR); CPPUNIT_ASSERT(pSideBar); auto pDockingWin = dynamic_cast<sfx2::sidebar::SidebarDockingWindow *>(pSideBar->GetWindow()); @@ -3273,8 +3271,8 @@ void DesktopLOKTest::testControlState() boost::property_tree::ptree aState; SfxViewShell* pViewShell = SfxViewShell::Current(); - pViewShell->GetViewFrame()->GetBindings().Update(); - pViewShell->GetViewFrame()->GetBindings().QueryControlState(SID_ATTR_TRANSFORM_WIDTH, aState); + pViewShell->GetViewFrame().GetBindings().Update(); + pViewShell->GetViewFrame().GetBindings().QueryControlState(SID_ATTR_TRANSFORM_WIDTH, aState); CPPUNIT_ASSERT(!aState.empty()); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d0c67bda098f..ed601003d042 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -906,7 +906,7 @@ void ExecuteOrientationChange() void setupSidebar(std::u16string_view sidebarDeckId = u"") { SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = pViewShell ? pViewShell->GetViewFrame() : nullptr; + SfxViewFrame* pViewFrame = pViewShell ? &pViewShell->GetViewFrame() : nullptr; if (pViewFrame) { if (!pViewFrame->GetChildWindow(SID_SIDEBAR)) @@ -949,7 +949,7 @@ void setupSidebar(std::u16string_view sidebarDeckId = u"") void hideSidebar() { SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr; + SfxViewFrame* pViewFrame = pViewShell ? &pViewShell->GetViewFrame() : nullptr; if (pViewFrame) pViewFrame->SetChildWindow(SID_SIDEBAR, false , false ); else @@ -3422,7 +3422,7 @@ static void doc_iniUnoCommands () util::URL aCommandURL; SfxViewShell* pViewShell = SfxViewShell::Current(); - SfxViewFrame* pViewFrame = pViewShell? pViewShell->GetViewFrame(): nullptr; + SfxViewFrame* pViewFrame = pViewShell ? &pViewShell->GetViewFrame() : nullptr; // check if Frame-Controller were created. if (!pViewFrame) |