basctl/source/basicide/basidesh.cxx |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 9ebba1d99457a1049c2f61ba15cd4c99a68d74e7
Author:     Rafael Lima <rafael.palma.l...@gmail.com>
AuthorDate: Wed Jan 11 20:21:29 2023 +0000
Commit:     Rafael Lima <rafael.palma.l...@gmail.com>
CommitDate: Wed Feb 8 11:46:34 2023 +0000

    tdf#147488 BASIC: Create empty module when an empty library is selected
    
    If the Standard library is empty (has no modules), when the Basic IDE is 
opened it shows only a black screen with nothing.
    
    This patch makes it so that when the Standard library has no modules, a 
generic module is created and shown.
    
    Change-Id: I26dbe41b4244492a21649ab08c5fc2df24ca12a9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145309
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Tested-by: Jenkins

diff --git a/basctl/source/basicide/basidesh.cxx 
b/basctl/source/basicide/basidesh.cxx
index eb3d6996c191..ae61007c7bf8 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -628,6 +628,9 @@ void Shell::UpdateWindows()
 {
     // remove all windows that may not be displayed
     bool bChangeCurWindow = pCurWin == nullptr;
+    // stores the total number of modules and dialogs visible
+    sal_uInt16 nTotalTabs = 0;
+
     if ( !m_aCurLibName.isEmpty() )
     {
         std::vector<VclPtr<BaseWindow> > aDeleteVec;
@@ -704,6 +707,7 @@ void Shell::UpdateWindows()
                             Sequence< OUString > aModNames( 
doc.getObjectNames( E_SCRIPTS, aLibName ) );
                             sal_Int32 nModCount = aModNames.getLength();
                             const OUString* pModNames = 
aModNames.getConstArray();
+                            nTotalTabs += nModCount;
 
                             for ( sal_Int32 j = 0 ; j < nModCount ; j++ )
                             {
@@ -733,6 +737,7 @@ void Shell::UpdateWindows()
                             Sequence< OUString > aDlgNames = 
doc.getObjectNames( E_DIALOGS, aLibName );
                             sal_Int32 nDlgCount = aDlgNames.getLength();
                             const OUString* pDlgNames = 
aDlgNames.getConstArray();
+                            nTotalTabs += nDlgCount;
 
                             for ( sal_Int32 j = 0 ; j < nDlgCount ; j++ )
                             {
@@ -761,7 +766,12 @@ void Shell::UpdateWindows()
 
     if ( bChangeCurWindow )
     {
-        if ( !pNextActiveWindow )
+        if ( nTotalTabs == 0 )
+        {
+            // If no tabs are opened, create a generic module and make it 
visible
+            pNextActiveWindow = CreateBasWin( m_aCurDocument, m_aCurLibName, 
OUString() );
+        }
+        else if ( !pNextActiveWindow )
         {
             pNextActiveWindow = FindApplicationWindow().get();
         }

Reply via email to