summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-11 13:50:50 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-12 17:55:27 +0100
commit4a72d6f474b105cdaa7a570b1f199475cc64bb14 (patch)
treeb800c82e70b849b8a25e28d0f78921c21c3b9392
parent1ac2c003a237af28132d34946f76b57652e20a47 (diff)
drop newly unused TreeListBox
Change-Id: Iea157bb472ee409a1a15b9f6c9cfe0adc21d1a03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88449 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--basctl/source/basicide/bastype2.cxx688
-rw-r--r--basctl/source/basicide/bastype3.cxx302
-rw-r--r--basctl/source/basicide/moduldlg.cxx1
-rw-r--r--basctl/source/basicide/moduldlg.hxx1
-rw-r--r--basctl/source/inc/bastype2.hxx67
5 files changed, 2 insertions, 1057 deletions
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 642b5c7adaea..a0bff5610898 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -159,694 +159,6 @@ EntryDescriptor::EntryDescriptor (
OSL_ENSURE( m_aDocument.isValid(), "EntryDescriptor::EntryDescriptor: invalid document!" );
}
-TreeListBox::TreeListBox (vcl::Window* pParent, WinBits nStyle)
- : SvTreeListBox(pParent, nStyle)
- , m_aNotifier( *this )
-{
- SetNodeDefaultImages();
- SetSelectionMode( SelectionMode::Single );
-}
-
-TreeListBox::~TreeListBox ()
-{
- disposeOnce();
-}
-
-void TreeListBox::dispose()
-{
- m_aNotifier.dispose();
-
- // destroy user data
- SvTreeListEntry* pEntry = First();
- while ( pEntry )
- {
- delete static_cast<Entry*>( pEntry->GetUserData() );
- pEntry->SetUserData( nullptr );
- pEntry = Next( pEntry );
- }
- SvTreeListBox::dispose();
-}
-
-void TreeListBox::ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
-{
- OSL_ENSURE( rDocument.isAlive(), "TreeListBox::ScanEntry: illegal document!" );
- if ( !rDocument.isAlive() )
- return;
-
- // can be called multiple times for updating!
-
- // actually test if basic's in the tree already?!
- SetUpdateMode(false);
-
- // level 1: BasicManager (application, document, ...)
- SvTreeListEntry* pDocumentRootEntry = FindRootEntry( rDocument, eLocation );
- if ( pDocumentRootEntry && IsExpanded( pDocumentRootEntry ) )
- ImpCreateLibEntries( pDocumentRootEntry, rDocument, eLocation );
- if ( !pDocumentRootEntry )
- {
- OUString aRootName( GetRootEntryName( rDocument, eLocation ) );
- Image aImage;
- GetRootEntryBitmaps( rDocument, aImage );
- AddEntry(
- aRootName,
- aImage,
- nullptr, true, std::make_unique<DocumentEntry>(rDocument, eLocation));
- }
-
- SetUpdateMode(true);
-}
-
-void TreeListBox::ImpCreateLibEntries( SvTreeListEntry* pDocumentRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation )
-{
- // get a sorted list of library names
- Sequence< OUString > aLibNames( rDocument.getLibraryNames() );
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
-
- for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
- {
- OUString aLibName = pLibNames[ i ];
-
- if ( eLocation == rDocument.getLibraryLocation( aLibName ) )
- {
- // check, if the module library is loaded
- bool bModLibLoaded = false;
- Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryLoaded( aLibName ) )
- bModLibLoaded = true;
-
- // check, if the dialog library is loaded
- bool bDlgLibLoaded = false;
- Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryLoaded( aLibName ) )
- bDlgLibLoaded = true;
-
- bool bLoaded = bModLibLoaded || bDlgLibLoaded;
-
- // if only one of the libraries is loaded, load also the other
- if ( bLoaded )
- {
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && !xModLibContainer->isLibraryLoaded( aLibName ) )
- xModLibContainer->loadLibrary( aLibName );
-
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && !xDlgLibContainer->isLibraryLoaded( aLibName ) )
- xDlgLibContainer->loadLibrary( aLibName );
- }
-
- // create tree list box entry
- OUString sId = bLoaded ? OUStringLiteral(RID_BMP_MODLIB) : OUStringLiteral(RID_BMP_MODLIBNOTLOADED);
- SvTreeListEntry* pLibRootEntry = FindEntry( pDocumentRootEntry, aLibName, OBJ_TYPE_LIBRARY );
- if ( pLibRootEntry )
- {
- SetEntryBitmaps(pLibRootEntry, Image(StockImage::Yes, sId));
- if ( IsExpanded(pLibRootEntry))
- ImpCreateLibSubEntries( pLibRootEntry, rDocument, aLibName );
- }
- else
- {
- AddEntry(
- aLibName,
- Image(StockImage::Yes, sId),
- pDocumentRootEntry, true,
- std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
- }
- }
- }
-}
-
-void TreeListBox::ImpCreateLibSubEntries( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName )
-{
- // modules
- {
- Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
-
- if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) && xModLibContainer->isLibraryLoaded( rLibName ) )
- {
- try
- {
- if( rDocument.isInVBAMode() )
- ImpCreateLibSubEntriesInVBAMode( pLibRootEntry, rDocument, rLibName );
- else
- {
- // get a sorted list of module names
- Sequence< OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
-
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
- {
- OUString aModName = pModNames[ i ];
- SvTreeListEntry* pModuleEntry = FindEntry( pLibRootEntry, aModName, OBJ_TYPE_MODULE );
- if ( !pModuleEntry )
- {
- pModuleEntry = AddEntry(
- aModName,
- Image(StockImage::Yes, RID_BMP_MODULE),
- pLibRootEntry, false,
- std::make_unique<Entry>(OBJ_TYPE_MODULE));
- }
-
- // methods
- {
- Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
- FillTreeListBox( pModuleEntry, aNames, OBJ_TYPE_METHOD, RID_BMP_MACRO );
- }
- }
- }
- }
- catch ( const container::NoSuchElementException& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
- }
- }
-
- // dialogs
- {
- Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
-
- 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 ) );
- FillTreeListBox( pLibRootEntry, aDlgNames, OBJ_TYPE_DIALOG, RID_BMP_DIALOG );
- }
- catch (const container::NoSuchElementException& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
- }
- }
-}
-
-void TreeListBox::ImpCreateLibSubEntriesInVBAMode( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName )
-{
- auto const aEntries = {
- std::make_pair( OBJ_TYPE_DOCUMENT_OBJECTS, IDEResId(RID_STR_DOCUMENT_OBJECTS) ),
- std::make_pair( OBJ_TYPE_USERFORMS, IDEResId(RID_STR_USERFORMS) ),
- std::make_pair( OBJ_TYPE_NORMAL_MODULES, IDEResId(RID_STR_NORMAL_MODULES) ),
- std::make_pair( OBJ_TYPE_CLASS_MODULES, IDEResId(RID_STR_CLASS_MODULES) ) };
- for( auto const & iter: aEntries )
- {
- EntryType eType = iter.first;
- OUString const & aEntryName = iter.second;
- SvTreeListEntry* pLibSubRootEntry = FindEntry( pLibRootEntry, aEntryName, eType );
- if( pLibSubRootEntry )
- {
- SetEntryBitmaps(pLibSubRootEntry, Image(StockImage::Yes, RID_BMP_MODLIB));
- if ( IsExpanded( pLibSubRootEntry ) )
- ImpCreateLibSubSubEntriesInVBAMode( pLibSubRootEntry, rDocument, rLibName );
- }
- else
- {
- AddEntry(
- aEntryName,
- Image(StockImage::Yes, RID_BMP_MODLIB),
- pLibRootEntry, true, std::make_unique<Entry>(eType));
- }
- }
-}
-
-void TreeListBox::ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const OUString& rLibName )
-{
- uno::Reference< container::XNameContainer > xLib = rDocument.getOrCreateLibrary( E_SCRIPTS, rLibName );
- if( !xLib.is() )
- return;
-
- try
- {
- // get a sorted list of module names
- Sequence< OUString > aModNames = rDocument.getObjectNames( E_SCRIPTS, rLibName );
- sal_Int32 nModCount = aModNames.getLength();
- const OUString* pModNames = aModNames.getConstArray();
-
- EntryDescriptor aDesc( GetEntryDescriptor( pLibSubRootEntry ) );
- EntryType eCurrentType( aDesc.GetType() );
-
- for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
- {
- OUString aModName = pModNames[ i ];
- EntryType eType = OBJ_TYPE_UNKNOWN;
- switch( ModuleInfoHelper::getModuleType( xLib, aModName ) )
- {
- case script::ModuleType::DOCUMENT:
- eType = OBJ_TYPE_DOCUMENT_OBJECTS;
- break;
- case script::ModuleType::FORM:
- eType = OBJ_TYPE_USERFORMS;
- break;
- case script::ModuleType::NORMAL:
- eType = OBJ_TYPE_NORMAL_MODULES;
- break;
- case script::ModuleType::CLASS:
- eType = OBJ_TYPE_CLASS_MODULES;
- break;
- }
- if( eType != eCurrentType )
- continue;
-
- // display a nice friendly name in the ObjectModule tab,
- // combining the objectname and module name, e.g. Sheet1 ( Financials )
- OUString aEntryName = aModName;
- if( eType == OBJ_TYPE_DOCUMENT_OBJECTS )
- {
- OUString sObjName;
- ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
- if( !sObjName.isEmpty() )
- {
- aEntryName += " (" + sObjName + ")";
- }
- }
- SvTreeListEntry* pModuleEntry = FindEntry( pLibSubRootEntry, aEntryName, OBJ_TYPE_MODULE );
- if ( !pModuleEntry )
- {
- pModuleEntry = AddEntry(
- aEntryName,
- Image(StockImage::Yes, RID_BMP_MODULE),
- pLibSubRootEntry, false,
- std::make_unique<Entry>(OBJ_TYPE_MODULE));
- }
-
- // methods
- {
- Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
- FillTreeListBox( pModuleEntry, aNames, OBJ_TYPE_METHOD, RID_BMP_MACRO );
- }
- }
- }
- catch ( const container::NoSuchElementException& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
-}
-
-SvTreeListEntry* TreeListBox::ImpFindEntry( SvTreeListEntry* pParent, const OUString& rText )
-{
- sal_uLong nRootPos = 0;
- SvTreeListEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
- while ( pEntry )
- {
- if ( rText == GetEntryText( pEntry ) )
- return pEntry;
-
- pEntry = pParent ? pEntry->NextSibling() : GetEntry( ++nRootPos );
- }
- return nullptr;
-}
-
-void TreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
-{
- UpdateEntries();
-}
-
-void TreeListBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
-{
- UpdateEntries();
-}
-
-void TreeListBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
-{
- // not interested in
-}
-
-void TreeListBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
-{
- // not interested in
-}
-
-void TreeListBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
-{
- // not interested in
-}
-
-void TreeListBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
-{
- UpdateEntries();
-}
-
-void TreeListBox::onDocumentClosed( const ScriptDocument& rDocument )
-{
- UpdateEntries();
- // The document is not yet actually deleted, so we need to remove its entry
- // manually.
- RemoveEntry(rDocument);
-}
-
-void TreeListBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
-{
- // not interested in
-}
-
-void TreeListBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
-{
- // not interested in
-}
-
-void TreeListBox::UpdateEntries()
-{
- EntryDescriptor aCurDesc( GetEntryDescriptor( FirstSelected() ) );
-
- // removing the invalid entries
- SvTreeListEntry* pLastValid = nullptr;
- SvTreeListEntry* pEntry = First();
- while ( pEntry )
- {
- if ( IsValidEntry( pEntry ) )
- pLastValid = pEntry;
- else
- RemoveEntry(pEntry);
- pEntry = pLastValid ? Next( pLastValid ) : First();
- }
-
- ScanAllEntries();
-
- SetCurrentEntry( aCurDesc );
-}
-
-// Removes the entry from the tree.
-void TreeListBox::RemoveEntry (SvTreeListEntry const * pEntry)
-{
- // removing the associated user data
- delete static_cast<Entry*>(pEntry->GetUserData());
- // removing the entry
- GetModel()->Remove( pEntry );
-}
-
-// Removes the entry of rDocument.
-void TreeListBox::RemoveEntry (ScriptDocument const& rDocument)
-{
- // finding the entry of rDocument
- for (SvTreeListEntry* pEntry = First(); pEntry; pEntry = Next(pEntry))
- if (rDocument == GetEntryDescriptor(pEntry).GetDocument())
- {
- RemoveEntry(pEntry);
- break;
- }
-}
-
-SvTreeListEntry* TreeListBox::CloneEntry( SvTreeListEntry* pSource )
-{
- SvTreeListEntry* pNew = SvTreeListBox::CloneEntry( pSource );
- Entry* pUser = static_cast<Entry*>(pSource->GetUserData());
-
- assert(pUser && "User data?!");
- DBG_ASSERT( pUser->GetType() != OBJ_TYPE_DOCUMENT, "TreeListBox::CloneEntry: document?!" );
-
- Entry* pNewUser = new Entry( *pUser );
- pNew->SetUserData( pNewUser );
- return pNew;
-}
-
-SvTreeListEntry* TreeListBox::FindEntry( SvTreeListEntry* pParent, const OUString& rText, EntryType eType )
-{
- sal_uLong nRootPos = 0;
- SvTreeListEntry* pEntry = pParent ? FirstChild( pParent ) : GetEntry( nRootPos );
- while ( pEntry )
- {
- Entry* pBasicEntry = static_cast<Entry*>(pEntry->GetUserData());
- assert(pBasicEntry && "FindEntry: no Entry ?!");
- if ( ( pBasicEntry->GetType() == eType ) && ( rText == GetEntryText( pEntry ) ) )
- return pEntry;
-
- pEntry = pParent ? pEntry->NextSibling() : GetEntry( ++nRootPos );
- }
- return nullptr;
-}
-
-bool TreeListBox::ExpandingHdl()
-{
- // expanding or collapsing?
- bool bOK = true;
- if ( GetModel()->GetDepth( GetHdlEntry() ) == 1 )
- {
- SvTreeListEntry* pCurEntry = GetCurEntry();
- EntryDescriptor aDesc( GetEntryDescriptor( pCurEntry ) );
- const ScriptDocument& aDocument( aDesc.GetDocument() );
- OSL_ENSURE( aDocument.isAlive(), "TreeListBox::ExpandingHdl: no document, or document is dead!" );
- if ( aDocument.isAlive() )
- {
- const OUString& aLibName( aDesc.GetLibName() );
- const OUString& aLibSubName( aDesc.GetLibSubName() );
- const OUString& aName( aDesc.GetName() );
- const OUString& aMethodName( aDesc.GetMethodName() );
-
- if ( !aLibName.isEmpty() && aLibSubName.isEmpty() && aName.isEmpty() && aMethodName.isEmpty() )
- {
- // check password, if library is password protected and not verified
- Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
- {
- Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
- if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aLibName ) && !xPasswd->isLibraryPasswordVerified( aLibName ) )
- {
- OUString aPassword;
- bOK = QueryPassword(GetFrameWeld(), xModLibContainer, aLibName, aPassword);
- }
- }
- }
- }
- }
- return bOK;
-}
-
-//Fills up treelist for macros and dialogs
-void TreeListBox::FillTreeListBox( SvTreeListEntry* pRootEntry, const Sequence< OUString >& rNames,
- const EntryType& eType, const OUString& aBmpMacro )
-{
- sal_Int32 nCount = rNames.getLength();
- const OUString* pNames = rNames.getConstArray();
-
- for ( sal_Int32 j = 0 ; j < nCount ; j++ )
- {
- OUString aName = pNames[ j ];
- SvTreeListEntry* pEntry = FindEntry( pRootEntry, aName, eType );
-
- if ( !pEntry )
- {
- AddEntry(
- aName,
- Image(StockImage::Yes, aBmpMacro),
- pRootEntry, false,
- std::make_unique<Entry>( eType ));
- }
- }
-}
-
-SvTreeListEntry* TreeListBox::AddEntry(
- OUString const& rText,
- const Image& rImage,
- SvTreeListEntry* pParent,
- bool bChildrenOnDemand,
- std::unique_ptr<Entry> && aUserData
-)
-{
- SvTreeListEntry* p = InsertEntry(
- rText, rImage, rImage, pParent, bChildrenOnDemand, TREELIST_APPEND,
- aUserData.get()
- );
- aUserData.release();
- return p;
-}
-
-void TreeListBox::SetEntryBitmaps( SvTreeListEntry * pEntry, const Image& rImage )
-{
- SetExpandedEntryBmp( pEntry, rImage );
- SetCollapsedEntryBmp( pEntry, rImage );
-}
-
-OUString TreeListBox::GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation )
-{
- return rDocument.getTitle( eLocation, LibraryType::All );
-}
-
-void TreeListBox::GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage )
-{
- OSL_ENSURE( rDocument.isValid(), "TreeListBox::GetRootEntryBitmaps: illegal document!" );
- if ( !rDocument.isValid() )
- return;
-
- if ( rDocument.isDocument() )
- {
- OUString sFactoryURL;
- Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
- Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xContext) );
- try
- {
- OUString sModule( xModuleManager->identify( rDocument.getDocument() ) );
- Sequence< beans::PropertyValue > aModuleDescr;
- xModuleManager->getByName( sModule ) >>= aModuleDescr;
- sal_Int32 nCount = aModuleDescr.getLength();
- const beans::PropertyValue* pModuleDescr = aModuleDescr.getConstArray();
- for ( sal_Int32 i = 0; i < nCount; ++i )
- {
- if ( pModuleDescr[ i ].Name == "ooSetupFactoryEmptyDocumentURL" )
- {
- pModuleDescr[ i ].Value >>= sFactoryURL;
- break;
- }
- }
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
-
- if ( !sFactoryURL.isEmpty() )
- {
- rImage = SvFileInformationManager::GetFileImage( INetURLObject( sFactoryURL ) );
- }
- else
- {
- // default icon
- rImage = Image(StockImage::Yes, RID_BMP_DOCUMENT);
- }
- }
- else
- {
- rImage = Image(StockImage::Yes, RID_BMP_INSTALLATION);
- }
-}
-
-void TreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc)
-{
- SvTreeListEntry* pCurEntry = nullptr;
- EntryDescriptor aDesc = rDesc;
- if ( aDesc.GetType() == OBJ_TYPE_UNKNOWN )
- {
- aDesc = EntryDescriptor(
- ScriptDocument::getApplicationScriptDocument(),
- LIBRARY_LOCATION_USER, "Standard",
- OUString(), ".", OBJ_TYPE_UNKNOWN
- );
- }
- ScriptDocument aDocument = aDesc.GetDocument();
- OSL_ENSURE( aDocument.isValid(), "TreeListBox::SetCurrentEntry: invalid document!" );
- LibraryLocation eLocation = aDesc.GetLocation();
- SvTreeListEntry* pRootEntry = FindRootEntry( aDocument, eLocation );
- if ( pRootEntry )
- {
- pCurEntry = pRootEntry;
- const OUString& aLibName( aDesc.GetLibName() );
- if ( !aLibName.isEmpty() )
- {
- Expand( pRootEntry );
- SvTreeListEntry* pLibEntry = FindEntry( pRootEntry, aLibName, OBJ_TYPE_LIBRARY );
- if ( pLibEntry )
- {
- pCurEntry = pLibEntry;
- const OUString& aLibSubName( aDesc.GetLibSubName() );
- if( !aLibSubName.isEmpty() )
- {
- Expand( pLibEntry );
- SvTreeListEntry* pLibSubEntry = ImpFindEntry( pLibEntry, aLibSubName );
- if( pLibSubEntry )
- {
- pCurEntry = pLibSubEntry;
- }
- }
- const OUString& aName( aDesc.GetName() );
- if ( !aName.isEmpty() )
- {
- Expand( pCurEntry );
- EntryType eType = OBJ_TYPE_MODULE;
- if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
- eType = OBJ_TYPE_DIALOG;
- SvTreeListEntry* pEntry = FindEntry( pCurEntry, aName, eType );
- if ( pEntry )
- {
- pCurEntry = pEntry;
- const OUString& aMethodName( aDesc.GetMethodName() );
- if ( !aMethodName.isEmpty() )
- {
- Expand( pEntry );
- SvTreeListEntry* pSubEntry = FindEntry( pEntry, aMethodName, OBJ_TYPE_METHOD );
- if ( pSubEntry )
- {
- pCurEntry = pSubEntry;
- }
- else
- {
- pSubEntry = FirstChild( pEntry );
- if ( pSubEntry )
- pCurEntry = pSubEntry;
- }
- }
- }
- else
- {
- pEntry = FirstChild( pLibEntry );
- if ( pEntry )
- pCurEntry = pEntry;
- }
- }
- }
- else
- {
- pLibEntry = FirstChild( pRootEntry );
- if ( pLibEntry )
- pCurEntry = pLibEntry;
- }
- }
- }
- else
- {
- pRootEntry = First();
- if ( pRootEntry )
- pCurEntry = pRootEntry;
- }
-
- SetCurEntry( pCurEntry );
-}
-
-void TreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
-{
- SvTreeListBox::MouseButtonDown( rMEvt );
- if ( rMEvt.IsLeft() && ( rMEvt.GetClicks() == 2 ) )
- {
- OpenCurrent();
- }
-}
-
-void TreeListBox::KeyInput( const KeyEvent& rEvt )
-{
- if ( rEvt.GetKeyCode() == KEY_RETURN && OpenCurrent() )
- {
- return;
- }
- SvTreeListBox::KeyInput( rEvt );
-}
-
-bool TreeListBox::OpenCurrent()
-{
- EntryDescriptor aDesc = GetEntryDescriptor(GetCurEntry());
- switch (aDesc.GetType())
- {
- case OBJ_TYPE_METHOD:
- case OBJ_TYPE_MODULE:
- case OBJ_TYPE_DIALOG:
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- {
- SbxItem aSbxItem(
- SID_BASICIDE_ARG_SBX, aDesc.GetDocument(),
- aDesc.GetLibName(), aDesc.GetName(), aDesc.GetMethodName(),
- ConvertType(aDesc.GetType())
- );
- pDispatcher->ExecuteList(
- SID_BASICIDE_SHOWSBX, SfxCallMode::SYNCHRON,
- { &aSbxItem }
- );
- return true;
- }
- break;
-
- default:
- break;
- }
- return false;
-}
-
SbTreeListBox::SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Window* pTopLevel)
: m_xControl(std::move(xControl))
, m_xIter(m_xControl->make_iterator())
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
index 93fb1525d473..19ca594a213b 100644
--- a/basctl/source/basicide/bastype3.cxx
+++ b/basctl/source/basicide/bastype3.cxx
@@ -36,99 +36,8 @@ namespace basctl
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
-
typedef std::deque< SvTreeListEntry* > EntryArray;
-
-void TreeListBox::RequestingChildren( SvTreeListEntry* pEntry )
-{
- EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
- const ScriptDocument& aDocument = aDesc.GetDocument();
- OSL_ENSURE( aDocument.isAlive(), "basctl::TreeListBox::RequestingChildren: invalid document!" );
- if ( !aDocument.isAlive() )
- return;
-
- LibraryLocation eLocation = aDesc.GetLocation();
- EntryType eType = aDesc.GetType();
-
- if ( eType == OBJ_TYPE_DOCUMENT )
- {
- ImpCreateLibEntries( pEntry, aDocument, eLocation );
- }
- else if ( eType == OBJ_TYPE_LIBRARY )
- {
- const OUString& aOULibName( aDesc.GetLibName() );
-
- // check password
- bool bOK = true;
- Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) );
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
- {
- Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
- if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
- {
- OUString aPassword;
- bOK = QueryPassword(GetFrameWeld(), xModLibContainer, aOULibName, aPassword);
- }
- }
-
- if ( bOK )
- {
- // load module library
- bool bModLibLoaded = false;
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
- {
- if ( !xModLibContainer->isLibraryLoaded( aOULibName ) )
- {
- EnterWait();
- xModLibContainer->loadLibrary( aOULibName );
- LeaveWait();
- }
- bModLibLoaded = xModLibContainer->isLibraryLoaded( aOULibName );
- }
-
- // load dialog library
- bool bDlgLibLoaded = false;
- Reference< script::XLibraryContainer > xDlgLibContainer = aDocument.getLibraryContainer( E_DIALOGS );
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
- {
- if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
- {
- EnterWait();
- xDlgLibContainer->loadLibrary( aOULibName );
- LeaveWait();
- }
- bDlgLibLoaded = xDlgLibContainer->isLibraryLoaded( aOULibName );
- }
-
- if ( bModLibLoaded || bDlgLibLoaded )
- {
- // create the sub entries
- ImpCreateLibSubEntries( pEntry, aDocument, aOULibName );
-
- // exchange image
- Image aImage(StockImage::Yes, OUStringLiteral(RID_BMP_MODLIB));
- SetEntryBitmaps( pEntry, aImage );
- }
- else
- {
- OSL_FAIL( "basctl::TreeListBox::RequestingChildren: Error loading library!" );
- }
- }
- }
- else if ( eType == OBJ_TYPE_DOCUMENT_OBJECTS
- || eType == OBJ_TYPE_USERFORMS
- || eType == OBJ_TYPE_NORMAL_MODULES
- || eType == OBJ_TYPE_CLASS_MODULES )
- {
- const OUString& aLibName( aDesc.GetLibName() );
- ImpCreateLibSubSubEntriesInVBAMode( pEntry, aDocument, aLibName );
- }
- else {
- OSL_FAIL( "basctl::TreeListBox::RequestingChildren: Unknown Type!" );
- }
-}
-
IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, bool)
{
EntryDescriptor aDesc = GetEntryDescriptor(&rEntry);
@@ -216,34 +125,6 @@ IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, const weld::TreeIter&, rEntry, b
return true;
}
-void TreeListBox::ExpandedHdl()
-{
- SvTreeListEntry* pEntry = GetHdlEntry();
- assert(pEntry && "What was collapsed?");
- if ( !IsExpanded( pEntry ) && pEntry->HasChildrenOnDemand() )
- {
- SvTreeListEntry* pChild = FirstChild( pEntry );
- while ( pChild )
- {
- GetModel()->Remove( pChild ); // does also call the DTOR
- pChild = FirstChild( pEntry );
- }
- }
-}
-
-void TreeListBox::ScanAllEntries()
-{
- ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER );
- ScanEntry( ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_SHARE );
-
- ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::DocumentsSorted ) );
- for (auto const& doc : aDocuments)
- {
- if ( doc.isAlive() )
- ScanEntry(doc, LIBRARY_LOCATION_DOCUMENT);
- }
-}
-
void SbTreeListBox::ScanAllEntries()
{
// instead of always freezing, freeze on the first add/remove, which keeps gtk
@@ -359,104 +240,6 @@ SbxVariable* SbTreeListBox::FindVariable(const weld::TreeIter* pEntry)
return pVar;
}
-EntryDescriptor TreeListBox::GetEntryDescriptor( SvTreeListEntry* pEntry )
-{
- ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
- LibraryLocation eLocation = LIBRARY_LOCATION_UNKNOWN;
- OUString aLibName;
- OUString aLibSubName;
- OUString aName;
- OUString aMethodName;
- EntryType eType = OBJ_TYPE_UNKNOWN;
-
- if ( !pEntry )
- return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
-
- EntryArray aEntries;
-
- while ( pEntry )
- {
- sal_uInt16 nDepth = GetModel()->GetDepth( pEntry );
- switch ( nDepth )
- {
- case 4:
- case 3:
- case 2:
- case 1:
- {
- aEntries.push_front( pEntry );
- }
- break;
- case 0:
- {
- if (DocumentEntry* pDocumentEntry = static_cast<DocumentEntry*>(pEntry->GetUserData()))
- {
- aDocument = pDocumentEntry->GetDocument();
- eLocation = pDocumentEntry->GetLocation();
- eType = OBJ_TYPE_DOCUMENT;
- }
- }
- break;
- }
- pEntry = GetParent( pEntry );
- }
-
- for (SvTreeListEntry* pLE : aEntries)
- {
- assert(pLE && "Entry not found in array");
- Entry* pBE = static_cast<Entry*>(pLE->GetUserData());
- assert(pBE && "No data found in entry!");
-
- switch ( pBE->GetType() )
- {
- case OBJ_TYPE_LIBRARY:
- {
- aLibName = GetEntryText( pLE );
- eType = pBE->GetType();
- }
- break;
- case OBJ_TYPE_MODULE:
- {
- aName = GetEntryText( pLE );
- eType = pBE->GetType();
- }
- break;
- case OBJ_TYPE_METHOD:
- {
- aMethodName = GetEntryText( pLE );
- eType = pBE->GetType();
- }
- break;
- case OBJ_TYPE_DIALOG:
- {
- aName = GetEntryText( pLE );
- eType = pBE->GetType();
- }
- break;
- case OBJ_TYPE_DOCUMENT_OBJECTS:
- case OBJ_TYPE_USERFORMS:
- case OBJ_TYPE_NORMAL_MODULES:
- case OBJ_TYPE_CLASS_MODULES:
- {
- aLibSubName = GetEntryText( pLE );
- eType = pBE->GetType();
- }
- break;
- default:
- {
- OSL_FAIL( "GetEntryDescriptor: unknown type" );
- eType = OBJ_TYPE_UNKNOWN;
- }
- break;
- }
-
- if ( eType == OBJ_TYPE_UNKNOWN )
- break;
- }
-
- return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
-}
-
EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry)
{
ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
@@ -561,20 +344,6 @@ EntryDescriptor SbTreeListBox::GetEntryDescriptor(const weld::TreeIter* pEntry)
return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
}
-ItemType TreeListBox::ConvertType (EntryType eType)
-{
- switch (eType)
- {
- case OBJ_TYPE_DOCUMENT: return TYPE_SHELL;
- case OBJ_TYPE_LIBRARY: return TYPE_LIBRARY;
- case OBJ_TYPE_MODULE: return TYPE_MODULE;
- case OBJ_TYPE_DIALOG: return TYPE_DIALOG;
- case OBJ_TYPE_METHOD: return TYPE_METHOD;
- default:
- return static_cast<ItemType>(OBJ_TYPE_UNKNOWN);
- }
-}
-
ItemType SbTreeListBox::ConvertType (EntryType eType)
{
switch (eType)
@@ -589,61 +358,6 @@ ItemType SbTreeListBox::ConvertType (EntryType eType)
}
}
-bool TreeListBox::IsValidEntry( SvTreeListEntry* pEntry )
-{
- bool bIsValid = false;
-
- EntryDescriptor aDesc( GetEntryDescriptor( pEntry ) );
- const ScriptDocument& aDocument( aDesc.GetDocument() );
- LibraryLocation eLocation( aDesc.GetLocation() );
- const OUString& aLibName( aDesc.GetLibName() );
- const OUString& aName( aDesc.GetName() );
- const OUString& aMethodName( aDesc.GetMethodName() );
- EntryType eType( aDesc.GetType() );
-
- switch ( eType )
- {
- case OBJ_TYPE_DOCUMENT:
- {
- bIsValid = aDocument.isAlive()
- && (aDocument.isApplication()
- || GetRootEntryName(aDocument, eLocation) == GetEntryText(pEntry));
- }
- break;
- case OBJ_TYPE_LIBRARY:
- {
- bIsValid = aDocument.hasLibrary( E_SCRIPTS, aLibName ) || aDocument.hasLibrary( E_DIALOGS, aLibName );
- }
- break;
- case OBJ_TYPE_MODULE:
- {
- bIsValid = aDocument.hasModule( aLibName, aName );
- }
- break;
- case OBJ_TYPE_DIALOG:
- {
- bIsValid = aDocument.hasDialog( aLibName, aName );
- }
- break;
- case OBJ_TYPE_METHOD:
- {
- bIsValid = HasMethod( aDocument, aLibName, aName, aMethodName );
- }
- break;
- case OBJ_TYPE_DOCUMENT_OBJECTS:
- case OBJ_TYPE_USERFORMS:
- case OBJ_TYPE_NORMAL_MODULES:
- case OBJ_TYPE_CLASS_MODULES:
- {
- bIsValid = true;
- }
- break;
- default: ;
- }
-
- return bIsValid;
-}
-
bool SbTreeListBox::IsValidEntry(weld::TreeIter& rEntry)
{
bool bIsValid = false;
@@ -704,22 +418,6 @@ SbModule* SbTreeListBox::FindModule(const weld::TreeIter* pEntry)
return dynamic_cast<SbModule*>(FindVariable(pEntry));
}
-SvTreeListEntry* TreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
-{
- OSL_ENSURE( rDocument.isValid(), "basctl::TreeListBox::FindRootEntry: invalid document!" );
- sal_uLong nRootPos = 0;
- SvTreeListEntry* pRootEntry = GetEntry( nRootPos );
- while ( pRootEntry )
- {
- DBG_ASSERT( static_cast<Entry*>(pRootEntry->GetUserData())->GetType() == OBJ_TYPE_DOCUMENT, "No shell entry?" );
- DocumentEntry* pBDEntry = static_cast<DocumentEntry*>(pRootEntry->GetUserData());
- if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation)
- return pRootEntry;
- pRootEntry = GetEntry( ++nRootPos );
- }
- return nullptr;
-}
-
bool SbTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, weld::TreeIter& rIter)
{
OSL_ENSURE( rDocument.isValid(), "basctl::TreeListBox::FindRootEntry: invalid document!" );
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 960e12e4fea7..bf675de02fce 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -38,6 +38,7 @@
#include <sfx2/request.hxx>
#include <sfx2/sfxsids.hrc>
#include <svl/stritem.hxx>
+#include <vcl/transfer.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <tools/debug.hxx>
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index fa636a5cdd41..37e3d9556185 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <bastype2.hxx>
+#include <tools/solar.h>
#include <vcl/weld.hxx>
#include <com/sun/star/task/XInteractionHandler.hpp>
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 5e22375bd0e9..c376852e3609 100644
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -26,13 +26,11 @@
#include "doceventnotifier.hxx"
-#include <vcl/treelistbox.hxx>
#include <vcl/weld.hxx>
#include "sbxitem.hxx"
#include <o3tl/typed_flags_set.hxx>
class SbModule;
-class SvTreeListEntry;
class SbxVariable;
enum class BrowseMode
@@ -174,71 +172,6 @@ public:
*/
-class TreeListBox : public SvTreeListBox, public DocumentEventListener
-{
-private:
- DocumentEventNotifier m_aNotifier;
- void SetEntryBitmaps( SvTreeListEntry * pEntry, const Image& rImage );
- virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
-
-protected:
- virtual void RequestingChildren( SvTreeListEntry* pParent ) override;
- virtual void ExpandedHdl() override;
- virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ) override;
- virtual bool ExpandingHdl() override;
- virtual void KeyInput( const KeyEvent& rEvt ) override;
-
- bool OpenCurrent();
- void ImpCreateLibEntries( SvTreeListEntry* pShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation );
- void ImpCreateLibSubEntries( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
- void ImpCreateLibSubEntriesInVBAMode( SvTreeListEntry* pLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
- void ImpCreateLibSubSubEntriesInVBAMode( SvTreeListEntry* pLibSubRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
- SvTreeListEntry* ImpFindEntry( SvTreeListEntry* pParent, const OUString& rText );
-
- // DocumentEventListener
- virtual void onDocumentCreated( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentOpened( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentSave( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentSaveDone( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentSaveAs( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentSaveAsDone( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentClosed( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentTitleChanged( const ScriptDocument& _rDocument ) override;
- virtual void onDocumentModeChanged( const ScriptDocument& _rDocument ) override;
-
-public:
- TreeListBox(vcl::Window* pParent, WinBits nStyle);
- virtual ~TreeListBox() override;
- virtual void dispose() override;
-
- void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
- void ScanAllEntries();
- void UpdateEntries();
-
- SvTreeListEntry* FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
- SvTreeListEntry* FindEntry( SvTreeListEntry* pParent, const OUString& rText, EntryType eType );
-
- EntryDescriptor GetEntryDescriptor( SvTreeListEntry* pEntry );
-
- static ItemType ConvertType (EntryType eType);
- bool IsValidEntry( SvTreeListEntry* pEntry );
-
- void FillTreeListBox( SvTreeListEntry* pRootEntry, const Sequence< OUString >& rNames,
- const EntryType& eType, const OUString& aBmpMacro );
- SvTreeListEntry* AddEntry(
- const OUString& rText, const Image& rImage,
- SvTreeListEntry* pParent, bool bChildrenOnDemand,
- std::unique_ptr<Entry> && aUserData
- );
- void RemoveEntry (SvTreeListEntry const *);
- void RemoveEntry (ScriptDocument const&);
-
- static OUString GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation );
- static void GetRootEntryBitmaps( const ScriptDocument& rDocument, Image& rImage );
-
- void SetCurrentEntry (EntryDescriptor const &);
-};
-
class SbTreeListBox : public DocumentEventListener
{
private: