[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/vcl sfx2/source sfx2/uiconfig vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Nov 26 10:31:22 UTC 2018


 include/vcl/weld.hxx                 |    1 
 sfx2/source/dialog/versdlg.cxx       |  268 +++++++++++++++++------------------
 sfx2/source/doc/objserv.cxx          |    6 
 sfx2/source/inc/versdlg.hxx          |   42 ++---
 sfx2/uiconfig/ui/versionsofdialog.ui |  176 ++++++++++++----------
 vcl/source/app/salvtables.cxx        |   15 +
 vcl/source/treelist/treelistbox.cxx  |    4 
 vcl/unx/gtk3/gtk3gtkinst.cxx         |   24 +++
 8 files changed, 295 insertions(+), 241 deletions(-)

New commits:
commit d86d564290b9bff664ff871e77e11f3f5f307172
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Nov 25 20:08:41 2018 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Nov 26 11:31:01 2018 +0100

    weld SfxVersionDialog
    
    Change-Id: I0b69192a6eab9dadac892968a4a2d4fa3d9febde
    Reviewed-on: https://gerrit.libreoffice.org/64023
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index ae7ed7505b1c..fa2ba7bcd03a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -505,6 +505,7 @@ public:
     virtual int get_height_rows(int nRows) const = 0;
 
     virtual void set_column_fixed_widths(const std::vector<int>& rWidths) = 0;
+    virtual OUString get_column_title(int nColumn) const = 0;
 
     virtual void set_selection_mode(bool bMultiple) = 0;
     virtual int count_selected_rows() const = 0;
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index ddd974ec5a93..7ceb3b7be93f 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -133,13 +133,6 @@ void SfxVersionsTabListBox_Impl::KeyInput(const KeyEvent& rKeyEvent)
     }
 }
 
-void SfxVersionsTabListBox_Impl::Resize()
-{
-    SvSimpleTable::Resize();
-    if (isInitialLayout(this))
-        setColSizes();
-}
-
 void SfxVersionsTabListBox_Impl::setColSizes()
 {
     HeaderBar &rBar = GetTheHeaderBar();
@@ -177,69 +170,85 @@ void SfxVersionsTabListBox_Impl::setColSizes()
     SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions, MapUnit::MapPixel);
 }
 
-SfxVersionDialog::SfxVersionDialog ( SfxViewFrame* pVwFrame, bool bIsSaveVersionOnClose )
-    : SfxModalDialog(nullptr, "VersionsOfDialog", "sfx/ui/versionsofdialog.ui")
-    , pViewFrame(pVwFrame)
-    , m_bIsSaveVersionOnClose(bIsSaveVersionOnClose)
+void SfxVersionsTabListBox_Impl::Resize()
 {
-    get(m_pSaveButton, "save");
-    get(m_pSaveCheckBox, "always");
-    get(m_pOpenButton, "open");
-    get(m_pViewButton, "show");
-    get(m_pDeleteButton, "delete");
-    get(m_pCompareButton, "compare");
-    get(m_pCmisButton, "cmis");
+    SvSimpleTable::Resize();
+    if (isInitialLayout(this))
+        setColSizes();
+}
 
-    SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("versions");
-    Size aControlSize(260, 114);
-    aControlSize = pContainer->LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
-    pContainer->set_width_request(aControlSize.Width());
-    pContainer->set_height_request(aControlSize.Height());
+void SfxVersionDialog::setColSizes()
+{
+    // recalculate the datetime column width
+    int nWidestTime(m_xVersionBox->get_pixel_size(getWidestTime(Application::GetSettings().GetLocaleDataWrapper())).Width());
+    int nW1 = m_xVersionBox->get_pixel_size(m_xVersionBox->get_column_title(1)).Width();
 
-    m_pVersionBox = VclPtr<SfxVersionsTabListBox_Impl>::Create(*pContainer, WB_TABSTOP);
+    int nMax = std::max(nWidestTime, nW1) + 12; // max width + a little offset
+    const int nRest = m_xVersionBox->get_preferred_size().Width() - nMax;
 
-    Link<Button*,void> aClickLink = LINK( this, SfxVersionDialog, ButtonHdl_Impl );
-    m_pViewButton->SetClickHdl ( aClickLink );
-    m_pSaveButton->SetClickHdl ( aClickLink );
-    m_pDeleteButton->SetClickHdl ( aClickLink );
-    m_pCompareButton->SetClickHdl ( aClickLink );
-    m_pOpenButton->SetClickHdl ( aClickLink );
-    m_pSaveCheckBox->SetClickHdl ( aClickLink );
-    m_pCmisButton->SetClickHdl ( aClickLink );
+    std::set<OUString> aAuthors;
+    SfxVersionInfo aInfo;
+    aAuthors.insert(SvtUserOptions().GetFullName());
 
-    m_pVersionBox->SetSelectHdl( LINK( this, SfxVersionDialog, SelectHdl_Impl ) );
-    m_pVersionBox->SetDoubleClickHdl( LINK( this, SfxVersionDialog, DClickHdl_Impl ) );
+    for (int i = 0; i < m_xVersionBox->n_children(); ++i)
+    {
+        aAuthors.insert(reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(i).toInt64())->aAuthor);
+    }
 
-    m_pVersionBox->GrabFocus();
-    m_pVersionBox->SetStyle( m_pVersionBox->GetStyle() | WB_HSCROLL | WB_CLIPCHILDREN );
-    m_pVersionBox->SetSelectionMode( SelectionMode::Single );
+    int nMaxAuthorWidth = nRest/4;
+    for (auto const& author : aAuthors)
+    {
+        nMaxAuthorWidth = std::max<int>(nMaxAuthorWidth, m_xVersionBox->get_pixel_size(author).Width());
+        if (nMaxAuthorWidth > nRest/2)
+        {
+            nMaxAuthorWidth = nRest/2;
+            break;
+        }
+    }
 
-    long aTabPositions[] = { 0, 0, 0 };
-    m_pVersionBox->SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aTabPositions), aTabPositions);
-    OUString sHeader1(get<FixedText>("datetime")->GetText());
-    OUString sHeader2(get<FixedText>("savedby")->GetText());
-    OUString sHeader3(get<FixedText>("comments")->GetText());
-    OUString sHeader = sHeader1 + "\t" + sHeader2 + "\t" + sHeader3;
-    m_pVersionBox->InsertHeaderEntry(sHeader);
+    std::vector<int> aWidths;
+    aWidths.push_back(nMax);
+    aWidths.push_back(nMaxAuthorWidth);
+    m_xVersionBox->set_column_fixed_widths(aWidths);
+}
 
-    HeaderBar &rBar = m_pVersionBox->GetTheHeaderBar();
-    HeaderBarItemBits nBits = rBar.GetItemBits(1) | HeaderBarItemBits::FIXEDPOS | HeaderBarItemBits::FIXED;
-    nBits &= ~HeaderBarItemBits::CLICKABLE;
-    rBar.SetItemBits(1, nBits);
-    rBar.SetItemBits(2, nBits);
-    rBar.SetItemBits(3, nBits);
+SfxVersionDialog::SfxVersionDialog(weld::Window* pParent, SfxViewFrame* pVwFrame, bool bIsSaveVersionOnClose)
+    : SfxDialogController(pParent, "sfx/ui/versionsofdialog.ui", "VersionsOfDialog")
+    , m_pViewFrame(pVwFrame)
+    , m_bIsSaveVersionOnClose(bIsSaveVersionOnClose)
+    , m_xSaveButton(m_xBuilder->weld_button("save"))
+    , m_xSaveCheckBox(m_xBuilder->weld_check_button("always"))
+    , m_xOpenButton(m_xBuilder->weld_button("open"))
+    , m_xViewButton(m_xBuilder->weld_button("show"))
+    , m_xDeleteButton(m_xBuilder->weld_button("delete"))
+    , m_xCompareButton(m_xBuilder->weld_button("compare"))
+    , m_xCmisButton(m_xBuilder->weld_button("cmis"))
+    , m_xVersionBox(m_xBuilder->weld_tree_view("versions"))
+{
+    m_xVersionBox->set_size_request(m_xVersionBox->get_approximate_digit_width() * 90,
+                                    m_xVersionBox->get_height_rows(15));
+    setColSizes();
 
-    m_pVersionBox->Resize();       // OS: Hack for correct selection
+    Link<weld::Button&,void> aClickLink = LINK( this, SfxVersionDialog, ButtonHdl_Impl );
+    m_xViewButton->connect_clicked( aClickLink );
+    m_xSaveButton->connect_clicked( aClickLink );
+    m_xDeleteButton->connect_clicked( aClickLink );
+    m_xCompareButton->connect_clicked( aClickLink );
+    m_xOpenButton->connect_clicked( aClickLink );
+    m_xSaveCheckBox->connect_clicked( aClickLink );
+    m_xCmisButton->connect_clicked( aClickLink );
 
+    m_xVersionBox->connect_changed( LINK( this, SfxVersionDialog, SelectHdl_Impl ) );
+    m_xVersionBox->connect_row_activated( LINK( this, SfxVersionDialog, DClickHdl_Impl ) );
+
+    m_xVersionBox->grab_focus();
 
     // set dialog title (filename or docinfo title)
-    OUString sText = GetText();
-    sText = sText + " " + pViewFrame->GetObjectShell()->GetTitle();
-    SetText( sText );
+    OUString sText = m_xDialog->get_title();
+    sText = sText + " " + m_pViewFrame->GetObjectShell()->GetTitle();
+    m_xDialog->set_title(sText);
 
     Init_Impl();
-
-    m_pVersionBox->setColSizes();
 }
 
 static OUString ConvertWhiteSpaces_Impl( const OUString& rText )
@@ -268,71 +277,56 @@ static OUString ConvertWhiteSpaces_Impl( const OUString& rText )
 
 void SfxVersionDialog::Init_Impl()
 {
-    SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
+    SfxObjectShell *pObjShell = m_pViewFrame->GetObjectShell();
     SfxMedium* pMedium = pObjShell->GetMedium();
     uno::Sequence < util::RevisionTag > aVersions = pMedium->GetVersionList( true );
     m_pTable.reset(new SfxVersionTableDtor( aVersions ));
-    for ( size_t n = 0; n < m_pTable->size(); ++n )
+    for (size_t n = 0; n < m_pTable->size(); ++n)
     {
         SfxVersionInfo *pInfo = m_pTable->at( n );
         OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper());
-        aEntry += "\t";
-        aEntry += pInfo->aAuthor;
-        aEntry += "\t";
-        aEntry += ConvertWhiteSpaces_Impl( pInfo->aComment );
-        SvTreeListEntry *pEntry = m_pVersionBox->InsertEntry( aEntry );
-        pEntry->SetUserData( pInfo );
+        m_xVersionBox->append(OUString::number(reinterpret_cast<sal_Int64>(pInfo)), aEntry);
+        auto nLastRow = m_xVersionBox->n_children() - 1;
+        m_xVersionBox->set_text(nLastRow, pInfo->aAuthor, 1);
+        m_xVersionBox->set_text(nLastRow, ConvertWhiteSpaces_Impl(pInfo->aComment), 2);
     }
 
-    m_pSaveCheckBox->Check( m_bIsSaveVersionOnClose );
+    if (auto nCount = m_pTable->size())
+        m_xVersionBox->select(nCount - 1);
+
+    m_xSaveCheckBox->set_active(m_bIsSaveVersionOnClose);
 
     bool bEnable = !pObjShell->IsReadOnly();
-    m_pSaveButton->Enable( bEnable );
-    m_pSaveCheckBox->Enable( bEnable );
+    m_xSaveButton->set_sensitive( bEnable );
+    m_xSaveCheckBox->set_sensitive( bEnable );
 
-    m_pOpenButton->Disable();
-    m_pViewButton->Disable();
-    m_pDeleteButton->Disable();
-    m_pCompareButton->Disable();
+    m_xOpenButton->set_sensitive(false);
+    m_xViewButton->set_sensitive(false);
+    m_xDeleteButton->set_sensitive(false);
+    m_xCompareButton->set_sensitive(false);
 
     SvtMiscOptions miscOptions;
     if ( !miscOptions.IsExperimentalMode() )
-        m_pCmisButton->Hide( );
+        m_xCmisButton->hide( );
     uno::Reference<document::XCmisDocument> xCmisDoc(pObjShell->GetModel(), uno::UNO_QUERY);
     if (xCmisDoc && xCmisDoc->isVersionable())
-        m_pCmisButton->Enable();
+        m_xCmisButton->set_sensitive(true);
     else
-        m_pCmisButton->Disable();
+        m_xCmisButton->set_sensitive(false);
 
-    SelectHdl_Impl(m_pVersionBox);
+    SelectHdl_Impl(*m_xVersionBox);
 }
 
 SfxVersionDialog::~SfxVersionDialog()
 {
-    disposeOnce();
-}
-
-void SfxVersionDialog::dispose()
-{
-    m_pTable.reset();
-    m_pVersionBox.disposeAndClear();
-    m_pSaveButton.clear();
-    m_pSaveCheckBox.clear();
-    m_pOpenButton.clear();
-    m_pViewButton.clear();
-    m_pDeleteButton.clear();
-    m_pCompareButton.clear();
-    m_pCmisButton.clear();
-    SfxModalDialog::dispose();
 }
 
 void SfxVersionDialog::Open_Impl()
 {
-    SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
+    SfxObjectShell *pObjShell = m_pViewFrame->GetObjectShell();
 
-    SvTreeListEntry *pEntry = m_pVersionBox->FirstSelected();
-    sal_uIntPtr nPos = SvTreeList::GetRelPos( pEntry );
-    SfxInt16Item aItem( SID_VERSION, static_cast<short>(nPos)+1 );
+    auto nPos = m_xVersionBox->get_selected_index();
+    SfxInt16Item aItem( SID_VERSION, nPos + 1);
     SfxStringItem aTarget( SID_TARGETNAME, "_blank" );
     SfxStringItem aReferer( SID_REFERER, "private:user" );
     SfxStringItem aFile( SID_FILE_NAME, pObjShell->GetMedium()->GetName() );
@@ -342,94 +336,94 @@ void SfxVersionDialog::Open_Impl()
     {
         // there is a password, it should be used during the opening
         SfxUnoAnyItem aEncryptionDataItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) );
-        pViewFrame->GetDispatcher()->ExecuteList(
+        m_pViewFrame->GetDispatcher()->ExecuteList(
             SID_OPENDOC, SfxCallMode::ASYNCHRON,
             { &aFile, &aItem, &aTarget, &aReferer, &aEncryptionDataItem });
     }
     else
     {
-        pViewFrame->GetDispatcher()->ExecuteList(
+        m_pViewFrame->GetDispatcher()->ExecuteList(
             SID_OPENDOC, SfxCallMode::ASYNCHRON,
             { &aFile, &aItem, &aTarget, &aReferer });
     }
 
-    Close();
+    m_xDialog->response(RET_OK);
 }
 
-IMPL_LINK_NOARG(SfxVersionDialog, DClickHdl_Impl, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(SfxVersionDialog, DClickHdl_Impl, weld::TreeView&, void)
 {
     Open_Impl();
-    return false;
 }
 
-IMPL_LINK_NOARG(SfxVersionDialog, SelectHdl_Impl, SvTreeListBox*, void)
+IMPL_LINK_NOARG(SfxVersionDialog, SelectHdl_Impl, weld::TreeView&, void)
 {
-    bool bEnable = ( m_pVersionBox->FirstSelected() != nullptr );
-    SfxObjectShell* pObjShell = pViewFrame->GetObjectShell();
-    m_pDeleteButton->Enable(bEnable && !pObjShell->IsReadOnly());
-    m_pOpenButton->Enable(bEnable);
-    m_pViewButton->Enable(bEnable);
+    bool bEnable = m_xVersionBox->get_selected_index() != -1;
+    SfxObjectShell* pObjShell = m_pViewFrame->GetObjectShell();
+    m_xDeleteButton->set_sensitive(bEnable && !pObjShell->IsReadOnly());
+    m_xOpenButton->set_sensitive(bEnable);
+    m_xViewButton->set_sensitive(bEnable);
 
     const SfxPoolItem *pDummy=nullptr;
-    pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_MERGE, pDummy );
-    SfxItemState eState = pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_COMPARE, pDummy );
-    m_pCompareButton->Enable(bEnable && eState >= SfxItemState::DEFAULT);
+    m_pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_MERGE, pDummy );
+    SfxItemState eState = m_pViewFrame->GetDispatcher()->QueryState( SID_DOCUMENT_COMPARE, pDummy );
+    m_xCompareButton->set_sensitive(bEnable && eState >= SfxItemState::DEFAULT);
 }
 
-IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
+IMPL_LINK(SfxVersionDialog, ButtonHdl_Impl, weld::Button&, rButton, void)
 {
-    SfxObjectShell *pObjShell = pViewFrame->GetObjectShell();
-    SvTreeListEntry *pEntry = m_pVersionBox->FirstSelected();
+    SfxObjectShell *pObjShell = m_pViewFrame->GetObjectShell();
+
+    int nEntry = m_xVersionBox->get_selected_index();
 
-    if (pButton == m_pSaveCheckBox)
+    if (&rButton == m_xSaveCheckBox.get())
     {
-        m_bIsSaveVersionOnClose = m_pSaveCheckBox->IsChecked();
+        m_bIsSaveVersionOnClose = m_xSaveCheckBox->get_active();
     }
-    else if (pButton == m_pSaveButton)
+    else if (&rButton == m_xSaveButton.get())
     {
         SfxVersionInfo aInfo;
         aInfo.aAuthor = SvtUserOptions().GetFullName();
-        SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), aInfo, true);
+        SfxViewVersionDialog_Impl aDlg(m_xDialog.get(), aInfo, true);
         short nRet = aDlg.run();
-        if ( nRet == RET_OK )
+        if (nRet == RET_OK)
         {
             SfxStringItem aComment( SID_DOCINFO_COMMENTS, aInfo.aComment );
             pObjShell->SetModified();
             const SfxPoolItem* aItems[2];
             aItems[0] = &aComment;
             aItems[1] = nullptr;
-            pViewFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, aItems );
-            m_pVersionBox->SetUpdateMode( false );
-            m_pVersionBox->Clear();
+            m_pViewFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, aItems );
+            m_xVersionBox->freeze();
+            m_xVersionBox->clear();
             Init_Impl();
-            m_pVersionBox->SetUpdateMode( true );
+            m_xVersionBox->thaw();
         }
     }
-    if (pButton == m_pDeleteButton && pEntry)
+    else if (&rButton == m_xDeleteButton.get() && nEntry != -1)
     {
-        pObjShell->GetMedium()->RemoveVersion_Impl( static_cast<SfxVersionInfo*>(pEntry->GetUserData())->aName );
+        SfxVersionInfo* pInfo = reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry).toInt64());
+        pObjShell->GetMedium()->RemoveVersion_Impl(pInfo->aName);
         pObjShell->SetModified();
-        m_pVersionBox->SetUpdateMode( false );
-        m_pVersionBox->Clear();
+        m_xVersionBox->freeze();
+        m_xVersionBox->clear();
         Init_Impl();
-        m_pVersionBox->SetUpdateMode( true );
+        m_xVersionBox->thaw();
     }
-    else if (pButton == m_pOpenButton && pEntry)
+    else if (&rButton == m_xOpenButton.get() && nEntry != -1)
     {
         Open_Impl();
     }
-    else if (pButton == m_pViewButton && pEntry)
+    else if (&rButton == m_xViewButton.get() && nEntry != -1)
     {
-        SfxVersionInfo* pInfo = static_cast<SfxVersionInfo*>(pEntry->GetUserData());
-        SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), *pInfo, false);
+        SfxVersionInfo* pInfo = reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry).toInt64());
+        SfxViewVersionDialog_Impl aDlg(m_xDialog.get(), *pInfo, false);
         aDlg.run();
     }
-    else if (pEntry && pButton == m_pCompareButton)
+    else if (&rButton == m_xCompareButton.get() && nEntry != -1)
     {
         SfxAllItemSet aSet( pObjShell->GetPool() );
-        sal_uIntPtr nPos = SvTreeList::GetRelPos( pEntry );
-        aSet.Put( SfxInt16Item( SID_VERSION, static_cast<short>(nPos)+1 ) );
-        aSet.Put( SfxStringItem( SID_FILE_NAME, pObjShell->GetMedium()->GetName() ) );
+        aSet.Put(SfxInt16Item(SID_VERSION, nEntry + 1));
+        aSet.Put(SfxStringItem(SID_FILE_NAME, pObjShell->GetMedium()->GetName()));
 
         SfxItemSet* pSet = pObjShell->GetMedium()->GetItemSet();
         const SfxStringItem* pFilterItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_FILTER_NAME, false);
@@ -439,12 +433,12 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
         if ( pFilterOptItem )
             aSet.Put( *pFilterOptItem );
 
-        pViewFrame->GetDispatcher()->Execute( SID_DOCUMENT_COMPARE, SfxCallMode::ASYNCHRON, aSet );
-        Close();
+        m_pViewFrame->GetDispatcher()->Execute( SID_DOCUMENT_COMPARE, SfxCallMode::ASYNCHRON, aSet );
+        m_xDialog->response(RET_CLOSE);
     }
-    else if (pButton == m_pCmisButton)
+    else if (&rButton == m_xCmisButton.get())
     {
-        VclPtrInstance< SfxCmisVersionsDialog > pDlg(pViewFrame);
+        VclPtrInstance< SfxCmisVersionsDialog > pDlg(m_pViewFrame);
         pDlg->Execute();
     }
 }
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 6777e64d9cf5..e7941cc01238 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -425,9 +425,9 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             if ( !IsOwnStorageFormat( *GetMedium() ) )
                 return;
 
-            ScopedVclPtrInstance< SfxVersionDialog > pDlg( pFrame, IsSaveVersionOnClose() );
-            pDlg->Execute();
-            SetSaveVersionOnClose( pDlg->IsSaveVersionOnClose() );
+            SfxVersionDialog aDlg(rReq.GetFrameWeld(), pFrame, IsSaveVersionOnClose());
+            aDlg.run();
+            SetSaveVersionOnClose(aDlg.IsSaveVersionOnClose());
             rReq.Done();
             return;
         }
diff --git a/sfx2/source/inc/versdlg.hxx b/sfx2/source/inc/versdlg.hxx
index f89c60ed2175..949c0b4bd6bc 100644
--- a/sfx2/source/inc/versdlg.hxx
+++ b/sfx2/source/inc/versdlg.hxx
@@ -44,31 +44,31 @@ public:
 };
 
 class SfxVersionTableDtor;
-class SfxVersionDialog : public SfxModalDialog
+class SfxVersionDialog : public SfxDialogController
 {
-    VclPtr<PushButton>                 m_pSaveButton;
-    VclPtr<CheckBox>                   m_pSaveCheckBox;
-    VclPtr<SfxVersionsTabListBox_Impl> m_pVersionBox;
-    VclPtr<PushButton>                 m_pOpenButton;
-    VclPtr<PushButton>                 m_pViewButton;
-    VclPtr<PushButton>                 m_pDeleteButton;
-    VclPtr<PushButton>                 m_pCompareButton;
-    VclPtr<PushButton>                 m_pCmisButton;
-    SfxViewFrame*               pViewFrame;
+    SfxViewFrame* m_pViewFrame;
+    bool m_bIsSaveVersionOnClose;
     std::unique_ptr<SfxVersionTableDtor> m_pTable;
-    bool                        m_bIsSaveVersionOnClose;
-
-    DECL_LINK(            DClickHdl_Impl, SvTreeListBox*, bool);
-    DECL_LINK(            SelectHdl_Impl, SvTreeListBox*, void);
-    DECL_LINK(            ButtonHdl_Impl, Button*, void );
-    void                        Init_Impl();
-    void                        Open_Impl();
+    std::unique_ptr<weld::Button> m_xSaveButton;
+    std::unique_ptr<weld::CheckButton> m_xSaveCheckBox;
+    std::unique_ptr<weld::Button> m_xOpenButton;
+    std::unique_ptr<weld::Button> m_xViewButton;
+    std::unique_ptr<weld::Button> m_xDeleteButton;
+    std::unique_ptr<weld::Button> m_xCompareButton;
+    std::unique_ptr<weld::Button> m_xCmisButton;
+    std::unique_ptr<weld::TreeView> m_xVersionBox;
+
+    DECL_LINK(DClickHdl_Impl, weld::TreeView&, void);
+    DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
+    DECL_LINK(ButtonHdl_Impl, weld::Button&, void );
+    void Init_Impl();
+    void Open_Impl();
+    void setColSizes();
 
 public:
-                                SfxVersionDialog ( SfxViewFrame* pFrame, bool );
-    virtual                     ~SfxVersionDialog () override;
-    virtual void                dispose() override;
-    bool                        IsSaveVersionOnClose() const { return m_bIsSaveVersionOnClose; }
+    SfxVersionDialog(weld::Window* pParent, SfxViewFrame* pFrame, bool);
+    virtual ~SfxVersionDialog() override;
+    bool IsSaveVersionOnClose() const { return m_bIsSaveVersionOnClose; }
 };
 
 class SfxViewVersionDialog_Impl : public SfxDialogController
diff --git a/sfx2/uiconfig/ui/versionsofdialog.ui b/sfx2/uiconfig/ui/versionsofdialog.ui
index 0c6a7311111f..96d81feaa9f7 100644
--- a/sfx2/uiconfig/ui/versionsofdialog.ui
+++ b/sfx2/uiconfig/ui/versionsofdialog.ui
@@ -1,30 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore3">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name text2 -->
+      <column type="gchararray"/>
+      <!-- column-name text3 -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="VersionsOfDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
-    <property name="resizable">False</property>
+    <property name="modal">True</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="layout_style">start</property>
+            <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="close">
-                <property name="label">gtk-close</property>
+              <object class="GtkButton" id="cmis">
+                <property name="label" translatable="yes" context="versionsofdialog|cmis">CMIS</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -33,11 +45,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="open">
-                <property name="label">gtk-open</property>
+              <object class="GtkButton" id="delete">
+                <property name="label">gtk-delete</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -47,8 +60,8 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="show">
-                <property name="label" translatable="yes" context="versionsofdialog|show">_Show...</property>
+              <object class="GtkButton" id="compare">
+                <property name="label" translatable="yes" context="versionsofdialog|compare">_Compare</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -61,13 +74,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="delete">
-                <property name="label">gtk-delete</property>
+              <object class="GtkButton" id="show">
+                <property name="label" translatable="yes" context="versionsofdialog|show">_Show...</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
-                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -76,12 +88,14 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="compare">
-                <property name="label" translatable="yes" context="versionsofdialog|compare">_Compare</property>
+              <object class="GtkButton" id="close">
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -90,11 +104,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="cmis">
-                <property name="label" translatable="yes" context="versionsofdialog|cmis">CMIS</property>
+              <object class="GtkButton" id="open">
+                <property name="label">gtk-open</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -221,47 +236,67 @@
                         <property name="hexpand">True</property>
                         <property name="vexpand">True</property>
                         <child>
-                          <object class="GtkBox" id="box1">
+                          <object class="GtkScrolledWindow">
                             <property name="visible">True</property>
-                            <property name="can_focus">False</property>
+                            <property name="can_focus">True</property>
                             <property name="hexpand">True</property>
-                            <property name="spacing">12</property>
-                            <property name="homogeneous">True</property>
-                            <child>
-                              <object class="GtkLabel" id="datetime">
-                                <property name="can_focus">False</property>
-                                <property name="no_show_all">True</property>
-                                <property name="label" translatable="yes" context="versionsofdialog|datetime">Date and time</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkLabel" id="savedby">
-                                <property name="can_focus">False</property>
-                                <property name="no_show_all">True</property>
-                                <property name="label" translatable="yes" context="versionsofdialog|savedby">Saved by</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
+                            <property name="vexpand">True</property>
+                            <property name="shadow_type">in</property>
                             <child>
-                              <object class="GtkLabel" id="comments">
-                                <property name="can_focus">False</property>
-                                <property name="no_show_all">True</property>
-                                <property name="label" translatable="yes" context="versionsofdialog|comments">Comments</property>
+                              <object class="GtkTreeView" id="versions">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="vexpand">True</property>
+                                <property name="model">liststore3</property>
+                                <property name="rules_hint">True</property>
+                                <property name="headers_visible">True</property>
+                                <property name="search_column">0</property>
+                                <property name="show_expanders">False</property>
+                                <child internal-child="selection">
+                                  <object class="GtkTreeSelection" id="versions-selection2"/>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                    <property name="resizable">True</property>
+                                    <property name="spacing">6</property>
+                                    <property name="title" translatable="yes" context="versionsofdialog|datetime">Date and time</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderer1"/>
+                                      <attributes>
+                                        <attribute name="text">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                                    <property name="resizable">True</property>
+                                    <property name="spacing">6</property>
+                                    <property name="title" translatable="yes" context="versionsofdialog|savedby">Saved by</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderer2"/>
+                                      <attributes>
+                                        <attribute name="text">1</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                                    <property name="resizable">True</property>
+                                    <property name="spacing">6</property>
+                                    <property name="title" translatable="yes" context="versionsofdialog|comments">Comments</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderer3"/>
+                                      <attributes>
+                                        <attribute name="text">2</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
                               </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">True</property>
-                                <property name="position">2</property>
-                              </packing>
                             </child>
                           </object>
                           <packing>
@@ -269,21 +304,6 @@
                             <property name="top_attach">0</property>
                           </packing>
                         </child>
-                        <child>
-                          <object class="svtlo-SvSimpleTableContainer" id="versions">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">True</property>
-                            <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">1</property>
-                          </packing>
-                        </child>
                       </object>
                     </child>
                   </object>
@@ -314,12 +334,12 @@
       </object>
     </child>
     <action-widgets>
+      <action-widget response="104">cmis</action-widget>
+      <action-widget response="103">delete</action-widget>
+      <action-widget response="102">compare</action-widget>
+      <action-widget response="101">show</action-widget>
       <action-widget response="-7">close</action-widget>
-      <action-widget response="0">open</action-widget>
-      <action-widget response="0">show</action-widget>
-      <action-widget response="0">delete</action-widget>
-      <action-widget response="0">compare</action-widget>
-      <action-widget response="0">cmis</action-widget>
+      <action-widget response="-5">open</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
   </object>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index bf547d1a2f9f..bf3ffe89898c 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1796,7 +1796,8 @@ public:
     {
         std::vector<long> aTabPositions;
         aTabPositions.push_back(0);
-        aTabPositions.insert(aTabPositions.end(), rWidths.begin(), rWidths.end());
+        for (size_t i = 0; i < rWidths.size(); ++i)
+            aTabPositions.push_back(aTabPositions[i] + rWidths[i]);
         m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel);
         SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
         if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
@@ -1806,6 +1807,16 @@ public:
         }
     }
 
+    virtual OUString get_column_title(int nColumn) const override
+    {
+        SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
+        if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
+        {
+            return pHeaderBar->GetItemText(pHeaderBar->GetItemId(nColumn));
+        }
+        return OUString();
+    }
+
     virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rStr, const OUString* pId,
                         const OUString* pIconName, VirtualDevice* pImageSurface, const OUString* pExpanderName,
                         bool bChildrenOnDemand) override
@@ -2243,7 +2254,7 @@ IMPL_LINK(SalInstanceTreeView, EndDragHdl, HeaderBar*, pHeaderBar, void)
     std::vector<long> aTabPositions;
     aTabPositions.push_back(0);
     for (int i = 0; i < pHeaderBar->GetItemCount() - 1; ++i)
-        aTabPositions.push_back(pHeaderBar->GetItemSize(pHeaderBar->GetItemId(i)));
+        aTabPositions.push_back(aTabPositions[i] + pHeaderBar->GetItemSize(pHeaderBar->GetItemId(i)));
     m_xTreeView->SetTabs(aTabPositions.size(), aTabPositions.data(), MapUnit::MapPixel);
 }
 
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index dbf1af9566b0..6aea58ad91b4 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -3679,6 +3679,10 @@ bool SvTreeListBox::set_property(const OString &rKey, const OUString &rValue)
             nStyle |= (WB_HASBUTTONS | WB_HASBUTTONSATROOT);
         SetStyle(nStyle);
     }
+    else if (rKey == "rules-hint")
+    {
+        SetAlternatingRowColors(toBool(rValue));
+    }
     else if (rKey == "enable-search")
     {
         SetQuickSearch(toBool(rValue));
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index ee4ec85daaa9..e207e7793b68 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4281,6 +4281,17 @@ public:
         g_list_free(pColumns);
     }
 
+    virtual OUString get_column_title(int nColumn) const override
+    {
+        GList *pColumns = gtk_tree_view_get_columns(m_pTreeView);
+        GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(pColumns, nColumn));
+        assert(pColumn && "wrong count");
+        const gchar* pTitle = gtk_tree_view_column_get_title(pColumn);
+        OUString sRet = OUString(pTitle, pTitle ? strlen(pTitle) : 0, RTL_TEXTENCODING_UTF8);
+        g_list_free(pColumns);
+        return sRet;
+    }
+
     virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rText, const OUString* pId, const OUString* pIconName,
                         VirtualDevice* pImageSurface, const OUString* pExpanderName, bool bChildrenOnDemand) override
     {
@@ -4754,6 +4765,19 @@ public:
         gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
     }
 
+    virtual Size get_preferred_size() const override
+    {
+        GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
+        if (GTK_IS_SCROLLED_WINDOW(pParent))
+        {
+            return Size(gtk_scrolled_window_get_min_content_width(GTK_SCROLLED_WINDOW(pParent)),
+                        gtk_scrolled_window_get_min_content_height(GTK_SCROLLED_WINDOW(pParent)));
+        }
+        GtkRequisition size;
+        gtk_widget_get_preferred_size(m_pWidget, nullptr, &size);
+        return Size(size.width, size.height);
+    }
+
     virtual void set_visible(bool visible) override
     {
         GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);


More information about the Libreoffice-commits mailing list