basctl/source/basicide/basides1.cxx            |    4 
 basctl/source/basicide/basobj2.cxx             |   12 
 basctl/source/basicide/macrodlg.cxx            |   30 
 basctl/source/basicide/macrodlg.hxx            |    2 
 basctl/source/basicide/moduldl2.cxx            |  724 +++++-------------
 basctl/source/basicide/moduldlg.cxx            |  995 ++++++++++---------------
 basctl/source/basicide/moduldlg.hxx            |  161 +---
 basctl/source/inc/basobj.hxx                   |    2 
 basctl/source/inc/bastype2.hxx                 |   14 
 basctl/uiconfig/basicide/ui/dialogpage.ui      |   59 +
 basctl/uiconfig/basicide/ui/libpage.ui         |   69 +
 basctl/uiconfig/basicide/ui/modulepage.ui      |   59 +
 basctl/uiconfig/basicide/ui/organizedialog.ui  |   80 +-
 compilerplugins/clang/unusedmethods.results    |    2 
 cui/source/dialogs/screenshotannotationdlg.cxx |    2 
 cui/source/inc/screenshotannotationdlg.hxx     |    4 
 extras/source/glade/libreoffice-catalog.xml.in |    6 
 include/sfx2/app.hxx                           |    2 
 include/vcl/weld.hxx                           |   21 
 sfx2/source/appl/app.cxx                       |   10 
 sfx2/source/appl/appserv.cxx                   |    2 
 solenv/clang-format/blacklist                  |    2 
 toolkit/source/awt/vclxtoolkit.cxx             |    2 
 vcl/inc/treeglue.hxx                           |   20 
 vcl/source/app/salvtables.cxx                  |   27 
 vcl/source/window/tabdlg.cxx                   |    2 
 vcl/unx/gtk3/gtk3gtkinst.cxx                   |   75 +
 27 files changed, 1152 insertions(+), 1236 deletions(-)

New commits:
commit 415dfaed9fe782e02e393ff6b0e79026f3ce0449
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Jun 7 15:42:52 2019 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jun 13 09:57:02 2019 +0200

    weld OrganizeDialog
    
    Change-Id: I976edb0b49c8439d1723be4544b10a5375b8e1d3
    Reviewed-on: https://gerrit.libreoffice.org/73900
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/basctl/source/basicide/basides1.cxx 
b/basctl/source/basicide/basides1.cxx
index 5fac7468fe41..c04f0c346893 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -328,10 +328,10 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
             if ( rReq.GetArgs() )
             {
                 const SfxUInt16Item &rTabId = 
rReq.GetArgs()->Get(SID_BASICIDE_ARG_TABID );
-                Organize( rTabId.GetValue() );
+                Organize(rReq.GetFrameWeld(), rTabId.GetValue());
             }
             else
-                Organize( 0 );
+                Organize(rReq.GetFrameWeld(), 0);
         }
         break;
         case SID_BASICIDE_CHOOSEMACRO:
diff --git a/basctl/source/basicide/basobj2.cxx 
b/basctl/source/basicide/basobj2.cxx
index de273c0810cd..694277c394e8 100644
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -55,14 +55,14 @@ extern "C" {
 
         return pScriptURL;
     }
-    SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer( sal_Int16 nTabId )
+    SAL_DLLPUBLIC_EXPORT void basicide_macro_organizer(void *pParent, 
sal_Int16 nTabId)
     {
         SAL_INFO("basctl.basicide","in basicide_macro_organizer");
-        basctl::Organize( nTabId );
+        basctl::Organize(static_cast<weld::Window*>(pParent), nTabId);
     }
 }
 
-void Organize( sal_Int16 tabId )
+void Organize(weld::Window* pParent, sal_Int16 tabId)
 {
     EnsureIde();
 
@@ -71,8 +71,8 @@ void Organize( sal_Int16 tabId )
         if (BaseWindow* pCurWin = pShell->GetCurWindow())
             aDesc = pCurWin->CreateEntryDescriptor();
 
-    vcl::Window* pParent = Application::GetDefDialogParent();
-    VclPtr<OrganizeDialog>::Create(pParent, tabId, 
aDesc)->StartExecuteAsync(nullptr);
+    auto xDlg(std::make_shared<OrganizeDialog>(pParent, tabId, aDesc));
+    weld::DialogController::runAsync(xDlg, [](int) {});
 }
 
 bool IsValidSbxName( const OUString& rName )
@@ -247,7 +247,7 @@ OUString ChooseMacro(weld::Window* pParent,
     OUString aScriptURL;
     SbMethod* pMethod = nullptr;
 
-    MacroChooser aChooser(pParent, xDocFrame);
+    MacroChooser aChooser(pParent, xDocFrame, true);
     if ( bChooseOnly || !SvtModuleOptions::IsBasicIDE() )
         aChooser.SetMode(MacroChooser::ChooseOnly);
 
diff --git a/basctl/source/basicide/macrodlg.cxx 
b/basctl/source/basicide/macrodlg.cxx
index 252328fb07eb..279aa235ed5e 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -50,7 +50,7 @@ using std::map;
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
-MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< 
frame::XFrame >& xDocFrame)
+MacroChooser::MacroChooser(weld::Window* pParnt, const Reference< 
frame::XFrame >& xDocFrame, bool bCreateEntries)
     : SfxDialogController(pParnt, "modules/BasicIDE/ui/basicmacrodialog.ui", 
"BasicMacroDialog")
     , m_xDocumentFrame(xDocFrame)
     // the Sfx doesn't ask the BasicManager whether modified or not
@@ -107,7 +107,8 @@ MacroChooser::MacroChooser(weld::Window* pParnt, const 
Reference< frame::XFrame
     if (SfxDispatcher* pDispatcher = GetDispatcher())
         pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
 
-    m_xBasicBox->ScanAllEntries();
+    if (bCreateEntries)
+        m_xBasicBox->ScanAllEntries();
 }
 
 MacroChooser::~MacroChooser()
@@ -742,24 +743,23 @@ IMPL_LINK(MacroChooser, ButtonHdl, weld::Button&, 
rButton, void)
 
         m_xBasicBox->get_selected(m_xBasicBoxIter.get());
         EntryDescriptor aDesc = 
m_xBasicBox->GetEntryDescriptor(m_xBasicBoxIter.get());
-        VclPtrInstance< OrganizeDialog > pDlg( nullptr, 0, aDesc ); //TODO
-        pDlg->StartExecuteAsync([this](sal_Int32 nRet){
-                if ( nRet ) // not only closed
-                {
-                    m_xDialog->response(Macro_Edit);
-                    return;
-                }
+        auto xDlg(std::make_shared<OrganizeDialog>(m_xDialog.get(), 0, aDesc));
+        weld::DialogController::runAsync(xDlg, [this](sal_Int32 nRet) {
+            if (nRet == RET_OK) // not only closed
+            {
+                m_xDialog->response(Macro_Edit);
+                return;
+            }
 
-                Shell* pShell = GetShell();
-                if ( pShell && pShell->IsAppBasicModified() )
-                    bForceStoreBasic = true;
+            Shell* pShell = GetShell();
+            if ( pShell && pShell->IsAppBasicModified() )
+                bForceStoreBasic = true;
 
-                m_xBasicBox->UpdateEntries();
-            });
+            m_xBasicBox->UpdateEntries();
+        });
     }
 }
 
-
 void MacroChooser::UpdateFields()
 {
     auto nMacroEntry = m_xMacroBox->get_selected_index();
diff --git a/basctl/source/basicide/macrodlg.hxx 
b/basctl/source/basicide/macrodlg.hxx
index 9ab71acc13fa..ceacc143c890 100644
--- a/basctl/source/basicide/macrodlg.hxx
+++ b/basctl/source/basicide/macrodlg.hxx
@@ -89,7 +89,7 @@ private:
     std::unique_ptr<weld::Button> m_xNewLibButton;
     std::unique_ptr<weld::Button> m_xNewModButton;
 public:
-    MacroChooser(weld::Window *pParent, const ::css::uno::Reference< 
::css::frame::XFrame >& xDocFrame);
+    MacroChooser(weld::Window *pParent, const ::css::uno::Reference< 
::css::frame::XFrame >& xDocFrame, bool bCreateEntries);
     virtual ~MacroChooser() override;
 
     SbMethod*           GetMacro();
diff --git a/basctl/source/basicide/moduldl2.cxx 
b/basctl/source/basicide/moduldl2.cxx
index 7352953b1ee0..00cfe90f3fb1 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -97,172 +97,165 @@ public:
     }
 };
 
-// LibUserData
-class LibUserData final
-{
-private:
-    ScriptDocument m_aDocument;
+} // namespace
 
-public:
-    explicit LibUserData(ScriptDocument const& rDocument)
-        : m_aDocument(rDocument)
+namespace
+{
+    int FindEntry(weld::TreeView& rBox, const OUString& rName)
     {
+        int nCount = rBox.n_children();
+        for (int i = 0; i < nCount; ++i)
+        {
+            if (rName.equalsIgnoreAsciiCase(rBox.get_text(i, 0)))
+                return i;
+        }
+        return -1;
     }
+}
 
-    const ScriptDocument& GetDocument() const { return m_aDocument; }
-};
-
-//  LibLBoxString
-class LibLBoxString : public SvLBoxString
+// NewObjectDialog
+IMPL_LINK_NOARG(NewObjectDialog, OkButtonHandler, weld::Button&, void)
 {
-public:
-    explicit LibLBoxString(const OUString& rTxt)
-        : SvLBoxString(rTxt)
+    if (!m_bCheckName || IsValidSbxName(m_xEdit->get_text()))
+        m_xDialog->response(RET_OK);
+    else
     {
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
+                                                       
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
+        xErrorBox->run();
+        m_xEdit->grab_focus();
     }
+}
 
-    virtual void Paint(const Point& rPos, SvTreeListBox& rDev, 
vcl::RenderContext& rRenderContext,
-                       const SvViewDataEntry* pView, const SvTreeListEntry& 
rEntry) override;
-};
-
-void LibLBoxString::Paint(const Point& rPos, SvTreeListBox& /*rDev*/, 
vcl::RenderContext& rRenderContext,
-                          const SvViewDataEntry* /*pView*/, const 
SvTreeListEntry& rEntry)
+NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, 
bool bCheckName)
+    : GenericDialogController(pParent, "modules/BasicIDE/ui/newlibdialog.ui", 
"NewLibDialog")
+    , m_xEdit(m_xBuilder->weld_entry("entry"))
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
+    , m_bCheckName(bCheckName)
 {
-    // Change text color if library is read only:
-    bool bReadOnly = false;
-    if (rEntry.GetUserData())
+    switch (eMode)
     {
-        ScriptDocument 
aDocument(static_cast<LibUserData*>(rEntry.GetUserData())->GetDocument());
-
-        OUString aLibName = static_cast<const 
SvLBoxString&>(rEntry.GetItem(1)).GetText();
-        Reference<script::XLibraryContainer2> 
xModLibContainer(aDocument.getLibraryContainer(E_SCRIPTS), UNO_QUERY);
-        Reference<script::XLibraryContainer2 > 
xDlgLibContainer(aDocument.getLibraryContainer(E_DIALOGS), UNO_QUERY);
-        bReadOnly = (xModLibContainer.is() && 
xModLibContainer->hasByName(aLibName) && 
xModLibContainer->isLibraryReadOnly(aLibName))
-                 || (xDlgLibContainer.is() && 
xDlgLibContainer->hasByName(aLibName) && 
xDlgLibContainer->isLibraryReadOnly(aLibName));
+        case ObjectMode::Library:
+            m_xDialog->set_title(IDEResId(RID_STR_NEWLIB));
+            break;
+        case ObjectMode::Module:
+            m_xDialog->set_title(IDEResId(RID_STR_NEWMOD));
+            break;
+        case ObjectMode::Dialog:
+            m_xDialog->set_title(IDEResId(RID_STR_NEWDLG));
+            break;
+        default:
+            assert(false);
     }
-    if (bReadOnly)
-        rRenderContext.DrawCtrlText(rPos, GetText(), 0, -1, 
DrawTextFlags::Disable);
-    else
-        rRenderContext.DrawText(rPos, GetText());
+    m_xOKButton->connect_clicked(LINK(this, NewObjectDialog, OkButtonHandler));
 }
 
-} // namespace
-
-//  basctl::CheckBox
-CheckBox::CheckBox(vcl::Window* pParent, WinBits nStyle)
-    : SvTabListBox(pParent, nStyle)
-    , eMode(ObjectMode::Module)
-    , m_aDocument(ScriptDocument::getApplicationScriptDocument())
+// GotoLineDialog
+GotoLineDialog::GotoLineDialog(weld::Window* pParent )
+    : GenericDialogController(pParent, 
"modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
+    , m_xEdit(m_xBuilder->weld_entry("entry"))
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
 {
-    long const aTabPositions[] = { 12 };  // TabPos needs at least one...
-                                          // 12 because of the CheckBox
-    SetTabs( SAL_N_ELEMENTS(aTabPositions), aTabPositions );
-    Init();
+    m_xEdit->grab_focus();
+    m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
 }
 
-VCL_BUILDER_FACTORY_CONSTRUCTOR(CheckBox, WB_TABSTOP)
-
-CheckBox::~CheckBox()
+GotoLineDialog::~GotoLineDialog()
 {
-    disposeOnce();
 }
 
-void CheckBox::dispose()
+sal_Int32 GotoLineDialog::GetLineNumber() const
 {
-    pCheckButton.reset();
-
-    // delete user data
-    SvTreeListEntry* pEntry = First();
-    while ( pEntry )
-    {
-        delete static_cast<LibUserData*>( pEntry->GetUserData() );
-        pEntry->SetUserData( nullptr );
-        pEntry = Next( pEntry );
-    }
-    SvTabListBox::dispose();
+    return m_xEdit->get_text().toInt32();
 }
 
-void CheckBox::Init()
+IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
 {
-    pCheckButton.reset(new SvLBoxButtonData(this));
-
-    if (eMode == ObjectMode::Library)
-        EnableCheckButton( pCheckButton.get() );
+    if (GetLineNumber())
+        m_xDialog->response(RET_OK);
     else
-        EnableCheckButton( nullptr );
-
-    SetHighlightRange();
+        m_xEdit->select_region(0, -1);
 }
 
-void CheckBox::SetMode (ObjectMode e)
+// ExportDialog
+IMPL_LINK_NOARG(ExportDialog, OkButtonHandler, weld::Button&, void)
 {
-    eMode = e;
-
-    if (eMode == ObjectMode::Library)
-        EnableCheckButton( pCheckButton.get() );
-    else
-        EnableCheckButton( nullptr );
+    m_bExportAsPackage = m_xExportAsPackageButton->get_active();
+    m_xDialog->response(RET_OK);
 }
 
-SvTreeListEntry* CheckBox::DoInsertEntry( const OUString& rStr, sal_uLong nPos 
)
+ExportDialog::ExportDialog(weld::Window * pParent)
+    : GenericDialogController(pParent, "modules/BasicIDE/ui/exportdialog.ui", 
"ExportDialog")
+    , m_bExportAsPackage(false)
+    , m_xExportAsPackageButton(m_xBuilder->weld_radio_button("extension"))
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
 {
-    return SvTabListBox::InsertEntryToColumn( rStr, nPos, 0 );
+    m_xExportAsPackageButton->set_active(true);
+    m_xOKButton->connect_clicked(LINK(this, ExportDialog, OkButtonHandler));
 }
 
-SvTreeListEntry* CheckBox::FindEntry( const OUString& rName )
+ExportDialog::~ExportDialog()
 {
-    sal_uLong nCount = GetEntryCount();
-    for ( sal_uLong i = 0; i < nCount; i++ )
-    {
-        SvTreeListEntry* pEntry = GetEntry( i );
-        DBG_ASSERT( pEntry, "pEntry?!" );
-        if ( rName.equalsIgnoreAsciiCase( GetEntryText( pEntry, 0 ) ) )
-            return pEntry;
-    }
-    return nullptr;
 }
 
-void CheckBox::InitEntry(SvTreeListEntry* pEntry, const OUString& rTxt,
-    const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind )
+// LibPage
+LibPage::LibPage(weld::Container* pParent, OrganizeDialog* pDialog)
+    : OrganizePage(pParent, "modules/BasicIDE/ui/libpage.ui", "LibPage", 
pDialog)
+    , m_xBasicsBox(m_xBuilder->weld_combo_box("location"))
+    , m_xLibBox(m_xBuilder->weld_tree_view("library"))
+    , m_xEditButton(m_xBuilder->weld_button("edit"))
+    , m_xPasswordButton(m_xBuilder->weld_button("password"))
+    , m_xNewLibButton(m_xBuilder->weld_button("new"))
+    , m_xInsertLibButton(m_xBuilder->weld_button("import"))
+    , m_xExportButton(m_xBuilder->weld_button("export"))
+    , m_xDelButton(m_xBuilder->weld_button("delete"))
+    , m_aCurDocument(ScriptDocument::getApplicationScriptDocument())
+    , m_eCurLocation(LIBRARY_LOCATION_UNKNOWN)
 {
-    SvTabListBox::InitEntry(pEntry, rTxt, rImg1, rImg2, eButtonKind);
+    Size aSize(m_xLibBox->get_approximate_digit_width() * 40,
+               m_xLibBox->get_height_rows(10));
+    m_xLibBox->set_size_request(aSize.Width(), aSize.Height());
 
-    if (eMode == ObjectMode::Module)
-    {
-        // initialize all columns with own string class (column 0 == bitmap)
-        sal_uInt16 nCount = pEntry->ItemCount();
-        for ( sal_uInt16 nCol = 1; nCol < nCount; ++nCol )
-        {
-            SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( 
nCol ));
-            pEntry->ReplaceItem(std::make_unique<LibLBoxString>( 
rCol.GetText() ), nCol);
-        }
-    }
-}
+    m_xEditButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xNewLibButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xPasswordButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xExportButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xInsertLibButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xDelButton->connect_clicked( LINK( this, LibPage, ButtonHdl ) );
+    m_xLibBox->connect_changed( LINK( this, LibPage, TreeListHighlightHdl ) );
 
-bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
-{
-    if (eMode != ObjectMode::Module)
-        return false;
+    m_xBasicsBox->connect_changed( LINK( this, LibPage, BasicSelectHdl ) );
+
+    m_xLibBox->connect_editing_started( LINK( this, LibPage, EditingEntryHdl ) 
);
+    m_xLibBox->connect_editing_done( LINK( this, LibPage, EditedEntryHdl ) );
+
+    FillListBox();
+    m_xBasicsBox->set_active(0);
+    SetCurLib();
 
-    DBG_ASSERT( pEntry, "No entry?" );
+    CheckButtons();
+}
 
+IMPL_LINK(LibPage, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
+{
     // check, if Standard library
-    OUString aLibName = GetEntryText( pEntry, 0 );
+    OUString aLibName = m_xLibBox->get_text(rIter, 0);
+
     if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) )
     {
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                        
VclMessageType::Warning, VclButtonsType::Ok, 
IDEResId(RID_STR_CANNOTCHANGENAMESTDLIB)));
         xErrorBox->run();
         return false;
     }
 
     // check, if library is readonly
-    Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
-    Reference< script::XLibraryContainer2 > xDlgLibContainer( 
m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+    Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+    Reference< script::XLibraryContainer2 > xDlgLibContainer( 
m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
     if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && 
xModLibContainer->isLibraryReadOnly( aLibName ) && 
!xModLibContainer->isLibraryLink( aLibName ) ) ||
          ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && 
xDlgLibContainer->isLibraryReadOnly( aLibName ) && 
!xDlgLibContainer->isLibraryLink( aLibName ) ) )
     {
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                        
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_LIBISREADONLY)));
         xErrorBox->run();
         return false;
@@ -289,23 +282,27 @@ bool CheckBox::EditingEntry( SvTreeListEntry* pEntry, 
Selection& )
     return true;
 }
 
-bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewName )
+IMPL_LINK(LibPage, EditedEntryHdl, const IterString&, rIterString, bool)
 {
-    bool bValid = rNewName.getLength() <= 30 && IsValidSbxName(rNewName);
-    OUString aOldName( GetEntryText( pEntry, 0 ) );
-    if ( bValid && ( aOldName != rNewName ) )
+    const weld::TreeIter& rIter = rIterString.first;
+    OUString sNewName = rIterString.second;
+
+    bool bValid = sNewName.getLength() <= 30 && IsValidSbxName(sNewName);
+    OUString aOldName(m_xLibBox->get_text(rIter, 0));
+
+    if (bValid && aOldName != sNewName)
     {
         try
         {
-            Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+            Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
             if ( xModLibContainer.is() )
-                xModLibContainer->renameLibrary( aOldName, rNewName );
+                xModLibContainer->renameLibrary( aOldName, sNewName );
 
-            Reference< script::XLibraryContainer2 > xDlgLibContainer( 
m_aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+            Reference< script::XLibraryContainer2 > xDlgLibContainer( 
m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
             if ( xDlgLibContainer.is() )
-                xDlgLibContainer->renameLibrary( aOldName, rNewName );
+                xDlgLibContainer->renameLibrary( aOldName, sNewName );
 
-            MarkDocumentModified( m_aDocument );
+            MarkDocumentModified( m_aCurDocument );
             if (SfxBindings* pBindings = GetBindingsPtr())
             {
                 pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
@@ -314,7 +311,7 @@ bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const 
OUString& rNewName )
         }
         catch (const container::ElementExistException& )
         {
-            std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+            std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                            
VclMessageType::Warning, VclButtonsType::Ok, 
IDEResId(RID_STR_SBXNAMEALLREADYUSED)));
             xErrorBox->run();
             return false;
@@ -328,8 +325,8 @@ bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, const 
OUString& rNewName )
 
     if ( !bValid )
     {
-        OUString sWarning(rNewName.getLength() > 30 ? 
IDEResId(RID_STR_LIBNAMETOLONG) : IDEResId(RID_STR_BADSBXNAME));
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+        OUString sWarning(sNewName.getLength() > 30 ? 
IDEResId(RID_STR_LIBNAMETOLONG) : IDEResId(RID_STR_BADSBXNAME));
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                        
VclMessageType::Warning, VclButtonsType::Ok, sWarning));
         xErrorBox->run();
 
@@ -338,211 +335,66 @@ bool CheckBox::EditedEntry( SvTreeListEntry* pEntry, 
const OUString& rNewName )
     return bValid;
 }
 
-// NewObjectDialog
-IMPL_LINK_NOARG(NewObjectDialog, OkButtonHandler, weld::Button&, void)
-{
-    if (!m_bCheckName || IsValidSbxName(m_xEdit->get_text()))
-        m_xDialog->response(RET_OK);
-    else
-    {
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
-                                                       
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
-        xErrorBox->run();
-        m_xEdit->grab_focus();
-    }
-}
-
-NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, 
bool bCheckName)
-    : GenericDialogController(pParent, "modules/BasicIDE/ui/newlibdialog.ui", 
"NewLibDialog")
-    , m_xEdit(m_xBuilder->weld_entry("entry"))
-    , m_xOKButton(m_xBuilder->weld_button("ok"))
-    , m_bCheckName(bCheckName)
-{
-    switch (eMode)
-    {
-        case ObjectMode::Library:
-            m_xDialog->set_title(IDEResId(RID_STR_NEWLIB));
-            break;
-        case ObjectMode::Module:
-            m_xDialog->set_title(IDEResId(RID_STR_NEWMOD));
-            break;
-        case ObjectMode::Dialog:
-            m_xDialog->set_title(IDEResId(RID_STR_NEWDLG));
-            break;
-        default:
-            assert(false);
-    }
-    m_xOKButton->connect_clicked(LINK(this, NewObjectDialog, OkButtonHandler));
-}
-
-// GotoLineDialog
-GotoLineDialog::GotoLineDialog(weld::Window* pParent )
-    : GenericDialogController(pParent, 
"modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
-    , m_xEdit(m_xBuilder->weld_entry("entry"))
-    , m_xOKButton(m_xBuilder->weld_button("ok"))
-{
-    m_xEdit->grab_focus();
-    m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
-}
-
-GotoLineDialog::~GotoLineDialog()
-{
-}
-
-sal_Int32 GotoLineDialog::GetLineNumber() const
-{
-    return m_xEdit->get_text().toInt32();
-}
-
-IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
-{
-    if (GetLineNumber())
-        m_xDialog->response(RET_OK);
-    else
-        m_xEdit->select_region(0, -1);
-}
-
-// ExportDialog
-IMPL_LINK_NOARG(ExportDialog, OkButtonHandler, weld::Button&, void)
-{
-    m_bExportAsPackage = m_xExportAsPackageButton->get_active();
-    m_xDialog->response(RET_OK);
-}
-
-ExportDialog::ExportDialog(weld::Window * pParent)
-    : GenericDialogController(pParent, "modules/BasicIDE/ui/exportdialog.ui", 
"ExportDialog")
-    , m_bExportAsPackage(false)
-    , m_xExportAsPackageButton(m_xBuilder->weld_radio_button("extension"))
-    , m_xOKButton(m_xBuilder->weld_button("ok"))
-{
-    m_xExportAsPackageButton->set_active(true);
-    m_xOKButton->connect_clicked(LINK(this, ExportDialog, OkButtonHandler));
-}
-
-ExportDialog::~ExportDialog()
-{
-}
-
-// LibPage
-LibPage::LibPage(vcl::Window * pParent)
-    : TabPage(pParent, "LibPage",
-        "modules/BasicIDE/ui/libpage.ui")
-    , m_aCurDocument(ScriptDocument::getApplicationScriptDocument())
-    , m_eCurLocation(LIBRARY_LOCATION_UNKNOWN)
-{
-    get(m_pBasicsBox, "location");
-    get(m_pLibBox, "library");
-    Size aSize(m_pLibBox->LogicToPixel(Size(130, 87), 
MapMode(MapUnit::MapAppFont)));
-    m_pLibBox->set_height_request(aSize.Height());
-    m_pLibBox->set_width_request(aSize.Width());
-    get(m_pEditButton, "edit");
-    get(m_pPasswordButton, "password");
-    get(m_pNewLibButton, "new");
-    get(m_pInsertLibButton, "import");
-    get(m_pExportButton, "export");
-    get(m_pDelButton, "delete");
-
-    pTabDlg = nullptr;
-
-    m_pEditButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pNewLibButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pPasswordButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pExportButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pInsertLibButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pDelButton->SetClickHdl( LINK( this, LibPage, ButtonHdl ) );
-    m_pLibBox->SetSelectHdl( LINK( this, LibPage, TreeListHighlightHdl ) );
-
-    m_pBasicsBox->SetSelectHdl( LINK( this, LibPage, BasicSelectHdl ) );
-
-    m_pLibBox->SetMode(ObjectMode::Module);
-    m_pLibBox->EnableInplaceEditing(true);
-    m_pLibBox->SetStyle( WB_HSCROLL | WB_BORDER | WB_TABSTOP );
-
-    long const aTabPositions[] = { 30, 120 };
-    m_pLibBox->SetTabs( SAL_N_ELEMENTS(aTabPositions), aTabPositions, 
MapUnit::MapPixel );
-
-    FillListBox();
-    m_pBasicsBox->SelectEntryPos( 0 );
-    SetCurLib();
-
-    CheckButtons();
-}
-
 LibPage::~LibPage()
 {
-    disposeOnce();
-}
-
-void LibPage::dispose()
-{
-    if (m_pBasicsBox)
+    if (m_xBasicsBox)
     {
-        const sal_Int32 nCount = m_pBasicsBox->GetEntryCount();
-        for ( sal_Int32 i = 0; i < nCount; ++i )
+        const sal_Int32 nCount = m_xBasicsBox->get_count();
+        for (sal_Int32 i = 0; i < nCount; ++i)
         {
-            DocumentEntry* pEntry = 
static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( i ));
+            DocumentEntry* pEntry = 
reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_id(i).toInt64());
             delete pEntry;
         }
     }
-    m_pBasicsBox.clear();
-    m_pLibBox.clear();
-    m_pEditButton.clear();
-    m_pPasswordButton.clear();
-    m_pNewLibButton.clear();
-    m_pInsertLibButton.clear();
-    m_pExportButton.clear();
-    m_pDelButton.clear();
-    pTabDlg.clear();
-    TabPage::dispose();
 }
 
 void LibPage::CheckButtons()
 {
-    SvTreeListEntry* pCur = m_pLibBox->GetCurEntry();
-    if ( pCur )
+    std::unique_ptr<weld::TreeIter> xCur(m_xLibBox->make_iterator());
+    if (m_xLibBox->get_cursor(xCur.get()))
     {
-        OUString aLibName = SvTabListBox::GetEntryText( pCur, 0 );
+        OUString aLibName = m_xLibBox->get_text(*xCur, 0);
         Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
         Reference< script::XLibraryContainer2 > xDlgLibContainer( 
m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
 
         if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
         {
-            m_pPasswordButton->Disable();
-            m_pNewLibButton->Disable();
-            m_pInsertLibButton->Disable();
-            m_pDelButton->Disable();
+            m_xPasswordButton->set_sensitive(false);
+            m_xNewLibButton->set_sensitive(false);
+            m_xInsertLibButton->set_sensitive(false);
+            m_xDelButton->set_sensitive(false);
         }
         else if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) )
         {
-            m_pPasswordButton->Disable();
-            m_pNewLibButton->Enable();
-            m_pInsertLibButton->Enable();
-            m_pExportButton->Disable();
-            m_pDelButton->Disable();
+            m_xPasswordButton->set_sensitive(false);
+            m_xNewLibButton->set_sensitive(true);
+            m_xInsertLibButton->set_sensitive(true);
+            m_xExportButton->set_sensitive(false);
+            m_xDelButton->set_sensitive(false);
         }
         else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( 
aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
                   ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
         {
-            m_pPasswordButton->Disable();
-            m_pNewLibButton->Enable();
-            m_pInsertLibButton->Enable();
+            m_xPasswordButton->set_sensitive(false);
+            m_xNewLibButton->set_sensitive(true);
+            m_xInsertLibButton->set_sensitive(true);
             if ( ( xModLibContainer.is() && xModLibContainer->hasByName( 
aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && 
!xModLibContainer->isLibraryLink( aLibName ) ) ||
                  ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && 
!xDlgLibContainer->isLibraryLink( aLibName ) ) )
-                m_pDelButton->Disable();
+                m_xDelButton->set_sensitive(false);
             else
-                m_pDelButton->Enable();
+                m_xDelButton->set_sensitive(true);
         }
         else
         {
             if ( xModLibContainer.is() && !xModLibContainer->hasByName( 
aLibName ) )
-                m_pPasswordButton->Disable();
+                m_xPasswordButton->set_sensitive(false);
             else
-                m_pPasswordButton->Enable();
+                m_xPasswordButton->set_sensitive(true);
 
-            m_pNewLibButton->Enable();
-            m_pInsertLibButton->Enable();
-            m_pExportButton->Enable();
-            m_pDelButton->Enable();
+            m_xNewLibButton->set_sensitive(true);
+            m_xInsertLibButton->set_sensitive(true);
+            m_xExportButton->set_sensitive(true);
+            m_xDelButton->set_sensitive(true);
         }
     }
 }
@@ -552,34 +404,31 @@ void LibPage::ActivatePage()
     SetCurLib();
 }
 
-void LibPage::DeactivatePage()
+IMPL_LINK_NOARG(LibPage, TreeListHighlightHdl, weld::TreeView&, void)
 {
+    CheckButtons();
 }
 
-IMPL_LINK( LibPage, TreeListHighlightHdl, SvTreeListBox *, pBox, void )
-{
-    if ( pBox->IsSelected( pBox->GetHdlEntry() ) )
-        CheckButtons();
-}
-
-IMPL_LINK_NOARG( LibPage, BasicSelectHdl, ListBox&, void )
+IMPL_LINK_NOARG( LibPage, BasicSelectHdl, weld::ComboBox&, void )
 {
     SetCurLib();
     CheckButtons();
 }
 
-IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void )
+IMPL_LINK( LibPage, ButtonHdl, weld::Button&, rButton, void )
 {
-    if (pButton == m_pEditButton)
+    if (&rButton == m_xEditButton.get())
     {
         SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
         SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs 
);
         SfxGetpApp()->ExecuteSlot( aRequest );
 
         SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( 
m_aCurDocument.getDocumentOrNull() ) );
-        SvTreeListEntry* pCurEntry = m_pLibBox->GetCurEntry();
-        DBG_ASSERT( pCurEntry, "Entry?!" );
-        OUString aLibName( SvTabListBox::GetEntryText( pCurEntry, 0 ) );
+
+        std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
+        if (!m_xLibBox->get_cursor(xCurEntry.get()))
+            return;
+        OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
         SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
         if (SfxDispatcher* pDispatcher = GetDispatcher())
             pDispatcher->ExecuteList( SID_BASICIDE_LIBSELECTED,
@@ -587,18 +436,20 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void )
         EndTabDialog();
         return;
     }
-    else if (pButton == m_pNewLibButton)
+    else if (&rButton == m_xNewLibButton.get())
         NewLib();
-    else if (pButton == m_pInsertLibButton)
+    else if (&rButton == m_xInsertLibButton.get())
         InsertLib();
-    else if (pButton == m_pExportButton)
+    else if (&rButton == m_xExportButton.get())
         Export();
-    else if (pButton == m_pDelButton)
+    else if (&rButton == m_xDelButton.get())
         DeleteCurrent();
-    else if (pButton == m_pPasswordButton)
+    else if (&rButton == m_xPasswordButton.get())
     {
-        SvTreeListEntry* pCurEntry = m_pLibBox->GetCurEntry();
-        OUString aLibName( SvTabListBox::GetEntryText( pCurEntry, 0 ) );
+        std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
+        if (!m_xLibBox->get_cursor(xCurEntry.get()))
+            return;
+        OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
 
         // load module library (if not loaded)
         Reference< script::XLibraryContainer > xModLibContainer = 
m_aCurDocument.getLibraryContainer( E_SCRIPTS );
@@ -633,7 +484,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void )
                 bool const bProtected = xPasswd->isLibraryPasswordProtected( 
aLibName );
 
                 // change password dialog
-                SvxPasswordDialog aDlg(GetFrameWeld(), !bProtected);
+                SvxPasswordDialog aDlg(m_pDialog->getDialog(), !bProtected);
                 aDlg.SetCheckPasswordHdl(LINK(this, LibPage, 
CheckPasswordHdl));
 
                 if (aDlg.run() == RET_OK)
@@ -642,10 +493,10 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton, void )
 
                     if ( bNewProtected != bProtected )
                     {
-                        sal_uLong nPos = m_pLibBox->GetModel()->GetAbsPos( 
pCurEntry );
-                        m_pLibBox->GetModel()->Remove( pCurEntry );
-                        ImpInsertLibEntry( aLibName, nPos );
-                        m_pLibBox->SetCurEntry( m_pLibBox->GetEntry( nPos ) );
+                        int nPos = 
m_xLibBox->get_iter_index_in_parent(*xCurEntry);
+                        m_xLibBox->remove(*xCurEntry);
+                        ImpInsertLibEntry(aLibName, nPos);
+                        m_xLibBox->set_cursor(nPos);
                     }
 
                     MarkDocumentModified( m_aCurDocument );
@@ -660,8 +511,11 @@ IMPL_LINK( LibPage, CheckPasswordHdl, SvxPasswordDialog *, 
pDlg, bool )
 {
     bool bRet = false;
 
-    SvTreeListEntry* pCurEntry = m_pLibBox->GetCurEntry();
-    OUString aLibName( SvTabListBox::GetEntryText( pCurEntry, 0 ) );
+    std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
+    if (!m_xLibBox->get_cursor(xCurEntry.get()))
+        return bRet;
+
+    OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
     Reference< script::XLibraryContainerPassword > xPasswd( 
m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
 
     if ( xPasswd.is() )
@@ -683,14 +537,14 @@ IMPL_LINK( LibPage, CheckPasswordHdl, SvxPasswordDialog 
*, pDlg, bool )
 
 void LibPage::NewLib()
 {
-    createLibImpl(GetFrameWeld(), m_aCurDocument, m_pLibBox, 
static_cast<SbTreeListBox*>(nullptr));
+    createLibImpl(m_pDialog->getDialog(), m_aCurDocument, m_xLibBox.get(), 
nullptr);
 }
 
 void LibPage::InsertLib()
 {
     Reference< uno::XComponentContext > xContext( 
::comphelper::getProcessComponentContext() );
     // file open dialog
-    sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, 
pTabDlg ? pTabDlg->GetFrameWeld() : nullptr);
+    sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, 
m_pDialog->getDialog());
     const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
 
     xFP->setTitle(IDEResId(RID_STR_APPENDLIBS));
@@ -782,7 +636,7 @@ void LibPage::InsertLib()
         // library import dialog
         if (!xLibDlg)
         {
-            xLibDlg.reset(new LibDialog(GetFrameWeld()));
+            xLibDlg.reset(new LibDialog(m_pDialog->getDialog()));
             xLibDlg->SetStorageName( aURLObj.getName() );
         }
 
@@ -801,7 +655,7 @@ void LibPage::InsertLib()
 
     if (!xLibDlg)
     {
-        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+        std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                        
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_NOLIBINSTORAGE)));
         xErrorBox->run();
         return;
@@ -821,7 +675,7 @@ void LibPage::InsertLib()
                 return;
 
             bool bChanges = false;
-            sal_uLong nNewPos = m_pLibBox->GetEntryCount();
+            int nNewPos = m_xLibBox->n_children();
             bool bRemove = false;
             bool bReplace = xLibDlg->IsReplace();
             bool bReference = xLibDlg->IsReference();
@@ -843,7 +697,7 @@ void LibPage::InsertLib()
                             // check, if the library is the Standard library
                             if ( aLibName == "Standard" )
                             {
-                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                                                
VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_REPLACESTDLIB)));
                                 xErrorBox->run();
                                 continue;
@@ -855,7 +709,7 @@ void LibPage::InsertLib()
                             {
                                 OUString aErrStr( IDEResId(RID_STR_REPLACELIB) 
);
                                 aErrStr = aErrStr.replaceAll("XX", aLibName) + 
"\n" + IDEResId(RID_STR_LIBISREADONLY);
-                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                                                
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
                                 xErrorBox->run();
                                 continue;
@@ -872,7 +726,7 @@ void LibPage::InsertLib()
                             else
                                 aErrStr = IDEResId(RID_STR_IMPORTNOTPOSSIBLE);
                             aErrStr = aErrStr.replaceAll("XX", aLibName) + 
"\n" +IDEResId(RID_STR_SBXNAMEALLREADYUSED);
-                            std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+                            std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                                            
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
                             xErrorBox->run();
                             continue;
@@ -893,7 +747,7 @@ void LibPage::InsertLib()
                             {
                                 OUString aErrStr( IDEResId(RID_STR_NOIMPORT) );
                                 aErrStr = aErrStr.replaceAll("XX", aLibName);
-                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+                                std::unique_ptr<weld::MessageDialog> 
xErrorBox(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                                                
VclMessageType::Warning, VclButtonsType::Ok, aErrStr));
                                 xErrorBox->run();
                                 continue;
@@ -905,9 +759,9 @@ void LibPage::InsertLib()
                     if ( bRemove )
                     {
                         // remove listbox entry
-                        SvTreeListEntry* pEntry_ = m_pLibBox->FindEntry( 
aLibName );
-                        if ( pEntry_ )
-                            m_pLibBox->SvTreeListBox::GetModel()->Remove( 
pEntry_ );
+                        int nEntry_ = FindEntry(*m_xLibBox, aLibName);
+                        if (nEntry_ != -1)
+                            m_xLibBox->remove(nEntry_);
 
                         // remove module library
                         if ( xModLibContainer.is() && 
xModLibContainer->hasByName( aLibName ) )
@@ -1039,14 +893,13 @@ void LibPage::InsertLib()
                     }
 
                     // insert listbox entry
-                    ImpInsertLibEntry( aLibName, m_pLibBox->GetEntryCount() );
+                    ImpInsertLibEntry( aLibName, m_xLibBox->n_children() );
                     bChanges = true;
                 }
             }
 
-            SvTreeListEntry* pFirstNew = m_pLibBox->GetEntry( nNewPos );
-            if ( pFirstNew )
-                m_pLibBox->SetCurEntry( pFirstNew );
+            if (nNewPos < m_xLibBox->n_children())
+                m_xLibBox->set_cursor(nNewPos);
 
             if ( bChanges )
                 MarkDocumentModified( m_aCurDocument );
@@ -1055,8 +908,10 @@ void LibPage::InsertLib()
 
 void LibPage::Export()
 {
-    SvTreeListEntry* pCurEntry = m_pLibBox->GetCurEntry();
-    OUString aLibName( SvTabListBox::GetEntryText( pCurEntry, 0 ) );
+    std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
+    if (!m_xLibBox->get_cursor(xCurEntry.get()))
+        return;
+    OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
 
     // Password verification
     Reference< script::XLibraryContainer2 > xModLibContainer( 
m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
@@ -1077,7 +932,7 @@ void LibPage::Export()
             return;
     }
 
-    std::unique_ptr<ExportDialog> xNewDlg(new ExportDialog(GetFrameWeld()));
+    std::unique_ptr<ExportDialog> xNewDlg(new 
ExportDialog(m_pDialog->getDialog()));
     if (xNewDlg->run() == RET_OK)
     {
         try
@@ -1147,7 +1002,7 @@ Reference< XProgressHandler > 
OLibCommandEnvironment::getProgressHandler()
 void LibPage::ExportAsPackage( const OUString& aLibName )
 {
     // file open dialog
-    sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, 
pTabDlg ? pTabDlg->GetFrameWeld() : nullptr);
+    sfx2::FileDialogHelper 
aDlg(ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, FileDialogFlags::NONE, 
m_pDialog->getDialog());
     const Reference <XFilePicker3>& xFP = aDlg.GetFilePicker();
 
     Reference< uno::XComponentContext > xContext( 
::comphelper::getProcessComponentContext() );
@@ -1292,8 +1147,10 @@ void LibPage::ExportAsBasic( const OUString& aLibName )
 
 void LibPage::DeleteCurrent()
 {
-    SvTreeListEntry* pCurEntry = m_pLibBox->GetCurEntry();
-    OUString aLibName( SvTabListBox::GetEntryText( pCurEntry, 0 ) );
+    std::unique_ptr<weld::TreeIter> xCurEntry(m_xLibBox->make_iterator());
+    if (!m_xLibBox->get_cursor(xCurEntry.get()))
+        return;
+    OUString aLibName(m_xLibBox->get_text(*xCurEntry, 0));
 
     // check, if library is link
     bool bIsLibraryLink = false;
@@ -1305,7 +1162,7 @@ void LibPage::DeleteCurrent()
         bIsLibraryLink = true;
     }
 
-    if (QueryDelLib(aLibName, bIsLibraryLink, GetFrameWeld()))
+    if (QueryDelLib(aLibName, bIsLibraryLink, m_pDialog->getDialog()))
     {
         // inform BasicIDE
         SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( 
m_aCurDocument.getDocumentOrNull() ) );
@@ -1320,16 +1177,14 @@ void LibPage::DeleteCurrent()
         if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
             xDlgLibContainer->removeLibrary( aLibName );
 
-        static_cast<SvTreeListBox&>(*m_pLibBox).GetModel()->Remove( pCurEntry 
);
+        m_xLibBox->remove(*xCurEntry);
         MarkDocumentModified( m_aCurDocument );
     }
 }
 
 void LibPage::EndTabDialog()
 {
-    DBG_ASSERT( pTabDlg, "TabDlg not set!" );
-    if ( pTabDlg )
-        pTabDlg->EndDialog( 1 );
+    m_pDialog->response(RET_OK);
 }
 
 void LibPage::FillListBox()
@@ -1346,16 +1201,15 @@ void LibPage::FillListBox()
 
 void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, 
LibraryLocation eLocation )
 {
-    OUString aEntryText( rDocument.getTitle( eLocation ) );
-    const sal_Int32 nPos = m_pBasicsBox->InsertEntry( aEntryText );
-    m_pBasicsBox->SetEntryData( nPos, new DocumentEntry(rDocument, eLocation) 
);
+    OUString aEntryText(rDocument.getTitle(eLocation));
+    OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new 
DocumentEntry(rDocument, eLocation))));
+    m_xBasicsBox->append(sId,  aEntryText);
 }
 
 void LibPage::SetCurLib()
 {
-    const sal_Int32 nSelPos = m_pBasicsBox->GetSelectedEntryPos();
-    DocumentEntry* pEntry = 
static_cast<DocumentEntry*>(m_pBasicsBox->GetEntryData( nSelPos ));
-    if ( pEntry )
+    DocumentEntry* pEntry = 
reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
+    if (pEntry)
     {
         const ScriptDocument& aDocument( pEntry->GetDocument() );
         DBG_ASSERT( aDocument.isAlive(), "LibPage::SetCurLib: no document, or 
document is dead!" );
@@ -1366,30 +1220,30 @@ void LibPage::SetCurLib()
         {
             m_aCurDocument = aDocument;
             m_eCurLocation = eLocation;
-            m_pLibBox->SetDocument( aDocument );
-            m_pLibBox->Clear();
+            m_xLibBox->clear();
 
             // get a sorted list of library names
             Sequence< OUString > aLibNames = aDocument.getLibraryNames();
             sal_Int32 nLibCount = aLibNames.getLength();
             const OUString* pLibNames = aLibNames.getConstArray();
 
-            for ( sal_Int32 i = 0 ; i < nLibCount ; i++ )
+            int nEntry = 0;
+            for (int i = 0 ; i < nLibCount; ++i)
             {
-                OUString aLibName( pLibNames[ i ] );
-                if ( eLocation == aDocument.getLibraryLocation( aLibName ) )
-                    ImpInsertLibEntry( aLibName, i );
+                OUString aLibName(pLibNames[i]);
+                if (eLocation == aDocument.getLibraryLocation(aLibName))
+                    ImpInsertLibEntry(aLibName, nEntry++);
             }
 
-            SvTreeListEntry* pEntry_ = m_pLibBox->FindEntry( "Standard" );
-            if ( !pEntry_ )
-                pEntry_ = m_pLibBox->GetEntry( 0 );
-            m_pLibBox->SetCurEntry( pEntry_ );
+            int nEntry_ = FindEntry(*m_xLibBox, "Standard");
+            if (nEntry_ == -1 && m_xLibBox->n_children())
+                nEntry_ = 0;
+            m_xLibBox->set_cursor(nEntry_);
         }
     }
 }
 
-SvTreeListEntry* LibPage::ImpInsertLibEntry( const OUString& rLibName, 
sal_uLong nPos )
+void LibPage::ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos )
 {
     // check, if library is password protected
     bool bProtected = false;
@@ -1403,141 +1257,22 @@ SvTreeListEntry* LibPage::ImpInsertLibEntry( const 
OUString& rLibName, sal_uLong
         }
     }
 
-    SvTreeListEntry* pNewEntry = m_pLibBox->DoInsertEntry( rLibName, nPos );
-    pNewEntry->SetUserData( new LibUserData(m_aCurDocument) );
+    m_xLibBox->insert_text(nPos, rLibName);
 
     if (bProtected)
-    {
-        Image aImage(StockImage::Yes, RID_BMP_LOCKED);
-        m_pLibBox->SetExpandedEntryBmp(pNewEntry, aImage);
-        m_pLibBox->SetCollapsedEntryBmp(pNewEntry, aImage);
-    }
+        m_xLibBox->set_image(nPos, RID_BMP_LOCKED);
 
     // check, if library is link
     if ( xModLibContainer.is() && xModLibContainer->hasByName( rLibName ) && 
xModLibContainer->isLibraryLink( rLibName ) )
     {
         OUString aLinkURL = xModLibContainer->getLibraryLinkURL( rLibName );
-        m_pLibBox->SetEntryText( aLinkURL, pNewEntry, 1 );
+        m_xLibBox->set_text(nPos, aLinkURL, 1);
     }
-
-    return pNewEntry;
 }
 
 // Helper function
 void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
-                   CheckBox* pLibBox, TreeListBox* 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 )
-                {
-                    SvTreeListEntry* pEntry = pBasicBox->GetCurEntry();
-                    SvTreeListEntry* pRootEntry = nullptr;
-                    while( pEntry )
-                    {
-                        pRootEntry = pEntry;
-                        pEntry = pBasicBox->GetParent( pEntry );
-                    }
-
-                    BrowseMode nMode = pBasicBox->GetMode();
-                    bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( 
nMode & BrowseMode::Modules );
-                    const OUString sId = bDlgMode ? 
OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_MODLIB);
-                    SvTreeListEntry* pNewLibEntry = pBasicBox->AddEntry(
-                        aLibName,
-                        Image(StockImage::Yes, sId),
-                        pRootEntry, false,
-                        std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
-                    DBG_ASSERT( pNewLibEntry, "Insert entry failed!" );
-
-                    if( pNewLibEntry )
-                    {
-                        SvTreeListEntry* pEntry_ = pBasicBox->AddEntry(
-                            aModName,
-                            Image(StockImage::Yes, RID_BMP_MODULE),
-                            pNewLibEntry, false,
-                            std::make_unique<Entry>(OBJ_TYPE_MODULE));
-                        DBG_ASSERT( pEntry_, "Insert entry failed!" );
-                        pBasicBox->SetCurEntry( pEntry_ );
-                        pBasicBox->Select( pBasicBox->GetCurEntry() );      // 
OV-Bug?!
-                    }
-                }
-            }
-            catch (const uno::Exception& )
-            {
-                DBG_UNHANDLED_EXCEPTION("basctl.basicide");
-            }
-        }
-    }
-}
-
-void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
-                   CheckBox* pLibBox, SbTreeListBox* pBasicBox)
+                   weld::TreeView* pLibBox, SbTreeListBox* pBasicBox)
 {
     OSL_ENSURE( rDocument.isAlive(), "createLibImpl: invalid document!" );
     if ( !rDocument.isAlive() )
@@ -1591,9 +1326,8 @@ void createLibImpl(weld::Window* pWin, const 
ScriptDocument& rDocument,
 
                 if( pLibBox )
                 {
-                    SvTreeListEntry* pEntry = pLibBox->DoInsertEntry( aLibName 
);
-                    pEntry->SetUserData( new LibUserData( rDocument ) );
-                    pLibBox->SetCurEntry( pEntry );
+                    pLibBox->append_text(aLibName);
+                    pLibBox->set_cursor(pLibBox->n_children() - 1);
                 }
 
                 // create a module
diff --git a/basctl/source/basicide/moduldlg.cxx 
b/basctl/source/basicide/moduldlg.cxx
index dda0bbf1581d..6f1cf5cf5da0 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -50,58 +50,48 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::resource;
 
-
-// ExtTreeListBox
-
-ExtTreeListBox::ExtTreeListBox(vcl::Window* pParent, WinBits nStyle)
-    : TreeListBox(pParent, nStyle)
-{
-}
-
-VCL_BUILDER_FACTORY_CONSTRUCTOR(ExtTreeListBox, WB_TABSTOP)
-
-bool ExtTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
+IMPL_LINK(ObjectPage, EditingEntryHdl, const weld::TreeIter&, rEntry, bool)
 {
     bool bRet = false;
 
-    if ( pEntry )
+    sal_uInt16 nDepth = m_xBasicBox->get_iter_depth(rEntry);
+    if (nDepth >= 2)
     {
-        sal_uInt16 nDepth = GetModel()->GetDepth( pEntry );
-        if ( nDepth >= 2 )
+        EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(&rEntry);
+        const ScriptDocument& aDocument( aDesc.GetDocument() );
+        const OUString& aLibName( aDesc.GetLibName() );
+        Reference< script::XLibraryContainer2 > xModLibContainer( 
aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+        Reference< script::XLibraryContainer2 > xDlgLibContainer( 
aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+        if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( 
aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
+                ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
         {
-            EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
-            const ScriptDocument& aDocument( aDesc.GetDocument() );
-            const OUString& aLibName( aDesc.GetLibName() );
-            Reference< script::XLibraryContainer2 > xModLibContainer( 
aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
-            Reference< script::XLibraryContainer2 > xDlgLibContainer( 
aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
-            if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( 
aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
-                    ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
-            {
-                // allow editing only for libraries, which are not readonly
-                bRet = true;
-            }
+            // allow editing only for libraries, which are not readonly
+            bRet = true;
         }
     }
 
     return bRet;
 }
 
-bool ExtTreeListBox::EditedEntry( SvTreeListEntry* pEntry, const OUString& 
rNewText )
+IMPL_LINK(ObjectPage, EditedEntryHdl, const IterString&, rIterString, bool)
 {
-    if ( !IsValidSbxName(rNewText) )
+    const weld::TreeIter& rEntry = rIterString.first;
+    OUString sNewText = rIterString.second;
+
+    if ( !IsValidSbxName(sNewText) )
     {
-        std::unique_ptr<weld::MessageDialog> 
xError(Application::CreateMessageDialog(GetFrameWeld(),
+        std::unique_ptr<weld::MessageDialog> 
xError(Application::CreateMessageDialog(m_pDialog->getDialog(),
                                                     VclMessageType::Warning, 
VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
         xError->run();
         return false;
     }
 
-    OUString aCurText( GetEntryText( pEntry ) );
-    if ( aCurText == rNewText )
+    OUString aCurText(m_xBasicBox->get_text(rEntry));
+    if ( aCurText == sNewText )
         // nothing to do
         return true;
 
-    EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
+    EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(&rEntry);
     const ScriptDocument& aDocument( aDesc.GetDocument() );
     DBG_ASSERT( aDocument.isValid(), "ExtTreeListBox::EditedEntry: no 
document!" );
     if ( !aDocument.isValid() )
@@ -110,8 +100,8 @@ bool ExtTreeListBox::EditedEntry( SvTreeListEntry* pEntry, 
const OUString& rNewT
     EntryType eType = aDesc.GetType();
 
     bool bSuccess = eType == OBJ_TYPE_MODULE ?
-        RenameModule(GetFrameWeld(), aDocument, aLibName, aCurText, rNewText) :
-        RenameDialog(GetFrameWeld(), aDocument, aLibName, aCurText, rNewText);
+        RenameModule(m_pDialog->getDialog(), aDocument, aLibName, aCurText, 
sNewText) :
+        RenameDialog(m_pDialog->getDialog(), aDocument, aLibName, aCurText, 
sNewText);
 
     if ( !bSuccess )
         return false;
@@ -120,142 +110,20 @@ bool ExtTreeListBox::EditedEntry( SvTreeListEntry* 
pEntry, const OUString& rNewT
 
     if (SfxDispatcher* pDispatcher = GetDispatcher())
     {
-        SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, rNewText, 
ConvertType( eType ) );
+        SbxItem aSbxItem(SID_BASICIDE_ARG_SBX, aDocument, aLibName, sNewText, 
SbTreeListBox::ConvertType(eType));
         pDispatcher->ExecuteList( SID_BASICIDE_SBXRENAMED,
                             SfxCallMode::SYNCHRON, { &aSbxItem });
     }
 
     // OV-Bug?!
-    SetEntryText( pEntry, rNewText );
-    SetCurEntry( pEntry );
-    SetCurEntry( pEntry );
-    Select( pEntry, false );
-    Select( pEntry );       // so that handler is called => update edit
+    m_xBasicBox->set_text(rEntry, sNewText);
+    m_xBasicBox->set_cursor(rEntry);
+    m_xBasicBox->unselect(rEntry);
+    m_xBasicBox->select(rEntry); // so that handler is called => update edit
 
     return true;
 }
 
-
-DragDropMode ExtTreeListBox::NotifyStartDrag( TransferDataContainer&, 
SvTreeListEntry* pEntry )
-{
-    DragDropMode nMode_ = DragDropMode::NONE;
-
-    if ( pEntry )
-    {
-        sal_uInt16 nDepth = GetModel()->GetDepth( pEntry );
-        if ( nDepth >= 2 )
-        {
-            nMode_ = DragDropMode::CTRL_COPY;
-            EntryDescriptor aDesc = GetEntryDescriptor(pEntry);
-            const ScriptDocument& aDocument( aDesc.GetDocument() );
-            const OUString& aLibName( aDesc.GetLibName() );
-            // allow MOVE mode only for libraries, which are not readonly
-            Reference< script::XLibraryContainer2 > xModLibContainer( 
aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
-            Reference< script::XLibraryContainer2 > xDlgLibContainer( 
aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
-            if ( !( ( xModLibContainer.is() && xModLibContainer->hasByName( 
aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
-                    ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) ) )
-            {
-                // Only allow copy for localized libraries
-                bool bAllowMove = true;
-                if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) )
-                {
-                    // Get StringResourceManager
-                    Reference< container::XNameContainer > xDialogLib( 
aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
-                    Reference< XStringResourceManager > xSourceMgr =
-                        LocalizationMgr::getStringResourceFromDialogLibrary( 
xDialogLib );
-                    if( xSourceMgr.is() )
-                        bAllowMove = ( xSourceMgr->getLocales().getLength() == 
0 );
-                }
-                if( bAllowMove )
-                    nMode_ |= DragDropMode::CTRL_MOVE;
-            }
-        }
-    }
-
-    return nMode_;
-}
-
-
-bool ExtTreeListBox::NotifyAcceptDrop( SvTreeListEntry* pEntry )
-{
-    // don't drop on a BasicManager (nDepth == 0)
-    sal_uInt16 nDepth = pEntry ? GetModel()->GetDepth( pEntry ) : 0;
-    bool bValid = nDepth != 0;
-
-    // don't drop in the same library
-    SvTreeListEntry* pSelected = FirstSelected();
-    if (!pSelected)
-        bValid = false;
-    else if ( ( nDepth == 1 ) && ( pEntry == GetParent( pSelected ) ) )
-        bValid = false;
-    else if ( ( nDepth == 2 ) && ( GetParent( pEntry ) == GetParent( pSelected 
) ) )
-        bValid = false;
-
-    // don't drop on a library, which is not loaded, readonly or password 
protected
-    // or which already has a module/dialog with this name
-    if ( bValid && ( nDepth > 0 ) )
-    {
-        // get source module/dialog name
-        EntryDescriptor aSourceDesc = GetEntryDescriptor(pSelected);
-        const OUString& aSourceName = aSourceDesc.GetName();
-        EntryType eSourceType = aSourceDesc.GetType();
-
-        // get target shell and target library name
-        EntryDescriptor aDestDesc = GetEntryDescriptor(pEntry);
-        ScriptDocument const& rDestDoc = aDestDesc.GetDocument();
-        const OUString& aDestLibName = aDestDesc.GetLibName();
-
-        // check if module library is not loaded, readonly or password 
protected
-        Reference< script::XLibraryContainer2 > xModLibContainer( 
rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
-        if ( xModLibContainer.is() && xModLibContainer->hasByName( 
aDestLibName ) )
-        {
-            if ( !xModLibContainer->isLibraryLoaded( aDestLibName ) )
-                bValid = false;
-
-            if ( xModLibContainer->isLibraryReadOnly( aDestLibName ) )
-                bValid = false;
-
-            Reference< script::XLibraryContainerPassword > xPasswd( 
xModLibContainer, UNO_QUERY );
-            if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( 
aDestLibName ) && !xPasswd->isLibraryPasswordVerified( aDestLibName ) )
-                bValid = false;
-        }
-
-        // check if dialog library is not loaded or readonly
-        Reference< script::XLibraryContainer2 > xDlgLibContainer( 
rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
-        if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aDestLibName ) )
-        {
-            if ( !xDlgLibContainer->isLibraryLoaded( aDestLibName ) )
-                bValid = false;
-
-            if ( xDlgLibContainer->isLibraryReadOnly( aDestLibName ) )
-                bValid = false;
-        }
-
-        // check, if module/dialog with this name is already existing in 
target library
-        if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( 
aDestLibName, aSourceName ) ) ||
-            ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( 
aDestLibName, aSourceName ) ) )
-        {
-            bValid = false;
-        }
-    }
-
-    return bValid;
-}
-
-TriState ExtTreeListBox::NotifyMoving( SvTreeListEntry* pTarget, 
SvTreeListEntry* pEntry,
-                        SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos 
)
-{
-    return NotifyCopyingMoving( pTarget, pEntry,
-                                    rpNewParent, rNewChildPos, true );
-}
-
-TriState ExtTreeListBox::NotifyCopying( SvTreeListEntry* pTarget, 
SvTreeListEntry* pEntry,
-                        SvTreeListEntry*& rpNewParent, sal_uLong& rNewChildPos 
)
-{
-    return NotifyCopyingMoving( pTarget, pEntry,
-                                    rpNewParent, rNewChildPos, false );
-}
-
 void Shell::CopyDialogResources(
     Reference< io::XInputStreamProvider >& io_xISP,
     ScriptDocument const& rSourceDoc,
@@ -312,339 +180,430 @@ void Shell::CopyDialogResources(
     }
 }
 
-TriState ExtTreeListBox::NotifyCopyingMoving( SvTreeListEntry* pTarget, 
SvTreeListEntry const * pEntry,
-                        SvTreeListEntry*& rpNewParent, sal_uLong& 
rNewChildPos, bool bMove )
+// OrganizeDialog
+OrganizeDialog::OrganizeDialog(weld::Window* pParent, sal_Int16 tabId,
+    EntryDescriptor const & rDesc )
+    : GenericDialogController(pParent, 
"modules/BasicIDE/ui/organizedialog.ui", "OrganizeDialog")
+    , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
+    , m_xModulePage(new ObjectPage(m_xTabCtrl->get_page("modules"), 
"ModulePage", BrowseMode::Modules, this))
+    , m_xDialogPage(new ObjectPage(m_xTabCtrl->get_page("dialogs"), 
"DialogPage", BrowseMode::Dialogs, this))
+    , m_xLibPage(new LibPage(m_xTabCtrl->get_page("libraries"), this))
+    , m_aCurEntry(rDesc)
+{
+    m_xTabCtrl->connect_enter_page(LINK(this, OrganizeDialog, 
ActivatePageHdl));
+
+    if (tabId == 0)
+        m_xTabCtrl->set_current_page("modules");
+    else if (tabId == 1)
+        m_xTabCtrl->set_current_page("dialogs");
+    else
+        m_xTabCtrl->set_current_page("libraries");
+
+    if (SfxDispatcher* pDispatcher = GetDispatcher())
+        pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+}
+
+IMPL_LINK(OrganizeDialog, ActivatePageHdl, const OString&, rPage, void)
 {
-    DBG_ASSERT( pEntry, "No entry?" );   // ASS is ok here, should not be 
reached
-    DBG_ASSERT( pTarget, "No target?" ); // with NULL (right at the beginning)
-    sal_uInt16 nDepth = GetModel()->GetDepth( pTarget );
-    DBG_ASSERT( nDepth, "Depth?" );
-    if ( nDepth == 1 )
-    {
-        // Target = Basic => put module/dialog under the Basic
-        rpNewParent = pTarget;
-        rNewChildPos = 0;
-    }
-    else if ( nDepth >= 2 )
-    {
-        // Target = module/dialog => put module/dialog under the superordinate 
Basic
-        rpNewParent = GetParent( pTarget );
-        rNewChildPos = SvTreeList::GetRelPos( pTarget ) + 1;
-    }
+    if (rPage == "modules")
+        m_xModulePage->ActivatePage();
+    else if (rPage == "dialogs")
+        m_xDialogPage->ActivatePage();
+    else if (rPage == "libraries")
+        m_xLibPage->ActivatePage();
+}
 
-    // get target shell and target library name
-    EntryDescriptor aDestDesc = GetEntryDescriptor(rpNewParent);
-    const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
-    const OUString& aDestLibName( aDestDesc.GetLibName() );
+OrganizeDialog::~OrganizeDialog()
+{
+}
 
-    // get source shell, library name and module/dialog name
-    EntryDescriptor aSourceDesc = GetEntryDescriptor(FirstSelected());
-    const ScriptDocument& rSourceDoc( aSourceDesc.GetDocument() );
-    const OUString& aSourceLibName( aSourceDesc.GetLibName() );
-    const OUString& aSourceName( aSourceDesc.GetName() );
-    EntryType eType = aSourceDesc.GetType();
+OrganizePage::OrganizePage(weld::Container* pParent, const OUString& rUIFile, 
const OString &rName, OrganizeDialog* pDialog)
+    : m_pDialog(pDialog)
+    , m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
+    , m_xContainer(m_xBuilder->weld_container(rName))
+{
+}
 
-    // get dispatcher
-    SfxDispatcher* pDispatcher = GetDispatcher();
+OrganizePage::~OrganizePage()
+{
+}
 
-    if ( bMove )    // move
+class SbTreeListBoxDropTarget : public DropTargetHelper
+{
+private:
+    SbTreeListBox& m_rTreeView;
+
+    virtual sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt) override
     {
-        // remove source module/dialog window
-        if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
-        {
-            if( pDispatcher )
-            {
-                SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, 
aSourceLibName, aSourceName, ConvertType( eType ) );
-                pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
-                      SfxCallMode::SYNCHRON, { &aSbxItem });
-            }
-        }
+        // to enable the autoscroll when we're close to the edges
+        weld::TreeView& rWidget = m_rTreeView.get_widget();
+        rWidget.get_dest_row_at_pos(rEvt.maPosPixel, nullptr);
 
-        try
-        {
-            if ( eType == OBJ_TYPE_MODULE ) // module
-            {
-                // get module
-                OUString aModule;
-                if ( rSourceDoc.getModule( aSourceLibName, aSourceName, 
aModule ) )
-                {
-                    // remove module from source library
-                    if ( rSourceDoc.removeModule( aSourceLibName, aSourceName 
) )
-                    {
-                        MarkDocumentModified( rSourceDoc );
+        weld::TreeView* pSource = rWidget.get_drag_source();
+        if (!pSource)
+            return DND_ACTION_NONE;
 
-                        // insert module into target library
-                        if ( rDestDoc.insertModule( aDestLibName, aSourceName, 
aModule ) )
-                            MarkDocumentModified( rDestDoc );
-                    }
-                }
-            }
-            else if ( eType == OBJ_TYPE_DIALOG )    // dialog
+        sal_Int8 nMode = DND_ACTION_NONE;
+
+        std::unique_ptr<weld::TreeIter> xEntry(pSource->make_iterator());
+        if (pSource->get_selected(xEntry.get()))
+        {
+            sal_uInt16 nDepth = pSource->get_iter_depth(*xEntry);
+            if (nDepth >= 2)
             {
-                // get dialog
-                Reference< io::XInputStreamProvider > xISP;
-                if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) 
)
+                nMode = DND_ACTION_COPY;
+                EntryDescriptor aDesc = 
m_rTreeView.GetEntryDescriptor(xEntry.get());
+                const ScriptDocument& aDocument( aDesc.GetDocument() );
+                const OUString& aLibName( aDesc.GetLibName() );
+                // allow MOVE mode only for libraries, which are not readonly
+                Reference< script::XLibraryContainer2 > xModLibContainer( 
aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+                Reference< script::XLibraryContainer2 > xDlgLibContainer( 
aDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+                if ( !( ( xModLibContainer.is() && 
xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( 
aLibName ) ) ||
+                        ( xDlgLibContainer.is() && 
xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( 
aLibName ) ) ) )
                 {
-                    Shell::CopyDialogResources( xISP, rSourceDoc,
-                        aSourceLibName, rDestDoc, aDestLibName, aSourceName );
-
-                    // remove dialog from source library
-                    if (RemoveDialog(rSourceDoc, aSourceLibName, aSourceName))
+                    // Only allow copy for localized libraries
+                    bool bAllowMove = true;
+                    if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aLibName ) )
                     {
-                        MarkDocumentModified(rSourceDoc);
-
-                        // insert dialog into target library
-                        if ( rDestDoc.insertDialog( aDestLibName, aSourceName, 
xISP ) )
-                            MarkDocumentModified(rDestDoc);
+                        // Get StringResourceManager
+                        Reference< container::XNameContainer > xDialogLib( 
aDocument.getLibrary( E_DIALOGS, aLibName, true ) );
+                        Reference< XStringResourceManager > xSourceMgr =
+                            
LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
+                        if( xSourceMgr.is() )
+                            bAllowMove = ( 
xSourceMgr->getLocales().getLength() == 0 );
                     }
+                    if( bAllowMove )
+                        nMode |= DND_ACTION_MOVE;
                 }
             }
         }
-        catch (const uno::Exception& )
-        {
-            DBG_UNHANDLED_EXCEPTION("basctl.basicide");
-        }
+        return nMode;
     }
-    else    // copy
+
+    virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt) override
     {
-        try
-        {
-            if ( eType == OBJ_TYPE_MODULE ) // module
-            {
-                // get module
-                OUString aModule;
-                if ( rSourceDoc.getModule( aSourceLibName, aSourceName, 
aModule ) )
-                {
-                    // insert module into target library
-                    if ( rDestDoc.insertModule( aDestLibName, aSourceName, 
aModule ) )
-                        MarkDocumentModified( rDestDoc );
-                }
-            }
-            else if ( eType == OBJ_TYPE_DIALOG )    // dialog
-            {
-                // get dialog
-                Reference< io::XInputStreamProvider > xISP;
-                if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, xISP ) 
)
-                {
-                    Shell::CopyDialogResources( xISP, rSourceDoc,
-                        aSourceLibName, rDestDoc, aDestLibName, aSourceName );
+        weld::TreeView& rWidget = m_rTreeView.get_widget();
+        weld::TreeView* pSource = rWidget.get_drag_source();
+        if (!pSource)
+            return DND_ACTION_NONE;
 
-                    // insert dialog into target library
-                    if ( rDestDoc.insertDialog( aDestLibName, aSourceName, 
xISP ) )
-                        MarkDocumentModified( rDestDoc );
-                }
-            }
+        std::unique_ptr<weld::TreeIter> xEntry(rWidget.make_iterator());
+        bool bEntry = rWidget.get_dest_row_at_pos(rEvt.maPosPixel, 
xEntry.get());
+
+        // don't drop on a BasicManager (nDepth == 0)
+        sal_uInt16 nDepth = bEntry ? m_rTreeView.get_iter_depth(*xEntry) : 0;
+        bool bValid = nDepth != 0;
+        // don't drop in the same library
+        std::unique_ptr<weld::TreeIter> xSelected(pSource->make_iterator());
+        bool bSelected = pSource->get_selected(xSelected.get());
+        if (!bSelected)
+            bValid = false;
+        else if (nDepth == 1)
+        {
+            std::unique_ptr<weld::TreeIter> 
xSelParent(pSource->make_iterator(xSelected.get()));
+            if (pSource->iter_parent(*xSelParent) && 
pSource->iter_compare(*xEntry, *xSelParent) == 0)
+                bValid = false;
         }
-        catch ( const Exception& )
+        else if (nDepth == 2)
         {
-            DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+            std::unique_ptr<weld::TreeIter> 
xParent(pSource->make_iterator(xEntry.get()));
+            std::unique_ptr<weld::TreeIter> 
xSelParent(pSource->make_iterator(xSelected.get()));
+            if (pSource->iter_parent(*xParent) && 
pSource->iter_parent(*xSelParent) && pSource->iter_compare(*xParent, 
*xSelParent) == 0)
+                bValid = false;
         }
-    }
 
-    // create target module/dialog window
-    if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
-    {
-        if( pDispatcher )
+        // don't drop on a library, which is not loaded, readonly or password 
protected
+        // or which already has a module/dialog with this name
+        if ( bValid && ( nDepth > 0 ) )
         {
-            SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, aDestLibName, 
aSourceName, ConvertType( eType ) );
-            pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
-                                  SfxCallMode::SYNCHRON, { &aSbxItem });
-        }
-    }
+            // get source module/dialog name
+            EntryDescriptor aSourceDesc = 
m_rTreeView.GetEntryDescriptor(xSelected.get());
+            const OUString& aSourceName = aSourceDesc.GetName();
+            EntryType eSourceType = aSourceDesc.GetType();
 
-    return TRISTATE_INDET;   // open...
-}
+            // get target shell and target library name
+            EntryDescriptor aDestDesc = 
m_rTreeView.GetEntryDescriptor(xEntry.get());
+            ScriptDocument const& rDestDoc = aDestDesc.GetDocument();
+            const OUString& aDestLibName = aDestDesc.GetLibName();
 
-// OrganizeDialog
-OrganizeDialog::OrganizeDialog(vcl::Window* pParent, sal_Int16 tabId,
-    EntryDescriptor const & rDesc )
-    : TabDialog( pParent, "OrganizeDialog",
-        "modules/BasicIDE/ui/organizedialog.ui" )
-    , m_aCurEntry( rDesc )
-{
-    get(m_pTabCtrl, "tabcontrol");
+            // check if module library is not loaded, readonly or password 
protected
+            Reference< script::XLibraryContainer2 > xModLibContainer( 
rDestDoc.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+            if ( xModLibContainer.is() && xModLibContainer->hasByName( 
aDestLibName ) )
+            {
+                if ( !xModLibContainer->isLibraryLoaded( aDestLibName ) )
+                    bValid = false;
 
-    sal_uInt16 nPageCount = m_pTabCtrl->GetPageCount();
-    for (sal_uInt16 nPage = 0; nPage < nPageCount; ++nPage)
-    {
-        sal_uInt16 nPageId = m_pTabCtrl->GetPageId(nPage);
-        m_pTabCtrl->SetTabPage(nPageId, nullptr);
-    }
+                if ( xModLibContainer->isLibraryReadOnly( aDestLibName ) )
+                    bValid = false;
 
-    m_pTabCtrl->SetActivatePageHdl(LINK(this, OrganizeDialog, 
ActivatePageHdl));
+                Reference< script::XLibraryContainerPassword > xPasswd( 
xModLibContainer, UNO_QUERY );
+                if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( 
aDestLibName ) && !xPasswd->isLibraryPasswordVerified( aDestLibName ) )
+                    bValid = false;
+            }
 
-    if( tabId == 0 )
-    {
-        m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("modules"));
-    }
-    else if ( tabId == 1 )
-    {
-        m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("dialogs"));
-    }
-    else
-    {
-        m_pTabCtrl->SetCurPageId(m_pTabCtrl->GetPageId("libraries"));
-    }
+            // check if dialog library is not loaded or readonly
+            Reference< script::XLibraryContainer2 > xDlgLibContainer( 
rDestDoc.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+            if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( 
aDestLibName ) )
+            {
+                if ( !xDlgLibContainer->isLibraryLoaded( aDestLibName ) )
+                    bValid = false;
 
-    ActivatePageHdl(m_pTabCtrl);
+                if ( xDlgLibContainer->isLibraryReadOnly( aDestLibName ) )
+                    bValid = false;
+            }
 
-    if (SfxDispatcher* pDispatcher = GetDispatcher())
-        pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
-}
+            // check, if module/dialog with this name is already existing in 
target library
+            if ( ( eSourceType == OBJ_TYPE_MODULE && rDestDoc.hasModule( 
aDestLibName, aSourceName ) ) ||
+                ( eSourceType == OBJ_TYPE_DIALOG && rDestDoc.hasDialog( 
aDestLibName, aSourceName ) ) )
+            {
+                bValid = false;
+            }
+        }
 
-OrganizeDialog::~OrganizeDialog()
-{
-    disposeOnce();
-}
+        if (bValid)
+            NotifyCopyingMoving(*xEntry, rEvt.mnAction & DND_ACTION_MOVE);
 
-void OrganizeDialog::dispose()
-{
-    if (m_pTabCtrl)
-    {
-        for ( sal_uInt16 i = 0; i < m_pTabCtrl->GetPageCount(); i++ )
-            VclPtr<vcl::Window>(m_pTabCtrl->GetTabPage( m_pTabCtrl->GetPageId( 
i ) )).disposeAndClear();
+        return DND_ACTION_NONE;
     }
-    m_pTabCtrl.clear();
-
-    TabDialog::dispose();
-};
-
-IMPL_LINK( OrganizeDialog, ActivatePageHdl, TabControl *, pTabCtrl, void )
-{
-    sal_uInt16 nId = pTabCtrl->GetCurPageId();
 
-    if ( !pTabCtrl->GetTabPage( nId ) )
+    void NotifyCopyingMoving(weld::TreeIter& rTarget, bool bMove)
     {
-        OString sPageName(pTabCtrl->GetPageName(nId));
-        VclPtr<TabPage> pNewTabPage;
-        if (sPageName == "modules")
+        sal_uInt16 nDepth = m_rTreeView.get_iter_depth(rTarget);
+        std::unique_ptr<weld::TreeIter> 
xNewParent(m_rTreeView.make_iterator(&rTarget));
+        int nNewChildPos = 0;
+        DBG_ASSERT( nDepth, "Depth?" );
+        if ( nDepth >= 2 )
         {
-            VclPtrInstance<ObjectPage> pObjectPage(pTabCtrl, "ModulePage", 
BrowseMode::Modules);
-            pNewTabPage.reset(pObjectPage);
-            pObjectPage->SetTabDlg(this);
-            pObjectPage->SetCurrentEntry(m_aCurEntry);
+            // Target = module/dialog => put module/dialog under the 
superordinate Basic
+            m_rTreeView.iter_parent(*xNewParent);
+            nNewChildPos = m_rTreeView.get_iter_index_in_parent(rTarget) + 1;
         }
-        else if (sPageName == "dialogs")
+
+        // get target shell and target library name
+        EntryDescriptor aDestDesc = 
m_rTreeView.GetEntryDescriptor(xNewParent.get());
+        const ScriptDocument& rDestDoc( aDestDesc.GetDocument() );
+        const OUString& aDestLibName( aDestDesc.GetLibName() );
+
+        // get source shell, library name and module/dialog name
+        std::unique_ptr<weld::TreeIter> xSelected(m_rTreeView.make_iterator());
+        if (!m_rTreeView.get_selected(xSelected.get()))
+            xSelected.reset();
+        EntryDescriptor aSourceDesc = 
m_rTreeView.GetEntryDescriptor(xSelected.get());
+        const ScriptDocument& rSourceDoc( aSourceDesc.GetDocument() );
+        const OUString& aSourceLibName( aSourceDesc.GetLibName() );
+        const OUString& aSourceName( aSourceDesc.GetName() );
+        EntryType eType = aSourceDesc.GetType();
+
+        // get dispatcher
+        SfxDispatcher* pDispatcher = GetDispatcher();
+
+        if ( bMove )    // move
         {
-            VclPtrInstance<ObjectPage> pObjectPage( pTabCtrl, "DialogPage", 
BrowseMode::Dialogs );
-            pNewTabPage.reset(pObjectPage);
-            pObjectPage->SetTabDlg(this);
-            pObjectPage->SetCurrentEntry(m_aCurEntry);
+            // remove source module/dialog window
+            if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
+            {
+                if( pDispatcher )
+                {
+                    SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rSourceDoc, 
aSourceLibName, aSourceName, SbTreeListBox::ConvertType(eType) );
+                    pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
+                          SfxCallMode::SYNCHRON, { &aSbxItem });
+                }
+            }
+
+            try
+            {
+                if ( eType == OBJ_TYPE_MODULE ) // module
+                {
+                    // get module
+                    OUString aModule;
+                    if ( rSourceDoc.getModule( aSourceLibName, aSourceName, 
aModule ) )
+                    {
+                        // remove module from source library
+                        if ( rSourceDoc.removeModule( aSourceLibName, 
aSourceName ) )
+                        {
+                            MarkDocumentModified( rSourceDoc );
+
+                            // insert module into target library
+                            if ( rDestDoc.insertModule( aDestLibName, 
aSourceName, aModule ) )
+                                MarkDocumentModified( rDestDoc );
+                        }
+                    }
+                }
+                else if ( eType == OBJ_TYPE_DIALOG )    // dialog
+                {
+                    // get dialog
+                    Reference< io::XInputStreamProvider > xISP;
+                    if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, 
xISP ) )
+                    {
+                        Shell::CopyDialogResources( xISP, rSourceDoc,
+                            aSourceLibName, rDestDoc, aDestLibName, 
aSourceName );
+
+                        // remove dialog from source library
+                        if (RemoveDialog(rSourceDoc, aSourceLibName, 
aSourceName))
+                        {
+                            MarkDocumentModified(rSourceDoc);
+
+                            // insert dialog into target library
+                            if ( rDestDoc.insertDialog( aDestLibName, 
aSourceName, xISP ) )
+                                MarkDocumentModified(rDestDoc);
+                        }
+                    }
+                }
+            }
+            catch (const uno::Exception& )
+            {
+                DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+            }
         }
-        else if (sPageName == "libraries")
+        else    // copy
         {
-            VclPtrInstance<LibPage> pLibPage( pTabCtrl );
-            pNewTabPage.reset(pLibPage);
-            pLibPage->SetTabDlg( this );
+            try
+            {
+                if ( eType == OBJ_TYPE_MODULE ) // module
+                {
+                    // get module
+                    OUString aModule;
+                    if ( rSourceDoc.getModule( aSourceLibName, aSourceName, 
aModule ) )
+                    {
+                        // insert module into target library
+                        if ( rDestDoc.insertModule( aDestLibName, aSourceName, 
aModule ) )
+                            MarkDocumentModified( rDestDoc );
+                    }
+                }
+                else if ( eType == OBJ_TYPE_DIALOG )    // dialog
+                {
+                    // get dialog
+                    Reference< io::XInputStreamProvider > xISP;
+                    if ( rSourceDoc.getDialog( aSourceLibName, aSourceName, 
xISP ) )
+                    {
+                        Shell::CopyDialogResources( xISP, rSourceDoc,
+                            aSourceLibName, rDestDoc, aDestLibName, 
aSourceName );
+
+                        // insert dialog into target library
+                        if ( rDestDoc.insertDialog( aDestLibName, aSourceName, 
xISP ) )
+                            MarkDocumentModified( rDestDoc );
+                    }
+                }
+            }
+            catch ( const Exception& )
+            {
+                DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+            }
         }
-        else
+
+        OUString sText(m_rTreeView.get_text(*xSelected));
+        OUString sId(m_rTreeView.get_id(*xSelected));
+        std::unique_ptr<weld::TreeIter> xRet(m_rTreeView.make_iterator());
+        m_rTreeView.get_widget().insert(xNewParent.get(), nNewChildPos, 
&sText, &sId, nullptr, nullptr, nullptr, false, xRet.get());
+        if (eType == OBJ_TYPE_MODULE)
+            m_rTreeView.get_widget().set_image(*xRet, RID_BMP_MODULE);
+        else if (eType == OBJ_TYPE_DIALOG)
+            m_rTreeView.get_widget().set_image(*xRet, RID_BMP_DIALOG);
+        if (!m_rTreeView.get_row_expanded(*xNewParent))
+            m_rTreeView.expand_row(*xNewParent);
+        m_rTreeView.select(*xRet);
+
+        if (bMove)
+            m_rTreeView.remove(*xSelected);
+
+        // create target module/dialog window
+        if ( rSourceDoc != rDestDoc || aSourceLibName != aDestLibName )
         {
-            OSL_FAIL( "PageHdl: Unknown ID" );
+            if( pDispatcher )
+            {
+                SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDestDoc, 
aDestLibName, aSourceName, SbTreeListBox::ConvertType(eType) );
+                pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
+                                      SfxCallMode::SYNCHRON, { &aSbxItem });
+            }
         }
-        DBG_ASSERT( pNewTabPage, "No page" );
-        pTabCtrl->SetTabPage( nId, pNewTabPage );
     }
-}
 
+public:
+    SbTreeListBoxDropTarget(SbTreeListBox& rTreeView)
+        : DropTargetHelper(rTreeView.get_widget().get_drop_target())
+        , m_rTreeView(rTreeView)
+    {
+    }
+};
 
 // ObjectPage
-
-
-ObjectPage::ObjectPage(vcl::Window *pParent, const OString &rName, BrowseMode 
nMode)
-    : TabPage(pParent, rName, "modules/BasicIDE/ui/" +
-        OStringToOUString(rName, RTL_TEXTENCODING_UTF8).toAsciiLowerCase() +
-        ".ui")
-{
-    get(m_pBasicBox, "library");
-    Size aSize(m_pBasicBox->LogicToPixel(Size(130, 117), 
MapMode(MapUnit::MapAppFont)));
-    m_pBasicBox->set_height_request(aSize.Height());
-    m_pBasicBox->set_width_request(aSize.Width());
-    get(m_pEditButton, "edit");
-    get(m_pNewModButton, "newmodule");
-    get(m_pNewDlgButton, "newdialog");
-    get(m_pDelButton, "delete");
-
-    pTabDlg = nullptr;
-
-    m_pEditButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
-    m_pDelButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
-    m_pBasicBox->SetSelectHdl( LINK( this, ObjectPage, BasicBoxHighlightHdl ) 
);
+ObjectPage::ObjectPage(weld::Container* pParent, const OString &rName, 
BrowseMode nMode, OrganizeDialog* pDialog)
+    : OrganizePage(pParent, "modules/BasicIDE/ui/" + OStringToOUString(rName, 
RTL_TEXTENCODING_UTF8).toAsciiLowerCase() + ".ui",
+        rName, pDialog)
+    , m_xBasicBox(new SbTreeListBox(m_xBuilder->weld_tree_view("library"), 
pDialog->getDialog()))
+    , m_xEditButton(m_xBuilder->weld_button("edit"))
+    , m_xNewModButton(m_xBuilder->weld_button("newmodule"))
+    , m_xNewDlgButton(m_xBuilder->weld_button("newdialog"))
+    , m_xDelButton(m_xBuilder->weld_button("delete"))
+{
+    Size aSize(m_xBasicBox->get_approximate_digit_width() * 40,
+               m_xBasicBox->get_height_rows(14));
+    m_xBasicBox->set_size_request(aSize.Width(), aSize.Height());
+
+    m_xEditButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
+    m_xDelButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) );
+    m_xBasicBox->connect_changed( LINK( this, ObjectPage, BasicBoxHighlightHdl 
) );
 
     if( nMode & BrowseMode::Modules )
     {
-        m_pNewModButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
-        m_pNewDlgButton->Hide();
+        m_xNewModButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) 
);
+        m_xNewDlgButton->hide();
     }
     else if ( nMode & BrowseMode::Dialogs )
     {
-        m_pNewDlgButton->SetClickHdl( LINK( this, ObjectPage, ButtonHdl ) );
-        m_pNewModButton->Hide();
+        m_xNewDlgButton->connect_clicked( LINK( this, ObjectPage, ButtonHdl ) 
);
+        m_xNewModButton->hide();
     }
 
-    m_pBasicBox->SetDragDropMode( DragDropMode::CTRL_MOVE | 
DragDropMode::CTRL_COPY );
-    m_pBasicBox->EnableInplaceEditing(true);
-    m_pBasicBox->SetMode( nMode );
-    m_pBasicBox->SetStyle( WB_BORDER | WB_TABSTOP |
-                        WB_HASLINES | WB_HASLINESATROOT |
-                        WB_HASBUTTONS | WB_HASBUTTONSATROOT |
-                        WB_HSCROLL );
-    m_pBasicBox->ScanAllEntries();
+    m_xDropTarget.reset(new SbTreeListBoxDropTarget(*m_xBasicBox));
 
-    m_pEditButton->GrabFocus();
+    m_xBasicBox->connect_editing_started( LINK( this, ObjectPage, 
EditingEntryHdl ) );
+    m_xBasicBox->connect_editing_done( LINK( this, ObjectPage, EditedEntryHdl 
) );
+
+    m_xBasicBox->SetMode( nMode );
+    m_xBasicBox->ScanAllEntries();
+
+    m_xEditButton->grab_focus();
     CheckButtons();
 }
 
 ObjectPage::~ObjectPage()
 {
-    disposeOnce();
-}
-
-void ObjectPage::dispose()
-{
-    m_pBasicBox.clear();
-    m_pEditButton.clear();
-    m_pNewModButton.clear();
-    m_pNewDlgButton.clear();
-    m_pDelButton.clear();
-    pTabDlg.clear();
-    TabPage::dispose();
 }
 
 void ObjectPage::SetCurrentEntry (EntryDescriptor const & rDesc)
 {
-    m_pBasicBox->SetCurrentEntry( rDesc );
+    m_xBasicBox->SetCurrentEntry( rDesc );
 }
 
 void ObjectPage::ActivatePage()
 {
-    m_pBasicBox->UpdateEntries();
-}
-
-void ObjectPage::DeactivatePage()
-{
+    m_xBasicBox->UpdateEntries();
 }
 
 void ObjectPage::CheckButtons()
 {
     // enable/disable edit button
-    SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
-    EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+    std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
+    if (!m_xBasicBox->get_cursor(xCurEntry.get()))
+        xCurEntry.reset();
+    EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
     const ScriptDocument& aDocument( aDesc.GetDocument() );
     const OUString& aLibName( aDesc.GetLibName() );
     const OUString& aLibSubName( aDesc.GetLibSubName() );
     bool bVBAEnabled = aDocument.isInVBAMode();
-    BrowseMode nMode = m_pBasicBox->GetMode();
+    BrowseMode nMode = m_xBasicBox->GetMode();
 
-    sal_uInt16 nDepth = pCurEntry ? m_pBasicBox->GetModel()->GetDepth( 
pCurEntry ) : 0;
+    sal_uInt16 nDepth = xCurEntry ? m_xBasicBox->get_iter_depth(*xCurEntry) : 
0;
     if ( nDepth >= 2 )
     {
         if( bVBAEnabled && ( nMode & BrowseMode::Modules ) && ( nDepth == 2 ) )
-            m_pEditButton->Disable();
+            m_xEditButton->set_sensitive(false);
         else
-        m_pEditButton->Enable();
+            m_xEditButton->set_sensitive(true);
     }
     else
-        m_pEditButton->Disable();
+        m_xEditButton->set_sensitive(false);
 
     // enable/disable new module/dialog buttons
     LibraryLocation eLocation( aDesc.GetLocation() );
@@ -661,49 +620,48 @@ void ObjectPage::CheckButtons()
     }
     if ( bReadOnly || eLocation == LIBRARY_LOCATION_SHARE )
     {
-        m_pNewModButton->Disable();
-        m_pNewDlgButton->Disable();
+        m_xNewModButton->set_sensitive(false);
+        m_xNewDlgButton->set_sensitive(false);
     }
     else
     {
-        m_pNewModButton->Enable();
-        m_pNewDlgButton->Enable();
+        m_xNewModButton->set_sensitive(true);
+        m_xNewDlgButton->set_sensitive(true);
     }
 
     // enable/disable delete button
     if ( nDepth >= 2 && !bReadOnly && eLocation != LIBRARY_LOCATION_SHARE )
     {
         if( bVBAEnabled && ( nMode & BrowseMode::Modules ) && ( ( nDepth == 2 
) || aLibSubName == IDEResId(RID_STR_DOCUMENT_OBJECTS) ) )
-            m_pDelButton->Disable();
+            m_xDelButton->set_sensitive(false);
         else
-        m_pDelButton->Enable();
+            m_xDelButton->set_sensitive(true);
     }
     else
-        m_pDelButton->Disable();
+        m_xDelButton->set_sensitive(false);
 }
 
-IMPL_LINK( ObjectPage, BasicBoxHighlightHdl, SvTreeListBox*, pBox, void )
+IMPL_LINK_NOARG(ObjectPage, BasicBoxHighlightHdl, weld::TreeView&, void)
 {
-    if ( !pBox->IsSelected( pBox->GetHdlEntry() ) )
-        return;
-
     CheckButtons();
 }
 
-IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton, void )
+IMPL_LINK(ObjectPage, ButtonHdl, weld::Button&, rButton, void)
 {
-    if (pButton == m_pEditButton)
+    if (&rButton == m_xEditButton.get())
     {
         SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
         SfxRequest aRequest( SID_BASICIDE_APPEAR, SfxCallMode::SYNCHRON, aArgs 
);
         SfxGetpApp()->ExecuteSlot( aRequest );
 
         SfxDispatcher* pDispatcher = GetDispatcher();
-        SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
-        DBG_ASSERT( pCurEntry, "Entry?!" );
-        if ( m_pBasicBox->GetModel()->GetDepth( pCurEntry ) >= 2 )
+
+        std::unique_ptr<weld::TreeIter> 
xCurEntry(m_xBasicBox->make_iterator());
+        if (!m_xBasicBox->get_cursor(xCurEntry.get()))
+            return;
+        if (m_xBasicBox->get_iter_depth(*xCurEntry) >= 2)
         {
-            EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+            EntryDescriptor aDesc = 
m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
             if ( pDispatcher )
             {
                 OUString aModName( aDesc.GetName() );
@@ -713,24 +671,24 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton, void 
)
                     aModName = aModName.getToken( 0, ' ' );
                 }
                 SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDesc.GetDocument(), 
aDesc.GetLibName(),
-                                  aModName, TreeListBox::ConvertType( 
aDesc.GetType() ) );
+                                  aModName, SbTreeListBox::ConvertType( 
aDesc.GetType() ) );
                 pDispatcher->ExecuteList(SID_BASICIDE_SHOWSBX,
                         SfxCallMode::SYNCHRON, { &aSbxItem });
             }
         }
         else    // only Lib selected
         {
-            DBG_ASSERT( m_pBasicBox->GetModel()->GetDepth( pCurEntry ) == 1, 
"No LibEntry?!" );
+            DBG_ASSERT( m_xBasicBox->get_iter_depth(*xCurEntry) == 1, "No 
LibEntry?!" );
             ScriptDocument aDocument( 
ScriptDocument::getApplicationScriptDocument() );
-            SvTreeListEntry* pParentEntry = m_pBasicBox->GetParent( pCurEntry 
);
-            if ( pParentEntry )
+            std::unique_ptr<weld::TreeIter> 
xParentEntry(m_xBasicBox->make_iterator(xCurEntry.get()));
+            if (m_xBasicBox->iter_parent(*xParentEntry))
             {
-                DocumentEntry* pDocumentEntry = 
static_cast<DocumentEntry*>(pParentEntry->GetUserData());
+                DocumentEntry* pDocumentEntry = 
reinterpret_cast<DocumentEntry*>(m_xBasicBox->get_id(*xParentEntry).toInt64());
                 if (pDocumentEntry)
                     aDocument = pDocumentEntry->GetDocument();
             }
             SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( 
aDocument.getDocumentOrNull() ) );
-            OUString aLibName( m_pBasicBox->GetEntryText( pCurEntry ) );
+            OUString aLibName(m_xBasicBox->get_text(*xCurEntry));
             SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
             if ( pDispatcher )
             {
@@ -740,11 +698,11 @@ IMPL_LINK( ObjectPage, ButtonHdl, Button *, pButton, void 
)
         }
         EndTabDialog();
     }
-    else if (pButton == m_pNewModButton)
+    else if (&rButton == m_xNewModButton.get())
         NewModule();
-    else if (pButton == m_pNewDlgButton)
+    else if (&rButton == m_xNewDlgButton.get())
         NewDialog();
-    else if (pButton == m_pDelButton)
+    else if (&rButton == m_xDelButton.get())
         DeleteCurrent();
 }
 
@@ -752,8 +710,10 @@ bool ObjectPage::GetSelection( ScriptDocument& rDocument, 
OUString& rLibName )
 {
     bool bRet = false;
 
-    SvTreeListEntry* pCurEntry = m_pBasicBox->GetCurEntry();
-    EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(pCurEntry);
+    std::unique_ptr<weld::TreeIter> xCurEntry(m_xBasicBox->make_iterator());
+    if (!m_xBasicBox->get_cursor(xCurEntry.get()))
+        xCurEntry.reset();
+    EntryDescriptor aDesc = m_xBasicBox->GetEntryDescriptor(xCurEntry.get());
     rDocument = aDesc.GetDocument();
     rLibName = aDesc.GetLibName();
     if ( rLibName.isEmpty() )
@@ -804,8 +764,8 @@ void ObjectPage::NewModule()
 
     if ( GetSelection( aDocument, aLibName ) )
     {
-        createModImpl(GetFrameWeld(), aDocument,
-                      *m_pBasicBox, aLibName, true);
+        createModImpl(m_pDialog->getDialog(), aDocument,
+                      *m_xBasicBox, aLibName, OUString(), true);
     }
 }
 
@@ -818,7 +778,7 @@ void ObjectPage::NewDialog()
     {
         aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
 
-        NewObjectDialog aNewDlg(GetFrameWeld(), ObjectMode::Dialog, true);
+        NewObjectDialog aNewDlg(m_pDialog->getDialog(), ObjectMode::Dialog, 
true);
         aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName));
 

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to