basctl/source/accessibility/accessibledialogwindow.cxx | 150 +-- basctl/source/basicide/basicrenderable.cxx | 44 - basctl/source/basicide/baside2.cxx | 448 +++++----- basctl/source/basicide/baside2b.cxx | 451 +++++----- basctl/source/basicide/baside3.cxx | 246 ++--- basctl/source/basicide/basides1.cxx | 170 ++-- basctl/source/basicide/basides2.cxx | 24 basctl/source/basicide/basidesh.cxx | 323 +++---- basctl/source/basicide/basobj3.cxx | 43 - basctl/source/basicide/bastype2.cxx | 50 - basctl/source/basicide/bastypes.cxx | 77 - basctl/source/basicide/docsignature.cxx | 22 basctl/source/basicide/layout.cxx | 93 +- basctl/source/basicide/localizationmgr.cxx | 116 +- basctl/source/basicide/macrodlg.cxx | 68 - basctl/source/basicide/moduldl2.cxx | 492 +++++------ basctl/source/basicide/moduldlg.cxx | 180 ++-- basctl/source/dlged/dlged.cxx | 445 +++++----- basctl/source/dlged/dlgedobj.cxx | 710 ++++++++--------- basctl/source/dlged/dlgedview.cxx | 82 - basctl/source/dlged/managelang.cxx | 46 - 21 files changed, 2145 insertions(+), 2135 deletions(-)
New commits: commit cd0ab2cf5063242ef3bff3c6899cea4d4bd53485 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sat Apr 18 15:04:58 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Apr 18 21:48:16 2020 +0200 loplugin:flatten in basctl Change-Id: I66e3f46fcaae4e15d230a5a7c98c1b20cfb4dbda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92485 Tested-by: Jenkins Tested-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx index ade28c57f738..eeb43b4f0c8b 100644 --- a/basctl/source/accessibility/accessibledialogwindow.cxx +++ b/basctl/source/accessibility/accessibledialogwindow.cxx @@ -80,28 +80,28 @@ AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWin : m_pDialogWindow(pDialogWindow) , m_pDlgEdModel(nullptr) { - if ( m_pDialogWindow ) - { - SdrPage& rPage = m_pDialogWindow->GetPage(); - const size_t nCount = rPage.GetObjCount(); + if ( !m_pDialogWindow ) + return; - for ( size_t i = 0; i < nCount; ++i ) + SdrPage& rPage = m_pDialogWindow->GetPage(); + const size_t nCount = rPage.GetObjCount(); + + for ( size_t i = 0; i < nCount; ++i ) + { + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) { - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) - { - ChildDescriptor aDesc( pDlgEdObj ); - if ( IsChildVisible( aDesc ) ) - m_aAccessibleChildren.push_back( aDesc ); - } + ChildDescriptor aDesc( pDlgEdObj ); + if ( IsChildVisible( aDesc ) ) + m_aAccessibleChildren.push_back( aDesc ); } + } - m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) ); + m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) ); - StartListening(m_pDialogWindow->GetEditor()); + StartListening(m_pDialogWindow->GetEditor()); - m_pDlgEdModel = &m_pDialogWindow->GetModel(); - StartListening(*m_pDlgEdModel); - } + m_pDlgEdModel = &m_pDialogWindow->GetModel(); + StartListening(*m_pDlgEdModel); } @@ -211,24 +211,24 @@ void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc ) AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc ); // if not found, insert in child list - if ( aIter == m_aAccessibleChildren.end() ) - { - // insert entry in child list - m_aAccessibleChildren.push_back( rDesc ); + if ( aIter != m_aAccessibleChildren.end() ) + return; - // get the accessible of the inserted child - Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) ); + // insert entry in child list + m_aAccessibleChildren.push_back( rDesc ); - // sort child list - SortChildren(); + // get the accessible of the inserted child + Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) ); - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aNewValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); - } + // sort child list + SortChildren(); + + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aNewValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); } } @@ -239,25 +239,25 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc ) AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc ); // if found, remove from child list - if ( aIter != m_aAccessibleChildren.end() ) - { - // get the accessible of the removed child - Reference< XAccessible > xChild( aIter->rxAccessible ); + if ( aIter == m_aAccessibleChildren.end() ) + return; - // remove entry from child list - m_aAccessibleChildren.erase( aIter ); + // get the accessible of the removed child + Reference< XAccessible > xChild( aIter->rxAccessible ); - // send accessible child event - if ( xChild.is() ) - { - Any aOldValue, aNewValue; - aOldValue <<= xChild; - NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + // remove entry from child list + m_aAccessibleChildren.erase( aIter ); - Reference< XComponent > xComponent( xChild, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } + // send accessible child event + if ( xChild.is() ) + { + Any aOldValue, aNewValue; + aOldValue <<= xChild; + NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue ); + + Reference< XComponent > xComponent( xChild, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } } @@ -397,25 +397,25 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) { - if ( m_pDialogWindow ) - { - if ( m_pDialogWindow->IsEnabled() ) - rStateSet.AddState( AccessibleStateType::ENABLED ); + if ( !m_pDialogWindow ) + return; - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + if ( m_pDialogWindow->IsEnabled() ) + rStateSet.AddState( AccessibleStateType::ENABLED ); - if ( m_pDialogWindow->HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::VISIBLE ); + if ( m_pDialogWindow->HasFocus() ) + rStateSet.AddState( AccessibleStateType::FOCUSED ); - if ( m_pDialogWindow->IsVisible() ) - rStateSet.AddState( AccessibleStateType::SHOWING ); + rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::OPAQUE ); + if ( m_pDialogWindow->IsVisible() ) + rStateSet.AddState( AccessibleStateType::SHOWING ); - rStateSet.AddState( AccessibleStateType::RESIZABLE ); - } + rStateSet.AddState( AccessibleStateType::OPAQUE ); + + rStateSet.AddState( AccessibleStateType::RESIZABLE ); } @@ -512,24 +512,24 @@ void AccessibleDialogWindow::disposing() { OAccessibleExtendedComponentHelper::disposing(); - if ( m_pDialogWindow ) - { - m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) ); - m_pDialogWindow = nullptr; + if ( !m_pDialogWindow ) + return; - if ( m_pDlgEdModel ) - EndListening( *m_pDlgEdModel ); - m_pDlgEdModel = nullptr; + m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) ); + m_pDialogWindow = nullptr; - // dispose all children - for (const ChildDescriptor & i : m_aAccessibleChildren) - { - Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY ); - if ( xComponent.is() ) - xComponent->dispose(); - } - m_aAccessibleChildren.clear(); + if ( m_pDlgEdModel ) + EndListening( *m_pDlgEdModel ); + m_pDlgEdModel = nullptr; + + // dispose all children + for (const ChildDescriptor & i : m_aAccessibleChildren) + { + Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY ); + if ( xComponent.is() ) + xComponent->dispose(); } + m_aAccessibleChildren.clear(); } // XServiceInfo diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx index e74f455f91df..eae8b5c81c93 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -182,33 +182,33 @@ void SAL_CALL Renderable::render ( { processProperties( i_xOptions ); - if( mpWindow ) - { - VclPtr<Printer> pPrinter = getPrinter(); - if (!pPrinter) - throw lang::IllegalArgumentException(); + if( !mpWindow ) + return; - sal_Int64 nContent = getIntValue( "PrintContent", -1 ); - if( nContent == 1 ) + VclPtr<Printer> pPrinter = getPrinter(); + if (!pPrinter) + throw lang::IllegalArgumentException(); + + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + if( nContent == 1 ) + { + OUString aPageRange( getStringValue( "PageRange" ) ); + if( !aPageRange.isEmpty() ) { - OUString aPageRange( getStringValue( "PageRange" ) ); - if( !aPageRange.isEmpty() ) - { - sal_Int32 nPageCount = mpWindow->countPages( pPrinter ); - StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 ); - StringRangeEnumerator::Iterator it = aRangeEnum.begin(); - for( ; it != aRangeEnum.end() && nRenderer; --nRenderer ) - ++it; - - sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer; - mpWindow->printPage( nPage, pPrinter ); - } - else - mpWindow->printPage( nRenderer, pPrinter ); + sal_Int32 nPageCount = mpWindow->countPages( pPrinter ); + StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 ); + StringRangeEnumerator::Iterator it = aRangeEnum.begin(); + for( ; it != aRangeEnum.end() && nRenderer; --nRenderer ) + ++it; + + sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer; + mpWindow->printPage( nPage, pPrinter ); } else - mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter ); + mpWindow->printPage( nRenderer, pPrinter ); } + else + mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter ); } } // namespace basctl diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 2aa29d74df71..46014b5e32db 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -167,26 +167,26 @@ void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, void lcl_ConvertTabsToSpaces( OUString& rLine ) { - if ( !rLine.isEmpty() ) + if ( rLine.isEmpty() ) + return; + + OUStringBuffer aResult( rLine ); + sal_Int32 nPos = 0; + sal_Int32 nMax = aResult.getLength(); + while ( nPos < nMax ) { - OUStringBuffer aResult( rLine ); - sal_Int32 nPos = 0; - sal_Int32 nMax = aResult.getLength(); - while ( nPos < nMax ) + if ( aResult[nPos] == '\t' ) { - if ( aResult[nPos] == '\t' ) - { - // not 4 Blanks, but at 4 TabPos: - OUStringBuffer aBlanker; - string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' '); - aResult.remove( nPos, 1 ); - aResult.insert( nPos, aBlanker.makeStringAndClear() ); - nMax = aResult.getLength(); - } - ++nPos; + // not 4 Blanks, but at 4 TabPos: + OUStringBuffer aBlanker; + string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' '); + aResult.remove( nPos, 1 ); + aResult.insert( nPos, aBlanker.makeStringAndClear() ); + nMax = aResult.getLength(); } - rLine = aResult.makeStringAndClear(); + ++nPos; } + rLine = aResult.makeStringAndClear(); } } // namespace @@ -270,43 +270,43 @@ void ModulWindow::Resize() void ModulWindow::CheckCompileBasic() { - if ( XModule().is() ) - { - // never compile while running! - bool const bRunning = StarBASIC::IsRunning(); - bool const bModified = ( !m_xModule->IsCompiled() || - ( GetEditEngine() && GetEditEngine()->IsModified() ) ); + if ( !XModule().is() ) + return; - if ( !bRunning && bModified ) - { - bool bDone = false; + // never compile while running! + bool const bRunning = StarBASIC::IsRunning(); + bool const bModified = ( !m_xModule->IsCompiled() || + ( GetEditEngine() && GetEditEngine()->IsModified() ) ); - GetShell()->GetViewFrame()->GetWindow().EnterWait(); + if ( !(!bRunning && bModified) ) + return; - AssertValidEditEngine(); - GetEditorWindow().SetSourceInBasic(); + bool bDone = false; - bool bWasModified = GetBasic()->IsModified(); + GetShell()->GetViewFrame()->GetWindow().EnterWait(); - { - // tdf#106529: only use strict compilation mode when compiling from the IDE - css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict")); - bDone = m_xModule->Compile(); - } - if ( !bWasModified ) - GetBasic()->SetModified(false); + AssertValidEditEngine(); + GetEditorWindow().SetSourceInBasic(); - if ( bDone ) - { - GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() ); - } + bool bWasModified = GetBasic()->IsModified(); - GetShell()->GetViewFrame()->GetWindow().LeaveWait(); + { + // tdf#106529: only use strict compilation mode when compiling from the IDE + css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict")); + bDone = m_xModule->Compile(); + } + if ( !bWasModified ) + GetBasic()->SetModified(false); - m_aStatus.bError = !bDone; - m_aStatus.bIsRunning = false; - } + if ( bDone ) + { + GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() ); } + + GetShell()->GetViewFrame()->GetWindow().LeaveWait(); + + m_aStatus.bError = !bDone; + m_aStatus.bIsRunning = false; } void ModulWindow::BasicExecute() @@ -325,50 +325,50 @@ void ModulWindow::BasicExecute() CheckCompileBasic(); - if ( XModule().is() && m_xModule->IsCompiled() && !m_aStatus.bError ) - { - if ( GetBreakPoints().size() ) - m_aStatus.nBasicFlags = m_aStatus.nBasicFlags | BasicDebugFlags::Break; + if ( !(XModule().is() && m_xModule->IsCompiled() && !m_aStatus.bError) ) + return; + + if ( GetBreakPoints().size() ) + m_aStatus.nBasicFlags = m_aStatus.nBasicFlags | BasicDebugFlags::Break; - if ( !m_aStatus.bIsRunning ) + if ( !m_aStatus.bIsRunning ) + { + DBG_ASSERT( m_xModule.is(), "No Module!" ); + AddStatus( BASWIN_RUNNINGBASIC ); + sal_uInt16 nStart, nEnd; + TextSelection aSel = GetEditView()->GetSelection(); + // Init cursor to top + const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1; + SbMethod* pMethod = nullptr; + // first Macro, else blind "Main" (ExtSearch?) + for ( sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count32(); nMacro++ ) { - DBG_ASSERT( m_xModule.is(), "No Module!" ); - AddStatus( BASWIN_RUNNINGBASIC ); - sal_uInt16 nStart, nEnd; - TextSelection aSel = GetEditView()->GetSelection(); - // Init cursor to top - const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1; - SbMethod* pMethod = nullptr; - // first Macro, else blind "Main" (ExtSearch?) - for ( sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count32(); nMacro++ ) - { - SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMacro )); - assert(pM && "Method?"); - pM->GetLineRange( nStart, nEnd ); - if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) - { - // matched a method to the cursor position - pMethod = pM; - break; - } - } - if ( !pMethod ) + SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMacro )); + assert(pM && "Method?"); + pM->GetLineRange( nStart, nEnd ); + if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd ) { - // If not in a method then prompt the user - ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>()); - return; + // matched a method to the cursor position + pMethod = pM; + break; } - pMethod->SetDebugFlags(m_aStatus.nBasicFlags); - BasicDLL::SetDebugMode(true); - RunMethod(pMethod); - BasicDLL::SetDebugMode(false); - // if cancelled during Interactive=false - BasicDLL::EnableBreak(true); - ClearStatus( BASWIN_RUNNINGBASIC ); } - else - m_aStatus.bIsRunning = false; // cancel of Reschedule() + if ( !pMethod ) + { + // If not in a method then prompt the user + ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>()); + return; + } + pMethod->SetDebugFlags(m_aStatus.nBasicFlags); + BasicDLL::SetDebugMode(true); + RunMethod(pMethod); + BasicDLL::SetDebugMode(false); + // if cancelled during Interactive=false + BasicDLL::EnableBreak(true); + ClearStatus( BASWIN_RUNNINGBASIC ); } + else + m_aStatus.bIsRunning = false; // cancel of Reschedule() } void ModulWindow::CompileBasic() @@ -422,34 +422,34 @@ void ModulWindow::LoadBasic() xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( "BASIC" ); - if( xFP->execute() == RET_OK ) + if( xFP->execute() != RET_OK ) + return; + + Sequence< OUString > aPaths = xFP->getSelectedFiles(); + m_sCurPath = aPaths[0]; + SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE ); + SvStream* pStream = aMedium.GetInStream(); + if ( pStream ) { - Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; - SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE ); - SvStream* pStream = aMedium.GetInStream(); - if ( pStream ) - { - AssertValidEditEngine(); - sal_uInt32 nLines = CalcLineCount( *pStream ); - // nLines*4: ReadText/Formatting/Highlighting/Formatting - GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 ); - GetEditEngine()->SetUpdateMode( false ); - GetEditView()->Read( *pStream ); - GetEditEngine()->SetUpdateMode( true ); - GetEditorWindow().PaintImmediately(); - GetEditorWindow().ForceSyntaxTimeout(); - GetEditorWindow().DestroyProgress(); - ErrCode nError = aMedium.GetError(); - if ( nError ) - ErrorHandler::HandleError( nError ); - } - else - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTREAD))); - xBox->run(); - } + AssertValidEditEngine(); + sal_uInt32 nLines = CalcLineCount( *pStream ); + // nLines*4: ReadText/Formatting/Highlighting/Formatting + GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 ); + GetEditEngine()->SetUpdateMode( false ); + GetEditView()->Read( *pStream ); + GetEditEngine()->SetUpdateMode( true ); + GetEditorWindow().PaintImmediately(); + GetEditorWindow().ForceSyntaxTimeout(); + GetEditorWindow().DestroyProgress(); + ErrCode nError = aMedium.GetError(); + if ( nError ) + ErrorHandler::HandleError( nError ); + } + else + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTREAD))); + xBox->run(); } } @@ -472,29 +472,29 @@ void ModulWindow::SaveBasicSource() xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( "BASIC" ); - if( xFP->execute() == RET_OK ) + if( xFP->execute() != RET_OK ) + return; + + Sequence< OUString > aPaths = xFP->getSelectedFiles(); + m_sCurPath = aPaths[0]; + SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC ); + SvStream* pStream = aMedium.GetOutStream(); + if ( pStream ) { - Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; - SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC ); - SvStream* pStream = aMedium.GetOutStream(); - if ( pStream ) - { - EnterWait(); - AssertValidEditEngine(); - GetEditEngine()->Write( *pStream ); - aMedium.Commit(); - LeaveWait(); - ErrCode nError = aMedium.GetError(); - if ( nError ) - ErrorHandler::HandleError( nError ); - } - else - { - std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); - xErrorBox->run(); - } + EnterWait(); + AssertValidEditEngine(); + GetEditEngine()->Write( *pStream ); + aMedium.Commit(); + LeaveWait(); + ErrCode nError = aMedium.GetError(); + if ( nError ) + ErrorHandler::HandleError( nError ); + } + else + { + std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); + xErrorBox->run(); } } @@ -509,33 +509,33 @@ void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine ) { DBG_ASSERT( XModule().is(), "No Module!" ); - if ( XModule().is() ) + if ( !XModule().is() ) + return; + + CheckCompileBasic(); + if ( m_aStatus.bError ) { - CheckCompileBasic(); - if ( m_aStatus.bError ) - { - return; - } + return; + } - BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine ); - if ( pBrk ) // remove - { - m_xModule->ClearBP( nLine ); - GetBreakPoints().remove( pBrk ); - } - else // create one + BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine ); + if ( pBrk ) // remove + { + m_xModule->ClearBP( nLine ); + GetBreakPoints().remove( pBrk ); + } + else // create one + { + if ( m_xModule->SetBP( nLine )) { - if ( m_xModule->SetBP( nLine )) + GetBreakPoints().InsertSorted( BreakPoint( nLine ) ); + if ( StarBASIC::IsRunning() ) { - GetBreakPoints().InsertSorted( BreakPoint( nLine ) ); - if ( StarBASIC::IsRunning() ) + for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) { - for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) - { - SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); - assert(pMethod && "Method not found! (NULL)"); - pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); - } + SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); + assert(pMethod && "Method not found! (NULL)"); + pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); } } } @@ -580,23 +580,23 @@ void ModulWindow::BasicToggleBreakPointEnabled() AssertValidEditEngine(); TextView* pView = GetEditView(); - if ( pView ) - { - TextSelection aSel = pView->GetSelection(); - BreakPointList& rList = GetBreakPoints(); + if ( !pView ) + return; + + TextSelection aSel = pView->GetSelection(); + BreakPointList& rList = GetBreakPoints(); - for ( sal_uInt32 nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine ) + for ( sal_uInt32 nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine ) + { + BreakPoint* pBrk = rList.FindBreakPoint( nLine ); + if ( pBrk ) { - BreakPoint* pBrk = rList.FindBreakPoint( nLine ); - if ( pBrk ) - { - pBrk->bEnabled = !pBrk->bEnabled; - UpdateBreakPoint( *pBrk ); - } + pBrk->bEnabled = !pBrk->bEnabled; + UpdateBreakPoint( *pBrk ); } - - GetBreakPointWindow().Invalidate(); } + + GetBreakPointWindow().Invalidate(); } void ModulWindow::ManageBreakPoints() @@ -717,43 +717,43 @@ void ModulWindow::EditMacro( const OUString& rMacroName ) { DBG_ASSERT( XModule().is(), "No Module!" ); - if ( XModule().is() ) - { - CheckCompileBasic(); + if ( !XModule().is() ) + return; - if ( !m_aStatus.bError ) - { - sal_uInt16 nStart, nEnd; - SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->Find( rMacroName, SbxClassType::Method )); - if ( pMethod ) - { - pMethod->GetLineRange( nStart, nEnd ); - if ( nStart ) - { - nStart--; - nEnd--; - } - TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) ); - AssertValidEditEngine(); - TextView * pView = GetEditView(); - // scroll if applicable so that first line is at the top - long nVisHeight = GetOutputSizePixel().Height(); - if ( pView->GetTextEngine()->GetTextHeight() > nVisHeight ) - { - long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight; - long nOldStartY = pView->GetStartDocPos().Y(); - long nNewStartY = static_cast<long>(nStart) * pView->GetTextEngine()->GetCharHeight(); - nNewStartY = std::min( nNewStartY, nMaxY ); - pView->Scroll( 0, -(nNewStartY-nOldStartY) ); - pView->ShowCursor( false ); - GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() ); - } - pView->SetSelection( aSel ); - pView->ShowCursor(); - pView->GetWindow()->GrabFocus(); - } - } + CheckCompileBasic(); + + if ( m_aStatus.bError ) + return; + + sal_uInt16 nStart, nEnd; + SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->Find( rMacroName, SbxClassType::Method )); + if ( !pMethod ) + return; + + pMethod->GetLineRange( nStart, nEnd ); + if ( nStart ) + { + nStart--; + nEnd--; } + TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) ); + AssertValidEditEngine(); + TextView * pView = GetEditView(); + // scroll if applicable so that first line is at the top + long nVisHeight = GetOutputSizePixel().Height(); + if ( pView->GetTextEngine()->GetTextHeight() > nVisHeight ) + { + long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight; + long nOldStartY = pView->GetStartDocPos().Y(); + long nNewStartY = static_cast<long>(nStart) * pView->GetTextEngine()->GetCharHeight(); + nNewStartY = std::min( nNewStartY, nMaxY ); + pView->Scroll( 0, -(nNewStartY-nOldStartY) ); + pView->ShowCursor( false ); + GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() ); + } + pView->SetSelection( aSel ); + pView->ShowCursor(); + pView->GetWindow()->GrabFocus(); } void ModulWindow::StoreData() @@ -775,18 +775,18 @@ void ModulWindow::UpdateData() // UpdateData is called when the source has changed from outside // => interrupts undesired! - if ( XModule().is() ) - { - SetModule( m_xModule->GetSource32() ); + if ( !XModule().is() ) + return; - if ( GetEditView() ) - { - TextSelection aSel = GetEditView()->GetSelection(); - setTextEngineText(*GetEditEngine(), m_xModule->GetSource32()); - GetEditView()->SetSelection( aSel ); - GetEditEngine()->SetModified( false ); - MarkDocumentModified( GetDocument() ); - } + SetModule( m_xModule->GetSource32() ); + + if ( GetEditView() ) + { + TextSelection aSel = GetEditView()->GetSelection(); + setTextEngineText(*GetEditEngine(), m_xModule->GetSource32()); + GetEditView()->SetSelection( aSel ); + GetEditEngine()->SetModified( false ); + MarkDocumentModified( GetDocument() ); } } @@ -1287,20 +1287,20 @@ SearchOptionFlags ModulWindow::GetSearchOptions() void ModulWindow::BasicStarted() { - if ( XModule().is() ) + if ( !XModule().is() ) + return; + + m_aStatus.bIsRunning = true; + BreakPointList& rList = GetBreakPoints(); + if ( rList.size() ) { - m_aStatus.bIsRunning = true; - BreakPointList& rList = GetBreakPoints(); - if ( rList.size() ) + rList.ResetHitCount(); + rList.SetBreakPointsInBasic( m_xModule.get() ); + for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) { - rList.ResetHitCount(); - rList.SetBreakPointsInBasic( m_xModule.get() ); - for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ ) - { - SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); - assert(pMethod && "Method not found! (NULL)"); - pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); - } + SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod )); + assert(pMethod && "Method not found! (NULL)"); + pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break ); } } } diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 83f09d64297e..270c6cfc5b12 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -406,28 +406,28 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt ) void EditorWindow::Resize() { // ScrollBars, etc. happens in Adjust... - if ( pEditView ) - { - long nVisY = pEditView->GetStartDocPos().Y(); + if ( !pEditView ) + return; + + long nVisY = pEditView->GetStartDocPos().Y(); + pEditView->ShowCursor(); + Size aOutSz( GetOutputSizePixel() ); + long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height(); + if ( nMaxVisAreaStart < 0 ) + nMaxVisAreaStart = 0; + if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart ) + { + Point aStartDocPos( pEditView->GetStartDocPos() ); + aStartDocPos.setY( nMaxVisAreaStart ); + pEditView->SetStartDocPos( aStartDocPos ); pEditView->ShowCursor(); - Size aOutSz( GetOutputSizePixel() ); - long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height(); - if ( nMaxVisAreaStart < 0 ) - nMaxVisAreaStart = 0; - if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart ) - { - Point aStartDocPos( pEditView->GetStartDocPos() ); - aStartDocPos.setY( nMaxVisAreaStart ); - pEditView->SetStartDocPos( aStartDocPos ); - pEditView->ShowCursor(); - rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y(); - rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y(); - } - InitScrollBars(); - if ( nVisY != pEditView->GetStartDocPos().Y() ) - Invalidate(); + rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y(); + rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y(); } + InitScrollBars(); + if ( nVisY != pEditView->GetStartDocPos().Y() ) + Invalidate(); } @@ -468,23 +468,23 @@ void EditorWindow::MouseButtonDown( const MouseEvent &rEvt ) void EditorWindow::Command( const CommandEvent& rCEvt ) { - if ( pEditView ) + if ( !pEditView ) + return; + + pEditView->Command( rCEvt ); + if ( ( rCEvt.GetCommand() == CommandEventId::Wheel ) || + ( rCEvt.GetCommand() == CommandEventId::StartAutoScroll ) || + ( rCEvt.GetCommand() == CommandEventId::AutoScroll ) ) { - pEditView->Command( rCEvt ); - if ( ( rCEvt.GetCommand() == CommandEventId::Wheel ) || - ( rCEvt.GetCommand() == CommandEventId::StartAutoScroll ) || - ( rCEvt.GetCommand() == CommandEventId::AutoScroll ) ) + HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() ); + } else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) { + SfxDispatcher* pDispatcher = GetDispatcher(); + if ( pDispatcher ) { - HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() ); - } else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) { - SfxDispatcher* pDispatcher = GetDispatcher(); - if ( pDispatcher ) - { - SfxDispatcher::ExecutePopup(); - } - if( pCodeCompleteWnd->IsVisible() ) // hide the code complete window - pCodeCompleteWnd->ClearAndHide(); + SfxDispatcher::ExecutePopup(); } + if( pCodeCompleteWnd->IsVisible() ) // hide the code complete window + pCodeCompleteWnd->ClearAndHide(); } } @@ -649,27 +649,28 @@ void EditorWindow::HandleAutoCorrect() pEditEngine->ReplaceText( sTextSelection, sStr ); pEditView->SetSelection( aSel ); } - if( r.tokenType == TokenType::Identifier ) - {// correct variables - if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() ) - { - sStr = aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ); - pEditEngine->ReplaceText( sTextSelection, sStr ); - pEditView->SetSelection( aSel ); - } - else + if( r.tokenType != TokenType::Identifier ) + return; + +// correct variables + if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() ) + { + sStr = aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ); + pEditEngine->ReplaceText( sTextSelection, sStr ); + pEditView->SetSelection( aSel ); + } + else + { + //autocorrect procedures + SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get(); + for( sal_uInt32 i=0; i < pArr->Count32(); ++i ) { - //autocorrect procedures - SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get(); - for( sal_uInt32 i=0; i < pArr->Count32(); ++i ) + if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) ) { - if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) ) - { - sStr = pArr->Get32(i)->GetName(); //if found, get the correct case - pEditEngine->ReplaceText( sTextSelection, sStr ); - pEditView->SetSelection( aSel ); - return; - } + sStr = pArr->Get32(i)->GetName(); //if found, get the correct case + pEditEngine->ReplaceText( sTextSelection, sStr ); + pEditView->SetSelection( aSel ); + return; } } } @@ -844,55 +845,56 @@ void EditorWindow::HandleCodeCompletion() std::vector<HighlightPortion> aPortions; aLine = aLine.copy(0, aSel.GetEnd().GetIndex()); aHighlighter.getHighlightPortions( aLine, aPortions ); - if( !aPortions.empty() ) - {//use the syntax highlighter to grab out nested reflection calls, eg. aVar.aMethod("aa").aOtherMethod .. - for( std::vector<HighlightPortion>::reverse_iterator i( - aPortions.rbegin()); - i != aPortions.rend(); ++i) - { - if( i->tokenType == TokenType::Whitespace ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line - break; - if( i->tokenType == TokenType::Identifier || i->tokenType == TokenType::Keywords ) // extract the identifiers(methods, base variable) - /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue - * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!) - * */ - aVect.insert( aVect.begin(), aLine.copy(i->nBegin, i->nEnd - i->nBegin) ); - } - - if( aVect.empty() )//nothing to do - return; + if( aPortions.empty() ) + return; - OUString sBaseName = aVect[aVect.size()-1];//variable name - OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName ); + //use the syntax highlighter to grab out nested reflection calls, eg. aVar.aMethod("aa").aOtherMethod .. + for( std::vector<HighlightPortion>::reverse_iterator i( + aPortions.rbegin()); + i != aPortions.rend(); ++i) + { + if( i->tokenType == TokenType::Whitespace ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line + break; + if( i->tokenType == TokenType::Identifier || i->tokenType == TokenType::Keywords ) // extract the identifiers(methods, base variable) + /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue + * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!) + * */ + aVect.insert( aVect.begin(), aLine.copy(i->nBegin, i->nEnd - i->nBegin) ); + } - if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() ) - {//correct variable name, if autocorrection on - const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) ); - if( !sStr.isEmpty() ) - { - TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); - TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); - pEditEngine->ReplaceText( sTextSelection, sStr ); - pEditView->SetSelection( aSel ); - } - } + if( aVect.empty() )//nothing to do + return; - UnoTypeCodeCompletetor aTypeCompletor( aVect, sVarType ); + OUString sBaseName = aVect[aVect.size()-1];//variable name + OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName ); - if( aTypeCompletor.CanCodeComplete() ) + if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() ) + {//correct variable name, if autocorrection on + const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) ); + if( !sStr.isEmpty() ) { - std::vector< OUString > aEntryVect;//entries to be inserted into the list - std::vector< OUString > aFieldVect = aTypeCompletor.GetXIdlClassFields();//fields - aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() ); - if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) - {// if extended types on, reflect classes, else just the structs (XIdlClass without methods) - std::vector< OUString > aMethVect = aTypeCompletor.GetXIdlClassMethods();//methods - aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() ); - } - if( !aEntryVect.empty() ) - SetupAndShowCodeCompleteWnd( aEntryVect, aSel ); + TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); + TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); + pEditEngine->ReplaceText( sTextSelection, sStr ); + pEditView->SetSelection( aSel ); } } + + UnoTypeCodeCompletetor aTypeCompletor( aVect, sVarType ); + + if( !aTypeCompletor.CanCodeComplete() ) + return; + + std::vector< OUString > aEntryVect;//entries to be inserted into the list + std::vector< OUString > aFieldVect = aTypeCompletor.GetXIdlClassFields();//fields + aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() ); + if( CodeCompleteOptions::IsExtendedTypeDeclaration() ) + {// if extended types on, reflect classes, else just the structs (XIdlClass without methods) + std::vector< OUString > aMethVect = aTypeCompletor.GetXIdlClassMethods();//methods + aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() ); + } + if( !aEntryVect.empty() ) + SetupAndShowCodeCompleteWnd( aEntryVect, aSel ); } void EditorWindow::SetupAndShowCodeCompleteWnd( const std::vector< OUString >& aEntryVect, TextSelection aSel ) @@ -1047,70 +1049,71 @@ void EditorWindow::CreateEditEngine() void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { - if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint)) + TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint); + if (!pTextHint) + return; + + TextHint const& rTextHint = *pTextHint; + if( rTextHint.GetId() == SfxHintId::TextViewScrolled ) { - TextHint const& rTextHint = *pTextHint; - if( rTextHint.GetId() == SfxHintId::TextViewScrolled ) - { - if ( rModulWindow.GetHScrollBar() ) - rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); - rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() ); - rModulWindow.GetBreakPointWindow().DoScroll - ( rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() ); - rModulWindow.GetLineNumberWindow().DoScroll - ( rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() ); - } - else if( rTextHint.GetId() == SfxHintId::TextHeightChanged ) + if ( rModulWindow.GetHScrollBar() ) + rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); + rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() ); + rModulWindow.GetBreakPointWindow().DoScroll + ( rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() ); + rModulWindow.GetLineNumberWindow().DoScroll + ( rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() ); + } + else if( rTextHint.GetId() == SfxHintId::TextHeightChanged ) + { + if ( pEditView->GetStartDocPos().Y() ) { - if ( pEditView->GetStartDocPos().Y() ) - { - long nOutHeight = GetOutputSizePixel().Height(); - long nTextHeight = pEditEngine->GetTextHeight(); - if ( nTextHeight < nOutHeight ) - pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() ); + long nOutHeight = GetOutputSizePixel().Height(); + long nTextHeight = pEditEngine->GetTextHeight(); + if ( nTextHeight < nOutHeight ) + pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() ); - rModulWindow.GetLineNumberWindow().Invalidate(); - } - - SetScrollBarRanges(); + rModulWindow.GetLineNumberWindow().Invalidate(); } - else if( rTextHint.GetId() == SfxHintId::TextFormatted ) + + SetScrollBarRanges(); + } + else if( rTextHint.GetId() == SfxHintId::TextFormatted ) + { + if ( rModulWindow.GetHScrollBar() ) { - if ( rModulWindow.GetHScrollBar() ) + const long nWidth = pEditEngine->CalcTextWidth(); + if ( nWidth != nCurTextWidth ) { - const long nWidth = pEditEngine->CalcTextWidth(); - if ( nWidth != nCurTextWidth ) - { - nCurTextWidth = nWidth; - rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1) ); - rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); - } + nCurTextWidth = nWidth; + rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1) ); + rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() ); } - long nPrevTextWidth = nCurTextWidth; - nCurTextWidth = pEditEngine->CalcTextWidth(); - if ( nCurTextWidth != nPrevTextWidth ) - SetScrollBarRanges(); } - else if( rTextHint.GetId() == SfxHintId::TextParaInserted ) - { - ParagraphInsertedDeleted( rTextHint.GetValue(), true ); - DoDelayedSyntaxHighlight( rTextHint.GetValue() ); - } - else if( rTextHint.GetId() == SfxHintId::TextParaRemoved ) - { - ParagraphInsertedDeleted( rTextHint.GetValue(), false ); - } - else if( rTextHint.GetId() == SfxHintId::TextParaContentChanged ) - { - DoDelayedSyntaxHighlight( rTextHint.GetValue() ); - } - else if( rTextHint.GetId() == SfxHintId::TextViewSelectionChanged ) + long nPrevTextWidth = nCurTextWidth; + nCurTextWidth = pEditEngine->CalcTextWidth(); + if ( nCurTextWidth != nPrevTextWidth ) + SetScrollBarRanges(); + } + else if( rTextHint.GetId() == SfxHintId::TextParaInserted ) + { + ParagraphInsertedDeleted( rTextHint.GetValue(), true ); + DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + } + else if( rTextHint.GetId() == SfxHintId::TextParaRemoved ) + { + ParagraphInsertedDeleted( rTextHint.GetValue(), false ); + } + else if( rTextHint.GetId() == SfxHintId::TextParaContentChanged ) + { + DoDelayedSyntaxHighlight( rTextHint.GetValue() ); + } + else if( rTextHint.GetId() == SfxHintId::TextViewSelectionChanged ) + { + if (SfxBindings* pBindings = GetBindingsPtr()) { - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_CUT ); - pBindings->Invalidate( SID_COPY ); - } + pBindings->Invalidate( SID_CUT ); + pBindings->Invalidate( SID_COPY ); } } } @@ -1171,22 +1174,22 @@ void EditorWindow::InitScrollBars() void EditorWindow::ImpDoHighlight( sal_uLong nLine ) { - if ( bDoSyntaxHighlight ) - { - OUString aLine( pEditEngine->GetText( nLine ) ); - bool const bWasModified = pEditEngine->IsModified(); - pEditEngine->RemoveAttribs( nLine ); - std::vector<HighlightPortion> aPortions; - aHighlighter.getHighlightPortions( aLine, aPortions ); + if ( !bDoSyntaxHighlight ) + return; - for (auto const& portion : aPortions) - { - Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(portion.tokenType); - pEditEngine->SetAttrib(TextAttribFontColor(aColor), nLine, portion.nBegin, portion.nEnd); - } + OUString aLine( pEditEngine->GetText( nLine ) ); + bool const bWasModified = pEditEngine->IsModified(); + pEditEngine->RemoveAttribs( nLine ); + std::vector<HighlightPortion> aPortions; + aHighlighter.getHighlightPortions( aLine, aPortions ); - pEditEngine->SetModified(bWasModified); + for (auto const& portion : aPortions) + { + Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(portion.tokenType); + pEditEngine->SetAttrib(TextAttribFontColor(aColor), nLine, portion.nBegin, portion.nEnd); } + + pEditEngine->SetModified(bWasModified); } void EditorWindow::ChangeFontColor( Color aColor ) @@ -1459,44 +1462,44 @@ void BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt ) void BreakPointWindow::Command( const CommandEvent& rCEvt ) { - if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) - { - if (!mpUIBuilder) - mpUIBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/BasicIDE/ui/breakpointmenus.ui", "")); + if ( rCEvt.GetCommand() != CommandEventId::ContextMenu ) + return; - Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) ); - Point aEventPos( PixelToLogic( aPos ) ); - BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : nullptr; - if ( pBrk ) + if (!mpUIBuilder) + mpUIBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/BasicIDE/ui/breakpointmenus.ui", "")); + + Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) ); + Point aEventPos( PixelToLogic( aPos ) ); + BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : nullptr; + if ( pBrk ) + { + // test if break point is enabled... + VclPtr<PopupMenu> xBrkPropMenu = mpUIBuilder->get_menu("breakmenu"); + xBrkPropMenu->CheckItem("active", pBrk->bEnabled); + OString sCommand = xBrkPropMenu->GetItemIdent(xBrkPropMenu->Execute(this, aPos)); + if (sCommand == "active") { - // test if break point is enabled... - VclPtr<PopupMenu> xBrkPropMenu = mpUIBuilder->get_menu("breakmenu"); - xBrkPropMenu->CheckItem("active", pBrk->bEnabled); - OString sCommand = xBrkPropMenu->GetItemIdent(xBrkPropMenu->Execute(this, aPos)); - if (sCommand == "active") - { - pBrk->bEnabled = !pBrk->bEnabled; - rModulWindow.UpdateBreakPoint( *pBrk ); - Invalidate(); - } - else if (sCommand == "properties") - { - BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints()); - aBrkDlg.SetCurrentBreakPoint( *pBrk ); - aBrkDlg.run(); - Invalidate(); - } + pBrk->bEnabled = !pBrk->bEnabled; + rModulWindow.UpdateBreakPoint( *pBrk ); + Invalidate(); } - else + else if (sCommand == "properties") { - VclPtr<PopupMenu> xBrkListMenu = mpUIBuilder->get_menu("breaklistmenu"); - OString sCommand = xBrkListMenu->GetItemIdent(xBrkListMenu->Execute(this, aPos)); - if (sCommand == "manage") - { - BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints()); - aBrkDlg.run(); - Invalidate(); - } + BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints()); + aBrkDlg.SetCurrentBreakPoint( *pBrk ); + aBrkDlg.run(); + Invalidate(); + } + } + else + { + VclPtr<PopupMenu> xBrkListMenu = mpUIBuilder->get_menu("breaklistmenu"); + OString sCommand = xBrkListMenu->GetItemIdent(xBrkListMenu->Execute(this, aPos)); + if (sCommand == "manage") + { + BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints()); + aBrkDlg.run(); + Invalidate(); } } } @@ -2751,41 +2754,41 @@ void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel ) void CodeCompleteWindow::ResizeAndPositionListBox() { - if (m_xListBox->n_children() >= 1) - { - // if there is at least one element inside - // calculate basic position: under the current line - tools::Rectangle aRect = static_cast<TextEngine*>(pParent->GetEditEngine())->PaMtoEditCursor( pParent->GetEditView()->GetSelection().GetEnd() ); - long nViewYOffset = pParent->GetEditView()->GetStartDocPos().Y(); - Point aPos = aRect.BottomRight();// this variable will be used later (if needed) - aPos.setY( (aPos.Y() - nViewYOffset) + nBasePad ); + if (m_xListBox->n_children() < 1) + return; - // get line count - const sal_uInt16 nLines = static_cast<sal_uInt16>(std::min(6, m_xListBox->n_children())); + // if there is at least one element inside + // calculate basic position: under the current line + tools::Rectangle aRect = static_cast<TextEngine*>(pParent->GetEditEngine())->PaMtoEditCursor( pParent->GetEditView()->GetSelection().GetEnd() ); + long nViewYOffset = pParent->GetEditView()->GetStartDocPos().Y(); + Point aPos = aRect.BottomRight();// this variable will be used later (if needed) + aPos.setY( (aPos.Y() - nViewYOffset) + nBasePad ); - m_xListBox->set_size_request(-1, m_xListBox->get_height_rows(nLines)); + // get line count + const sal_uInt16 nLines = static_cast<sal_uInt16>(std::min(6, m_xListBox->n_children())); - Size aSize = m_xContainer->get_preferred_size(); - //set the size - SetSizePixel( aSize ); + m_xListBox->set_size_request(-1, m_xListBox->get_height_rows(nLines)); - //calculate position - const tools::Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() ); //the visible area - const Point& aBottomPoint = aVisArea.BottomRight(); + Size aSize = m_xContainer->get_preferred_size(); + //set the size + SetSizePixel( aSize ); - if( aVisArea.TopRight().getY() + aPos.getY() + aSize.getHeight() > aBottomPoint.getY() ) - {//clipped at the bottom: move it up - const long& nParentFontHeight = pParent->GetEditEngine()->GetFont().GetFontHeight(); //parent's font (in the IDE): needed for height - aPos.AdjustY( -(aSize.getHeight() + nParentFontHeight + nCursorPad) ); - } + //calculate position + const tools::Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() ); //the visible area + const Point& aBottomPoint = aVisArea.BottomRight(); - if( aVisArea.TopLeft().getX() + aPos.getX() + aSize.getWidth() > aBottomPoint.getX() ) - {//clipped at the right side, move it a bit left - aPos.AdjustX( -(aSize.getWidth() + aVisArea.TopLeft().getX()) ); - } - //set the position - SetPosPixel( aPos ); + if( aVisArea.TopRight().getY() + aPos.getY() + aSize.getHeight() > aBottomPoint.getY() ) + {//clipped at the bottom: move it up + const long& nParentFontHeight = pParent->GetEditEngine()->GetFont().GetFontHeight(); //parent's font (in the IDE): needed for height + aPos.AdjustY( -(aSize.getHeight() + nParentFontHeight + nCursorPad) ); + } + + if( aVisArea.TopLeft().getX() + aPos.getX() + aSize.getWidth() > aBottomPoint.getX() ) + {//clipped at the right side, move it a bit left + aPos.AdjustX( -(aSize.getWidth() + aVisArea.TopLeft().getX()) ); } + //set the position + SetPosPixel( aPos ); } void CodeCompleteWindow::SelectFirstEntry() diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index ece79057fc58..eab48715882b 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -621,138 +621,138 @@ void DialogWindow::SaveDialog() xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All ); xFP->setCurrentFilter( aDialogStr ); - if( xFP->execute() == RET_OK ) - { - Sequence< OUString > aPaths = xFP->getSelectedFiles(); - m_sCurPath = aPaths[0]; + if( xFP->execute() != RET_OK ) + return; - // export dialog model to xml - Reference< container::XNameContainer > xDialogModel = GetDialog(); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); - Reference< XInputStream > xInput( xISP->createInputStream() ); + Sequence< OUString > aPaths = xFP->getSelectedFiles(); + m_sCurPath = aPaths[0]; - Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); + // export dialog model to xml + Reference< container::XNameContainer > xDialogModel = GetDialog(); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); + Reference< XInputStream > xInput( xISP->createInputStream() ); - Reference< XOutputStream > xOutput; - try + Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); + + Reference< XOutputStream > xOutput; + try + { + if( xSFI->exists( m_sCurPath ) ) + xSFI->kill( m_sCurPath ); + xOutput = xSFI->openFileWrite( m_sCurPath ); + } + catch(const Exception& ) + {} + + if( xOutput.is() ) + { + Sequence< sal_Int8 > bytes; + sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() ); + for (;;) { - if( xSFI->exists( m_sCurPath ) ) - xSFI->kill( m_sCurPath ); - xOutput = xSFI->openFileWrite( m_sCurPath ); + if( nRead ) + xOutput->writeBytes( bytes ); + + nRead = xInput->readBytes( bytes, 1024 ); + if (! nRead) + break; } - catch(const Exception& ) - {} - if( xOutput.is() ) + // With resource? + Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY ); + Reference< resource::XStringResourceResolver > xStringResourceResolver; + if( xDialogModelPropSet.is() ) { - Sequence< sal_Int8 > bytes; - sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() ); - for (;;) + try { - if( nRead ) - xOutput->writeBytes( bytes ); - - nRead = xInput->readBytes( bytes, 1024 ); - if (! nRead) - break; + Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" ); + aResourceResolver >>= xStringResourceResolver; } + catch(const beans::UnknownPropertyException& ) + {} + } - // With resource? - Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY ); - Reference< resource::XStringResourceResolver > xStringResourceResolver; - if( xDialogModelPropSet.is() ) - { - try - { - Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" ); - aResourceResolver >>= xStringResourceResolver; - } - catch(const beans::UnknownPropertyException& ) - {} - } + bool bResource = false; + if( xStringResourceResolver.is() ) + { + Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); + if( aLocaleSeq.hasElements() ) + bResource = true; + } - bool bResource = false; - if( xStringResourceResolver.is() ) - { - Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); - if( aLocaleSeq.hasElements() ) - bResource = true; - } + if( bResource ) + { + INetURLObject aURLObj( m_sCurPath ); + aURLObj.removeExtension(); + OUString aDialogName( aURLObj.getName() ); + aURLObj.removeSegment(); + OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + OUString aComment = "# " + aDialogName + " strings" ; + Reference< task::XInteractionHandler > xDummyHandler; - if( bResource ) + // Remove old properties files in case of overwriting Dialog files + if( xSFI->isFolder( aURL ) ) { - INetURLObject aURLObj( m_sCurPath ); - aURLObj.removeExtension(); - OUString aDialogName( aURLObj.getName() ); - aURLObj.removeSegment(); - OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - OUString aComment = "# " + aDialogName + " strings" ; - Reference< task::XInteractionHandler > xDummyHandler; - - // Remove old properties files in case of overwriting Dialog files - if( xSFI->isFolder( aURL ) ) - { - Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false ); + Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false ); - OUString aDialogName_ = aDialogName + "_" ; - sal_Int32 nCount = aContentSeq.getLength(); - const OUString* pFiles = aContentSeq.getConstArray(); - for( int i = 0 ; i < nCount ; i++ ) + OUString aDialogName_ = aDialogName + "_" ; + sal_Int32 nCount = aContentSeq.getLength(); + const OUString* pFiles = aContentSeq.getConstArray(); + for( int i = 0 ; i < nCount ; i++ ) + { + OUString aCompleteName = pFiles[i]; + OUString aPureName; + OUString aExtension; + sal_Int32 iDot = aCompleteName.lastIndexOf( '.' ); + sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' ); + if( iDot != -1 ) { - OUString aCompleteName = pFiles[i]; - OUString aPureName; - OUString aExtension; - sal_Int32 iDot = aCompleteName.lastIndexOf( '.' ); - sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' ); - if( iDot != -1 ) - { - sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0; - aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom ); - aExtension = aCompleteName.copy( iDot + 1 ); - } + sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0; + aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom ); + aExtension = aCompleteName.copy( iDot + 1 ); + } - if( aExtension == "properties" || aExtension == "default" ) + if( aExtension == "properties" || aExtension == "default" ) + { + if( aPureName.startsWith( aDialogName_ ) ) { - if( aPureName.startsWith( aDialogName_ ) ) + try { - try - { - xSFI->kill( aCompleteName ); - } - catch(const uno::Exception& ) - {} + xSFI->kill( aCompleteName ); } + catch(const uno::Exception& ) + {} } } } + } - Reference< XStringResourceWithLocation > xStringResourceWithLocation = - StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/, - xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler ); + Reference< XStringResourceWithLocation > xStringResourceWithLocation = + StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/, + xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler ); - // Add locales - Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); - const lang::Locale* pLocales = aLocaleSeq.getConstArray(); - sal_Int32 nLocaleCount = aLocaleSeq.getLength(); - for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ ) - { - const lang::Locale& rLocale = pLocales[ iLocale ]; - xStringResourceWithLocation->newLocale( rLocale ); - } + // Add locales + Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales(); + const lang::Locale* pLocales = aLocaleSeq.getConstArray(); + sal_Int32 nLocaleCount = aLocaleSeq.getLength(); + for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ ) + { + const lang::Locale& rLocale = pLocales[ iLocale ]; + xStringResourceWithLocation->newLocale( rLocale ); + } - LocalizationMgr::copyResourceForDialog( xDialogModel, - xStringResourceResolver, xStringResourceWithLocation ); + LocalizationMgr::copyResourceForDialog( xDialogModel, + xStringResourceResolver, xStringResourceWithLocation ); - xStringResourceWithLocation->store(); - } - } - else - { - std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); - xBox->run(); + xStringResourceWithLocation->store(); } } + else + { + std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE))); + xBox->run(); + } } static std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq @@ -1166,32 +1166,32 @@ bool DialogWindow::IsPasteAllowed() void DialogWindow::StoreData() { - if ( IsModified() ) + if ( !IsModified() ) + return; + + try { - try + Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true ); + + if( xLib.is() ) { - Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true ); + Reference< container::XNameContainer > xDialogModel = m_pEditor->GetDialog(); - if( xLib.is() ) + if( xDialogModel.is() ) { - Reference< container::XNameContainer > xDialogModel = m_pEditor->GetDialog(); - - if( xDialogModel.is() ) - { - Reference< XComponentContext > xContext( - comphelper::getProcessComponentContext() ); - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); - xLib->replaceByName( GetName(), Any( xISP ) ); - } + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() ); + xLib->replaceByName( GetName(), Any( xISP ) ); } } - catch (const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION("basctl.basicide"); - } - MarkDocumentModified( GetDocument() ); - m_pEditor->ClearModifyFlag(); } + catch (const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("basctl.basicide"); + } + MarkDocumentModified( GetDocument() ); + m_pEditor->ClearModifyFlag(); } void DialogWindow::Activating () diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index ff7224ac6cb0..12399e823019 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -1120,75 +1120,75 @@ bool Shell::HasUIFeature(SfxShellFeature nFeature) const void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRememberAsCurrent ) { - if ( pNewWin != pCurWin ) + if ( pNewWin == pCurWin ) + return; + + pCurWin = pNewWin; + if (pLayout) + pLayout->Deactivating(); + if (pCurWin) { - pCurWin = pNewWin; - if (pLayout) - pLayout->Deactivating(); - if (pCurWin) - { - if (pCurWin->GetType() == TYPE_MODULE) - pLayout = pModulLayout.get(); - else - pLayout = pDialogLayout.get(); - AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel()); - pLayout->Activating(*pCurWin); - GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid()); - if (bRememberAsCurrent) - pCurWin->InsertLibInfo(); - if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise - pCurWin->Show(); - pCurWin->Init(); - if (!GetExtraData()->ShellInCriticalSection()) - { - vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow(); - vcl::Window* pFocusWindow = Application::GetFocusWindow(); - while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) ) - pFocusWindow = pFocusWindow->GetParent(); - if ( pFocusWindow ) // Focus in BasicIDE - pCurWin->GrabFocus(); - } - } + if (pCurWin->GetType() == TYPE_MODULE) + pLayout = pModulLayout.get(); else + pLayout = pDialogLayout.get(); + AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel()); + pLayout->Activating(*pCurWin); + GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid()); + if (bRememberAsCurrent) + pCurWin->InsertLibInfo(); + if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise + pCurWin->Show(); + pCurWin->Init(); + if (!GetExtraData()->ShellInCriticalSection()) { - SetWindow(pLayout); - pLayout = nullptr; - } - if ( bUpdateTabBar ) - { - sal_uInt16 nKey = GetWindowId( pCurWin ); - if ( pCurWin && ( pTabBar->GetPagePos( nKey ) == TabBar::PAGE_NOT_FOUND ) ) - pTabBar->InsertPage( nKey, pCurWin->GetTitle() ); // has just been faded in - pTabBar->SetCurPageId( nKey ); + vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow(); + vcl::Window* pFocusWindow = Application::GetFocusWindow(); + while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) ) + pFocusWindow = pFocusWindow->GetParent(); + if ( pFocusWindow ) // Focus in BasicIDE + pCurWin->GrabFocus(); } - if ( pCurWin && pCurWin->IsSuspended() ) // if the window is shown in the case of an error... - pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED ); - if ( pCurWin ) - { - SetWindow( pCurWin ); - if ( pCurWin->GetDocument().isDocument() ) - SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() ); - } - else if (pLayout) - { - SetWindow(pLayout); - GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); - SfxObjectShell::SetCurrentComponent(nullptr); - } - aObjectCatalog->SetCurrentEntry(pCurWin); - SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr ); - InvalidateBasicIDESlots(); - InvalidateControlSlots(); - EnableScrollbars(pCurWin != nullptr); + } + else + { + SetWindow(pLayout); + pLayout = nullptr; + } + if ( bUpdateTabBar ) + { + sal_uInt16 nKey = GetWindowId( pCurWin ); + if ( pCurWin && ( pTabBar->GetPagePos( nKey ) == TabBar::PAGE_NOT_FOUND ) ) + pTabBar->InsertPage( nKey, pCurWin->GetTitle() ); // has just been faded in + pTabBar->SetCurPageId( nKey ); + } + if ( pCurWin && pCurWin->IsSuspended() ) // if the window is shown in the case of an error... + pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED ); + if ( pCurWin ) + { + SetWindow( pCurWin ); + if ( pCurWin->GetDocument().isDocument() ) + SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() ); + } + else if (pLayout) + { + SetWindow(pLayout); + GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); + SfxObjectShell::SetCurrentComponent(nullptr); + } + aObjectCatalog->SetCurrentEntry(pCurWin); + SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr ); + InvalidateBasicIDESlots(); + InvalidateControlSlots(); + EnableScrollbars(pCurWin != nullptr); - if ( m_pCurLocalizationMgr ) - m_pCurLocalizationMgr->handleTranslationbar(); + if ( m_pCurLocalizationMgr ) + m_pCurLocalizationMgr->handleTranslationbar(); - ManageToolbars(); + ManageToolbars(); - // fade out (in) property browser in module (dialog) windows - UIFeatureChanged(); - } + // fade out (in) property browser in module (dialog) windows + UIFeatureChanged(); } void Shell::ManageToolbars() @@ -1203,33 +1203,33 @@ void Shell::ManageToolbars() Reference< beans::XPropertySet > xFrameProps ( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); - if ( xFrameProps.is() ) + if ( !xFrameProps.is() ) + return; + + Reference< css::frame::XLayoutManager > xLayoutManager; + uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" ); + a >>= xLayoutManager; + if ( !xLayoutManager.is() ) + return; + + xLayoutManager->lock(); + if (dynamic_cast<DialogWindow*>(pCurWin.get())) { - Reference< css::frame::XLayoutManager > xLayoutManager; - uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" ); - a >>= xLayoutManager; - if ( xLayoutManager.is() ) - { - xLayoutManager->lock(); - if (dynamic_cast<DialogWindow*>(pCurWin.get())) - { - xLayoutManager->destroyElement( aMacroBarResName ); + xLayoutManager->destroyElement( aMacroBarResName ); - xLayoutManager->requestElement( aDialogBarResName ); - xLayoutManager->requestElement( aInsertControlsBarResName ); - xLayoutManager->requestElement( aFormControlsBarResName ); - } - else - { - xLayoutManager->destroyElement( aDialogBarResName ); - xLayoutManager->destroyElement( aInsertControlsBarResName ); - xLayoutManager->destroyElement( aFormControlsBarResName ); + xLayoutManager->requestElement( aDialogBarResName ); + xLayoutManager->requestElement( aInsertControlsBarResName ); + xLayoutManager->requestElement( aFormControlsBarResName ); + } + else + { + xLayoutManager->destroyElement( aDialogBarResName ); + xLayoutManager->destroyElement( aInsertControlsBarResName ); + xLayoutManager->destroyElement( aFormControlsBarResName ); - xLayoutManager->requestElement( aMacroBarResName ); - } - xLayoutManager->unlock(); - } + xLayoutManager->requestElement( aMacroBarResName ); } + xLayoutManager->unlock(); } VclPtr<BaseWindow> Shell::FindApplicationWindow() diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index ebf8245089c5..fedebcb1d98b 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -115,20 +115,20 @@ void Shell::SetMDITitle() } SfxViewFrame* pViewFrame = GetViewFrame(); - if ( pViewFrame ) - { - SfxObjectShell* pShell = pViewFrame->GetObjectShell(); - if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle ) - { - pShell->SetTitle( aTitle ); - pShell->SetModified(false); - } + if ( !pViewFrame ) + return; - css::uno::Reference< css::frame::XController > xController = GetController (); - css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY); - if (xTitle.is ()) - xTitle->setTitle (aTitle); + SfxObjectShell* pShell = pViewFrame->GetObjectShell(); + if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle ) + { + pShell->SetTitle( aTitle ); + pShell->SetModified(false); } + + css::uno::Reference< css::frame::XController > xController = GetController (); + css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY); + if (xTitle.is ()) + xTitle->setTitle (aTitle); } VclPtr<ModulWindow> Shell::CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName ) diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx index b2394690c08c..896b77f2f892 100644 --- a/basctl/source/basicide/basidesh.cxx +++ b/basctl/source/basicide/basidesh.cxx @@ -473,69 +473,70 @@ SfxUndoManager* Shell::GetUndoManager() void Shell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { - if (GetShell()) + if (!GetShell()) + return; + + if (rHint.GetId() == SfxHintId::Dying) { - if (rHint.GetId() == SfxHintId::Dying) - { - EndListening( rBC, true /* log off all */ ); - aObjectCatalog->UpdateEntries(); - } + EndListening( rBC, true /* log off all */ ); + aObjectCatalog->UpdateEntries(); + } - if (SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint)) - { - const SfxHintId nHintId = pSbxHint->GetId(); - if ( ( nHintId == SfxHintId::BasicStart ) || - ( nHintId == SfxHintId::BasicStop ) ) - { - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_BASICRUN ); - pBindings->Update( SID_BASICRUN ); - pBindings->Invalidate( SID_BASICCOMPILE ); - pBindings->Update( SID_BASICCOMPILE ); - pBindings->Invalidate( SID_BASICSTEPOVER ); - pBindings->Update( SID_BASICSTEPOVER ); - pBindings->Invalidate( SID_BASICSTEPINTO ); - pBindings->Update( SID_BASICSTEPINTO ); - pBindings->Invalidate( SID_BASICSTEPOUT ); - pBindings->Update( SID_BASICSTEPOUT ); - pBindings->Invalidate( SID_BASICSTOP ); - pBindings->Update( SID_BASICSTOP ); - pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); - pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); - pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS ); - pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS ); - pBindings->Invalidate( SID_BASICIDE_MODULEDLG ); - pBindings->Update( SID_BASICIDE_MODULEDLG ); - pBindings->Invalidate( SID_BASICLOAD ); - pBindings->Update( SID_BASICLOAD ); - } + SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint); + if (!pSbxHint) + return; - if ( nHintId == SfxHintId::BasicStop ) - { - // not only at error/break or explicit stoppage, - // if the update is turned off due to a programming bug - BasicStopped(); - if (pLayout) - pLayout->UpdateDebug(true); // clear... - if( m_pCurLocalizationMgr ) - m_pCurLocalizationMgr->handleBasicStopped(); - } - else if( m_pCurLocalizationMgr ) - { - m_pCurLocalizationMgr->handleBasicStarted(); - } + const SfxHintId nHintId = pSbxHint->GetId(); + if ( !(( nHintId == SfxHintId::BasicStart ) || + ( nHintId == SfxHintId::BasicStop )) ) + return; - for (auto const& window : aWindowTable) - { - BaseWindow* pWin = window.second; - if ( nHintId == SfxHintId::BasicStart ) - pWin->BasicStarted(); - else - pWin->BasicStopped(); - } - } - } + if (SfxBindings* pBindings = GetBindingsPtr()) + { + pBindings->Invalidate( SID_BASICRUN ); + pBindings->Update( SID_BASICRUN ); + pBindings->Invalidate( SID_BASICCOMPILE ); + pBindings->Update( SID_BASICCOMPILE ); + pBindings->Invalidate( SID_BASICSTEPOVER ); + pBindings->Update( SID_BASICSTEPOVER ); + pBindings->Invalidate( SID_BASICSTEPINTO ); + pBindings->Update( SID_BASICSTEPINTO ); + pBindings->Invalidate( SID_BASICSTEPOUT ); + pBindings->Update( SID_BASICSTEPOUT ); + pBindings->Invalidate( SID_BASICSTOP ); + pBindings->Update( SID_BASICSTOP ); + pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); + pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); + pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS ); + pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS ); + pBindings->Invalidate( SID_BASICIDE_MODULEDLG ); + pBindings->Update( SID_BASICIDE_MODULEDLG ); + pBindings->Invalidate( SID_BASICLOAD ); + pBindings->Update( SID_BASICLOAD ); + } + + if ( nHintId == SfxHintId::BasicStop ) + { + // not only at error/break or explicit stoppage, + // if the update is turned off due to a programming bug + BasicStopped(); + if (pLayout) + pLayout->UpdateDebug(true); // clear... + if( m_pCurLocalizationMgr ) + m_pCurLocalizationMgr->handleBasicStopped(); + } + else if( m_pCurLocalizationMgr ) + { + m_pCurLocalizationMgr->handleBasicStarted(); + } + + for (auto const& window : aWindowTable) + { + BaseWindow* pWin = window.second; + if ( nHintId == SfxHintId::BasicStart ) + pWin->BasicStarted(); + else + pWin->BasicStopped(); } } @@ -802,91 +803,93 @@ void Shell::InvalidateBasicIDESlots() { // only those that have an optic effect... - if (GetShell()) - { - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_COPY ); - pBindings->Invalidate( SID_CUT ); - pBindings->Invalidate( SID_PASTE ); - pBindings->Invalidate( SID_UNDO ); - pBindings->Invalidate( SID_REDO ); - pBindings->Invalidate( SID_SAVEDOC ); - pBindings->Invalidate( SID_SIGNATURE ); - pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO ); - pBindings->Invalidate( SID_BASICIDE_MODULEDLG ); - pBindings->Invalidate( SID_BASICIDE_OBJCAT ); - pBindings->Invalidate( SID_BASICSTOP ); - pBindings->Invalidate( SID_BASICRUN ); - pBindings->Invalidate( SID_BASICCOMPILE ); - pBindings->Invalidate( SID_BASICLOAD ); - pBindings->Invalidate( SID_BASICSAVEAS ); - pBindings->Invalidate( SID_BASICIDE_MATCHGROUP ); - pBindings->Invalidate( SID_BASICSTEPINTO ); - pBindings->Invalidate( SID_BASICSTEPOVER ); - pBindings->Invalidate( SID_BASICSTEPOUT ); - pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); - pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS ); - pBindings->Invalidate( SID_BASICIDE_ADDWATCH ); - pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH ); - - pBindings->Invalidate( SID_PRINTDOC ); - pBindings->Invalidate( SID_PRINTDOCDIRECT ); - pBindings->Invalidate( SID_SETUPPRINTER ); - pBindings->Invalidate( SID_DIALOG_TESTMODE ); - - pBindings->Invalidate( SID_DOC_MODIFIED ); - pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); - pBindings->Invalidate( SID_BASICIDE_STAT_POS ); - pBindings->Invalidate( SID_ATTR_INSERT ); - pBindings->Invalidate( SID_ATTR_SIZE ); - } - } + if (!GetShell()) + return; + + SfxBindings* pBindings = GetBindingsPtr(); + if (!pBindings) + return; + + pBindings->Invalidate( SID_COPY ); + pBindings->Invalidate( SID_CUT ); + pBindings->Invalidate( SID_PASTE ); + pBindings->Invalidate( SID_UNDO ); + pBindings->Invalidate( SID_REDO ); + pBindings->Invalidate( SID_SAVEDOC ); + pBindings->Invalidate( SID_SIGNATURE ); + pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO ); + pBindings->Invalidate( SID_BASICIDE_MODULEDLG ); + pBindings->Invalidate( SID_BASICIDE_OBJCAT ); + pBindings->Invalidate( SID_BASICSTOP ); + pBindings->Invalidate( SID_BASICRUN ); + pBindings->Invalidate( SID_BASICCOMPILE ); + pBindings->Invalidate( SID_BASICLOAD ); + pBindings->Invalidate( SID_BASICSAVEAS ); + pBindings->Invalidate( SID_BASICIDE_MATCHGROUP ); + pBindings->Invalidate( SID_BASICSTEPINTO ); + pBindings->Invalidate( SID_BASICSTEPOVER ); + pBindings->Invalidate( SID_BASICSTEPOUT ); + pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); + pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS ); + pBindings->Invalidate( SID_BASICIDE_ADDWATCH ); + pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH ); + + pBindings->Invalidate( SID_PRINTDOC ); + pBindings->Invalidate( SID_PRINTDOCDIRECT ); + pBindings->Invalidate( SID_SETUPPRINTER ); + pBindings->Invalidate( SID_DIALOG_TESTMODE ); + + pBindings->Invalidate( SID_DOC_MODIFIED ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); + pBindings->Invalidate( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_ATTR_INSERT ); + pBindings->Invalidate( SID_ATTR_SIZE ); } void Shell::InvalidateControlSlots() { - if (GetShell()) - { - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_INSERT_FORM_RADIO ); - pBindings->Invalidate( SID_INSERT_FORM_CHECK ); - pBindings->Invalidate( SID_INSERT_FORM_LIST ); - pBindings->Invalidate( SID_INSERT_FORM_COMBO ); - pBindings->Invalidate( SID_INSERT_FORM_VSCROLL ); - pBindings->Invalidate( SID_INSERT_FORM_HSCROLL ); - pBindings->Invalidate( SID_INSERT_FORM_SPIN ); - - pBindings->Invalidate( SID_INSERT_SELECT ); - pBindings->Invalidate( SID_INSERT_PUSHBUTTON ); - pBindings->Invalidate( SID_INSERT_RADIOBUTTON ); - pBindings->Invalidate( SID_INSERT_CHECKBOX ); - pBindings->Invalidate( SID_INSERT_LISTBOX ); - pBindings->Invalidate( SID_INSERT_COMBOBOX ); - pBindings->Invalidate( SID_INSERT_GROUPBOX ); - pBindings->Invalidate( SID_INSERT_EDIT ); - pBindings->Invalidate( SID_INSERT_FIXEDTEXT ); - pBindings->Invalidate( SID_INSERT_IMAGECONTROL ); - pBindings->Invalidate( SID_INSERT_PROGRESSBAR ); - pBindings->Invalidate( SID_INSERT_HSCROLLBAR ); - pBindings->Invalidate( SID_INSERT_VSCROLLBAR ); - pBindings->Invalidate( SID_INSERT_HFIXEDLINE ); - pBindings->Invalidate( SID_INSERT_VFIXEDLINE ); - pBindings->Invalidate( SID_INSERT_DATEFIELD ); - pBindings->Invalidate( SID_INSERT_TIMEFIELD ); - pBindings->Invalidate( SID_INSERT_NUMERICFIELD ); - pBindings->Invalidate( SID_INSERT_CURRENCYFIELD ); - pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD ); - pBindings->Invalidate( SID_INSERT_PATTERNFIELD ); - pBindings->Invalidate( SID_INSERT_FILECONTROL ); - pBindings->Invalidate( SID_INSERT_SPINBUTTON ); - pBindings->Invalidate( SID_INSERT_GRIDCONTROL ); - pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL ); - pBindings->Invalidate( SID_INSERT_TREECONTROL ); - pBindings->Invalidate( SID_CHOOSE_CONTROLS ); - } - } + if (!GetShell()) + return; + + SfxBindings* pBindings = GetBindingsPtr(); + if (!pBindings) + return; + + pBindings->Invalidate( SID_INSERT_FORM_RADIO ); + pBindings->Invalidate( SID_INSERT_FORM_CHECK ); + pBindings->Invalidate( SID_INSERT_FORM_LIST ); + pBindings->Invalidate( SID_INSERT_FORM_COMBO ); + pBindings->Invalidate( SID_INSERT_FORM_VSCROLL ); + pBindings->Invalidate( SID_INSERT_FORM_HSCROLL ); + pBindings->Invalidate( SID_INSERT_FORM_SPIN ); + + pBindings->Invalidate( SID_INSERT_SELECT ); + pBindings->Invalidate( SID_INSERT_PUSHBUTTON ); + pBindings->Invalidate( SID_INSERT_RADIOBUTTON ); + pBindings->Invalidate( SID_INSERT_CHECKBOX ); + pBindings->Invalidate( SID_INSERT_LISTBOX ); + pBindings->Invalidate( SID_INSERT_COMBOBOX ); + pBindings->Invalidate( SID_INSERT_GROUPBOX ); + pBindings->Invalidate( SID_INSERT_EDIT ); + pBindings->Invalidate( SID_INSERT_FIXEDTEXT ); + pBindings->Invalidate( SID_INSERT_IMAGECONTROL ); + pBindings->Invalidate( SID_INSERT_PROGRESSBAR ); + pBindings->Invalidate( SID_INSERT_HSCROLLBAR ); + pBindings->Invalidate( SID_INSERT_VSCROLLBAR ); + pBindings->Invalidate( SID_INSERT_HFIXEDLINE ); + pBindings->Invalidate( SID_INSERT_VFIXEDLINE ); + pBindings->Invalidate( SID_INSERT_DATEFIELD ); + pBindings->Invalidate( SID_INSERT_TIMEFIELD ); + pBindings->Invalidate( SID_INSERT_NUMERICFIELD ); + pBindings->Invalidate( SID_INSERT_CURRENCYFIELD ); + pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD ); + pBindings->Invalidate( SID_INSERT_PATTERNFIELD ); + pBindings->Invalidate( SID_INSERT_FILECONTROL ); + pBindings->Invalidate( SID_INSERT_SPINBUTTON ); + pBindings->Invalidate( SID_INSERT_GRIDCONTROL ); + pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL ); + pBindings->Invalidate( SID_INSERT_TREECONTROL ); + pBindings->Invalidate( SID_CHOOSE_CONTROLS ); } void Shell::EnableScrollbars( bool bEnable ) @@ -897,32 +900,32 @@ void Shell::EnableScrollbars( bool bEnable ) void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck ) { - if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) ) - { - ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); + if ( !(!bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName )) ) + return; - m_aCurDocument = rDocument; - m_aCurLibName = aLibName; + ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() ); - if ( pListener ) - { - pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); - pListener->addContainerListener( m_aCurDocument, aLibName ); - } + m_aCurDocument = rDocument; + m_aCurLibName = aLibName; + + if ( pListener ) + { + pListener->removeContainerListener( m_aCurDocument, m_aCurLibName ); + pListener->addContainerListener( m_aCurDocument, aLibName ); + } - if ( bUpdateWindows ) - UpdateWindows(); + if ( bUpdateWindows ) + UpdateWindows(); - SetMDITitle(); + SetMDITitle(); - SetCurLibForLocalization( rDocument, aLibName ); + SetCurLibForLocalization( rDocument, aLibName ); - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR ); - pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG ); - pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG ); - } + if (SfxBindings* pBindings = GetBindingsPtr()) + { + pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR ); + pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG ); + pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG ); } } diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 41c4f52052a4..64255fc1162a 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -344,27 +344,28 @@ void BasicStopped( void InvalidateDebuggerSlots() { - if (SfxBindings* pBindings = GetBindingsPtr()) - { - pBindings->Invalidate( SID_BASICSTOP ); - pBindings->Update( SID_BASICSTOP ); - pBindings->Invalidate( SID_BASICRUN ); - pBindings->Update( SID_BASICRUN ); - pBindings->Invalidate( SID_BASICCOMPILE ); - pBindings->Update( SID_BASICCOMPILE ); - pBindings->Invalidate( SID_BASICSTEPOVER ); - pBindings->Update( SID_BASICSTEPOVER ); - pBindings->Invalidate( SID_BASICSTEPINTO ); - pBindings->Update( SID_BASICSTEPINTO ); - pBindings->Invalidate( SID_BASICSTEPOUT ); - pBindings->Update( SID_BASICSTEPOUT ); - pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); - pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); - pBindings->Invalidate( SID_BASICIDE_STAT_POS ); - pBindings->Update( SID_BASICIDE_STAT_POS ); - pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); - pBindings->Update( SID_BASICIDE_STAT_TITLE ); - } + SfxBindings* pBindings = GetBindingsPtr(); + if (!pBindings) + return; + + pBindings->Invalidate( SID_BASICSTOP ); + pBindings->Update( SID_BASICSTOP ); + pBindings->Invalidate( SID_BASICRUN ); + pBindings->Update( SID_BASICRUN ); + pBindings->Invalidate( SID_BASICCOMPILE ); + pBindings->Update( SID_BASICCOMPILE ); + pBindings->Invalidate( SID_BASICSTEPOVER ); + pBindings->Update( SID_BASICSTEPOVER ); + pBindings->Invalidate( SID_BASICSTEPINTO ); + pBindings->Update( SID_BASICSTEPINTO ); + pBindings->Invalidate( SID_BASICSTEPOUT ); + pBindings->Update( SID_BASICSTEPOUT ); + pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT ); + pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); + pBindings->Invalidate( SID_BASICIDE_STAT_POS ); + pBindings->Update( SID_BASICIDE_STAT_POS ); + pBindings->Invalidate( SID_BASICIDE_STAT_TITLE ); + pBindings->Update( SID_BASICIDE_STAT_TITLE ); } long HandleBasicError( StarBASIC const * pBasic ) diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx index 4efdb2c1be41..f120f41e0577 100644 --- a/basctl/source/basicide/bastype2.cxx +++ b/basctl/source/basicide/bastype2.cxx @@ -330,38 +330,38 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry, } // dialogs - if ( nMode & BrowseMode::Dialogs ) - { - Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) ); + if ( !(nMode & BrowseMode::Dialogs) ) + return; - if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( rLibName ) && xDlgLibContainer->isLibraryLoaded( rLibName ) ) - { - try - { - // get a sorted list of dialog names - Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) ); - sal_Int32 nDlgCount = aDlgNames.getLength(); - const OUString* pDlgNames = aDlgNames.getConstArray(); + Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) ); - auto xTreeIter = m_xControl->make_iterator(); + if ( !(xDlgLibContainer.is() && xDlgLibContainer->hasByName( rLibName ) && xDlgLibContainer->isLibraryLoaded( rLibName )) ) + return; - for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ ) - { - OUString aDlgName = pDlgNames[ i ]; - m_xControl->copy_iterator(rLibRootEntry, *xTreeIter); - bool bDialogEntry = FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xTreeIter); - if (!bDialogEntry) - { - AddEntry(aDlgName, RID_BMP_DIALOG, &rLibRootEntry, false, std::make_unique<Entry>(OBJ_TYPE_DIALOG)); - } - } - } - catch (const container::NoSuchElementException& ) + try + { + // get a sorted list of dialog names + Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) ); + sal_Int32 nDlgCount = aDlgNames.getLength(); + const OUString* pDlgNames = aDlgNames.getConstArray(); + + auto xTreeIter = m_xControl->make_iterator(); + + for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ ) + { ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits