weld SdCustomShowDlg and SdDefineCustomShowDlg

Change-Id: I44d40a286eb5d70982284a270f340653858d38cf
Reviewed-on: https://gerrit.libreoffice.org/54076
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx
index 65cfb1a..1cd4f51 100644
--- a/sd/inc/sdabstdlg.hxx
+++ b/sd/inc/sdabstdlg.hxx
@@ -180,7 +180,7 @@ public:

    virtual VclPtr<VclAbstractDialog>          CreateBreakDlg(weld::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount ) = 0;
    virtual VclPtr<AbstractCopyDlg>            CreateCopyDlg(vcl::Window* pWindow, const SfxItemSet& rInAttrs, ::sd::View* pView ) = 0;
    virtual VclPtr<AbstractSdCustomShowDlg>    CreateSdCustomShowDlg(vcl::Window* pWindow, SdDrawDocument& rDrawDoc) = 0;
    virtual VclPtr<AbstractSdCustomShowDlg>    CreateSdCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc) = 0;
    virtual VclPtr<SfxAbstractTabDialog>       CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) = 0;
    virtual VclPtr<SfxAbstractTabDialog>       CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) = 0;
    virtual VclPtr<AbstractSdModifyFieldDlg>   CreateSdModifyFieldDlg(vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet) = 0;
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index a306432..a4a0a04 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -307,8 +307,9 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
            SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
            CPPUNIT_ASSERT(pDrawDoc);

            auto const parent = getViewShell()->GetActiveWindow();
            pRetval = getSdAbstractDialogFactory()->CreateSdCustomShowDlg(
                getViewShell()->GetActiveWindow(),
                parent == nullptr ? nullptr : parent->GetFrameWeld(),
                *pDrawDoc);
            break;
        }
diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx
index 66fe068..060f314 100644
--- a/sd/source/ui/dlg/custsdlg.cxx
+++ b/sd/source/ui/dlg/custsdlg.cxx
@@ -32,36 +32,34 @@
#include <svtools/treelistentry.hxx>

// SdCustomShowDlg
SdCustomShowDlg::SdCustomShowDlg( vcl::Window* pWindow,
                            SdDrawDocument& rDrawDoc ) :
    ModalDialog     ( pWindow, "CustomSlideShows", "modules/simpress/ui/customslideshows.ui" ),
    rDoc            ( rDrawDoc ),
    pCustomShowList ( nullptr ),
    pCustomShow     ( nullptr ),
    bModified       ( false )
SdCustomShowDlg::SdCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc)
    : GenericDialogController(pWindow, "modules/simpress/ui/customslideshows.ui", "CustomSlideShows")
    , rDoc(rDrawDoc)
    , pCustomShowList(nullptr)
    , pCustomShow(nullptr)
    , bModified(false)
    , m_xLbCustomShows(m_xBuilder->weld_tree_view("customshowlist"))
    , m_xCbxUseCustomShow(m_xBuilder->weld_check_button("usecustomshows"))
    , m_xBtnNew(m_xBuilder->weld_button("new"))
    , m_xBtnEdit(m_xBuilder->weld_button("edit"))
    , m_xBtnRemove(m_xBuilder->weld_button("delete"))
    , m_xBtnCopy(m_xBuilder->weld_button("copy"))
    , m_xBtnHelp(m_xBuilder->weld_button("help"))
    , m_xBtnStartShow(m_xBuilder->weld_button("startshow"))
    , m_xBtnOK(m_xBuilder->weld_button("ok"))
{
    get( m_pBtnNew, "new" );
    get( m_pBtnEdit, "edit" );
    get( m_pBtnRemove, "delete" );
    get( m_pBtnCopy, "copy" );
    get( m_pBtnHelp, "help" );
    get( m_pBtnStartShow, "startshow" );
    get( m_pBtnOK, "ok" );
    get( m_pLbCustomShows, "customshowlist");
    get( m_pCbxUseCustomShow, "usecustomshows" );
    m_xLbCustomShows->set_size_request(m_xLbCustomShows->get_approximate_digit_width() * 32,
                                       m_xLbCustomShows->get_height_rows(8));

    m_pLbCustomShows->set_width_request(m_pLbCustomShows->approximate_char_width() * 32);
    m_pLbCustomShows->SetDropDownLineCount(8);
    Link<weld::Button&,void> aLink( LINK( this, SdCustomShowDlg, ClickButtonHdl ) );
    m_xBtnNew->connect_clicked( aLink );
    m_xBtnEdit->connect_clicked( aLink );
    m_xBtnRemove->connect_clicked( aLink );
    m_xBtnCopy->connect_clicked( aLink );
    m_xCbxUseCustomShow->connect_clicked( aLink );
    m_xLbCustomShows->connect_changed( LINK( this, SdCustomShowDlg, SelectListBoxHdl ) );

    Link<Button*,void> aLink( LINK( this, SdCustomShowDlg, ClickButtonHdl ) );
    m_pBtnNew->SetClickHdl( aLink );
    m_pBtnEdit->SetClickHdl( aLink );
    m_pBtnRemove->SetClickHdl( aLink );
    m_pBtnCopy->SetClickHdl( aLink );
    m_pCbxUseCustomShow->SetClickHdl( aLink );
    m_pLbCustomShows->SetSelectHdl( LINK( this, SdCustomShowDlg, SelectListBoxHdl ) );

    m_pBtnStartShow->SetClickHdl( LINK( this, SdCustomShowDlg, StartShowHdl ) ); // for test
    m_xBtnStartShow->connect_clicked( LINK( this, SdCustomShowDlg, StartShowHdl ) ); // for test

    // get CustomShow list of docs
    pCustomShowList = rDoc.GetCustomShowList();
@@ -73,56 +71,42 @@ SdCustomShowDlg::SdCustomShowDlg( vcl::Window* pWindow,
             pCustomShow != nullptr;
             pCustomShow = pCustomShowList->Next() )
        {
            m_pLbCustomShows->InsertEntry( pCustomShow->GetName() );
            m_xLbCustomShows->append_text(pCustomShow->GetName());
        }
        m_pLbCustomShows->SelectEntryPos( static_cast<sal_Int32>(nPosToSelect) );
        m_xLbCustomShows->select(nPosToSelect);
        pCustomShowList->Seek( nPosToSelect );
    }

    m_pCbxUseCustomShow->Check( pCustomShowList && rDoc.getPresentationSettings().mbCustomShow );
    m_xCbxUseCustomShow->set_active(pCustomShowList && rDoc.getPresentationSettings().mbCustomShow);

    CheckState();
}

SdCustomShowDlg::~SdCustomShowDlg()
{
    disposeOnce();
}

void SdCustomShowDlg::dispose()
{
    m_pLbCustomShows.clear();
    m_pCbxUseCustomShow.clear();
    m_pBtnNew.clear();
    m_pBtnEdit.clear();
    m_pBtnRemove.clear();
    m_pBtnCopy.clear();
    m_pBtnHelp.clear();
    m_pBtnStartShow.clear();
    m_pBtnOK.clear();
    ModalDialog::dispose();
}

void SdCustomShowDlg::CheckState()
{
    sal_Int32 nPos = m_pLbCustomShows->GetSelectedEntryPos();
    int nPos = m_xLbCustomShows->get_selected_index();

    bool bEnable = nPos != LISTBOX_ENTRY_NOTFOUND;
    m_pBtnEdit->Enable( bEnable );
    m_pBtnRemove->Enable( bEnable );
    m_pBtnCopy->Enable( bEnable );
    m_pCbxUseCustomShow->Enable( bEnable );
    m_pBtnStartShow->Enable();
    bool bEnable = nPos != -1;
    m_xBtnEdit->set_sensitive( bEnable );
    m_xBtnRemove->set_sensitive( bEnable );
    m_xBtnCopy->set_sensitive( bEnable );
    m_xCbxUseCustomShow->set_sensitive( bEnable );
    m_xBtnStartShow->set_sensitive(true);

    if (bEnable && pCustomShowList)
        pCustomShowList->Seek( nPos );
}

IMPL_LINK( SdCustomShowDlg, ClickButtonHdl, Button *, p, void )
IMPL_LINK( SdCustomShowDlg, ClickButtonHdl, weld::Button&, r, void )
{
    SelectHdl(p);
    SelectHdl(&r);
}
IMPL_LINK( SdCustomShowDlg, SelectListBoxHdl, ListBox&, rListBox, void )

IMPL_LINK( SdCustomShowDlg, SelectListBoxHdl, weld::TreeView&, rListBox, void )
{
    SelectHdl(&rListBox);
}
@@ -130,11 +114,11 @@ IMPL_LINK( SdCustomShowDlg, SelectListBoxHdl, ListBox&, rListBox, void )
void SdCustomShowDlg::SelectHdl(void const *p)
{
    // new CustomShow
    if( p == m_pBtnNew )
    if (p == m_xBtnNew.get())
    {
        pCustomShow = nullptr;
        ScopedVclPtrInstance< SdDefineCustomShowDlg > aDlg( this, rDoc, pCustomShow );
        if( aDlg->Execute() == RET_OK )
        SdDefineCustomShowDlg aDlg(m_xDialog.get(), rDoc, pCustomShow);
        if (aDlg.run() == RET_OK)
        {
            if( pCustomShow )
            {
@@ -143,59 +127,59 @@ void SdCustomShowDlg::SelectHdl(void const *p)

                pCustomShowList->push_back( pCustomShow );
                pCustomShowList->Last();
                m_pLbCustomShows->InsertEntry( pCustomShow->GetName() );
                m_pLbCustomShows->SelectEntry( pCustomShow->GetName() );
                m_xLbCustomShows->append_text( pCustomShow->GetName() );
                m_xLbCustomShows->select_text( pCustomShow->GetName() );
            }

            if( aDlg->IsModified() )
            if (aDlg.IsModified())
                bModified = true;
        }
        else if( pCustomShow )
            DELETEZ( pCustomShow );
    }
    // edit CustomShow
    else if( p == m_pBtnEdit )
    else if( p == m_xBtnEdit.get() )
    {
        sal_Int32 nPos = m_pLbCustomShows->GetSelectedEntryPos();
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
        int nPos = m_xLbCustomShows->get_selected_index();
        if (nPos != -1)
        {
            DBG_ASSERT( pCustomShowList, "pCustomShowList does not exist" );
            pCustomShow = (*pCustomShowList)[ nPos ];
            ScopedVclPtrInstance< SdDefineCustomShowDlg > aDlg( this, rDoc, pCustomShow );
            SdDefineCustomShowDlg aDlg(m_xDialog.get(), rDoc, pCustomShow);

            if( aDlg->Execute() == RET_OK )
            if (aDlg.run() == RET_OK)
            {
                if( pCustomShow )
                {
                    (*pCustomShowList)[nPos] = pCustomShow;
                    pCustomShowList->Seek( nPos );
                    m_pLbCustomShows->RemoveEntry( nPos );
                    m_pLbCustomShows->InsertEntry( pCustomShow->GetName(), nPos );
                    m_pLbCustomShows->SelectEntryPos( nPos );
                    pCustomShowList->Seek(nPos);
                    m_xLbCustomShows->remove(nPos);
                    m_xLbCustomShows->insert_text(pCustomShow->GetName(), nPos);
                    m_xLbCustomShows->select(nPos);
                }
                if( aDlg->IsModified() )
                if (aDlg.IsModified())
                    bModified = true;
            }
        }
    }
    // delete CustomShow
    else if( p == m_pBtnRemove )
    else if( p == m_xBtnRemove.get() )
    {
        sal_Int32 nPos = m_pLbCustomShows->GetSelectedEntryPos();
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
        int nPos = m_xLbCustomShows->get_selected_index();
        if (nPos != -1)
        {
            delete (*pCustomShowList)[nPos];
            pCustomShowList->erase( pCustomShowList->begin() + nPos );
            m_pLbCustomShows->RemoveEntry( nPos );
            m_pLbCustomShows->SelectEntryPos( nPos == 0 ? nPos : nPos - 1 );
            m_xLbCustomShows->remove(nPos);
            m_xLbCustomShows->select(nPos == 0 ? nPos : nPos - 1);
            bModified = true;
        }
    }
    // copy CustomShow
    else if( p == m_pBtnCopy )
    else if( p == m_xBtnCopy.get() )
    {
        sal_Int32 nPos = m_pLbCustomShows->GetSelectedEntryPos();
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
        int nPos = m_xLbCustomShows->get_selected_index();
        if (nPos != -1)
        {
            SdCustomShow* pShow = new SdCustomShow( *(*pCustomShowList)[nPos] );
            OUString aStr( pShow->GetName() );
@@ -244,21 +228,21 @@ void SdCustomShowDlg::SelectHdl(void const *p)

            pCustomShowList->push_back( pShow );
            pCustomShowList->Last();
            m_pLbCustomShows->InsertEntry( pShow->GetName() );
            m_pLbCustomShows->SelectEntry( pShow->GetName() );
            m_xLbCustomShows->append_text(pShow->GetName());
            m_xLbCustomShows->select_text(pShow->GetName());

            bModified = true;
        }
    }
    else if( p == m_pLbCustomShows )
    else if( p == m_xLbCustomShows.get() )
    {
        sal_Int32 nPos = m_pLbCustomShows->GetSelectedEntryPos();
        if( nPos != LISTBOX_ENTRY_NOTFOUND )
            pCustomShowList->Seek( nPos );
        int nPos = m_xLbCustomShows->get_selected_index();
        if (nPos != -1)
            pCustomShowList->Seek(nPos);

        bModified = true;
    }
    else if( p == m_pCbxUseCustomShow )
    else if( p == m_xCbxUseCustomShow.get() )
    {
        bModified = true;
    }
@@ -267,51 +251,46 @@ void SdCustomShowDlg::SelectHdl(void const *p)
}

// StartShow-Hdl
IMPL_LINK_NOARG(SdCustomShowDlg, StartShowHdl, Button*, void)
IMPL_LINK_NOARG(SdCustomShowDlg, StartShowHdl, weld::Button&, void)
{
    EndDialog( RET_YES );
    m_xDialog->response(RET_YES);
}

// CheckState
bool SdCustomShowDlg::IsCustomShow() const
{
    return( m_pCbxUseCustomShow->IsEnabled() && m_pCbxUseCustomShow->IsChecked() );
    return (m_xCbxUseCustomShow->get_sensitive() && m_xCbxUseCustomShow->get_active());
}

// SdDefineCustomShowDlg
SdDefineCustomShowDlg::SdDefineCustomShowDlg( vcl::Window* pWindow,
                        SdDrawDocument& rDrawDoc, SdCustomShow*& rpCS ) :
    ModalDialog     ( pWindow, "DefineCustomSlideShow", "modules/simpress/ui/definecustomslideshow.ui" ),
    rDoc            ( rDrawDoc ),
    rpCustomShow    ( rpCS ),
    bModified       ( false )
SdDefineCustomShowDlg::SdDefineCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc, SdCustomShow*& rpCS)
    : GenericDialogController(pWindow, "modules/simpress/ui/definecustomslideshow.ui", "DefineCustomSlideShow")
    , rDoc(rDrawDoc)
    , rpCustomShow(rpCS)
    , bModified(false)
    , m_xEdtName(m_xBuilder->weld_entry("customname"))
    , m_xLbPages(m_xBuilder->weld_tree_view("pages"))
    , m_xBtnAdd(m_xBuilder->weld_button("add"))
    , m_xBtnRemove(m_xBuilder->weld_button("remove"))
    , m_xLbCustomPages(m_xBuilder->weld_tree_view("custompages"))
    , m_xBtnOK(m_xBuilder->weld_button("ok"))
    , m_xBtnCancel(m_xBuilder->weld_button("cancel"))
    , m_xBtnHelp(m_xBuilder->weld_button("help"))
{
    get( m_pEdtName, "customname" );
    get( m_pLbPages, "pages" );
    get( m_pBtnAdd, "add" );
    get( m_pBtnRemove, "remove" );
    get( m_pLbCustomPages, "custompages" );
    get( m_pBtnOK, "ok" );
    get( m_pBtnCancel, "cancel" );
    get( m_pBtnHelp, "help" );
    Link<weld::Button&,void> aLink = LINK( this, SdDefineCustomShowDlg, ClickButtonHdl );
    m_xBtnAdd->connect_clicked( aLink );
    m_xBtnRemove->connect_clicked( aLink );
    m_xEdtName->connect_changed( LINK( this, SdDefineCustomShowDlg, ClickButtonEditHdl ) );
    m_xLbPages->connect_changed( LINK( this, SdDefineCustomShowDlg, ClickButtonHdl4 ) ); // because of status
    m_xLbCustomPages->connect_changed( LINK( this, SdDefineCustomShowDlg, ClickButtonHdl3 ) ); // because of status

    Link<Button*,void> aLink = LINK( this, SdDefineCustomShowDlg, ClickButtonHdl );
    m_pBtnAdd->SetClickHdl( aLink );
    m_pBtnRemove->SetClickHdl( aLink );
    m_pEdtName->SetModifyHdl( LINK( this, SdDefineCustomShowDlg, ClickButtonEditHdl ) );
    m_pLbPages->SetSelectHdl( LINK( this, SdDefineCustomShowDlg, ClickButtonHdl4 ) ); // because of status
    m_pLbCustomPages->SetSelectHdl( LINK( this, SdDefineCustomShowDlg, ClickButtonHdl3 ) ); // because of status
    m_xBtnOK->connect_clicked( LINK( this, SdDefineCustomShowDlg, OKHdl ) );

    m_pBtnOK->SetClickHdl( LINK( this, SdDefineCustomShowDlg, OKHdl ) );

    // Hack: m_pLbPages used to be MultiLB. We don't have VCL builder equivalent
    // of it yet. So enable selecting multiple items here
    m_pLbPages->EnableMultiSelection( true );
    m_xLbPages->set_selection_mode(true);

    // shape 'em a bit
    m_pLbPages->set_width_request(m_pLbPages->approximate_char_width() * 16);
    m_pLbCustomPages->set_width_request(m_pLbPages->approximate_char_width() * 16);
    m_pLbPages->SetDropDownLineCount(10);
    m_xLbPages->set_size_request(m_xLbPages->get_approximate_digit_width() * 24, m_xLbPages->get_height_rows(10));
    m_xLbCustomPages->set_size_request(m_xLbPages->get_approximate_digit_width() * 24, m_xLbCustomPages->get_height_rows(10));

    // fill Listbox with page names of Docs
    for( long nPage = 0;
@@ -319,128 +298,106 @@ SdDefineCustomShowDlg::SdDefineCustomShowDlg( vcl::Window* pWindow,
         nPage++ )
    {
        SdPage* pPage = rDoc.GetSdPage( static_cast<sal_uInt16>(nPage), PageKind::Standard );
        OUString aStr( pPage->GetName() );
        m_pLbPages->InsertEntry( aStr );
        m_xLbPages->append_text(pPage->GetName());
    }
    // aLbPages.SelectEntryPos( 0 );

    if( rpCustomShow )
    {
        aOldName = rpCustomShow->GetName();
        m_pEdtName->SetText( aOldName );
        m_xEdtName->set_text( aOldName );

        // fill ListBox with CustomShow pages
        for( SdCustomShow::PageVec::iterator it = rpCustomShow->PagesVector().begin();
             it != rpCustomShow->PagesVector().end(); ++it )
        {
            SvTreeListEntry* pEntry = m_pLbCustomPages->InsertEntry( (*it)->GetName() );
            pEntry->SetUserData( const_cast<SdPage*>(*it) );
            m_xLbCustomPages->append(OUString::number(reinterpret_cast<sal_uInt64>(*it)) ,(*it)->GetName(), "");
        }
    }
    else
    {
        rpCustomShow = new SdCustomShow;
        m_pEdtName->SetText( SdResId( STR_NEW_CUSTOMSHOW ) );
        m_pEdtName->SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
        rpCustomShow->SetName( m_pEdtName->GetText() );
        m_xEdtName->set_text( SdResId( STR_NEW_CUSTOMSHOW ) );
        m_xEdtName->select_region(0, -1);
        rpCustomShow->SetName( m_xEdtName->get_text() );
    }

    m_pLbCustomPages->SetDragDropMode( DragDropMode::CTRL_MOVE );
    m_pLbCustomPages->SetHighlightRange();

    m_pBtnOK->Enable( false );
    m_xBtnOK->set_sensitive( false );
    CheckState();
}

SdDefineCustomShowDlg::~SdDefineCustomShowDlg()
{
    disposeOnce();
}

void SdDefineCustomShowDlg::dispose()
{
    m_pEdtName.clear();
    m_pLbPages.clear();
    m_pBtnAdd.clear();
    m_pBtnRemove.clear();
    m_pLbCustomPages.clear();
    m_pBtnOK.clear();
    m_pBtnCancel.clear();
    m_pBtnHelp.clear();
    ModalDialog::dispose();
}

// CheckState
void SdDefineCustomShowDlg::CheckState()
{
    bool bPages = m_pLbPages->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND;
    //sal_Bool bCSPages = aLbCustomPages.GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND;
    bool bCSPages = m_pLbCustomPages->FirstSelected() != nullptr;
    bool bCount = m_pLbCustomPages->GetEntryCount() > 0;
    bool bPages = m_xLbPages->count_selected_rows() > 0;
    bool bCSPages = m_xLbCustomPages->get_selected_index() != -1;
    bool bCount = m_xLbCustomPages->n_children() > 0;

    m_pBtnOK->Enable( bCount );
    m_pBtnAdd->Enable( bPages );
    m_pBtnRemove->Enable( bCSPages );
    m_xBtnOK->set_sensitive( bCount );
    m_xBtnAdd->set_sensitive( bPages );
    m_xBtnRemove->set_sensitive( bCSPages );
}

IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl, Button*, p, void )
IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl, weld::Button&, rWidget, void )
{
    ClickButtonHdl2(p);
    ClickButtonHdl2(&rWidget);
}
IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl3, SvTreeListBox*, p, void )

IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl3, weld::TreeView&, rWidget, void )
{
    ClickButtonHdl2(p);
    ClickButtonHdl2(&rWidget);
}
IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl4, ListBox&, rListBox, void )

IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl4, weld::TreeView&, rListBox, void )
{
    ClickButtonHdl2(&rListBox);
}
IMPL_LINK( SdDefineCustomShowDlg, ClickButtonEditHdl, Edit&, rEdit, void )

IMPL_LINK( SdDefineCustomShowDlg, ClickButtonEditHdl, weld::Entry&, rEdit, void )
{
    ClickButtonHdl2(&rEdit);
}

// ButtonHdl()
void SdDefineCustomShowDlg::ClickButtonHdl2(void const * p)
{
    if( p == m_pBtnAdd )
    if( p == m_xBtnAdd.get() )
    {
        sal_Int32 nCount = m_pLbPages->GetSelectedEntryCount();
        if( nCount > 0 )
        auto aRows = m_xLbPages->get_selected_rows();
        if (!aRows.empty())
        {
            sal_uLong nPosCP = TREELIST_APPEND;
            SvTreeListEntry* pEntry = m_pLbCustomPages->FirstSelected();
            if( pEntry )
                nPosCP = m_pLbCustomPages->GetModel()->GetAbsPos( pEntry ) + 1;
            int nPosCP = m_xLbCustomPages->get_selected_index();
            if (nPosCP != -1)
                ++nPosCP;

            for( sal_Int32 i = 0; i < nCount; i++ )
            for (auto i : aRows)
            {
                OUString aStr = m_pLbPages->GetSelectedEntry( i );
                pEntry = m_pLbCustomPages->InsertEntry( aStr,
                                            nullptr, false, nPosCP );
                OUString aStr = m_xLbPages->get_text(i);
                SdPage* pPage = rDoc.GetSdPage(i, PageKind::Standard);
                m_xLbCustomPages->insert(nPosCP, OUString::number(reinterpret_cast<sal_uInt64>(pPage)), aStr, "");
                m_xLbCustomPages->select(nPosCP != -1 ? nPosCP : m_xLbCustomPages->n_children() - 1);

                m_pLbCustomPages->Select( pEntry );
                SdPage* pPage = rDoc.GetSdPage( static_cast<sal_uInt16>(m_pLbPages->
                                    GetSelectedEntryPos( i )), PageKind::Standard );
                pEntry->SetUserData( pPage );

                if( nPosCP != TREELIST_APPEND )
                    nPosCP++;
                if (nPosCP != -1)
                    ++nPosCP;
            }
            bModified = true;
        }
    }
    else if( p == m_pBtnRemove )
    else if (p == m_xBtnRemove.get())
    {
        SvTreeListEntry* pEntry = m_pLbCustomPages->FirstSelected();
        if( pEntry )
        int nPos = m_xLbCustomPages->get_selected_index();
        if (nPos != -1)
        {
            sal_uLong nPos = m_pLbCustomPages->GetModel()->GetAbsPos( pEntry );
            m_pLbCustomPages->GetModel()->Remove( m_pLbCustomPages->GetModel()->GetEntryAtAbsPos( nPos ) );

            m_xLbCustomPages->remove(nPos);
            m_xLbCustomPages->select(nPos == 0 ? nPos : nPos - 1);
            bModified = true;
        }
    }
    else if( p == m_pEdtName )
    else if( p == m_xEdtName.get() )
    {
        bModified = true;
    }
@@ -455,10 +412,10 @@ void SdDefineCustomShowDlg::ClickButtonHdl2(void const * p)
void SdDefineCustomShowDlg::CheckCustomShow()
{
    bool bDifferent = false;
    SvTreeListEntry* pEntry = nullptr;

    // compare count
    if( rpCustomShow->PagesVector().size() != m_pLbCustomPages->GetEntryCount() )
    size_t nCount = m_xLbCustomPages->n_children();
    if (rpCustomShow->PagesVector().size() != nCount)
    {
        rpCustomShow->PagesVector().clear();
        bDifferent = true;
@@ -468,11 +425,12 @@ void SdDefineCustomShowDlg::CheckCustomShow()
    if( !bDifferent )
    {
        SdCustomShow::PageVec::iterator it1 = rpCustomShow->PagesVector().begin();
        pEntry = m_pLbCustomPages->First();
        for( ; it1 != rpCustomShow->PagesVector().end() && pEntry != nullptr && !bDifferent;
             ++it1, pEntry = m_pLbCustomPages->Next( pEntry ) )
        size_t i = 0;
        for( ; it1 != rpCustomShow->PagesVector().end() && i < nCount && !bDifferent;
             ++it1, ++i )
        {
            if( *it1 != pEntry->GetUserData() )
            SdPage* pPage = reinterpret_cast<SdPage*>(m_xLbCustomPages->get_id(i).toUInt64());
            if (*it1 != pPage)
            {
                rpCustomShow->PagesVector().clear();
                bDifferent = true;
@@ -483,18 +441,16 @@ void SdDefineCustomShowDlg::CheckCustomShow()
    // set new page pointer
    if( bDifferent )
    {
        for( pEntry = m_pLbCustomPages->First();
             pEntry != nullptr;
             pEntry = m_pLbCustomPages->Next( pEntry ) )
        for (size_t i = 0; i < nCount; ++i)
        {
            SdPage* pPage = static_cast<SdPage*>(pEntry->GetUserData());
            rpCustomShow->PagesVector().push_back( pPage );
            SdPage* pPage = reinterpret_cast<SdPage*>(m_xLbCustomPages->get_id(i).toUInt64());
            rpCustomShow->PagesVector().push_back(pPage);
        }
        bModified = true;
    }

    // compare name and set name if necessary
    OUString aStr( m_pEdtName->GetText() );
    OUString aStr( m_xEdtName->get_text() );
    if( rpCustomShow->GetName() != aStr )
    {
        rpCustomShow->SetName( aStr );
@@ -503,14 +459,14 @@ void SdDefineCustomShowDlg::CheckCustomShow()
}

// OK-Hdl
IMPL_LINK_NOARG(SdDefineCustomShowDlg, OKHdl, Button*, void)
IMPL_LINK_NOARG(SdDefineCustomShowDlg, OKHdl, weld::Button&, void)
{
    // check name...
    bool bDifferent = true;
    SdCustomShowList* pCustomShowList = rDoc.GetCustomShowList();
    if( pCustomShowList )
    {
        OUString aName( m_pEdtName->GetText() );
        OUString aName( m_xEdtName->get_text() );
        SdCustomShow* pCustomShow;

        long nPosToSelect = pCustomShowList->GetCurPos();
@@ -528,15 +484,15 @@ IMPL_LINK_NOARG(SdDefineCustomShowDlg, OKHdl, Button*, void)
    {
        CheckCustomShow();

        EndDialog( RET_OK );
        m_xDialog->response(RET_OK);
    }
    else
    {
        std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(),
        std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_xDialog.get(),
                                                   VclMessageType::Warning, VclButtonsType::Ok,
                                                   SdResId(STR_WARN_NAME_DUPLICATE)));
        xWarn->run();
        m_pEdtName->GrabFocus();
        m_xEdtName->grab_focus();
    }
}

diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index af5f634..180d63d 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -48,7 +48,12 @@

IMPL_ABSTDLG_BASE(SdVclAbstractDialog_Impl);
IMPL_ABSTDLG_BASE(AbstractCopyDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSdCustomShowDlg_Impl);

short AbstractSdCustomShowDlg_Impl::Execute()
{
    return m_xDlg->run();
}

IMPL_ABSTDLG_BASE(SdAbstractTabDialog_Impl);
IMPL_ABSTDLG_BASE(SdPresLayoutTemplateDlg_Impl);
IMPL_ABSTDLG_BASE(AbstractSdModifyFieldDlg_Impl);
@@ -109,12 +114,12 @@ void AbstractCopyDlg_Impl::GetAttr( SfxItemSet& rOutAttrs )

bool AbstractSdCustomShowDlg_Impl::IsModified() const
{
    return pDlg->IsModified();
    return m_xDlg->IsModified();
}

bool AbstractSdCustomShowDlg_Impl::IsCustomShow() const
{
    return pDlg->IsCustomShow();
    return m_xDlg->IsCustomShow();
}

void SdAbstractTabDialog_Impl::SetCurPageId( const OString& rName )
@@ -322,9 +327,9 @@ VclPtr<AbstractCopyDlg> SdAbstractDialogFactory_Impl::CreateCopyDlg(vcl::Window*
    return VclPtr<AbstractCopyDlg_Impl>::Create( VclPtr<::sd::CopyDlg>::Create( pParent, rInAttrs, pView ) );
}

VclPtr<AbstractSdCustomShowDlg> SdAbstractDialogFactory_Impl::CreateSdCustomShowDlg(vcl::Window* pParent, SdDrawDocument& rDrawDoc )
VclPtr<AbstractSdCustomShowDlg> SdAbstractDialogFactory_Impl::CreateSdCustomShowDlg(weld::Window* pParent, SdDrawDocument& rDrawDoc )
{
    return VclPtr<AbstractSdCustomShowDlg_Impl>::Create( VclPtr<SdCustomShowDlg>::Create(pParent, rDrawDoc) );
    return VclPtr<AbstractSdCustomShowDlg_Impl>::Create(new SdCustomShowDlg(pParent, rDrawDoc));
}

VclPtr<SfxAbstractTabDialog>  SdAbstractDialogFactory_Impl::CreateSdTabCharDialog(vcl::Window* pParent, const SfxItemSet* pAttr, SfxObjectShell* pDocShell )
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 66ba0a9..8008f4c 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -91,7 +91,14 @@ class AbstractCopyDlg_Impl : public AbstractCopyDlg
class SdCustomShowDlg;
class AbstractSdCustomShowDlg_Impl : public AbstractSdCustomShowDlg
{
    DECL_ABSTDLG_BASE(AbstractSdCustomShowDlg_Impl,SdCustomShowDlg)
private:
    std::unique_ptr<SdCustomShowDlg> m_xDlg;
public:
    AbstractSdCustomShowDlg_Impl(SdCustomShowDlg* pDlg)
        : m_xDlg(pDlg)
    {
    }
    virtual short       Execute() override;
    virtual bool        IsModified() const override ;
    virtual bool        IsCustomShow() const override ;
};
@@ -255,7 +262,7 @@ public:

    virtual VclPtr<VclAbstractDialog>          CreateBreakDlg(weld::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override;
    virtual VclPtr<AbstractCopyDlg>            CreateCopyDlg(vcl::Window* pParent, const SfxItemSet& rInAttrs, ::sd::View* pView) override;
    virtual VclPtr<AbstractSdCustomShowDlg>    CreateSdCustomShowDlg(vcl::Window* pParent, SdDrawDocument& rDrawDoc) override;
    virtual VclPtr<AbstractSdCustomShowDlg>    CreateSdCustomShowDlg(weld::Window* pParent, SdDrawDocument& rDrawDoc) override;
    virtual VclPtr<SfxAbstractTabDialog>       CreateSdTabCharDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell) override;
    virtual VclPtr<SfxAbstractTabDialog>       CreateSdTabPageDialog(vcl::Window* pWindow, const SfxItemSet* pAttr, SfxObjectShell* pDocShell, bool bAreaPage) override;
    virtual VclPtr<AbstractSdModifyFieldDlg>   CreateSdModifyFieldDlg( vcl::Window* pWindow, const SvxFieldData* pInField, const SfxItemSet& rSet ) override;
diff --git a/sd/source/ui/func/fucushow.cxx b/sd/source/ui/func/fucushow.cxx
index e5d1877..df6e0f9 100644
--- a/sd/source/ui/func/fucushow.cxx
+++ b/sd/source/ui/func/fucushow.cxx
@@ -55,7 +55,8 @@ rtl::Reference<FuPoor> FuCustomShowDlg::Create( ViewShell* pViewSh, ::sd::Window
void FuCustomShowDlg::DoExecute( SfxRequest& )
{
    SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
    ScopedVclPtr<AbstractSdCustomShowDlg> pDlg(pFact ? pFact->CreateSdCustomShowDlg(mpViewShell->GetActiveWindow(), *mpDoc) : nullptr);
    vcl::Window* pWin = mpViewShell->GetActiveWindow();
    ScopedVclPtr<AbstractSdCustomShowDlg> pDlg(pFact ? pFact->CreateSdCustomShowDlg(pWin ? pWin->GetFrameWeld() : nullptr, *mpDoc) : nullptr);
    if( pDlg )
    {
        sal_uInt16 nRet = pDlg->Execute();
diff --git a/sd/source/ui/inc/custsdlg.hxx b/sd/source/ui/inc/custsdlg.hxx
index 5a40666..c02a9df 100644
--- a/sd/source/ui/inc/custsdlg.hxx
+++ b/sd/source/ui/inc/custsdlg.hxx
@@ -20,83 +20,75 @@
#ifndef INCLUDED_SD_SOURCE_UI_INC_CUSTSDLG_HXX
#define INCLUDED_SD_SOURCE_UI_INC_CUSTSDLG_HXX

#include <vcl/button.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/fixed.hxx>
#include <vcl/edit.hxx>
#include <svtools/treelistbox.hxx>
#include <vcl/dialog.hxx>
#include <vcl/weld.hxx>

class SdDrawDocument;
class SdCustomShow;
class SdCustomShowList;

class SdCustomShowDlg : public ModalDialog
class SdCustomShowDlg : public weld::GenericDialogController
{
private:
    VclPtr<ListBox>         m_pLbCustomShows;
    VclPtr<CheckBox>        m_pCbxUseCustomShow;
    VclPtr<PushButton>      m_pBtnNew;
    VclPtr<PushButton>      m_pBtnEdit;
    VclPtr<PushButton>      m_pBtnRemove;
    VclPtr<PushButton>      m_pBtnCopy;
    VclPtr<HelpButton>      m_pBtnHelp;
    VclPtr<PushButton>      m_pBtnStartShow;
    VclPtr<OKButton>        m_pBtnOK;

    SdDrawDocument& rDoc;
    SdCustomShowList* pCustomShowList;
    SdCustomShow*   pCustomShow;
    bool            bModified;

    std::unique_ptr<weld::TreeView> m_xLbCustomShows;
    std::unique_ptr<weld::CheckButton> m_xCbxUseCustomShow;
    std::unique_ptr<weld::Button> m_xBtnNew;
    std::unique_ptr<weld::Button> m_xBtnEdit;
    std::unique_ptr<weld::Button> m_xBtnRemove;
    std::unique_ptr<weld::Button> m_xBtnCopy;
    std::unique_ptr<weld::Button> m_xBtnHelp;
    std::unique_ptr<weld::Button> m_xBtnStartShow;
    std::unique_ptr<weld::Button> m_xBtnOK;

    void            CheckState();

    DECL_LINK( ClickButtonHdl, Button*, void );
    DECL_LINK( SelectListBoxHdl, ListBox&, void );
    DECL_LINK( StartShowHdl, Button*, void );
    DECL_LINK( ClickButtonHdl, weld::Button&, void );
    DECL_LINK( SelectListBoxHdl, weld::TreeView&, void );
    DECL_LINK( StartShowHdl, weld::Button&, void );
    void SelectHdl(void const *);

public:
                SdCustomShowDlg( vcl::Window* pWindow, SdDrawDocument& rDrawDoc );
                virtual ~SdCustomShowDlg() override;
    virtual void dispose() override;
    SdCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc);
    virtual ~SdCustomShowDlg() override;
    bool         IsModified() const { return bModified; }
    bool         IsCustomShow() const;
};

class SdDefineCustomShowDlg : public ModalDialog
class SdDefineCustomShowDlg : public weld::GenericDialogController
{
private:
    VclPtr<Edit>            m_pEdtName;
    VclPtr<ListBox>         m_pLbPages;
    VclPtr<PushButton>      m_pBtnAdd;
    VclPtr<PushButton>      m_pBtnRemove;
    VclPtr<SvTreeListBox>   m_pLbCustomPages;
    VclPtr<OKButton>        m_pBtnOK;
    VclPtr<CancelButton>    m_pBtnCancel;
    VclPtr<HelpButton>      m_pBtnHelp;

    SdDrawDocument& rDoc;
    SdCustomShow*&  rpCustomShow;
    bool            bModified;
    OUString        aOldName;

    std::unique_ptr<weld::Entry> m_xEdtName;
    std::unique_ptr<weld::TreeView> m_xLbPages;
    std::unique_ptr<weld::Button> m_xBtnAdd;
    std::unique_ptr<weld::Button> m_xBtnRemove;
    std::unique_ptr<weld::TreeView> m_xLbCustomPages;
    std::unique_ptr<weld::Button> m_xBtnOK;
    std::unique_ptr<weld::Button> m_xBtnCancel;
    std::unique_ptr<weld::Button> m_xBtnHelp;

    void            CheckState();
    void            CheckCustomShow();

    DECL_LINK( ClickButtonHdl, Button*, void );
    DECL_LINK( ClickButtonEditHdl, Edit&, void );
    DECL_LINK( ClickButtonHdl3, SvTreeListBox*, void );
    DECL_LINK( ClickButtonHdl4, ListBox&, void );
    DECL_LINK( OKHdl, Button*, void );
    DECL_LINK( ClickButtonHdl, weld::Button&, void );
    DECL_LINK( ClickButtonEditHdl, weld::Entry&, void );
    DECL_LINK( ClickButtonHdl3, weld::TreeView&, void );
    DECL_LINK( ClickButtonHdl4, weld::TreeView&, void );
    DECL_LINK( OKHdl, weld::Button&, void );
    void ClickButtonHdl2(void const *);

public:

                    SdDefineCustomShowDlg( vcl::Window* pWindow,
                            SdDrawDocument& rDrawDoc, SdCustomShow*& rpCS );
                    virtual ~SdDefineCustomShowDlg() override;
    virtual void    dispose() override;
    SdDefineCustomShowDlg(weld::Window* pWindow, SdDrawDocument& rDrawDoc, SdCustomShow*& rpCS);
    virtual ~SdDefineCustomShowDlg() override;

    bool            IsModified() const { return bModified; }
};
diff --git a/sd/uiconfig/simpress/ui/customslideshows.ui b/sd/uiconfig/simpress/ui/customslideshows.ui
index 07343b5..8397a58 100644
--- a/sd/uiconfig/simpress/ui/customslideshows.ui
+++ b/sd/uiconfig/simpress/ui/customslideshows.ui
@@ -1,11 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sd">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
  <object class="GtkDialog" id="CustomSlideShows">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="customslideshows|CustomSlideShows">Custom Slide Shows</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
@@ -83,13 +94,37 @@
                <property name="orientation">vertical</property>
                <property name="spacing">6</property>
                <child>
                  <object class="GtkTreeView" id="customshowlist:border">
                  <object class="GtkScrolledWindow">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <child internal-child="selection">
                      <object class="GtkTreeSelection" id="treeview-selection1"/>
                    <property name="shadow_type">in</property>
                    <child>
                      <object class="GtkTreeView" id="customshowlist">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="model">liststore1</property>
                        <property name="headers_visible">False</property>
                        <property name="headers_clickable">False</property>
                        <property name="search_column">0</property>
                        <property name="show_expanders">False</property>
                        <child internal-child="selection">
                          <object class="GtkTreeSelection" id="treeview-selection1"/>
                        </child>
                        <child>
                          <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                            <child>
                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
                              <attributes>
                                <attribute name="text">0</attribute>
                              </attributes>
                            </child>
                          </object>
                        </child>
                      </object>
                    </child>
                  </object>
                  <packing>
@@ -210,5 +245,8 @@
      <action-widget response="0">startshow</action-widget>
      <action-widget response="-5">ok</action-widget>
    </action-widgets>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>
diff --git a/sd/uiconfig/simpress/ui/definecustomslideshow.ui b/sd/uiconfig/simpress/ui/definecustomslideshow.ui
index 22bbaad..e6dbd89 100644
--- a/sd/uiconfig/simpress/ui/definecustomslideshow.ui
+++ b/sd/uiconfig/simpress/ui/definecustomslideshow.ui
@@ -1,12 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sd">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
  <object class="GtkListStore" id="liststore2">
    <columns>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
  <object class="GtkDialog" id="DefineCustomSlideShow">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="definecustomslideshow|DefineCustomSlideShow">Define Custom Slide Show</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child internal-child="vbox">
      <object class="GtkBox" id="dialog-vbox1">
@@ -132,7 +150,7 @@
                    <property name="halign">start</property>
                    <property name="label" translatable="yes" context="definecustomslideshow|label2">_Existing slides:</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">pages:border</property>
                    <property name="mnemonic_widget">pages</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
@@ -146,7 +164,7 @@
                    <property name="halign">start</property>
                    <property name="label" translatable="yes" context="definecustomslideshow|label3">_Selected slides:</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">custompages:border</property>
                    <property name="mnemonic_widget">custompages</property>
                  </object>
                  <packing>
                    <property name="left_attach">2</property>
@@ -154,14 +172,38 @@
                  </packing>
                </child>
                <child>
                  <object class="GtkTreeView" id="pages:border">
                  <object class="GtkScrolledWindow">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <child internal-child="selection">
                      <object class="GtkTreeSelection" id="treeview-selection1">
                        <property name="mode">multiple</property>
                    <property name="shadow_type">in</property>
                    <child>
                      <object class="GtkTreeView" id="pages">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="model">liststore1</property>
                        <property name="headers_visible">False</property>
                        <property name="headers_clickable">False</property>
                        <property name="search_column">0</property>
                        <property name="show_expanders">False</property>
                        <child internal-child="selection">
                          <object class="GtkTreeSelection" id="treeview-selection1">
                            <property name="mode">multiple</property>
                          </object>
                        </child>
                        <child>
                          <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                            <child>
                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
                              <attributes>
                                <attribute name="text">0</attribute>
                              </attributes>
                            </child>
                          </object>
                        </child>
                      </object>
                    </child>
                  </object>
@@ -171,13 +213,38 @@
                  </packing>
                </child>
                <child>
                  <object class="svtlo-SvTreeListBox" id="custompages:border">
                  <object class="GtkScrolledWindow">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <child internal-child="selection">
                      <object class="GtkTreeSelection" id="Tree List-selection1"/>
                    <property name="shadow_type">in</property>
                    <child>
                      <object class="GtkTreeView" id="custompages">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="model">liststore2</property>
                        <property name="headers_visible">False</property>
                        <property name="headers_clickable">False</property>
                        <property name="reorderable">True</property>
                        <property name="search_column">0</property>
                        <property name="show_expanders">False</property>
                        <child internal-child="selection">
                          <object class="GtkTreeSelection" id="treeview-selection2"/>
                        </child>
                        <child>
                          <object class="GtkTreeViewColumn" id="treeviewcolumn2">
                            <child>
                              <object class="GtkCellRendererText" id="cellrenderertext2"/>
                              <attributes>
                                <attribute name="text">0</attribute>
                              </attributes>
                            </child>
                          </object>
                        </child>
                      </object>
                    </child>
                  </object>
                  <packing>
@@ -248,10 +315,13 @@
      <action-widget response="-6">cancel</action-widget>
      <action-widget response="-11">help</action-widget>
    </action-widgets>
    <child>
      <placeholder/>
    </child>
  </object>
  <object class="GtkSizeGroup" id="sizegroup1">
    <widgets>
      <widget name="custompages:border"/>
      <widget name="custompages"/>
    </widgets>
  </object>
</interface>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index f0cbf0e..7b972ce 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3128,17 +3128,17 @@ public:
    {
        assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen");
        disable_notify_events();
        if (pos != -1)
        if (pos == -1 || (pos == 0 && n_children() == 0))
        {
            gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(m_pTreeView));
        }
        else
        {
            GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
            gtk_tree_selection_select_path(gtk_tree_view_get_selection(m_pTreeView), path);
            gtk_tree_view_scroll_to_cell(m_pTreeView, path, nullptr, false, 0, 0);
            gtk_tree_path_free(path);
        }
        else
        {
            gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(m_pTreeView));
        }
        enable_notify_events();
    }

@@ -3146,16 +3146,16 @@ public:
    {
        assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen");
        disable_notify_events();
        if (pos != -1)
        if (pos == -1 || (pos == 0 && n_children() == 0))
        {
            gtk_tree_selection_select_all(gtk_tree_view_get_selection(m_pTreeView));
        }
        else
        {
            GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
            gtk_tree_selection_unselect_path(gtk_tree_view_get_selection(m_pTreeView), path);
            gtk_tree_path_free(path);
        }
        else
        {
            gtk_tree_selection_select_all(gtk_tree_view_get_selection(m_pTreeView));
        }
        enable_notify_events();
    }