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 /basctl | |
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 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.cxx | 6 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 4 | ||||
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/basides1.cxx | 33 | ||||
-rw-r--r-- | basctl/source/basicide/basides2.cxx | 13 | ||||
-rw-r--r-- | basctl/source/basicide/basides3.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/basidesh.cxx | 17 | ||||
-rw-r--r-- | basctl/source/basicide/basobj3.cxx | 14 | ||||
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 4 | ||||
-rw-r--r-- | basctl/source/basicide/localizationmgr.cxx | 2 | ||||
-rw-r--r-- | basctl/source/basicide/moduldl2.cxx | 8 |
11 files changed, 51 insertions, 54 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 60f0ccaa4332..ad1dd3682b22 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -282,7 +282,7 @@ void ModulWindow::CheckCompileBasic() bool bDone = false; - GetShell()->GetViewFrame()->GetWindow().EnterWait(); + GetShell()->GetViewFrame().GetWindow().EnterWait(); AssertValidEditEngine(); GetEditorWindow().SetSourceInBasic(); @@ -302,7 +302,7 @@ void ModulWindow::CheckCompileBasic() GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() ); } - GetShell()->GetViewFrame()->GetWindow().LeaveWait(); + GetShell()->GetViewFrame().GetWindow().LeaveWait(); m_aStatus.bError = !bDone; m_aStatus.bIsRunning = false; @@ -612,7 +612,7 @@ void ModulWindow::ManageBreakPoints() void ModulWindow::BasicErrorHdl( StarBASIC const * pBasic ) { - GetShell()->GetViewFrame()->ToTop(); + GetShell()->GetViewFrame().ToTop(); // Return value: BOOL // FALSE: cancel diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 2601b5f987c1..d941a653dc8b 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -1045,7 +1045,7 @@ void EditorWindow::CreateEditEngine() // nLines*4: SetText+Formatting+DoHighlight+Formatting // it could be cut down on one formatting but you would wait even longer // for the text then if the source code is long... - pProgress.reset(new ProgressInfo(GetShell()->GetViewFrame()->GetObjectShell(), + pProgress.reset(new ProgressInfo(GetShell()->GetViewFrame().GetObjectShell(), IDEResId(RID_STR_GENERATESOURCE), nLines * 4)); setTextEngineText(*pEditEngine, aOUSource); @@ -1393,7 +1393,7 @@ void EditorWindow::CreateProgress( const OUString& rText, sal_uInt32 nRange ) { DBG_ASSERT( !pProgress, "ProgressInfo exists already" ); pProgress.reset(new ProgressInfo( - GetShell()->GetViewFrame()->GetObjectShell(), + GetShell()->GetViewFrame().GetObjectShell(), rText, nRange )); diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 33528679b2fd..309caa0357c9 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -313,7 +313,7 @@ void DialogWindow::GetState( SfxItemSet& rSet ) case SID_SHOW_PROPERTYBROWSER: { Shell* pShell = GetShell(); - SfxViewFrame* pViewFrame = pShell ? pShell->GetViewFrame() : nullptr; + SfxViewFrame* pViewFrame = pShell ? &pShell->GetViewFrame() : nullptr; if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !m_pEditor->GetView().AreObjectsMarked() ) rSet.DisableItem( nWh ); diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index b870a14a92a5..c690dccddc54 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -92,7 +92,7 @@ void Shell::ExecuteSearch( SfxRequest& rReq ) break; case FID_SEARCH_ON: mbJustOpened = true; - GetViewFrame()->GetBindings().Invalidate(SID_SEARCH_ITEM); + GetViewFrame().GetBindings().Invalidate(SID_SEARCH_ITEM); break; case SID_BASICIDE_REPEAT_SEARCH: case FID_SEARCH_NOW: @@ -175,8 +175,8 @@ void Shell::ExecuteSearch( SfxRequest& rReq ) { if ( !pWin ) { - SfxViewFrame* pViewFrame = GetViewFrame(); - SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SEARCH_DLG ) : nullptr; + SfxViewFrame& rViewFrame = GetViewFrame(); + SfxChildWindow* pChildWin = rViewFrame.GetChildWindow(SID_SEARCH_DLG); auto xParent = pChildWin ? pChildWin->GetController() : nullptr; std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(xParent ? xParent->getDialog() : nullptr, @@ -260,7 +260,7 @@ void Shell::ExecuteCurrent( SfxRequest& rReq ) case SID_UNDO: case SID_REDO: if ( GetUndoManager() && pCurWin->AllowUndo() ) - GetViewFrame()->ExecuteSlot( rReq ); + GetViewFrame().ExecuteSlot( rReq ); break; default: pCurWin->ExecuteCommand( rReq ); @@ -399,9 +399,8 @@ void Shell::ExecuteGlobal( SfxRequest& rReq ) if ( pModule && !pModule->GetMethods()->Find( rInfo.GetMethod(), SbxClassType::Method ) ) CreateMacro( pModule, rInfo.GetMethod() ); } - SfxViewFrame* pViewFrame = GetViewFrame(); - if ( pViewFrame ) - pViewFrame->ToTop(); + SfxViewFrame& rViewFrame = GetViewFrame(); + rViewFrame.ToTop(); VclPtr<ModulWindow> pWin = FindBasWin( aDocument, aLibName, rInfo.GetModule(), true ); DBG_ASSERT( pWin, "Edit/Create Macro: Window was not created/found!" ); SetCurWindow( pWin, true ); @@ -1047,7 +1046,7 @@ void Shell::GetState(SfxItemSet &rSet) case SID_REDO: { if( GetUndoManager() ) // recursive GetState else - GetViewFrame()->GetSlotState( nWh, nullptr, &rSet ); + GetViewFrame().GetSlotState( nWh, nullptr, &rSet ); } break; case SID_BASICIDE_CURRENT_LANG: @@ -1189,17 +1188,17 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe pLayout = pModulLayout.get(); else pLayout = pDialogLayout.get(); - AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel()); + AdjustPosSizePixel(Point(0, 0), GetViewFrame().GetWindow().GetOutputSizePixel()); pLayout->Activating(*pCurWin); - GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid()); + GetViewFrame().GetWindow().SetHelpId(pCurWin->GetHid()); if (bRememberAsCurrent) pCurWin->InsertLibInfo(); - if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise + if (GetViewFrame().GetWindow().IsVisible()) // SFX will do it later otherwise pCurWin->Show(); pCurWin->Init(); if (!GetExtraData()->ShellInCriticalSection()) { - vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow(); + vcl::Window* pFrameWindow = &GetViewFrame().GetWindow(); vcl::Window* pFocusWindow = Application::GetFocusWindow(); while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) ) pFocusWindow = pFocusWindow->GetParent(); @@ -1230,7 +1229,7 @@ void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRemembe else if (pLayout) { SetWindow(pLayout); - GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); + GetViewFrame().GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); SfxObjectShell::SetCurrentComponent(nullptr); } aObjectCatalog->SetCurrentEntry(pCurWin); @@ -1260,7 +1259,7 @@ void Shell::ManageToolbars() return; Reference< beans::XPropertySet > xFrameProps - ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); + ( GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY ); if ( !xFrameProps.is() ) return; @@ -1341,7 +1340,7 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const * pBasic ) { Shell* pShell = GetShell(); for ( sal_uInt16 n = 0; n < nWaitCount; n++ ) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); } } } @@ -1385,11 +1384,11 @@ VclPtr<ModulWindow> Shell::ShowActiveModuleWindow( StarBASIC const * pBasic ) void Shell::AdjustPosSizePixel( const Point &rPos, const Size &rSize ) { // not if iconified because the whole text would be displaced then at restore - if ( GetViewFrame()->GetWindow().GetOutputSizePixel().Height() == 0 ) + if ( GetViewFrame().GetWindow().GetOutputSizePixel().Height() == 0 ) return; Size aTabBarSize; - aTabBarSize.setHeight( GetViewFrame()->GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN ); + aTabBarSize.setHeight( GetViewFrame().GetWindow().GetFont().GetFontHeight() + TAB_HEIGHT_MARGIN ); aTabBarSize.setWidth( rSize.Width() ); Size aSz( rSize ); diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index ca219f4c9059..5bd69b76f380 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -82,7 +82,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate ) { if ( pCurWin ) { - DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell()); + DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell()); assert(pDocShell && "DocShell ?!"); return pDocShell->GetPrinter( bCreate ); } @@ -91,7 +91,7 @@ SfxPrinter* Shell::GetPrinter( bool bCreate ) sal_uInt16 Shell::SetPrinter( SfxPrinter *pNewPrinter, SfxPrinterChangeFlags ) { - DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame()->GetObjectShell()); + DocShell* pDocShell = static_cast<DocShell*>(GetViewFrame().GetObjectShell()); assert(pDocShell && "DocShell ?!"); pDocShell->SetPrinter( pNewPrinter ); return 0; @@ -114,11 +114,8 @@ void Shell::SetMDITitle() aTitle += " " + IDEResId(RID_STR_SIGNED) + " "; } - SfxViewFrame* pViewFrame = GetViewFrame(); - if ( !pViewFrame ) - return; - - SfxObjectShell* pShell = pViewFrame->GetObjectShell(); + SfxViewFrame& rViewFrame = GetViewFrame(); + SfxObjectShell* pShell = rViewFrame.GetObjectShell(); if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle ) { pShell->SetTitle( aTitle ); @@ -168,7 +165,7 @@ VclPtr<ModulWindow> Shell::CreateBasWin( const ScriptDocument& rDocument, const { // new module window if (!pModulLayout) - pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog)); + pModulLayout.reset(VclPtr<ModulWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog)); pWin = VclPtr<ModulWindow>::Create(pModulLayout.get(), rDocument, aLibName, aModName, aModule); nKey = InsertWindowInTable( pWin ); } diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index d47b6ae3a26c..44bc54ba624f 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -81,7 +81,7 @@ VclPtr<DialogWindow> Shell::CreateDlgWin( const ScriptDocument& rDocument, const // new dialog window if (!pDialogLayout) - pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame()->GetWindow(), *aObjectCatalog)); + pDialogLayout.reset(VclPtr<DialogWindowLayout>::Create(&GetViewFrame().GetWindow(), *aObjectCatalog)); pWin = VclPtr<DialogWindow>::Create(pDialogLayout.get(), rDocument, aLibName, aDlgName, xDialogModel); nKey = InsertWindowInTable( pWin ); } diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index 0c3c5bb16de7..73d27e2eea34 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -164,10 +164,10 @@ unsigned Shell::nShellCount = 0; Shell::Shell( SfxViewFrame& rFrame_, SfxViewShell* /* pOldShell */ ) : SfxViewShell( rFrame_, SfxViewShellFlags::NO_NEWWINDOW ), m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ), - aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), true) ), - aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), false) ), + aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), true) ), + aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame().GetWindow(), false) ), pLayout(nullptr), - aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())), + aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame().GetWindow())), m_bAppBasicModified( false ), m_aNotifier( *this ) { @@ -192,15 +192,15 @@ void Shell::Init() LanguageBoxControl::RegisterControl( SID_BASICIDE_CURRENT_LANG ); SvxZoomSliderControl::RegisterControl( SID_ATTR_ZOOMSLIDER ); - GetViewFrame()->GetWindow().SetBackground( - GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetWindowColor() + GetViewFrame().GetWindow().SetBackground( + GetViewFrame().GetWindow().GetSettings().GetStyleSettings().GetWindowColor() ); pCurWin = nullptr; m_aCurDocument = ScriptDocument::getApplicationScriptDocument(); bCreatingWindow = false; - pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame()->GetWindow())); + pTabBar.reset(VclPtr<TabBar>::Create(&GetViewFrame().GetWindow())); nCurKey = 100; InitScrollBars(); @@ -427,17 +427,16 @@ void Shell::StoreAllWindowData( bool bPersistent ) } } - bool Shell::PrepareClose( bool bUI ) { // reset here because it's modified after printing etc. (DocInfo) - GetViewFrame()->GetObjectShell()->SetModified(false); + GetViewFrame().GetObjectShell()->SetModified(false); if ( StarBASIC::IsRunning() ) { if( bUI ) { - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame()->GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetViewFrame().GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, IDEResId(RID_STR_CANNOTCLOSE))); xInfoBox->run(); diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index a470461be6a7..4672cdd52c2b 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -321,9 +321,9 @@ void BasicStopped( if (Shell* pShell = GetShell()) { sal_uInt16 nWait = 0; - while ( pShell->GetViewFrame()->GetWindow().IsWait() ) + while ( pShell->GetViewFrame().GetWindow().IsWait() ) { - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); nWait++; } if ( pnWaitCount ) @@ -430,7 +430,7 @@ SfxBindings* GetBindingsPtr() SfxViewFrame* pFrame = nullptr; if (Shell* pShell = GetShell()) { - pFrame = pShell->GetViewFrame(); + pFrame = &pShell->GetViewFrame(); } else { @@ -454,9 +454,11 @@ SfxBindings* GetBindingsPtr() SfxDispatcher* GetDispatcher () { if (Shell* pShell = GetShell()) - if (SfxViewFrame* pViewFrame = pShell->GetViewFrame()) - if (SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher()) - return pDispatcher; + { + SfxViewFrame& rViewFrame = pShell->GetViewFrame(); + if (SfxDispatcher* pDispatcher = rViewFrame.GetDispatcher()) + return pDispatcher; + } return nullptr; } } // namespace basctl diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 0bf829b2bb5d..5fd607108dc1 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -94,7 +94,7 @@ void BaseWindow::Init() pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, HorzScrollHdl ) ); // Show the read-only infobar if the module/dialog is read-only - GetShell()->GetViewFrame()->RemoveInfoBar(BASIC_IDE_READONLY_INFOBAR); + GetShell()->GetViewFrame().RemoveInfoBar(BASIC_IDE_READONLY_INFOBAR); if (IsReadOnly()) ShowReadOnlyInfoBar(); @@ -240,7 +240,7 @@ void BaseWindow::ShowReadOnlyInfoBar() else aMsg = IDEResId(RID_STR_DIALOG_READONLY); - GetShell()->GetViewFrame()->AppendInfoBar(BASIC_IDE_READONLY_INFOBAR, OUString(), + GetShell()->GetViewFrame().AppendInfoBar(BASIC_IDE_READONLY_INFOBAR, OUString(), aMsg, InfobarType::INFO, true); } diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx index 18a19d6e7b17..17371bed2968 100644 --- a/basctl/source/basicide/localizationmgr.cxx +++ b/basctl/source/basicide/localizationmgr.cxx @@ -82,7 +82,7 @@ void LocalizationMgr::handleTranslationbar () static constexpr OUStringLiteral aToolBarResName = u"private:resource/toolbar/translationbar"; Reference< beans::XPropertySet > xFrameProps - ( m_pShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); + ( m_pShell->GetViewFrame().GetFrame().GetFrameInterface(), uno::UNO_QUERY ); if ( !xFrameProps.is() ) return; diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 82443228dbe8..12650fc8f66a 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -461,10 +461,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void ) { Shell* pShell = GetShell(); if (pShell) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); xModLibContainer->loadLibrary( aLibName ); if (pShell) - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); } // load dialog library (if not loaded) @@ -473,10 +473,10 @@ IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void ) { Shell* pShell = GetShell(); if (pShell) - pShell->GetViewFrame()->GetWindow().EnterWait(); + pShell->GetViewFrame().GetWindow().EnterWait(); xDlgLibContainer->loadLibrary( aLibName ); if (pShell) - pShell->GetViewFrame()->GetWindow().LeaveWait(); + pShell->GetViewFrame().GetWindow().LeaveWait(); } // check, if library is password protected |