summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-11-05 21:01:23 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-11-19 14:05:41 +0100
commit5e0c3fd7a42f93489a3d59a83bad2a72de1af63c (patch)
treef0f6fa97722200d82d3d04c5da5fd0ec594e272c /basctl
parent6fe56989cfe0c4aa58cd8532db9cfdb5116f2a73 (diff)
weld TreeView
a) use GtkTreeStores for GtkTreeViews b) ironically can't store GtkTreeStore contents in .ui apparently c) set show_expanders for all non-trees and unconverted cases d) on-demand subtrees Change-Id: I3c1036a222daba2c129b1a22ffeb3fe35005ae31 Reviewed-on: https://gerrit.libreoffice.org/63558 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.cxx2
-rw-r--r--basctl/source/basicide/basides1.cxx2
-rw-r--r--basctl/source/basicide/basobj2.cxx27
-rw-r--r--basctl/source/basicide/bastype2.cxx684
-rw-r--r--basctl/source/basicide/bastype3.cxx387
-rw-r--r--basctl/source/basicide/macrodlg.cxx540
-rw-r--r--basctl/source/basicide/macrodlg.hxx68
-rw-r--r--basctl/source/basicide/moduldl2.cxx102
-rw-r--r--basctl/source/basicide/moduldlg.cxx96
-rw-r--r--basctl/source/basicide/moduldlg.hxx4
-rw-r--r--basctl/source/inc/basobj.hxx9
-rw-r--r--basctl/source/inc/bastype2.hxx90
-rw-r--r--basctl/uiconfig/basicide/ui/basicmacrodialog.ui149
-rw-r--r--basctl/uiconfig/basicide/ui/managebreakpoints.ui3
-rw-r--r--basctl/uiconfig/basicide/ui/managelanguages.ui1
15 files changed, 1793 insertions, 371 deletions
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 1725324bff3b..81efba1d5b3d 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -339,7 +339,7 @@ void ModulWindow::BasicExecute()
if ( !pMethod )
{
// If not in a method then prompt the user
- ChooseMacro( uno::Reference< frame::XModel >() );
+ ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>());
return;
}
pMethod->SetDebugFlags(m_aStatus.nBasicFlags);
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index 0d7ff9cb2a00..2bb3aacd395a 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -331,7 +331,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
break;
case SID_BASICIDE_CHOOSEMACRO:
{
- ChooseMacro( nullptr );
+ ChooseMacro(rReq.GetFrameWeld(), nullptr);
}
break;
case SID_BASICIDE_CREATEMACRO:
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index be25e26b41a0..c127446433a2 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -45,11 +45,11 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::container;
extern "C" {
- SAL_DLLPUBLIC_EXPORT rtl_uString* basicide_choose_macro( void* pOnlyInDocument_AsXModel, void* pDocFrame_AsXFrame, sal_Bool bChooseOnly )
+ SAL_DLLPUBLIC_EXPORT rtl_uString* basicide_choose_macro(void* pParent, void* pOnlyInDocument_AsXModel, void* pDocFrame_AsXFrame, sal_Bool bChooseOnly )
{
Reference< frame::XModel > aDocument( static_cast< frame::XModel* >( pOnlyInDocument_AsXModel ) );
Reference< frame::XFrame > aDocFrame( static_cast< frame::XFrame* >( pDocFrame_AsXFrame ) );
- OUString aScriptURL = basctl::ChooseMacro( aDocument, aDocFrame, bChooseOnly );
+ OUString aScriptURL = basctl::ChooseMacro(static_cast<weld::Window*>(pParent), aDocument, aDocFrame, bChooseOnly);
rtl_uString* pScriptURL = aScriptURL.pData;
rtl_uString_acquire( pScriptURL );
@@ -235,9 +235,10 @@ namespace
}
}
-OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument,
- const uno::Reference< frame::XFrame >& xDocFrame,
- bool bChooseOnly )
+OUString ChooseMacro(weld::Window* pParent,
+ const uno::Reference< frame::XModel >& rxLimitToDocument,
+ const uno::Reference< frame::XFrame >& xDocFrame,
+ bool bChooseOnly)
{
EnsureIde();
@@ -246,15 +247,17 @@ OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument,
OUString aScriptURL;
SbMethod* pMethod = nullptr;
- ScopedVclPtrInstance< MacroChooser > pChooser( nullptr, xDocFrame, true );
+ MacroChooser aChooser(pParent, xDocFrame, true);
if ( bChooseOnly || !SvtModuleOptions::IsBasicIDE() )
- pChooser->SetMode(MacroChooser::ChooseOnly);
+ aChooser.SetMode(MacroChooser::ChooseOnly);
if ( !bChooseOnly && rxLimitToDocument.is() )
+ {
// Hack!
- pChooser->SetMode(MacroChooser::Recording);
+ aChooser.SetMode(MacroChooser::Recording);
+ }
- short nRetValue = pChooser->Execute();
+ short nRetValue = aChooser.run();
GetExtraData()->ChoosingMacro() = false;
@@ -264,9 +267,9 @@ OUString ChooseMacro( const uno::Reference< frame::XModel >& rxLimitToDocument,
{
bool bError = false;
- pMethod = pChooser->GetMacro();
- if ( !pMethod && pChooser->GetMode() == MacroChooser::Recording )
- pMethod = pChooser->CreateMacro();
+ pMethod = aChooser.GetMacro();
+ if ( !pMethod && aChooser.GetMode() == MacroChooser::Recording )
+ pMethod = aChooser.CreateMacro();
if ( !pMethod )
break;
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 8066cf2f8814..b143924fe149 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -895,6 +895,690 @@ bool TreeListBox::OpenCurrent()
return false;
}
+SbTreeListBox::SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Window* pTopLevel)
+ : m_xControl(std::move(xControl))
+ , m_xIter(m_xControl->make_iterator())
+ , m_pTopLevel(pTopLevel)
+ , m_aNotifier(*this)
+{
+ m_xControl->connect_row_activated(LINK(this, SbTreeListBox, OpenCurrentHdl));
+ m_xControl->connect_expanding(LINK(this, SbTreeListBox, RequestingChildrenHdl));
+ nMode = BrowseMode::All; // everything
+}
+
+SbTreeListBox::~SbTreeListBox()
+{
+ m_aNotifier.dispose();
+
+ bool bValidIter = m_xControl->get_iter_first(*m_xIter);
+ while (bValidIter)
+ {
+ Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(*m_xIter).toInt64());
+ delete pBasicEntry;
+ bValidIter = m_xControl->iter_next(*m_xIter);
+ }
+}
+
+void SbTreeListBox::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?!
+ m_xControl->freeze();
+ // level 1: BasicManager (application, document, ...)
+ bool bDocumentRootEntry = FindRootEntry(rDocument, eLocation, *m_xIter);
+ if (bDocumentRootEntry && m_xControl->get_row_expanded(*m_xIter))
+ ImpCreateLibEntries(*m_xIter, rDocument, eLocation);
+ if (!bDocumentRootEntry)
+ {
+ OUString aRootName(GetRootEntryName(rDocument, eLocation));
+ OUString aImage(GetRootEntryBitmaps(rDocument));
+ AddEntry(aRootName, aImage, nullptr, true, o3tl::make_unique<DocumentEntry>(rDocument, eLocation));
+ }
+ m_xControl->thaw();
+}
+
+void SbTreeListBox::ImpCreateLibEntries(weld::TreeIter& rIter, 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;
+ if ( ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules ) )
+ sId = bLoaded ? OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_DLGLIBNOTLOADED);
+ else
+ sId = bLoaded ? OUStringLiteral(RID_BMP_MODLIB) : OUStringLiteral(RID_BMP_MODLIBNOTLOADED);
+ std::unique_ptr<weld::TreeIter> xLibRootEntry(m_xControl->make_iterator(&rIter));
+ bool bLibRootEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibRootEntry);
+ if (bLibRootEntry)
+ {
+ SetEntryBitmaps(*xLibRootEntry, sId);
+ if (m_xControl->get_row_expanded(*xLibRootEntry))
+ ImpCreateLibSubEntries(*xLibRootEntry, rDocument, aLibName);
+ }
+ else
+ {
+ AddEntry(aLibName, sId, &rIter, true, o3tl::make_unique<Entry>(OBJ_TYPE_LIBRARY));
+ }
+ }
+ }
+}
+
+void SbTreeListBox::ImpCreateLibSubEntries(weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName)
+{
+ // modules
+ if ( nMode & BrowseMode::Modules )
+ {
+ Reference< script::XLibraryContainer > xModLibContainer( rDocument.getLibraryContainer( E_SCRIPTS ) );
+
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) && xModLibContainer->isLibraryLoaded( rLibName ) )
+ {
+ try
+ {
+ if( rDocument.isInVBAMode() )
+ {
+ ImpCreateLibSubEntriesInVBAMode(rLibRootEntry, 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();
+
+ auto xTreeIter = m_xControl->make_iterator();
+
+ for ( sal_Int32 i = 0 ; i < nModCount ; i++ )
+ {
+ OUString aModName = pModNames[ i ];
+ m_xControl->copy_iterator(rLibRootEntry, *xTreeIter);
+ bool bModuleEntry = FindEntry(aModName, OBJ_TYPE_MODULE, *xTreeIter);
+ if (!bModuleEntry)
+ {
+ AddEntry(aModName, RID_BMP_MODULE, &rLibRootEntry, false, o3tl::make_unique<Entry>(OBJ_TYPE_MODULE));
+ }
+
+ // methods
+ if ( nMode & BrowseMode::Subs )
+ {
+ Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
+ sal_Int32 nCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+
+ auto xSubTreeIter = m_xControl->make_iterator();
+
+ for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ {
+ OUString aName = pNames[ j ];
+ m_xControl->copy_iterator(*xTreeIter, *xSubTreeIter);
+ bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xSubTreeIter);
+ if (!bEntry)
+ {
+ AddEntry(aName, RID_BMP_MACRO, xTreeIter.get(), false, o3tl::make_unique<Entry>(OBJ_TYPE_METHOD));
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+ }
+ }
+
+ // dialogs
+ if ( nMode & BrowseMode::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 ) );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const OUString* pDlgNames = aDlgNames.getConstArray();
+
+ auto xTreeIter = m_xControl->make_iterator();
+
+ 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, o3tl::make_unique<Entry>(OBJ_TYPE_DIALOG));
+ }
+ }
+ }
+ catch (const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+ }
+ }
+}
+
+void SbTreeListBox::ImpCreateLibSubEntriesInVBAMode(weld::TreeIter& rLibRootEntry, 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;
+ std::unique_ptr<weld::TreeIter> xLibSubRootEntry(m_xControl->make_iterator(&rLibRootEntry));
+ bool bLibSubRootEntry = FindEntry(aEntryName, eType, *xLibSubRootEntry);
+ if (bLibSubRootEntry)
+ {
+ SetEntryBitmaps(*xLibSubRootEntry, RID_BMP_MODLIB);
+ if (m_xControl->get_row_expanded(*xLibSubRootEntry))
+ ImpCreateLibSubSubEntriesInVBAMode(*xLibSubRootEntry, rDocument, rLibName);
+ }
+ else
+ {
+ m_xControl->copy_iterator(rLibRootEntry, *xLibSubRootEntry);
+ AddEntry(aEntryName, RID_BMP_MODLIB, xLibSubRootEntry.get(), true, o3tl::make_unique<Entry>(eType));
+ }
+ }
+}
+
+void SbTreeListBox::ImpCreateLibSubSubEntriesInVBAMode(weld::TreeIter& rLibSubRootEntry, 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(&rLibSubRootEntry));
+ 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 + ")";
+ }
+ }
+ std::unique_ptr<weld::TreeIter> xModuleEntry(m_xControl->make_iterator(&rLibSubRootEntry));
+ bool bModuleEntry = FindEntry(aEntryName, OBJ_TYPE_MODULE, *xModuleEntry);
+ if (!bModuleEntry)
+ {
+ m_xControl->copy_iterator(rLibSubRootEntry, *xModuleEntry);
+ AddEntry(aEntryName, RID_BMP_MODULE, xModuleEntry.get(), false,
+ o3tl::make_unique<Entry>(OBJ_TYPE_MODULE));
+ }
+
+ // methods
+ if ( nMode & BrowseMode::Subs )
+ {
+ Sequence< OUString > aNames = GetMethodNames( rDocument, rLibName, aModName );
+ sal_Int32 nCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+
+ for ( sal_Int32 j = 0 ; j < nCount ; j++ )
+ {
+ OUString aName = pNames[ j ];
+ std::unique_ptr<weld::TreeIter> xEntry(m_xControl->make_iterator(xModuleEntry.get()));
+ bool bEntry = FindEntry(aName, OBJ_TYPE_METHOD, *xEntry);
+ if (!bEntry)
+ {
+ AddEntry(aName, RID_BMP_MACRO, xModuleEntry.get(), false, o3tl::make_unique<Entry>(OBJ_TYPE_METHOD));
+ }
+ }
+ }
+ }
+ }
+ catch ( const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+}
+
+bool SbTreeListBox::ImpFindEntry(weld::TreeIter& rIter, const OUString& rText)
+{
+ bool bValidIter = m_xControl->iter_children(rIter);
+ while (bValidIter)
+ {
+ if (rText == m_xControl->get_text(rIter))
+ return true;
+ bValidIter = m_xControl->iter_next_sibling(rIter);
+ }
+ return false;
+}
+
+void SbTreeListBox::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void SbTreeListBox::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void SbTreeListBox::onDocumentSave( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void SbTreeListBox::onDocumentSaveDone( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void SbTreeListBox::onDocumentSaveAs( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void SbTreeListBox::onDocumentSaveAsDone( const ScriptDocument& /*_rDocument*/ )
+{
+ UpdateEntries();
+}
+
+void SbTreeListBox::onDocumentClosed( const ScriptDocument& rDocument )
+{
+ UpdateEntries();
+ // The document is not yet actually deleted, so we need to remove its entry
+ // manually.
+ RemoveEntry(rDocument);
+}
+
+void SbTreeListBox::onDocumentTitleChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void SbTreeListBox::onDocumentModeChanged( const ScriptDocument& /*_rDocument*/ )
+{
+ // not interested in
+}
+
+void SbTreeListBox::UpdateEntries()
+{
+ bool bValidIter = m_xControl->get_selected(m_xIter.get());
+ EntryDescriptor aCurDesc(GetEntryDescriptor(bValidIter ? m_xIter.get() : nullptr));
+
+ // removing the invalid entries
+ std::unique_ptr<weld::TreeIter> xLastValid(m_xControl->make_iterator(nullptr));
+ bool bLastValid = false;
+ bValidIter = m_xControl->get_iter_first(*m_xIter);
+ while (bValidIter)
+ {
+ if (IsValidEntry(*m_xIter))
+ {
+ m_xControl->copy_iterator(*m_xIter, *xLastValid);
+ bLastValid = true;
+ }
+ else
+ RemoveEntry(*m_xIter);
+ if (bLastValid)
+ {
+ m_xControl->copy_iterator(*xLastValid, *m_xIter);
+ bValidIter = m_xControl->iter_next(*m_xIter);
+ }
+ else
+ bValidIter = m_xControl->get_iter_first(*m_xIter);
+ }
+
+ ScanAllEntries();
+
+ SetCurrentEntry( aCurDesc );
+}
+
+// Removes the entry from the tree.
+void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
+{
+ // removing the associated user data
+ Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ delete pBasicEntry;
+ // removing the entry
+ m_xControl->remove(rIter);
+}
+
+// Removes the entry of rDocument.
+void SbTreeListBox::RemoveEntry (ScriptDocument const& rDocument)
+{
+ // finding the entry of rDocument
+ bool bValidIter = m_xControl->get_iter_first(*m_xIter);
+ while (bValidIter)
+ {
+ if (rDocument == GetEntryDescriptor(m_xIter.get()).GetDocument())
+ {
+ RemoveEntry(*m_xIter);
+ break;
+ }
+ bValidIter = m_xControl->iter_next(*m_xIter);
+ }
+}
+
+bool SbTreeListBox::FindEntry(const OUString& rText, EntryType eType, weld::TreeIter& rIter)
+{
+ bool bValidIter = m_xControl->iter_children(rIter);
+ while (bValidIter)
+ {
+ Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ assert(pBasicEntry && "FindEntry: no Entry ?!");
+ if (pBasicEntry->GetType() == eType && rText == m_xControl->get_text(rIter))
+ return true;
+ bValidIter = m_xControl->iter_next_sibling(rIter);
+ }
+ return false;
+}
+
+bool SbTreeListBox::IsEntryProtected(weld::TreeIter* pEntry)
+{
+ bool bProtected = false;
+ if (pEntry && m_xControl->get_iter_depth(*pEntry) == 1)
+ {
+ EntryDescriptor aDesc(GetEntryDescriptor(pEntry));
+ const ScriptDocument& rDocument( aDesc.GetDocument() );
+ OSL_ENSURE( rDocument.isAlive(), "TreeListBox::IsEntryProtected: no document, or document is dead!" );
+ if ( rDocument.isAlive() )
+ {
+ const OUString& aOULibName( aDesc.GetLibName() );
+ Reference< script::XLibraryContainer > xModLibContainer( rDocument.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 ) )
+ {
+ bProtected = true;
+ }
+ }
+ }
+ }
+ return bProtected;
+}
+
+void SbTreeListBox::AddEntry(
+ const OUString& rText,
+ const OUString& rImage,
+ weld::TreeIter* pParent,
+ bool bChildrenOnDemand,
+ std::unique_ptr<Entry>&& rUserData)
+{
+ OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
+ m_xControl->insert(pParent, -1, rText, &sId, nullptr, nullptr, &rImage, bChildrenOnDemand);
+}
+
+void SbTreeListBox::SetEntryBitmaps(weld::TreeIter& rIter, const OUString& rImage)
+{
+ m_xControl->set_expander_image(rIter, rImage);
+}
+
+LibraryType SbTreeListBox::GetLibraryType() const
+{
+ LibraryType eType = LibraryType::All;
+ if ( ( nMode & BrowseMode::Modules ) && !( nMode & BrowseMode::Dialogs ) )
+ eType = LibraryType::Module;
+ else if ( !( nMode & BrowseMode::Modules ) && ( nMode & BrowseMode::Dialogs ) )
+ eType = LibraryType::Dialog;
+ return eType;
+}
+
+OUString SbTreeListBox::GetRootEntryName( const ScriptDocument& rDocument, LibraryLocation eLocation ) const
+{
+ return rDocument.getTitle( eLocation, GetLibraryType() );
+}
+
+OUString SbTreeListBox::GetRootEntryBitmaps(const ScriptDocument& rDocument)
+{
+ OSL_ENSURE( rDocument.isValid(), "TreeListBox::GetRootEntryBitmaps: illegal document!" );
+ if (!rDocument.isValid())
+ return OUString();
+
+ 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() ) );
+ Reference< container::XNameAccess > xModuleConfig( xModuleManager, UNO_QUERY );
+ if ( xModuleConfig.is() )
+ {
+ Sequence< beans::PropertyValue > aModuleDescr;
+ xModuleConfig->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() )
+ {
+ return SvFileInformationManager::GetFileImageId(INetURLObject(sFactoryURL));
+ }
+ else
+ {
+ // default icon
+ return OUString(RID_BMP_DOCUMENT);
+ }
+ }
+ return OUString(RID_BMP_INSTALLATION);
+}
+
+void SbTreeListBox::SetCurrentEntry (EntryDescriptor const & rDesc)
+{
+ bool bCurEntry = false;
+ auto xCurIter = m_xControl->make_iterator();
+ 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();
+ bool bRootEntry = FindRootEntry(aDocument, eLocation, *m_xIter);
+ if (bRootEntry)
+ {
+ m_xControl->copy_iterator(*m_xIter, *xCurIter);
+ bCurEntry = true;
+ const OUString& aLibName( aDesc.GetLibName() );
+ if ( !aLibName.isEmpty() )
+ {
+ m_xControl->expand_row(*m_xIter);
+ auto xLibIter = m_xControl->make_iterator(m_xIter.get());
+ bool bLibEntry = FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xLibIter);
+ if (bLibEntry)
+ {
+ m_xControl->copy_iterator(*xLibIter, *xCurIter);
+ const OUString& aLibSubName( aDesc.GetLibSubName() );
+ if( !aLibSubName.isEmpty() )
+ {
+ m_xControl->expand_row(*xLibIter);
+ auto xSubLibIter = m_xControl->make_iterator(xLibIter.get());
+ bool bSubLibEntry = ImpFindEntry(*xSubLibIter, aLibSubName);
+ if (bSubLibEntry)
+ {
+ m_xControl->copy_iterator(*xSubLibIter, *xCurIter);
+ }
+ }
+ const OUString& aName( aDesc.GetName() );
+ if ( !aName.isEmpty() )
+ {
+ m_xControl->expand_row(*xCurIter);
+ EntryType eType = OBJ_TYPE_MODULE;
+ if ( aDesc.GetType() == OBJ_TYPE_DIALOG )
+ eType = OBJ_TYPE_DIALOG;
+ auto xEntryIter = m_xControl->make_iterator(xCurIter.get());
+ bool bEntry = FindEntry(aName, eType, *xEntryIter);
+ if (bEntry)
+ {
+ m_xControl->copy_iterator(*xEntryIter, *xCurIter);
+ const OUString& aMethodName( aDesc.GetMethodName() );
+ if (!aMethodName.isEmpty())
+ {
+ m_xControl->expand_row(*xCurIter);
+ auto xSubEntryIter = m_xControl->make_iterator(xCurIter.get());
+ bool bSubEntry = FindEntry(aMethodName, OBJ_TYPE_METHOD, *xSubEntryIter);
+ if (bSubEntry)
+ {
+ m_xControl->copy_iterator(*xSubEntryIter, *xCurIter);
+ }
+ else
+ {
+ m_xControl->copy_iterator(*xCurIter, *xSubEntryIter);
+ if (m_xControl->iter_children(*xSubEntryIter))
+ m_xControl->copy_iterator(*xSubEntryIter, *xCurIter);
+ }
+ }
+ }
+ else
+ {
+ auto xSubEntryIter = m_xControl->make_iterator(xCurIter.get());
+ if (m_xControl->iter_children(*xSubEntryIter))
+ m_xControl->copy_iterator(*xSubEntryIter, *xCurIter);
+ }
+ }
+ }
+ else
+ {
+ auto xSubLibIter = m_xControl->make_iterator(m_xIter.get());
+ if (m_xControl->iter_children(*xSubLibIter))
+ m_xControl->copy_iterator(*xLibIter, *xCurIter);
+ }
+ }
+ }
+ else
+ {
+ bCurEntry = m_xControl->get_iter_first(*xCurIter);
+ }
+
+ if (!bCurEntry)
+ return;
+
+ m_xControl->set_cursor(*xCurIter);
+}
+
+IMPL_LINK_NOARG(SbTreeListBox, OpenCurrentHdl, weld::TreeView&, void)
+{
+ bool bValidIter = m_xControl->get_cursor(m_xIter.get());
+ if (!bValidIter)
+ return;
+ EntryDescriptor aDesc = GetEntryDescriptor(m_xIter.get());
+ 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;
+ }
+ break;
+
+ default:
+ m_xControl->expand_row(*m_xIter);
+ break;
+ }
+}
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/bastype3.cxx b/basctl/source/basicide/bastype3.cxx
index 0a9e99fbc9c5..f2d23347afc0 100644
--- a/basctl/source/basicide/bastype3.cxx
+++ b/basctl/source/basicide/bastype3.cxx
@@ -128,6 +128,93 @@ void TreeListBox::RequestingChildren( SvTreeListEntry* pEntry )
}
}
+IMPL_LINK(SbTreeListBox, RequestingChildrenHdl, weld::TreeIter&, rEntry, bool)
+{
+ EntryDescriptor aDesc = GetEntryDescriptor(&rEntry);
+ const ScriptDocument& aDocument = aDesc.GetDocument();
+ OSL_ENSURE( aDocument.isAlive(), "basctl::TreeListBox::RequestingChildren: invalid document!" );
+ if (!aDocument.isAlive())
+ return false;
+
+ LibraryLocation eLocation = aDesc.GetLocation();
+ EntryType eType = aDesc.GetType();
+
+ if ( eType == OBJ_TYPE_DOCUMENT )
+ {
+ ImpCreateLibEntries( rEntry, 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( xModLibContainer, aOULibName, aPassword );
+ }
+ }
+
+ if ( bOK )
+ {
+ // load module library
+ bool bModLibLoaded = false;
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
+ {
+ if ( !xModLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ weld::WaitObject aWait(m_pTopLevel);
+ xModLibContainer->loadLibrary( aOULibName );
+ }
+ bModLibLoaded = xModLibContainer->isLibraryLoaded( aOULibName );
+ }
+
+ // load dialog library
+ bool bDlgLibLoaded = false;
+ Reference< script::XLibraryContainer > xDlgLibContainer( aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) )
+ {
+ if ( !xDlgLibContainer->isLibraryLoaded( aOULibName ) )
+ {
+ weld::WaitObject aWait(m_pTopLevel);
+ xDlgLibContainer->loadLibrary( aOULibName );
+ }
+ bDlgLibLoaded = xDlgLibContainer->isLibraryLoaded( aOULibName );
+ }
+
+ if ( bModLibLoaded || bDlgLibLoaded )
+ {
+ // create the sub entries
+ ImpCreateLibSubEntries( rEntry, aDocument, aOULibName );
+
+ // exchange image
+ const bool bDlgMode = (nMode & BrowseMode::Dialogs) && !(nMode & BrowseMode::Modules);
+ OUString aImage(bDlgMode ? OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_MODLIB));
+ SetEntryBitmaps(rEntry, 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( rEntry, aDocument, aLibName );
+ }
+
+ return true;
+}
+
void TreeListBox::ExpandedHdl()
{
SvTreeListEntry* pEntry = GetHdlEntry();
@@ -156,6 +243,19 @@ void TreeListBox::ScanAllEntries()
}
}
+void SbTreeListBox::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);
+ }
+}
+
SbxVariable* TreeListBox::FindVariable( SvTreeListEntry* pEntry )
{
if ( !pEntry )
@@ -249,6 +349,100 @@ SbxVariable* TreeListBox::FindVariable( SvTreeListEntry* pEntry )
return pVar;
}
+SbxVariable* SbTreeListBox::FindVariable(weld::TreeIter* pEntry)
+{
+ if ( !pEntry )
+ return nullptr;
+
+ ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
+ std::unique_ptr<weld::TreeIter> xIter(m_xControl->make_iterator(pEntry));
+ std::vector<std::pair<Entry*, OUString>> aEntries;
+ bool bValidIter = true;
+ do
+ {
+ sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
+ Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ switch (nDepth)
+ {
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ {
+ aEntries.emplace_back(pBE, m_xControl->get_text(*xIter));
+ }
+ break;
+ case 0:
+ {
+ aDocument = static_cast<DocumentEntry*>(pBE)->GetDocument();
+ }
+ break;
+ }
+ bValidIter = m_xControl->iter_parent(*xIter);
+ } while (bValidIter);
+
+ SbxVariable* pVar = nullptr;
+ if (!aEntries.empty())
+ {
+ std::reverse(aEntries.begin(), aEntries.end());
+ bool bDocumentObjects = false;
+ for (auto& pair : aEntries)
+ {
+ Entry* pBE = pair.first;
+ assert(pBE && "No data found in entry!");
+ OUString aName(pair.second);
+
+ switch ( pBE->GetType() )
+ {
+ case OBJ_TYPE_LIBRARY:
+ if (BasicManager* pBasMgr = aDocument.getBasicManager())
+ pVar = pBasMgr->GetLib( aName );
+ break;
+ case OBJ_TYPE_MODULE:
+ DBG_ASSERT(dynamic_cast<StarBASIC*>(pVar), "FindVariable: invalid Basic");
+ if(!pVar)
+ {
+ break;
+ }
+ // extract the module name from the string like "Sheet1 (Example1)"
+ if( bDocumentObjects )
+ {
+ sal_Int32 nIndex = 0;
+ aName = aName.getToken( 0, ' ', nIndex );
+ }
+ pVar = static_cast<StarBASIC*>(pVar)->FindModule( aName );
+ break;
+ case OBJ_TYPE_METHOD:
+ DBG_ASSERT(dynamic_cast<SbxObject*>(pVar), "FindVariable: invalid module/object");
+ if(!pVar)
+ {
+ break;
+ }
+ pVar = static_cast<SbxObject*>(pVar)->GetMethods()->Find(aName, SbxClassType::Method);
+ break;
+ case OBJ_TYPE_DIALOG:
+ // sbx dialogs removed
+ break;
+ case OBJ_TYPE_DOCUMENT_OBJECTS:
+ bDocumentObjects = true;
+ SAL_FALLTHROUGH;
+ case OBJ_TYPE_USERFORMS:
+ case OBJ_TYPE_NORMAL_MODULES:
+ case OBJ_TYPE_CLASS_MODULES:
+ // skip, to find the child entry.
+ continue;
+ default:
+ OSL_FAIL( "FindVariable: unknown type" );
+ pVar = nullptr;
+ break;
+ }
+ if ( !pVar )
+ break;
+ }
+ }
+ return pVar;
+}
+
EntryDescriptor TreeListBox::GetEntryDescriptor( SvTreeListEntry* pEntry )
{
ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
@@ -350,6 +544,111 @@ EntryDescriptor TreeListBox::GetEntryDescriptor( SvTreeListEntry* pEntry )
return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aName, aMethodName, eType );
}
+EntryDescriptor SbTreeListBox::GetEntryDescriptor(weld::TreeIter* 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 );
+
+ std::vector<std::pair<Entry*, OUString>> aEntries;
+
+ m_xControl->get_text(*pEntry);
+ std::unique_ptr<weld::TreeIter> xIter(m_xControl->make_iterator(pEntry));
+ m_xControl->get_text(*xIter);
+ bool bValidIter = true;
+ do
+ {
+ sal_uInt16 nDepth = m_xControl->get_iter_depth(*xIter);
+ Entry* pBE = reinterpret_cast<Entry*>(m_xControl->get_id(*xIter).toInt64());
+ switch (nDepth)
+ {
+ case 4:
+ case 3:
+ case 2:
+ case 1:
+ {
+ aEntries.emplace_back(pBE, m_xControl->get_text(*xIter));
+ }
+ break;
+ case 0:
+ {
+ if (DocumentEntry* pDocumentEntry = static_cast<DocumentEntry*>(pBE))
+ {
+ aDocument = pDocumentEntry->GetDocument();
+ eLocation = pDocumentEntry->GetLocation();
+ eType = OBJ_TYPE_DOCUMENT;
+ }
+ }
+ break;
+ }
+ bValidIter = m_xControl->iter_parent(*xIter);
+ } while (bValidIter);
+
+ if ( !aEntries.empty() )
+ {
+ for (auto& pair : aEntries)
+ {
+ Entry* pBE = pair.first;
+ assert(pBE && "No data found in entry!");
+
+ switch ( pBE->GetType() )
+ {
+ case OBJ_TYPE_LIBRARY:
+ {
+ aLibName = pair.second;
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_MODULE:
+ {
+ aName = pair.second;
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_METHOD:
+ {
+ aMethodName = pair.second;
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_DIALOG:
+ {
+ aName = pair.second;
+ eType = pBE->GetType();
+ }
+ break;
+ case OBJ_TYPE_DOCUMENT_OBJECTS:
+ case OBJ_TYPE_USERFORMS:
+ case OBJ_TYPE_NORMAL_MODULES:
+ case OBJ_TYPE_CLASS_MODULES:
+ {
+ aLibSubName = pair.second;
+ 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 );
+}
+
ItemType TreeListBox::ConvertType (EntryType eType)
{
switch (eType)
@@ -364,6 +663,20 @@ ItemType TreeListBox::ConvertType (EntryType eType)
}
}
+ItemType SbTreeListBox::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);
+ }
+}
+
bool TreeListBox::IsValidEntry( SvTreeListEntry* pEntry )
{
bool bIsValid = false;
@@ -419,11 +732,71 @@ bool TreeListBox::IsValidEntry( SvTreeListEntry* pEntry )
return bIsValid;
}
+bool SbTreeListBox::IsValidEntry(weld::TreeIter& rEntry)
+{
+ bool bIsValid = false;
+
+ EntryDescriptor aDesc(GetEntryDescriptor(&rEntry));
+ 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) == m_xControl->get_text(rEntry));
+ }
+ 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;
+}
+
SbModule* TreeListBox::FindModule( SvTreeListEntry* pEntry )
{
return dynamic_cast<SbModule*>(FindVariable(pEntry));
}
+SbModule* SbTreeListBox::FindModule(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!" );
@@ -440,6 +813,20 @@ SvTreeListEntry* TreeListBox::FindRootEntry( const ScriptDocument& rDocument, Li
return nullptr;
}
+bool SbTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation, weld::TreeIter& rIter)
+{
+ OSL_ENSURE( rDocument.isValid(), "basctl::TreeListBox::FindRootEntry: invalid document!" );
+ bool bValidIter = m_xControl->get_iter_first(rIter);
+ while (bValidIter)
+ {
+ DocumentEntry* pBDEntry = reinterpret_cast<DocumentEntry*>(m_xControl->get_id(rIter).toInt64());
+ if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation)
+ return true;
+ bValidIter = m_xControl->iter_next_sibling(rIter);
+ }
+ return false;
+}
+
OUString CreateMgrAndLibStr( const OUString& rMgrName, const OUString& rLibName )
{
return "[" + rMgrName + "]." + rLibName;
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 25f94c59c12e..182627597940 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -45,108 +45,85 @@ using std::map;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-MacroChooser::MacroChooser( vcl::Window* pParnt, const Reference< frame::XFrame >& xDocFrame, bool bCreateEntries )
- : SfxModalDialog(pParnt, "BasicMacroDialog", "modules/BasicIDE/ui/basicmacrodialog.ui")
+MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< frame::XFrame >& xDocFrame, bool bCreateEntries)
+ : SfxDialogController(pParnt, "modules/BasicIDE/ui/basicmacrodialog.ui", "BasicMacroDialog")
, m_xDocumentFrame(xDocFrame)
- , bNewDelIsDel(true)
// the Sfx doesn't ask the BasicManager whether modified or not
// => start saving in case of a change without a into the BasicIDE.
, bForceStoreBasic(false)
, nMode(All)
+ , m_xMacroNameEdit(m_xBuilder->weld_entry("macronameedit"))
+ , m_xMacroFromTxT(m_xBuilder->weld_label("macrofromft"))
+ , m_xMacrosSaveInTxt(m_xBuilder->weld_label("macrotoft"))
+ , m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view("libraries"), m_xDialog.get()))
+ , m_xBasicBoxIter(m_xBasicBox->make_iterator())
+ , m_xMacrosInTxt(m_xBuilder->weld_label("existingmacrosft"))
+ , m_xMacroBox(m_xBuilder->weld_tree_view("macros"))
+ , m_xMacroBoxIter(m_xMacroBox->make_iterator())
+ , m_xRunButton(m_xBuilder->weld_button("ok"))
+ , m_xCloseButton(m_xBuilder->weld_button("close"))
+ , m_xAssignButton(m_xBuilder->weld_button("assign"))
+ , m_xEditButton(m_xBuilder->weld_button("edit"))
+ , m_xDelButton(m_xBuilder->weld_button("delete"))
+ , m_xNewButton(m_xBuilder->weld_button("new"))
+ , m_xOrganizeButton(m_xBuilder->weld_button("organize"))
+ , m_xNewLibButton(m_xBuilder->weld_button("newlibrary"))
+ , m_xNewModButton(m_xBuilder->weld_button("newmodule"))
{
- get(m_pMacroNameEdit, "macronameedit");
- get(m_pMacroFromTxT, "macrofromft");
- get(m_pMacrosSaveInTxt, "macrotoft");
- get(m_pBasicBox, "libraries");
- get(m_pMacrosInTxt, "existingmacrosft");
- m_aMacrosInTxtBaseStr = m_pMacrosInTxt->GetText();
- get(m_pMacroBox, "macros");
- get(m_pRunButton, "run");
- get(m_pCloseButton, "close");
- get(m_pAssignButton, "assign");
- get(m_pEditButton, "edit");
- get(m_pDelButton, "delete");
- get(m_pOrganizeButton, "organize");
- get(m_pNewLibButton, "newlibrary");
- get(m_pNewModButton, "newmodule");
-
- m_pMacroBox->SetSelectionMode( SelectionMode::Single );
- m_pMacroBox->SetHighlightRange(); // select over the whole width
-
- m_pRunButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pCloseButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pAssignButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pEditButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pDelButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pOrganizeButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xBasicBox->set_size_request(m_xBasicBox->get_approximate_digit_width() * 30, m_xBasicBox->get_height_rows(18));
+ m_xMacroBox->set_size_request(m_xMacroBox->get_approximate_digit_width() * 30, m_xMacroBox->get_height_rows(18));
- // Buttons only for MacroChooser::Recording
- m_pNewLibButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pNewModButton->SetClickHdl( LINK( this, MacroChooser, ButtonHdl ) );
- m_pNewLibButton->Hide(); // default
- m_pNewModButton->Hide(); // default
- m_pMacrosSaveInTxt->Hide(); // default
+ m_aMacrosInTxtBaseStr = m_xMacrosInTxt->get_label();
+
+ m_xRunButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xCloseButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xAssignButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xEditButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xDelButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xNewButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xOrganizeButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
- m_pMacrosInTxt->SetStyle( WB_NOMULTILINE | WB_PATHELLIPSIS );
+ // Buttons only for MacroChooser::Recording
+ m_xNewLibButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xNewModButton->connect_clicked( LINK( this, MacroChooser, ButtonHdl ) );
+ m_xNewLibButton->hide(); // default
+ m_xNewModButton->hide(); // default
+ m_xMacrosSaveInTxt->hide(); // default
- m_pMacroNameEdit->SetModifyHdl( LINK( this, MacroChooser, EditModifyHdl ) );
+ m_xMacroNameEdit->connect_changed( LINK( this, MacroChooser, EditModifyHdl ) );
- m_pBasicBox->SetSelectHdl( LINK( this, MacroChooser, BasicSelectHdl ) );
+ m_xBasicBox->connect_changed( LINK( this, MacroChooser, BasicSelectHdl ) );
- m_pMacroBox->SetDoubleClickHdl( LINK( this, MacroChooser, MacroDoubleClickHdl ) );
- m_pMacroBox->SetSelectHdl( LINK( this, MacroChooser, MacroSelectHdl ) );
+ m_xMacroBox->connect_row_activated( LINK( this, MacroChooser, MacroDoubleClickHdl ) );
+ m_xMacroBox->connect_changed( LINK( this, MacroChooser, MacroSelectHdl ) );
- m_pBasicBox->SetMode( BrowseMode::Modules );
- m_pBasicBox->SetStyle( WB_TABSTOP | WB_BORDER |
- WB_HASLINES | WB_HASLINESATROOT |
- WB_HASBUTTONS | WB_HASBUTTONSATROOT |
- WB_HSCROLL );
+ m_xBasicBox->SetMode( BrowseMode::Modules );
if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
- if ( bCreateEntries )
- m_pBasicBox->ScanAllEntries();
+ if (bCreateEntries)
+ m_xBasicBox->ScanAllEntries();
}
MacroChooser::~MacroChooser()
{
- disposeOnce();
-}
-
-void MacroChooser::dispose()
-{
- if ( bForceStoreBasic )
+ if (bForceStoreBasic)
{
SfxGetpApp()->SaveBasicAndDialogContainer();
bForceStoreBasic = false;
}
- m_pMacroNameEdit.clear();
- m_pMacroFromTxT.clear();
- m_pMacrosSaveInTxt.clear();
- m_pBasicBox.clear();
- m_pMacrosInTxt.clear();
- m_pMacroBox.clear();
- m_pRunButton.clear();
- m_pCloseButton.clear();
- m_pAssignButton.clear();
- m_pEditButton.clear();
- m_pDelButton.clear();
- m_pOrganizeButton.clear();
- m_pNewLibButton.clear();
- m_pNewModButton.clear();
- SfxModalDialog::dispose();
}
void MacroChooser::StoreMacroDescription()
{
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(m_pBasicBox->FirstSelected());
+ m_xBasicBox->get_selected(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
OUString aMethodName;
- SvTreeListEntry* pEntry = m_pMacroBox->FirstSelected();
- if ( pEntry )
- aMethodName = m_pMacroBox->GetEntryText( pEntry );
+ if (m_xMacroBox->get_selected(m_xMacroBoxIter.get()))
+ aMethodName = m_xMacroBox->get_text(*m_xMacroBoxIter);
else
- aMethodName = m_pMacroNameEdit->GetText();
+ aMethodName = m_xMacroNameEdit->get_text();
if ( !aMethodName.isEmpty() )
{
aDesc.SetMethodName( aMethodName );
@@ -171,68 +148,57 @@ void MacroChooser::RestoreMacroDescription()
aDesc = pData->GetLastEntryDescriptor();
}
- m_pBasicBox->SetCurrentEntry( aDesc );
+ m_xBasicBox->SetCurrentEntry( aDesc );
OUString aLastMacro( aDesc.GetMethodName() );
- if ( !aLastMacro.isEmpty() )
+ if (!aLastMacro.isEmpty())
{
// find entry in macro box
- SvTreeListEntry* pEntry = nullptr;
- sal_uLong nPos = 0;
- SvTreeListEntry* pE = m_pMacroBox->GetEntry( nPos );
- while ( pE )
- {
- if ( m_pMacroBox->GetEntryText( pE ) == aLastMacro )
- {
- pEntry = pE;
- break;
- }
- pE = m_pMacroBox->GetEntry( ++nPos );
- }
-
- if ( pEntry )
- m_pMacroBox->SetCurEntry( pEntry );
+ auto nIndex = m_xMacroBox->find_text(aLastMacro);
+ if (nIndex != -1)
+ m_xMacroBox->select(nIndex);
else
{
- m_pMacroNameEdit->SetText( aLastMacro );
- m_pMacroNameEdit->SetSelection( Selection( 0, 0 ) );
+ m_xMacroNameEdit->set_text(aLastMacro);
+ m_xMacroNameEdit->select_region(0, 0);
}
}
}
-short MacroChooser::Execute()
+short MacroChooser::run()
{
RestoreMacroDescription();
- m_pRunButton->GrabFocus();
+ m_xRunButton->grab_focus();
// #104198 Check if "wrong" document is active
- SvTreeListEntry* pSelectedEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc( m_pBasicBox->GetEntryDescriptor( pSelectedEntry ) );
- const ScriptDocument& rSelectedDoc( aDesc.GetDocument() );
+ bool bSelectedEntry = m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc(m_xBasicBox->GetEntryDescriptor(bSelectedEntry ? m_xBasicBoxIter.get() : nullptr));
+ const ScriptDocument& rSelectedDoc(aDesc.GetDocument());
// App Basic is always ok, so only check if shell was found
if( rSelectedDoc.isDocument() && !rSelectedDoc.isActive() )
{
// Search for the right entry
- sal_uLong nRootPos = 0;
- SvTreeListEntry* pRootEntry = m_pBasicBox->GetEntry( nRootPos );
- while( pRootEntry )
+ bool bValidIter = m_xBasicBox->get_iter_first(*m_xBasicBoxIter);
+ while (bValidIter)
{
- EntryDescriptor aCmpDesc( m_pBasicBox->GetEntryDescriptor( pRootEntry ) );
+ EntryDescriptor aCmpDesc(m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get()));
const ScriptDocument& rCmpDoc( aCmpDesc.GetDocument() );
- if ( rCmpDoc.isDocument() && rCmpDoc.isActive() )
+ if (rCmpDoc.isDocument() && rCmpDoc.isActive())
{
- SvTreeListEntry* pEntry = pRootEntry;
- SvTreeListEntry* pLastValid = pEntry;
- while ( pEntry )
+ std::unique_ptr<weld::TreeIter> xEntry(m_xBasicBox->make_iterator());
+ m_xBasicBox->copy_iterator(*m_xBasicBoxIter, *xEntry);
+ std::unique_ptr<weld::TreeIter> xLastValid(m_xBasicBox->make_iterator());
+ bool bValidEntryIter = true;
+ do
{
- pLastValid = pEntry;
- pEntry = m_pBasicBox->FirstChild( pEntry );
+ m_xBasicBox->copy_iterator(*xEntry, *xLastValid);
+ bValidEntryIter = m_xBasicBox->iter_children(*xEntry);
}
- if( pLastValid )
- m_pBasicBox->SetCurEntry( pLastValid );
+ while (bValidEntryIter);
+ m_xBasicBox->set_cursor(*xLastValid);
}
- pRootEntry = m_pBasicBox->GetEntry( ++nRootPos );
+ bValidIter = m_xBasicBox->iter_next_sibling(*m_xBasicBoxIter);
}
}
@@ -240,36 +206,35 @@ short MacroChooser::Execute()
UpdateFields();
if ( StarBASIC::IsRunning() )
- m_pCloseButton->GrabFocus();
+ m_xCloseButton->grab_focus();
- return ModalDialog::Execute();
+ return SfxDialogController::run();
}
-void MacroChooser::EnableButton( Button& rButton, bool bEnable )
+void MacroChooser::EnableButton(weld::Button& rButton, bool bEnable)
{
if ( bEnable )
{
if (nMode == ChooseOnly || nMode == Recording)
- rButton.Enable(&rButton == m_pRunButton);
+ rButton.set_sensitive(&rButton == m_xRunButton.get());
else
- rButton.Enable();
+ rButton.set_sensitive(true);
}
else
- rButton.Disable();
+ rButton.set_sensitive(false);
}
-
SbMethod* MacroChooser::GetMacro()
{
SbMethod* pMethod = nullptr;
- SbModule* pModule = m_pBasicBox->FindModule( m_pBasicBox->GetCurEntry() );
- if ( pModule )
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
+ if (pModule)
{
- SvTreeListEntry* pEntry = m_pMacroBox->FirstSelected();
- if ( pEntry )
+ if (m_xMacroBox->get_selected(m_xMacroBoxIter.get()))
{
- OUString aMacroName( m_pMacroBox->GetEntryText( pEntry ) );
- pMethod = pModule->FindMethod( aMacroName, SbxClassType::Method );
+ OUString aMacroName(m_xMacroBox->get_text(*m_xMacroBoxIter));
+ pMethod = pModule->FindMethod(aMacroName, SbxClassType::Method);
}
}
return pMethod;
@@ -280,7 +245,7 @@ void MacroChooser::DeleteMacro()
{
SbMethod* pMethod = GetMacro();
DBG_ASSERT( pMethod, "DeleteMacro: No Macro !" );
- if (pMethod && QueryDelMacro(pMethod->GetName(), GetFrameWeld()))
+ if (pMethod && QueryDelMacro(pMethod->GetName(), m_xDialog.get()))
{
if (SfxDispatcher* pDispatcher = GetDispatcher())
pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
@@ -312,9 +277,9 @@ void MacroChooser::DeleteMacro()
OUString aModName = pModule->GetName();
OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aSource ) );
- SvTreeListEntry* pEntry = m_pMacroBox->FirstSelected();
- DBG_ASSERT( pEntry, "DeleteMacro: Entry ?!" );
- m_pMacroBox->GetModel()->Remove( pEntry );
+ bool bSelected = m_xMacroBox->get_selected(m_xMacroBoxIter.get());
+ DBG_ASSERT(bSelected, "DeleteMacro: Entry ?!");
+ m_xMacroBox->remove(*m_xMacroBoxIter);
bForceStoreBasic = true;
}
}
@@ -322,8 +287,8 @@ void MacroChooser::DeleteMacro()
SbMethod* MacroChooser::CreateMacro()
{
SbMethod* pMethod = nullptr;
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
OSL_ENSURE( aDocument.isAlive(), "MacroChooser::CreateMacro: no document!" );
if ( !aDocument.isAlive() )
@@ -365,11 +330,11 @@ SbMethod* MacroChooser::CreateMacro()
// Retain the desired macro name before the macro dialog box is forced to close
// by opening the module name dialog window when no module exists in the current library.
- OUString aSubName = m_pMacroNameEdit->GetText();
+ OUString aSubName = m_xMacroNameEdit->get_text();
if ( !pModule )
{
- pModule = createModImpl(GetFrameWeld(), aDocument, *m_pBasicBox, aLibName, aModName, false);
+ pModule = createModImpl(m_xDialog.get(), aDocument, *m_xBasicBox, aLibName, aModName, false);
}
DBG_ASSERT( !pModule || !pModule->FindMethod( aSubName, SbxClassType::Method ), "Macro exists already!" );
@@ -379,28 +344,30 @@ SbMethod* MacroChooser::CreateMacro()
return pMethod;
}
-void MacroChooser::SaveSetCurEntry( SvTreeListBox& rBox, SvTreeListEntry* pEntry )
+void MacroChooser::SaveSetCurEntry(weld::TreeView& rBox, weld::TreeIter& rEntry)
{
// the edit would be killed by the highlight otherwise:
- OUString aSaveText( m_pMacroNameEdit->GetText() );
- Selection aCurSel( m_pMacroNameEdit->GetSelection() );
+ OUString aSaveText(m_xMacroNameEdit->get_text());
+ int nStartPos, nEndPos;
+ m_xMacroNameEdit->get_selection_bounds(nStartPos, nEndPos);
- rBox.SetCurEntry( pEntry );
- m_pMacroNameEdit->SetText( aSaveText );
- m_pMacroNameEdit->SetSelection( aCurSel );
+ rBox.set_cursor(rEntry);
+
+ m_xMacroNameEdit->set_text(aSaveText);
+ m_xMacroNameEdit->select_region(nStartPos, nEndPos);
}
void MacroChooser::CheckButtons()
{
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
- SvTreeListEntry* pMacroEntry = m_pMacroBox->FirstSelected();
+ const bool bCurEntry = m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(bCurEntry ? m_xBasicBoxIter.get() : nullptr);
+ const bool bMacroEntry = m_xMacroBox->get_selected(nullptr);
SbMethod* pMethod = GetMacro();
// check, if corresponding libraries are readonly
bool bReadOnly = false;
- sal_uInt16 nDepth = pCurEntry ? m_pBasicBox->GetModel()->GetDepth( pCurEntry ) : 0;
+ sal_uInt16 nDepth = bCurEntry ? m_xBasicBox->get_iter_depth(*m_xBasicBoxIter) : 0;
if ( nDepth == 1 || nDepth == 2 )
{
const ScriptDocument& aDocument( aDesc.GetDocument() );
@@ -420,45 +387,52 @@ void MacroChooser::CheckButtons()
bool bEnable = pMethod != nullptr;
if (nMode != ChooseOnly && StarBASIC::IsRunning())
bEnable = false;
- EnableButton(*m_pRunButton, bEnable);
+ EnableButton(*m_xRunButton, bEnable);
}
// organising still possible?
// Assign...
- EnableButton(*m_pAssignButton, pMethod != nullptr);
+ EnableButton(*m_xAssignButton, pMethod != nullptr);
// Edit...
- EnableButton(*m_pEditButton, pMacroEntry != nullptr);
+ EnableButton(*m_xEditButton, bMacroEntry);
// Organizer...
- EnableButton(*m_pOrganizeButton, !StarBASIC::IsRunning() && nMode == All);
+ EnableButton(*m_xOrganizeButton, !StarBASIC::IsRunning() && nMode == All);
- // m_pDelButton->...
- bool bProtected = m_pBasicBox->IsEntryProtected( pCurEntry );
+ // m_xDelButton/m_xNewButton ->...
+ bool bProtected = bCurEntry && m_xBasicBox->IsEntryProtected(m_xBasicBoxIter.get());
bool bShare = ( aDesc.GetLocation() == LIBRARY_LOCATION_SHARE );
- EnableButton(*m_pDelButton, !StarBASIC::IsRunning() && nMode == All && !bProtected && !bReadOnly && !bShare);
- bool bPrev = bNewDelIsDel;
- bNewDelIsDel = pMethod != nullptr;
- if (bPrev != bNewDelIsDel && nMode == All)
+ bool bEnable = !StarBASIC::IsRunning() && nMode == All && !bProtected && !bReadOnly && !bShare;
+ EnableButton(*m_xDelButton, bEnable);
+ EnableButton(*m_xNewButton, bEnable);
+ if (nMode == All)
{
- OUString aBtnText( bNewDelIsDel ? IDEResId(RID_STR_BTNDEL) : IDEResId(RID_STR_BTNNEW) );
- m_pDelButton->SetText( aBtnText );
+ if (pMethod)
+ {
+ m_xDelButton->show();
+ m_xNewButton->hide();
+ }
+ else
+ {
+ m_xNewButton->show();
+ m_xDelButton->hide();
+ }
}
if (nMode == Recording)
{
// save button
- m_pRunButton->Enable(!bProtected && !bReadOnly && !bShare);
+ m_xRunButton->set_sensitive(!bProtected && !bReadOnly && !bShare);
// new library button
- m_pNewLibButton->Enable(!bShare);
+ m_xNewLibButton->set_sensitive(!bShare);
// new module button
- m_pNewModButton->Enable(!bProtected && !bReadOnly && !bShare);
+ m_xNewModButton->set_sensitive(!bProtected && !bReadOnly && !bShare);
}
}
-
-IMPL_LINK_NOARG(MacroChooser, MacroDoubleClickHdl, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(MacroChooser, MacroDoubleClickHdl, weld::TreeView&, void)
{
SbMethod* pMethod = GetMacro();
SbModule* pModule = pMethod ? pMethod->GetModule() : nullptr;
@@ -468,51 +442,36 @@ IMPL_LINK_NOARG(MacroChooser, MacroDoubleClickHdl, SvTreeListBox*, bool)
if (aDocument.isDocument() && !aDocument.allowMacros())
{
std::unique_ptr<weld::MessageDialog> xError(
- Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning,
+ Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning,
VclButtonsType::Ok, IDEResId(RID_STR_CANNOTRUNMACRO)));
xError->run();
- return false;
+ return;
}
StoreMacroDescription();
if (nMode == Recording)
{
- if (pMethod && !QueryReplaceMacro(pMethod->GetName(), GetFrameWeld()))
- return false;
+ if (pMethod && !QueryReplaceMacro(pMethod->GetName(), m_xDialog.get()))
+ return;
}
- EndDialog(Macro_OkRun);
- return false;
+ m_xDialog->response(Macro_OkRun);
}
-IMPL_LINK( MacroChooser, MacroSelectHdl, SvTreeListBox *, pBox, void )
+IMPL_LINK_NOARG(MacroChooser, MacroSelectHdl, weld::TreeView&, void)
{
- // Is also called if deselected!
- // Two function calls in every SelectHdl because
- // there's no separate DeselectHDL.
- // So find out if select or deselect:
- if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
- {
- UpdateFields();
- CheckButtons();
- }
+ UpdateFields();
+ CheckButtons();
}
-IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox, void )
+IMPL_LINK_NOARG(MacroChooser, BasicSelectHdl, weld::TreeView&, void)
{
- // Is also called if deselected!
- // Two function calls in every SelectHdl because
- // there's no separate DeselectHDL.
- // So find out if select or deselect:
- if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
- return;
-
- SbModule* pModule = m_pBasicBox->FindModule( m_pBasicBox->GetCurEntry() );
-
- m_pMacroBox->Clear();
- if ( pModule )
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ SbModule* pModule = m_xBasicBox->FindModule(m_xBasicBoxIter.get());
+ m_xMacroBox->clear();
+ if (pModule)
{
- m_pMacrosInTxt->SetText( m_aMacrosInTxtBaseStr + " " + pModule->GetName() );
+ m_xMacrosInTxt->set_label(m_aMacrosInTxtBaseStr + " " + pModule->GetName());
// The macros should be called in the same order that they
// are written down in the module.
@@ -530,16 +489,15 @@ IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox, void )
aMacros.emplace( nStart, pMethod );
}
- m_pMacroBox->SetUpdateMode(false);
+ m_xMacroBox->freeze();
for (auto const& macro : aMacros)
- m_pMacroBox->InsertEntry( macro.second->GetName() );
- m_pMacroBox->SetUpdateMode(true);
+ m_xMacroBox->append_text(macro.second->GetName());
+ m_xMacroBox->thaw();
- if ( m_pMacroBox->GetEntryCount() )
+ if (m_xMacroBox->n_children())
{
- SvTreeListEntry* pEntry = m_pMacroBox->GetEntry( 0 );
- DBG_ASSERT( pEntry, "Entry ?!" );
- m_pMacroBox->SetCurEntry( pEntry );
+ m_xMacroBox->get_iter_first(*m_xMacroBoxIter);
+ m_xMacroBox->set_cursor(*m_xMacroBoxIter);
}
}
@@ -547,56 +505,58 @@ IMPL_LINK( MacroChooser, BasicSelectHdl, SvTreeListBox *, pBox, void )
CheckButtons();
}
-
-IMPL_LINK_NOARG( MacroChooser, EditModifyHdl, Edit&, void )
+IMPL_LINK_NOARG(MacroChooser, EditModifyHdl, weld::Entry&, void)
{
// select the module in which the macro is put at "new",
// if BasicManager or Lib is selecting
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- if ( pCurEntry )
+ if (m_xBasicBox->get_cursor(m_xBasicBoxIter.get()))
{
- sal_uInt16 nDepth = m_pBasicBox->GetModel()->GetDepth( pCurEntry );
- if ( ( nDepth == 1 ) && ( m_pBasicBox->IsEntryProtected( pCurEntry ) ) )
+ sal_uInt16 nDepth = m_xBasicBox->get_iter_depth(*m_xBasicBoxIter);
+ if (nDepth == 1 && m_xBasicBox->IsEntryProtected(m_xBasicBoxIter.get()))
{
// then put to the respective Std-Lib...
- SvTreeListEntry* pManagerEntry = m_pBasicBox->GetModel()->GetParent( pCurEntry );
- pCurEntry = m_pBasicBox->GetModel()->FirstChild( pManagerEntry );
+ m_xBasicBox->iter_parent(*m_xBasicBoxIter);
+ m_xBasicBox->iter_children(*m_xBasicBoxIter);
}
- if ( nDepth < 2 )
+ if (nDepth < 2)
{
- SvTreeListEntry* pNewEntry = pCurEntry;
- while ( pCurEntry && ( nDepth < 2 ) )
+ std::unique_ptr<weld::TreeIter> xNewEntry(m_xBasicBox->make_iterator());
+ m_xBasicBox->copy_iterator(*m_xBasicBoxIter, *xNewEntry);
+ bool bCurEntry = true;
+ do
{
- pCurEntry = m_pBasicBox->FirstChild( pCurEntry );
- if ( pCurEntry )
+ bCurEntry = m_xBasicBox->iter_children(*m_xBasicBoxIter);
+ if (bCurEntry)
{
- pNewEntry = pCurEntry;
- nDepth = m_pBasicBox->GetModel()->GetDepth( pCurEntry );
+ m_xBasicBox->copy_iterator(*m_xBasicBoxIter, *xNewEntry);
+ nDepth = m_xBasicBox->get_iter_depth(*m_xBasicBoxIter);
}
}
- SaveSetCurEntry( *m_pBasicBox, pNewEntry );
+ while (bCurEntry && (nDepth < 2));
+ SaveSetCurEntry(m_xBasicBox->get_widget(), *xNewEntry);
}
- if ( m_pMacroBox->GetEntryCount() )
+ auto nCount = m_xMacroBox->n_children();
+ if (nCount)
{
- OUString aEdtText( m_pMacroNameEdit->GetText() );
+ OUString aEdtText(m_xMacroNameEdit->get_text());
bool bFound = false;
- for ( sal_uLong n = 0; n < m_pMacroBox->GetEntryCount(); n++ )
+ bool bValidIter = m_xMacroBox->get_iter_first(*m_xMacroBoxIter);
+ while (bValidIter)
{
- SvTreeListEntry* pEntry = m_pMacroBox->GetEntry( n );
- DBG_ASSERT( pEntry, "Entry ?!" );
- if ( m_pMacroBox->GetEntryText( pEntry ).equalsIgnoreAsciiCase( aEdtText ) )
+ if (m_xMacroBox->get_text(*m_xMacroBoxIter).equalsIgnoreAsciiCase(aEdtText))
{
- SaveSetCurEntry(*m_pMacroBox, pEntry);
+ SaveSetCurEntry(*m_xMacroBox, *m_xMacroBoxIter);
bFound = true;
break;
}
+ bValidIter = m_xMacroBox->iter_next_sibling(*m_xMacroBoxIter);
}
- if ( !bFound )
+ if (!bFound)
{
- SvTreeListEntry* pEntry = m_pMacroBox->FirstSelected();
+ bValidIter = m_xMacroBox->get_selected(m_xMacroBoxIter.get());
// if the entry exists ->Select ->Description...
- if ( pEntry )
- m_pMacroBox->Select( pEntry, false );
+ if (bValidIter)
+ m_xMacroBox->unselect(*m_xMacroBoxIter);
}
}
}
@@ -604,11 +564,10 @@ IMPL_LINK_NOARG( MacroChooser, EditModifyHdl, Edit&, void )
CheckButtons();
}
-
-IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
+IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, rButton, void)
{
// apart from New/Record the Description is done by LoseFocus
- if (pButton == m_pRunButton)
+ if (&rButton == m_xRunButton.get())
{
StoreMacroDescription();
@@ -624,7 +583,7 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
if ( aDocument.isDocument() && !aDocument.allowMacros() )
{
- std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_CANNOTRUNMACRO)));
xError->run();
return;
@@ -633,32 +592,32 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
}
else if (nMode == Recording )
{
- if ( !IsValidSbxName(m_pMacroNameEdit->GetText()) )
+ if ( !IsValidSbxName(m_xMacroNameEdit->get_text()) )
{
- std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
xError->run();
- m_pMacroNameEdit->SetSelection( Selection( 0, m_pMacroNameEdit->GetText().getLength() ) );
- m_pMacroNameEdit->GrabFocus();
+ m_xMacroNameEdit->select_region(0, -1);
+ m_xMacroNameEdit->grab_focus();
return;
}
SbMethod* pMethod = GetMacro();
- if (pMethod && !QueryReplaceMacro(pMethod->GetName(), GetFrameWeld()))
+ if (pMethod && !QueryReplaceMacro(pMethod->GetName(), m_xDialog.get()))
return;
}
- EndDialog(Macro_OkRun);
+ m_xDialog->response(Macro_OkRun);
}
- else if (pButton == m_pCloseButton)
+ else if (&rButton == m_xCloseButton.get())
{
StoreMacroDescription();
- EndDialog(Macro_Close);
+ m_xDialog->response(Macro_Close);
}
- else if ((pButton == m_pEditButton) || (pButton == m_pDelButton))
+ else if (&rButton == m_xEditButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xNewButton.get())
{
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
if ( !aDocument.isAlive() )
@@ -674,11 +633,10 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
}
const OUString& aSub( aDesc.GetMethodName() );
SfxMacroInfoItem aInfoItem( SID_BASICIDE_ARG_MACROINFO, pBasMgr, aLib, aMod, aSub, OUString() );
- if (pButton == m_pEditButton)
+ if (&rButton == m_xEditButton.get())
{
- SvTreeListEntry* pEntry = m_pMacroBox->FirstSelected();
- if ( pEntry )
- aInfoItem.SetMethod( m_pMacroBox->GetEntryText( pEntry ) );
+ if (m_xMacroBox->get_selected(m_xMacroBoxIter.get()))
+ aInfoItem.SetMethod(m_xMacroBox->get_text(*m_xMacroBoxIter));
StoreMacroDescription();
SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs );
@@ -689,11 +647,11 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
pDispatcher->ExecuteList(SID_BASICIDE_EDITMACRO,
SfxCallMode::ASYNCHRON, { &aInfoItem });
}
- EndDialog(Macro_Edit);
+ m_xDialog->response(Macro_Edit);
}
else
{
- if ( bNewDelIsDel )
+ if (&rButton == m_xDelButton.get())
{
DeleteMacro();
if (SfxDispatcher* pDispatcher = GetDispatcher())
@@ -703,18 +661,18 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
}
CheckButtons();
UpdateFields();
- //if ( m_pMacroBox->GetCurEntry() ) // OV-Bug ?
- // m_pMacroBox->Select( m_pMacroBox->GetCurEntry() );
+ //if ( m_xMacroBox->GetCurEntry() ) // OV-Bug ?
+ // m_xMacroBox->Select( m_xMacroBox->GetCurEntry() );
}
else
{
- if ( !IsValidSbxName(m_pMacroNameEdit->GetText()) )
+ if ( !IsValidSbxName(m_xMacroNameEdit->get_text()) )
{
- std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
xError->run();
- m_pMacroNameEdit->SetSelection( Selection( 0, m_pMacroNameEdit->GetText().getLength() ) );
- m_pMacroNameEdit->GrabFocus();
+ m_xMacroNameEdit->select_region(0, -1);
+ m_xMacroNameEdit->grab_focus();
return;
}
SbMethod* pMethod = CreateMacro();
@@ -733,15 +691,15 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
SfxCallMode::ASYNCHRON, { &aInfoItem });
}
StoreMacroDescription();
- EndDialog(Macro_New);
+ m_xDialog->response(Macro_New);
}
}
}
}
- else if (pButton == m_pAssignButton)
+ else if (&rButton == m_xAssignButton.get())
{
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
DBG_ASSERT( aDocument.isAlive(), "MacroChooser::ButtonHdl: no document, or document is dead!" );
if ( !aDocument.isAlive() )
@@ -749,7 +707,7 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
BasicManager* pBasMgr = aDocument.getBasicManager();
const OUString& aLib( aDesc.GetLibName() );
const OUString& aMod( aDesc.GetName() );
- OUString aSub( m_pMacroNameEdit->GetText() );
+ OUString aSub( m_xMacroNameEdit->get_text() );
SbMethod* pMethod = GetMacro();
DBG_ASSERT( pBasMgr, "BasMgr?" );
DBG_ASSERT( pMethod, "Method?" );
@@ -765,33 +723,34 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
aRequest.AppendItem( aItem );
SfxGetpApp()->ExecuteSlot( aRequest );
}
- else if (pButton == m_pNewLibButton)
+ else if (&rButton == m_xNewLibButton.get())
{
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
- createLibImpl(GetFrameWeld(), aDocument, nullptr, m_pBasicBox);
+ createLibImpl(m_xDialog.get(), aDocument, nullptr, m_xBasicBox.get());
}
- else if (pButton == m_pNewModButton)
+ else if (&rButton == m_xNewModButton.get())
{
- SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+ m_xBasicBox->get_cursor(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
const ScriptDocument& aDocument( aDesc.GetDocument() );
const OUString& aLibName( aDesc.GetLibName() );
- createModImpl(GetFrameWeld(), aDocument, *m_pBasicBox, aLibName, OUString(), true);
+ createModImpl(m_xDialog.get(), aDocument, *m_xBasicBox, aLibName, OUString(), true);
}
- else if (pButton == m_pOrganizeButton)
+ else if (&rButton == m_xOrganizeButton.get())
{
StoreMacroDescription();
- EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(m_pBasicBox->FirstSelected());
- VclPtrInstance< OrganizeDialog > pDlg( this, 0, aDesc );
+ m_xBasicBox->get_selected(m_xBasicBoxIter.get());
+ EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
+ VclPtrInstance< OrganizeDialog > pDlg( nullptr, 0, aDesc ); //TODO
sal_uInt16 nRet = pDlg->Execute();
pDlg.reset();
if ( nRet ) // not only closed
{
- EndDialog(Macro_Edit);
+ m_xDialog->response(Macro_Edit);
return;
}
@@ -799,18 +758,17 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton, void )
if ( pShell && pShell->IsAppBasicModified() )
bForceStoreBasic = true;
- m_pBasicBox->UpdateEntries();
+ m_xBasicBox->UpdateEntries();
}
}
void MacroChooser::UpdateFields()
{
- SvTreeListEntry* pMacroEntry = m_pMacroBox->GetCurEntry();
-
- m_pMacroNameEdit->SetText( "" );
- if ( pMacroEntry )
- m_pMacroNameEdit->SetText( m_pMacroBox->GetEntryText( pMacroEntry ) );
+ auto nMacroEntry = m_xMacroBox->get_selected_index();
+ m_xMacroNameEdit->set_text("");
+ if (nMacroEntry != -1)
+ m_xMacroNameEdit->set_text(m_xMacroBox->get_text(nMacroEntry));
}
void MacroChooser::SetMode (Mode nM)
@@ -820,35 +778,39 @@ void MacroChooser::SetMode (Mode nM)
{
case All:
{
- m_pRunButton->SetText(IDEResId(RID_STR_RUN));
- EnableButton(*m_pDelButton, true);
- EnableButton(*m_pOrganizeButton, true);
+ m_xRunButton->set_label(IDEResId(RID_STR_RUN));
+ EnableButton(*m_xDelButton, true);
+ EnableButton(*m_xNewButton, true);
+ EnableButton(*m_xOrganizeButton, true);
break;
}
case ChooseOnly:
{
- m_pRunButton->SetText(IDEResId(RID_STR_CHOOSE));
- EnableButton(*m_pDelButton, false);
- EnableButton(*m_pOrganizeButton, false);
+ m_xRunButton->set_label(IDEResId(RID_STR_CHOOSE));
+ EnableButton(*m_xDelButton, false);
+ EnableButton(*m_xNewButton, false);
+ EnableButton(*m_xOrganizeButton, false);
break;
}
case Recording:
{
- m_pRunButton->SetText(IDEResId(RID_STR_RECORD));
- EnableButton(*m_pDelButton, false);
- EnableButton(*m_pOrganizeButton, false);
-
- m_pAssignButton->Hide();
- m_pEditButton->Hide();
- m_pDelButton->Hide();
- m_pOrganizeButton->Hide();
- m_pMacroFromTxT->Hide();
-
- m_pNewLibButton->Show();
- m_pNewModButton->Show();
- m_pMacrosSaveInTxt->Show();
+ m_xRunButton->set_label(IDEResId(RID_STR_RECORD));
+ EnableButton(*m_xDelButton, false);
+ EnableButton(*m_xNewButton, false);
+ EnableButton(*m_xOrganizeButton, false);
+
+ m_xAssignButton->hide();
+ m_xEditButton->hide();
+ m_xDelButton->hide();
+ m_xNewButton->hide();
+ m_xOrganizeButton->hide();
+ m_xMacroFromTxT->hide();
+
+ m_xNewLibButton->show();
+ m_xNewModButton->show();
+ m_xMacrosSaveInTxt->show();
break;
}
diff --git a/basctl/source/basicide/macrodlg.hxx b/basctl/source/basicide/macrodlg.hxx
index 8a0e1ff16a93..35e54799b734 100644
--- a/basctl/source/basicide/macrodlg.hxx
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -22,22 +22,20 @@
#include <bastype2.hxx>
#include <sfx2/basedlgs.hxx>
-
#include <com/sun/star/frame/XFrame.hpp>
-
-#include <vcl/button.hxx>
+#include <vcl/weld.hxx>
namespace basctl
{
enum MacroExitCode {
- Macro_Close = 10,
- Macro_OkRun = 11,
- Macro_New = 12,
- Macro_Edit = 14,
+ Macro_Close = 110,
+ Macro_OkRun = 111,
+ Macro_New = 112,
+ Macro_Edit = 114,
};
-class MacroChooser : public SfxModalDialog
+class MacroChooser : public SfxDialogController
{
public:
enum Mode {
@@ -47,58 +45,58 @@ public:
};
private:
- VclPtr<Edit> m_pMacroNameEdit;
- VclPtr<FixedText> m_pMacroFromTxT;
- VclPtr<FixedText> m_pMacrosSaveInTxt;
- VclPtr<TreeListBox> m_pBasicBox;
- VclPtr<FixedText> m_pMacrosInTxt;
OUString m_aMacrosInTxtBaseStr;
- VclPtr<SvTreeListBox> m_pMacroBox;
-
- VclPtr<PushButton> m_pRunButton;
- VclPtr<CloseButton> m_pCloseButton;
- VclPtr<PushButton> m_pAssignButton;
- VclPtr<PushButton> m_pEditButton;
- VclPtr<PushButton> m_pDelButton;
- VclPtr<PushButton> m_pOrganizeButton;
- VclPtr<PushButton> m_pNewLibButton;
- VclPtr<PushButton> m_pNewModButton;
// For forwarding to Assign dialog
::css::uno::Reference< ::css::frame::XFrame > m_xDocumentFrame;
- bool bNewDelIsDel;
bool bForceStoreBasic;
Mode nMode;
- DECL_LINK( MacroSelectHdl, SvTreeListBox *, void );
- DECL_LINK( MacroDoubleClickHdl, SvTreeListBox*, bool );
- DECL_LINK( BasicSelectHdl, SvTreeListBox *, void );
- DECL_LINK( EditModifyHdl, Edit&, void );
- DECL_LINK( ButtonHdl, Button *, void );
+ DECL_LINK(MacroSelectHdl, weld::TreeView&, void);
+ DECL_LINK(MacroDoubleClickHdl, weld::TreeView&, void);
+ DECL_LINK(BasicSelectHdl, weld::TreeView&, void);
+ DECL_LINK(EditModifyHdl, weld::Entry&, void);
+ DECL_LINK(ButtonHdl, weld::Button&, void);
void CheckButtons();
- void SaveSetCurEntry( SvTreeListBox& rBox, SvTreeListEntry* pEntry );
+ void SaveSetCurEntry(weld::TreeView& rBox, weld::TreeIter& rEntry);
void UpdateFields();
- void EnableButton( Button& rButton, bool bEnable );
+ void EnableButton(weld::Button& rButton, bool bEnable);
static OUString GetInfo( SbxVariable* pVar );
void StoreMacroDescription();
void RestoreMacroDescription();
+ std::unique_ptr<weld::Entry> m_xMacroNameEdit;
+ std::unique_ptr<weld::Label> m_xMacroFromTxT;
+ std::unique_ptr<weld::Label> m_xMacrosSaveInTxt;
+ std::unique_ptr<SbTreeListBox> m_xBasicBox;
+ std::unique_ptr<weld::TreeIter> m_xBasicBoxIter;
+ std::unique_ptr<weld::Label> m_xMacrosInTxt;
+ std::unique_ptr<weld::TreeView> m_xMacroBox;
+ std::unique_ptr<weld::TreeIter> m_xMacroBoxIter;
+ std::unique_ptr<weld::Button> m_xRunButton;
+ std::unique_ptr<weld::Button> m_xCloseButton;
+ std::unique_ptr<weld::Button> m_xAssignButton;
+ std::unique_ptr<weld::Button> m_xEditButton;
+ std::unique_ptr<weld::Button> m_xDelButton;
+ std::unique_ptr<weld::Button> m_xNewButton;
+ std::unique_ptr<weld::Button> m_xOrganizeButton;
+ std::unique_ptr<weld::Button> m_xNewLibButton;
+ std::unique_ptr<weld::Button> m_xNewModButton;
public:
- MacroChooser( vcl::Window* pParent, const ::css::uno::Reference< ::css::frame::XFrame >& xDocFrame, bool bCreateEntries );
- virtual ~MacroChooser() override;
- virtual void dispose() override;
+ MacroChooser(weld::Window *pParent, const ::css::uno::Reference< ::css::frame::XFrame >& xDocFrame, bool bCreateEntries);
+ virtual ~MacroChooser() override;
SbMethod* GetMacro();
void DeleteMacro();
SbMethod* CreateMacro();
- virtual short Execute() override;
+ virtual short run() override;
void SetMode (Mode);
Mode GetMode () const { return nMode; }
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 2e13017bb80f..7c16245fd392 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -698,7 +698,7 @@ IMPL_LINK( LibPage, CheckPasswordHdl, SvxPasswordDialog *, pDlg, bool )
void LibPage::NewLib()
{
- createLibImpl(GetFrameWeld(), m_aCurDocument, m_pLibBox, nullptr);
+ createLibImpl(GetFrameWeld(), m_aCurDocument, m_pLibBox, static_cast<SbTreeListBox*>(nullptr));
}
void LibPage::InsertLib()
@@ -1552,6 +1552,106 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
}
}
}
+
+void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
+ CheckBox* pLibBox, SbTreeListBox* pBasicBox)
+{
+ OSL_ENSURE( rDocument.isAlive(), "createLibImpl: invalid document!" );
+ if ( !rDocument.isAlive() )
+ return;
+
+ // create library name
+ OUString aLibName;
+ bool bValid = false;
+ sal_Int32 i = 1;
+ while ( !bValid )
+ {
+ aLibName = "Library" + OUString::number( i );
+ if ( !rDocument.hasLibrary( E_SCRIPTS, aLibName ) && !rDocument.hasLibrary( E_DIALOGS, aLibName ) )
+ bValid = true;
+ i++;
+ }
+
+ NewObjectDialog aNewDlg(pWin, ObjectMode::Library);
+ aNewDlg.SetObjectName(aLibName);
+
+ if (aNewDlg.run())
+ {
+ if (!aNewDlg.GetObjectName().isEmpty())
+ aLibName = aNewDlg.GetObjectName();
+
+ if ( aLibName.getLength() > 30 )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_LIBNAMETOLONG)));
+ xErrorBox->run();
+ }
+ else if ( !IsValidSbxName( aLibName ) )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
+ xErrorBox->run();
+ }
+ else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
+ xErrorBox->run();
+ }
+ else
+ {
+ try
+ {
+ // create module and dialog library
+ Reference< container::XNameContainer > xModLib( rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName ) );
+ Reference< container::XNameContainer > xDlgLib( rDocument.getOrCreateLibrary( E_DIALOGS, aLibName ) );
+
+ if( pLibBox )
+ {
+ SvTreeListEntry* pEntry = pLibBox->DoInsertEntry( aLibName );
+ pEntry->SetUserData( new LibUserData( rDocument ) );
+ pLibBox->SetCurEntry( pEntry );
+ }
+
+ // create a module
+ OUString aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+ OUString sModuleCode;
+ if ( !rDocument.createModule( aLibName, aModName, true, sModuleCode ) )
+ throw Exception("could not create module " + aModName, nullptr);
+
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
+ SfxCallMode::SYNCHRON, { &aSbxItem });
+
+ if( pBasicBox )
+ {
+ std::unique_ptr<weld::TreeIter> xIter(pBasicBox->make_iterator(nullptr));
+ bool bValidIter = pBasicBox->get_cursor(xIter.get());
+ std::unique_ptr<weld::TreeIter> xRootEntry(pBasicBox->make_iterator(xIter.get()));
+ while (bValidIter)
+ {
+ pBasicBox->copy_iterator(*xIter, *xRootEntry);
+ bValidIter = pBasicBox->iter_parent(*xIter);
+ }
+
+ BrowseMode nMode = pBasicBox->GetMode();
+ bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules );
+ const OUString sId = bDlgMode ? OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_MODLIB);
+ pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, o3tl::make_unique<Entry>(OBJ_TYPE_LIBRARY));
+ pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, o3tl::make_unique<Entry>(OBJ_TYPE_MODULE));
+ pBasicBox->set_cursor(*xRootEntry);
+ pBasicBox->select(*xRootEntry);
+ }
+ }
+ catch (const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+ }
+ }
+}
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 1a2af91d35de..1f525beb7c26 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -1055,6 +1055,102 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
return pModule;
}
+SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
+ SbTreeListBox& rBasicBox, const OUString& rLibName, const OUString& _aModName, bool bMain )
+{
+ OSL_ENSURE( rDocument.isAlive(), "createModImpl: invalid document!" );
+ if ( !rDocument.isAlive() )
+ return nullptr;
+
+ SbModule* pModule = nullptr;
+
+ OUString aLibName( rLibName );
+ if ( aLibName.isEmpty() )
+ aLibName = "Standard" ;
+ rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+ OUString aModName = _aModName;
+ if ( aModName.isEmpty() )
+ aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+
+ NewObjectDialog aNewDlg(pWin, ObjectMode::Module, true);
+ aNewDlg.SetObjectName(aModName);
+
+ if (aNewDlg.run() != RET_CANCEL)
+ {
+ if (!aNewDlg.GetObjectName().isEmpty())
+ aModName = aNewDlg.GetObjectName();
+
+ try
+ {
+ OUString sModuleCode;
+ // the module has existed
+ if( rDocument.hasModule( aLibName, aModName ) )
+ return nullptr;
+ rDocument.createModule( aLibName, aModName, bMain, sModuleCode );
+ BasicManager* pBasMgr = rDocument.getBasicManager();
+ StarBASIC* pBasic = pBasMgr? pBasMgr->GetLib( aLibName ) : nullptr;
+ if ( pBasic )
+ pModule = pBasic->FindModule( aModName );
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ {
+ pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
+ SfxCallMode::SYNCHRON, { &aSbxItem });
+ }
+ LibraryLocation eLocation = rDocument.getLibraryLocation( aLibName );
+ std::unique_ptr<weld::TreeIter> xIter(rBasicBox.make_iterator());
+ bool bRootEntry = rBasicBox.FindRootEntry(rDocument, eLocation, *xIter);
+ if (bRootEntry)
+ {
+ if (!rBasicBox.get_row_expanded(*xIter))
+ rBasicBox.expand_row(*xIter);
+ bool bLibEntry = rBasicBox.FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter);
+ DBG_ASSERT( bLibEntry, "LibEntry not found!" );
+ if (bLibEntry)
+ {
+ if (!rBasicBox.get_row_expanded(*xIter))
+ rBasicBox.expand_row(*xIter);
+ std::unique_ptr<weld::TreeIter> xSubRootEntry(rBasicBox.make_iterator(xIter.get()));
+ if (pBasic && rDocument.isInVBAMode())
+ {
+ // add the new module in the "Modules" entry
+ std::unique_ptr<weld::TreeIter> xLibSubEntry(rBasicBox.make_iterator(xIter.get()));
+ bool bLibSubEntry = rBasicBox.FindEntry(IDEResId(RID_STR_NORMAL_MODULES) , OBJ_TYPE_NORMAL_MODULES, *xLibSubEntry);
+ if (bLibSubEntry)
+ {
+ if (!rBasicBox.get_row_expanded(*xLibSubEntry))
+ rBasicBox.expand_row(*xLibSubEntry);
+ rBasicBox.copy_iterator(*xLibSubEntry, *xSubRootEntry);
+ }
+ }
+
+ std::unique_ptr<weld::TreeIter> xEntry(rBasicBox.make_iterator(xSubRootEntry.get()));
+ bool bEntry = rBasicBox.FindEntry(aModName, OBJ_TYPE_MODULE, *xEntry);
+ if (!bEntry)
+ {
+ rBasicBox.AddEntry(aModName, RID_BMP_MODULE, xEntry.get(), false,
+ o3tl::make_unique<Entry>(OBJ_TYPE_MODULE));
+ }
+ rBasicBox.set_cursor(*xEntry);
+ rBasicBox.select(*xEntry);
+ }
+ }
+ }
+ catch (const container::ElementExistException& )
+ {
+ std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
+ xError->run();
+ }
+ catch (const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+ }
+ return pModule;
+}
+
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx
index cbd8b5c171f5..3da0ff1a9d2e 100644
--- a/basctl/source/basicide/moduldlg.hxx
+++ b/basctl/source/basicide/moduldlg.hxx
@@ -250,9 +250,13 @@ public:
// Helper functions
SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
+ SbTreeListBox& rBasicBox, const OUString& rLibName, const OUString& aModName, bool bMain);
+SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
TreeListBox& rBasicBox, const OUString& rLibName, const OUString& aModName, bool bMain);
void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
CheckBox* pLibBox, TreeListBox* pBasicBox);
+void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
+ CheckBox* pLibBox, SbTreeListBox* pBasicBox);
} // namespace basctl
diff --git a/basctl/source/inc/basobj.hxx b/basctl/source/inc/basobj.hxx
index 7b84c2f02f27..acdb1f04032d 100644
--- a/basctl/source/inc/basobj.hxx
+++ b/basctl/source/inc/basobj.hxx
@@ -30,7 +30,7 @@ class StarBASIC;
class SfxUInt16Item;
class SfxBindings;
class SfxDispatcher;
-namespace weld { class Widget; }
+namespace weld { class Widget; class Window; }
namespace basctl
{
@@ -73,12 +73,11 @@ namespace basctl
// new methods for macros
- OUString ChooseMacro(
+ OUString ChooseMacro(weld::Window* pParent,
const css::uno::Reference< css::frame::XModel >& rxLimitToDocument, const css::uno::Reference< css::frame::XFrame >& xDocFrame,
bool bChooseOnly );
- inline OUString ChooseMacro(
- const css::uno::Reference< css::frame::XModel >& rxLimitToDocument )
- { return ChooseMacro(rxLimitToDocument, css::uno::Reference< css::frame::XFrame >(), false/*bChooseOnly*/); }
+ inline OUString ChooseMacro(weld::Window* pParent, const css::uno::Reference<css::frame::XModel>& rLimitToDocument)
+ { return ChooseMacro(pParent, rLimitToDocument, css::uno::Reference< css::frame::XFrame >(), false/*bChooseOnly*/); }
/// @throws css::container::NoSuchElementException
/// @throws css::uno::RuntimeException
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 5dccdb17bb09..7115e6f2f589 100644
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -27,6 +27,7 @@
#include "doceventnotifier.hxx"
#include <vcl/treelistbox.hxx>
+#include <vcl/weld.hxx>
#include <basic/sbstar.hxx>
#include "sbxitem.hxx"
#include "basobj.hxx"
@@ -181,7 +182,7 @@ private:
BrowseMode nMode;
DocumentEventNotifier m_aNotifier;
void SetEntryBitmaps( SvTreeListEntry * pEntry, const Image& rImage );
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
+ virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
protected:
virtual void RequestingChildren( SvTreeListEntry* pParent ) override;
@@ -251,6 +252,93 @@ private:
LibraryType GetLibraryType() const;
};
+class SbTreeListBox : public DocumentEventListener
+{
+private:
+ std::unique_ptr<weld::TreeView> m_xControl;
+ std::unique_ptr<weld::TreeIter> m_xIter;
+ weld::Window* m_pTopLevel;
+ BrowseMode nMode;
+ DocumentEventNotifier m_aNotifier;
+ void SetEntryBitmaps(weld::TreeIter& rIter, const OUString& rImage);
+
+protected:
+ DECL_LINK(RequestingChildrenHdl, weld::TreeIter&, bool);
+ DECL_LINK(OpenCurrentHdl, weld::TreeView&, void);
+ void ImpCreateLibEntries(weld::TreeIter& rShellRootEntry, const ScriptDocument& rDocument, LibraryLocation eLocation);
+ void ImpCreateLibSubEntries(weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName);
+ void ImpCreateLibSubEntriesInVBAMode(weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName );
+ void ImpCreateLibSubSubEntriesInVBAMode(weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName);
+ bool ImpFindEntry(weld::TreeIter& rIter, 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:
+ SbTreeListBox(std::unique_ptr<weld::TreeView> xControl, weld::Window* pTopLevel);
+ virtual ~SbTreeListBox() override;
+
+ void ScanEntry( const ScriptDocument& rDocument, LibraryLocation eLocation );
+ void ScanAllEntries();
+ void UpdateEntries();
+
+ bool IsEntryProtected(weld::TreeIter* pEntry);
+
+ void SetMode( BrowseMode nM ) { nMode = nM; }
+ BrowseMode GetMode() const { return nMode; }
+
+ SbModule* FindModule(weld::TreeIter* pEntry);
+ SbxVariable* FindVariable(weld::TreeIter* pEntry);
+ bool FindRootEntry(const ScriptDocument& rDocument, LibraryLocation eLocation, weld::TreeIter& rIter);
+ bool FindEntry(const OUString& rText, EntryType eType, weld::TreeIter& rIter);
+ EntryDescriptor GetEntryDescriptor(weld::TreeIter* pEntry);
+
+ static ItemType ConvertType (EntryType eType);
+ bool IsValidEntry(weld::TreeIter& rEntry);
+ void AddEntry(const OUString& rText, const OUString& rImage,
+ weld::TreeIter* pIter, bool bChildrenOnDemand, std::unique_ptr<Entry>&& rUserData);
+
+ void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); }
+ std::unique_ptr<weld::TreeIter> make_iterator(weld::TreeIter* pIter = nullptr) const { return m_xControl->make_iterator(pIter); }
+ void copy_iterator(const weld::TreeIter& rSource, weld::TreeIter& rDest) const { m_xControl->copy_iterator(rSource, rDest); }
+ bool get_selected(weld::TreeIter* pIter) const { return m_xControl->get_selected(pIter); }
+ void select(const weld::TreeIter& rIter) { m_xControl->select(rIter); }
+ bool get_cursor(weld::TreeIter* pIter) const { return m_xControl->get_cursor(pIter); }
+ void set_cursor(const weld::TreeIter& rIter) { m_xControl->set_cursor(rIter); }
+ bool get_iter_first(weld::TreeIter& rIter) const { return m_xControl->get_iter_first(rIter); }
+ bool iter_next_sibling(weld::TreeIter& rIter) const { return m_xControl->iter_next_sibling(rIter); }
+ bool iter_children(weld::TreeIter& rIter) const { return m_xControl->iter_children(rIter); }
+ bool iter_parent(weld::TreeIter& rIter) const { return m_xControl->iter_parent(rIter); }
+ int get_iter_depth(const weld::TreeIter& rIter) const { return m_xControl->get_iter_depth(rIter); }
+ OUString get_text(const weld::TreeIter& rIter) const { return m_xControl->get_text(rIter); }
+ bool get_row_expanded(const weld::TreeIter& rIter) const { return m_xControl->get_row_expanded(rIter); }
+ void expand_row(weld::TreeIter& rIter) { m_xControl->expand_row(rIter); }
+ void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); }
+ float get_approximate_digit_width() const { return m_xControl->get_approximate_digit_width(); }
+ int get_height_rows(int nRows) const { return m_xControl->get_height_rows(nRows); }
+
+ void RemoveEntry(const weld::TreeIter& rIter);
+ void RemoveEntry(const ScriptDocument&);
+
+ OUString GetRootEntryName(const ScriptDocument& rDocument, LibraryLocation eLocation) const;
+ static OUString GetRootEntryBitmaps(const ScriptDocument& rDocument);
+
+ void SetCurrentEntry (EntryDescriptor const &);
+
+ weld::TreeView& get_widget() { return *m_xControl; }
+
+private:
+ LibraryType GetLibraryType() const;
+};
+
} // namespace basctl
#endif // INCLUDED_BASCTL_SOURCE_INC_BASTYPE2_HXX
diff --git a/basctl/uiconfig/basicide/ui/basicmacrodialog.ui b/basctl/uiconfig/basicide/ui/basicmacrodialog.ui
index fb5331c8e3d9..9548679d2c47 100644
--- a/basctl/uiconfig/basicide/ui/basicmacrodialog.ui
+++ b/basctl/uiconfig/basicide/ui/basicmacrodialog.ui
@@ -1,13 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="basctl">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name image -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name surface -->
+ <column type="CairoSurface"/>
+ <!-- column-name expander -->
+ <column type="GdkPixbuf"/>
+ </columns>
+ </object>
+ <object class="GtkTreeStore" id="liststore2">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name image -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name surface -->
+ <column type="CairoSurface"/>
+ <!-- column-name expander -->
+ <column type="GdkPixbuf"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="BasicMacroDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="basicmacrodialog|BasicMacroDialog">%PRODUCTNAME Basic Macros</property>
+ <property name="modal">True</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -21,13 +52,14 @@
<property name="homogeneous">True</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="run">
+ <object class="GtkButton" id="ok">
<property name="label" translatable="yes" context="basicmacrodialog|run">Run</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -46,7 +78,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">7</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -101,16 +133,37 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="vcllo-SvTreeListBox" id="macros:border">
- <property name="width_request">280</property>
- <property name="height_request">300</property>
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="Tree List-selection1"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="macros">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore2</property>
+ <property name="headers_visible">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Tree List-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -149,17 +202,45 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="basctllo-TreeListBox" id="libraries:border">
- <property name="width_request">280</property>
- <property name="height_request">300</property>
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="opacity">0.91000000000000003</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="libraries">
+ <property name="width_request">-1</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="search_column">0</property>
+ <property name="enable_tree_lines">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
+ <attributes>
+ <attribute name="pixbuf">4</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
</child>
@@ -221,7 +302,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="vexpand">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
@@ -229,7 +309,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
- <property name="vexpand">True</property>
</object>
</child>
</object>
@@ -257,6 +336,7 @@
<property name="resize_mode">immediate</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
+ <property name="homogeneous">True</property>
<property name="layout_style">start</property>
<child>
<object class="GtkButton" id="assign">
@@ -264,6 +344,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -277,6 +358,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -286,11 +368,11 @@
</child>
<child>
<object class="GtkButton" id="delete">
- <property name="label">gtk-delete</property>
+ <property name="label">_Delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="use_stock">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -299,16 +381,31 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="new">
+ <property name="label">_New</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkButton" id="organize">
<property name="label" translatable="yes" context="basicmacrodialog|organize">Organizer...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -317,11 +414,12 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -330,11 +428,12 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">5</property>
+ <property name="position">6</property>
</packing>
</child>
</object>
@@ -366,7 +465,7 @@
</object>
</child>
<action-widgets>
- <action-widget response="0">run</action-widget>
+ <action-widget response="-5">ok</action-widget>
<action-widget response="-7">close</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
diff --git a/basctl/uiconfig/basicide/ui/managebreakpoints.ui b/basctl/uiconfig/basicide/ui/managebreakpoints.ui
index 1f8246616693..66cbb93aeb05 100644
--- a/basctl/uiconfig/basicide/ui/managebreakpoints.ui
+++ b/basctl/uiconfig/basicide/ui/managebreakpoints.ui
@@ -2,7 +2,7 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="basctl">
<requires lib="gtk+" version="3.18"/>
- <object class="GtkListStore" id="liststore1">
+ <object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name text -->
<column type="gchararray"/>
@@ -182,6 +182,7 @@
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
diff --git a/basctl/uiconfig/basicide/ui/managelanguages.ui b/basctl/uiconfig/basicide/ui/managelanguages.ui
index 510fcab621b6..eac660761fda 100644
--- a/basctl/uiconfig/basicide/ui/managelanguages.ui
+++ b/basctl/uiconfig/basicide/ui/managelanguages.ui
@@ -158,6 +158,7 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>