[Libreoffice-commits] core.git: solenv/sanitizers sw/source sw/uiconfig

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Mar 15 08:59:02 UTC 2019


 solenv/sanitizers/ui/modules/swriter.suppr |    1 
 sw/source/ui/dialog/uiregionsw.cxx         |  354 +++++++++++++++++------------
 sw/source/uibase/inc/condedit.hxx          |    1 
 sw/source/uibase/inc/regionsw.hxx          |   60 ++--
 sw/uiconfig/swriter/ui/sectionpage.ui      |   83 +++++-
 5 files changed, 309 insertions(+), 190 deletions(-)

New commits:
commit a98bb35d4e11471cee6b3dbf66b2c3d25df39bfa
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Mar 14 16:18:24 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 15 09:58:26 2019 +0100

    weld SwInsertSectionTabPage
    
    Change-Id: Ifdd794ae97eac3885c828f7610135b60ce7b3b7d
    Reviewed-on: https://gerrit.libreoffice.org/69282
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 2c7b4fac20bf..e92034ca2521 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -231,6 +231,7 @@ sw/uiconfig/swriter/ui/savemonitordialog.ui://GtkLabel[@id='saving'] orphan-labe
 sw/uiconfig/swriter/ui/savemonitordialog.ui://GtkLabel[@id='printer'] orphan-label
 sw/uiconfig/swriter/ui/savemonitordialog.ui://GtkLabel[@id='printinfo'] orphan-label
 sw/uiconfig/swriter/ui/sectionpage.ui://GtkEntry[@id='filename'] duplicate-mnemonic
+sw/uiconfig/swriter/ui/sectionpage.ui://GtkEntry[@id='sectionnames-entry'] no-labelled-by
 sw/uiconfig/swriter/ui/selectaddressdialog.ui://GtkLabel[@id='desc'] orphan-label
 sw/uiconfig/swriter/ui/selectaddressdialog.ui://GtkLabel[@id='label2'] orphan-label
 sw/uiconfig/swriter/ui/selectaddressdialog.ui://svtlo-SvSimpleTableContainer[@id='sources:border'] no-labelled-by
diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx
index 877083ceaf34..bbe3d39617d1 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -77,6 +77,7 @@ Image BuildBitmap(bool bProtect, bool bHidden)
 }
 
 static void   lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox );
+static void   lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox );
 
 static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
 {
@@ -125,6 +126,54 @@ static void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAva
     }
 }
 
+static void lcl_FillList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames, const SwSectionFormat* pNewFormat )
+{
+    if( !pNewFormat )
+    {
+        const size_t nCount = rSh.GetSectionFormatCount();
+        for (size_t i = 0; i<nCount; i++)
+        {
+            SectionType eTmpType;
+            const SwSectionFormat* pFormat = &rSh.GetSectionFormat(i);
+            if( !pFormat->GetParent() &&
+                    pFormat->IsInNodesArr() &&
+                    (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
+                    && TOX_HEADER_SECTION != eTmpType )
+            {
+                    const OUString sString(pFormat->GetSection()->GetSectionName());
+                    if (pAvailNames)
+                        pAvailNames->append_text(sString);
+                    rSubRegions.append_text(sString);
+                    lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
+            }
+        }
+    }
+    else
+    {
+        SwSections aTmpArr;
+        pNewFormat->GetChildSections(aTmpArr, SectionSort::Pos);
+        if( !aTmpArr.empty() )
+        {
+            SectionType eTmpType;
+            for( const auto pSect : aTmpArr )
+            {
+                const SwSectionFormat* pFormat = pSect->GetFormat();
+                if( pFormat->IsInNodesArr()&&
+                    (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
+                    && TOX_HEADER_SECTION != eTmpType )
+                {
+                    const OUString sString(pFormat->GetSection()->GetSectionName());
+                    if (pAvailNames)
+                        pAvailNames->append_text(sString);
+                    rSubRegions.append_text(sString);
+                    lcl_FillList( rSh, rSubRegions, pAvailNames, pFormat );
+                }
+            }
+        }
+    }
+}
+
+
 static void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames )
 {
     lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
@@ -139,6 +188,20 @@ static void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, Combo
     }
 }
 
+static void lcl_FillSubRegionList( SwWrtShell& rSh, weld::ComboBox& rSubRegions, weld::ComboBox* pAvailNames )
+{
+    lcl_FillList( rSh, rSubRegions, pAvailNames, nullptr );
+    IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess();
+    for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
+        ppMark != pMarkAccess->getBookmarksEnd();
+        ++ppMark)
+    {
+        const ::sw::mark::IMark* pBkmk = ppMark->get();
+        if( pBkmk->IsExpanded() )
+            rSubRegions.append_text( pBkmk->GetName() );
+    }
+}
+
 // user data class for region information
 class SectRepr
 {
@@ -1403,6 +1466,26 @@ static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox )
     }
 }
 
+// helper function - read section names from medium
+static void lcl_ReadSections( SfxMedium& rMedium, weld::ComboBox& rBox )
+{
+    rBox.clear();
+    uno::Reference < embed::XStorage > xStg;
+    if( rMedium.IsStorage() && (xStg = rMedium.GetStorage()).is() )
+    {
+        std::vector<OUString> aArr;
+        SotClipboardFormatId nFormat = SotStorage::GetFormatID( xStg );
+        if ( nFormat == SotClipboardFormatId::STARWRITER_60 || nFormat == SotClipboardFormatId::STARWRITERGLOB_60 ||
+            nFormat == SotClipboardFormatId::STARWRITER_8 || nFormat == SotClipboardFormatId::STARWRITERGLOB_8)
+            SwGetReaderXML()->GetSectionList( rMedium, aArr );
+
+        for (auto const& it : aArr)
+        {
+            rBox.append_text(it);
+        }
+    }
+}
+
 SwInsertSectionTabDialog::SwInsertSectionTabDialog(
             vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell& rSh)
     : SfxTabDialog(pParent, "InsertSectionDialog",
@@ -1500,43 +1583,42 @@ short   SwInsertSectionTabDialog::Ok()
     return nRet;
 }
 
-SwInsertSectionTabPage::SwInsertSectionTabPage(
-                            vcl::Window *pParent, const SfxItemSet &rAttrSet)
-    : SfxTabPage(pParent, "SectionPage",
-        "modules/swriter/ui/sectionpage.ui", &rAttrSet)
+SwInsertSectionTabPage::SwInsertSectionTabPage(TabPageParent pParent, const SfxItemSet &rAttrSet)
+    : SfxTabPage(pParent, "modules/swriter/ui/sectionpage.ui", "SectionPage", &rAttrSet)
     , m_pWrtSh(nullptr)
-{
-    get(m_pCurName, "sectionnames");
-    m_pCurName->SetStyle(m_pCurName->GetStyle() | WB_SORT);
-    m_pCurName->set_height_request(m_pCurName->GetTextHeight() * 12);
-    get(m_pFileCB, "link");
-    get(m_pDDECB, "dde");
-    get(m_pDDECommandFT, "ddelabel");
-    get(m_pFileNameFT, "filelabel");
-    get(m_pFileNameED, "filename");
-    get(m_pFilePB, "selectfile");
-    get(m_pSubRegionFT, "sectionlabel");
-    get(m_pSubRegionED, "sectionname");
-    m_pSubRegionED->SetStyle(m_pSubRegionED->GetStyle() | WB_SORT);
-    get(m_pProtectCB, "protect");
-    get(m_pPasswdCB, "withpassword");
-    get(m_pPasswdPB, "selectpassword");
-    get(m_pHideCB, "hide");
-    get(m_pConditionFT, "condlabel");
-    get(m_pConditionED, "withcond");
+    , m_xCurName(m_xBuilder->weld_entry_tree_view("sectionnames", "sectionnames-entry",
+                                                  "sectionnames-list"))
+    , m_xFileCB(m_xBuilder->weld_check_button("link"))
+    , m_xDDECB(m_xBuilder->weld_check_button("dde"))
+    , m_xDDECommandFT(m_xBuilder->weld_label("ddelabel"))
+    , m_xFileNameFT(m_xBuilder->weld_label("filelabel"))
+    , m_xFileNameED(m_xBuilder->weld_entry("filename"))
+    , m_xFilePB(m_xBuilder->weld_button("selectfile"))
+    , m_xSubRegionFT(m_xBuilder->weld_label("sectionlabel"))
+    , m_xSubRegionED(m_xBuilder->weld_combo_box("sectionname"))
+    , m_xProtectCB(m_xBuilder->weld_check_button("protect"))
+    , m_xPasswdCB(m_xBuilder->weld_check_button("withpassword"))
+    , m_xPasswdPB(m_xBuilder->weld_button("selectpassword"))
+    , m_xHideCB(m_xBuilder->weld_check_button("hide"))
+    , m_xConditionFT(m_xBuilder->weld_label("condlabel"))
+    , m_xConditionED(new SwConditionEdit(m_xBuilder->weld_entry("withcond")))
     // edit in readonly sections
-    get(m_pEditInReadonlyCB, "editable");
+    , m_xEditInReadonlyCB(m_xBuilder->weld_check_button("editable"))
+{
+    m_xCurName->make_sorted();
+    m_xCurName->set_height_request_by_rows(12);
+    m_xSubRegionED->make_sorted();
 
-    m_pProtectCB->SetClickHdl  ( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
-    m_pPasswdCB->SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
-    m_pPasswdPB->SetClickHdl   ( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
-    m_pHideCB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
-    m_pFileCB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
-    m_pFilePB->SetClickHdl     ( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
-    m_pCurName->SetModifyHdl   ( LINK( this, SwInsertSectionTabPage, NameEditHdl));
-    m_pDDECB->SetClickHdl      ( LINK( this, SwInsertSectionTabPage, DDEHdl ));
-    ChangeProtectHdl(m_pProtectCB);
-    m_pSubRegionED->EnableAutocomplete( true, true );
+    m_xProtectCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeProtectHdl));
+    m_xPasswdCB->connect_toggled( LINK( this, SwInsertSectionTabPage, TogglePasswdHdl));
+    m_xPasswdPB->connect_clicked( LINK( this, SwInsertSectionTabPage, ChangePasswdHdl));
+    m_xHideCB->connect_toggled( LINK( this, SwInsertSectionTabPage, ChangeHideHdl));
+    m_xFileCB->connect_toggled( LINK( this, SwInsertSectionTabPage, UseFileHdl ));
+    m_xFilePB->connect_clicked( LINK( this, SwInsertSectionTabPage, FileSearchHdl ));
+    m_xCurName->connect_changed( LINK( this, SwInsertSectionTabPage, NameEditHdl));
+    m_xDDECB->connect_toggled( LINK( this, SwInsertSectionTabPage, DDEHdl ));
+    ChangeProtectHdl(*m_xProtectCB);
+//TODO    m_xSubRegionED->EnableAutocomplete( true, true );
 }
 
 SwInsertSectionTabPage::~SwInsertSectionTabPage()
@@ -1544,28 +1626,6 @@ SwInsertSectionTabPage::~SwInsertSectionTabPage()
     disposeOnce();
 }
 
-void SwInsertSectionTabPage::dispose()
-{
-    m_pDocInserter.reset();
-    m_pCurName.clear();
-    m_pFileCB.clear();
-    m_pDDECB.clear();
-    m_pDDECommandFT.clear();
-    m_pFileNameFT.clear();
-    m_pFileNameED.clear();
-    m_pFilePB.clear();
-    m_pSubRegionFT.clear();
-    m_pSubRegionED.clear();
-    m_pProtectCB.clear();
-    m_pPasswdCB.clear();
-    m_pPasswdPB.clear();
-    m_pHideCB.clear();
-    m_pConditionFT.clear();
-    m_pConditionED.clear();
-    m_pEditInReadonlyCB.clear();
-    SfxTabPage::dispose();
-}
-
 void    SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
 {
     m_pWrtSh = &rSh;
@@ -1573,14 +1633,14 @@ void    SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
     bool bWeb = dynamic_cast<SwWebDocShell*>( m_pWrtSh->GetView().GetDocShell() )!= nullptr;
     if(bWeb)
     {
-        m_pHideCB->Hide();
-        m_pConditionED->Hide();
-        m_pConditionFT->Hide();
-        m_pDDECB->Hide();
-        m_pDDECommandFT->Hide();
+        m_xHideCB->hide();
+        m_xConditionED->hide();
+        m_xConditionFT->hide();
+        m_xDDECB->hide();
+        m_xDDECommandFT->hide();
     }
 
-    lcl_FillSubRegionList(*m_pWrtSh, *m_pSubRegionED, m_pCurName);
+    lcl_FillSubRegionList(*m_pWrtSh, *m_xSubRegionED, m_xCurName.get());
 
     SwSectionData *const pSectionData =
         static_cast<SwInsertSectionTabDialog*>(GetTabDialog())
@@ -1588,38 +1648,38 @@ void    SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh)
     if (pSectionData) // something set?
     {
         const OUString sSectionName(pSectionData->GetSectionName());
-        m_pCurName->SetText(rSh.GetUniqueSectionName(&sSectionName));
-        m_pProtectCB->Check( pSectionData->IsProtectFlag() );
+        m_xCurName->set_entry_text(rSh.GetUniqueSectionName(&sSectionName));
+        m_xProtectCB->set_active( pSectionData->IsProtectFlag() );
         m_sFileName = pSectionData->GetLinkFileName();
         m_sFilePasswd = pSectionData->GetLinkFilePassword();
-        m_pFileCB->Check( !m_sFileName.isEmpty() );
-        m_pFileNameED->SetText( m_sFileName );
-        UseFileHdl(m_pFileCB);
+        m_xFileCB->set_active( !m_sFileName.isEmpty() );
+        m_xFileNameED->set_text( m_sFileName );
+        UseFileHdl(*m_xFileCB);
     }
     else
     {
-        m_pCurName->SetText( rSh.GetUniqueSectionName() );
+        m_xCurName->set_entry_text(rSh.GetUniqueSectionName());
     }
 }
 
 bool SwInsertSectionTabPage::FillItemSet( SfxItemSet* )
 {
-    SwSectionData aSection(CONTENT_SECTION, m_pCurName->GetText());
-    aSection.SetCondition(m_pConditionED->GetText());
-    bool bProtected = m_pProtectCB->IsChecked();
+    SwSectionData aSection(CONTENT_SECTION, m_xCurName->get_active_text());
+    aSection.SetCondition(m_xConditionED->get_text());
+    bool bProtected = m_xProtectCB->get_active();
     aSection.SetProtectFlag(bProtected);
-    aSection.SetHidden(m_pHideCB->IsChecked());
+    aSection.SetHidden(m_xHideCB->get_active());
     // edit in readonly sections
-    aSection.SetEditInReadonlyFlag(m_pEditInReadonlyCB->IsChecked());
+    aSection.SetEditInReadonlyFlag(m_xEditInReadonlyCB->get_active());
 
     if(bProtected)
     {
         aSection.SetPassword(m_aNewPasswd);
     }
-    const OUString sFileName = m_pFileNameED->GetText();
-    const OUString sSubRegion = m_pSubRegionED->GetText();
-    bool bDDe = m_pDDECB->IsChecked();
-    if(m_pFileCB->IsChecked() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
+    const OUString sFileName = m_xFileNameED->get_text();
+    const OUString sSubRegion = m_xSubRegionED->get_active_text();
+    bool bDDe = m_xDDECB->get_active();
+    if (m_xFileCB->get_active() && (!sFileName.isEmpty() || !sSubRegion.isEmpty() || bDDe))
     {
         OUString aLinkFile;
         if( bDDe )
@@ -1652,7 +1712,7 @@ bool SwInsertSectionTabPage::FillItemSet( SfxItemSet* )
         aSection.SetLinkFileName(aLinkFile);
         if (!aLinkFile.isEmpty())
         {
-            aSection.SetType( m_pDDECB->IsChecked() ?
+            aSection.SetType( m_xDDECB->get_active() ?
                                     DDE_LINK_SECTION :
                                         FILE_LINK_SECTION);
         }
@@ -1665,35 +1725,34 @@ void SwInsertSectionTabPage::Reset( const SfxItemSet* )
 {
 }
 
-VclPtr<SfxTabPage> SwInsertSectionTabPage::Create( TabPageParent pParent,
-                                                   const SfxItemSet* rAttrSet)
+VclPtr<SfxTabPage> SwInsertSectionTabPage::Create(TabPageParent pParent,
+                                                  const SfxItemSet* rAttrSet)
 {
-    return VclPtr<SwInsertSectionTabPage>::Create(pParent.pParent, *rAttrSet);
+    return VclPtr<SwInsertSectionTabPage>::Create(pParent, *rAttrSet);
 }
 
-IMPL_LINK( SwInsertSectionTabPage, ChangeHideHdl, Button *, pBox, void )
+IMPL_LINK(SwInsertSectionTabPage, ChangeHideHdl, weld::ToggleButton&, rBox, void)
 {
-    bool bHide = static_cast<CheckBox*>(pBox)->IsChecked();
-    m_pConditionED->Enable(bHide);
-    m_pConditionFT->Enable(bHide);
+    bool bHide = rBox.get_active();
+    m_xConditionED->set_sensitive(bHide);
+    m_xConditionFT->set_sensitive(bHide);
 }
 
-IMPL_LINK( SwInsertSectionTabPage, ChangeProtectHdl, Button *, pBox, void )
+IMPL_LINK(SwInsertSectionTabPage, ChangeProtectHdl, weld::ToggleButton&, rBox, void)
 {
-    bool bCheck = static_cast<CheckBox*>(pBox)->IsChecked();
-    m_pPasswdCB->Enable(bCheck);
-    m_pPasswdPB->Enable(bCheck);
+    bool bCheck = rBox.get_active();
+    m_xPasswdCB->set_sensitive(bCheck);
+    m_xPasswdPB->set_sensitive(bCheck);
 }
 
-IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton, void )
+void SwInsertSectionTabPage::ChangePasswd(bool bChange)
 {
-    bool bChange = pButton == m_pPasswdPB;
-    bool bSet = bChange ? bChange : m_pPasswdCB->IsChecked();
-    if(bSet)
+    bool bSet = bChange ? bChange : m_xPasswdCB->get_active();
+    if (bSet)
     {
         if(!m_aNewPasswd.getLength() || bChange)
         {
-            SfxPasswordDialog aPasswdDlg(GetFrameWeld());
+            SfxPasswordDialog aPasswdDlg(GetDialogFrameWeld());
             aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
             if (RET_OK == aPasswdDlg.run())
             {
@@ -1704,92 +1763,101 @@ IMPL_LINK( SwInsertSectionTabPage, ChangePasswdHdl, Button *, pButton, void )
                 }
                 else
                 {
-                    std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pButton->GetFrameWeld(),
+                    std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
                                                                   VclMessageType::Info, VclButtonsType::Ok,
                                                                   SwResId(STR_WRONG_PASSWD_REPEAT)));
                     xInfoBox->run();
                 }
             }
             else if(!bChange)
-                m_pPasswdCB->Check(false);
+                m_xPasswdCB->set_active(false);
         }
     }
     else
         m_aNewPasswd.realloc(0);
 }
 
-IMPL_LINK_NOARG(SwInsertSectionTabPage, NameEditHdl, Edit&, void)
+IMPL_LINK_NOARG(SwInsertSectionTabPage, TogglePasswdHdl, weld::ToggleButton&, void)
 {
-    const OUString aName = m_pCurName->GetText();
-    GetTabDialog()->GetOKButton().Enable(!aName.isEmpty() &&
-            m_pCurName->GetEntryPos( aName ) == LISTBOX_ENTRY_NOTFOUND);
+    ChangePasswd(false);
 }
 
-IMPL_LINK( SwInsertSectionTabPage, UseFileHdl, Button *, pButton, void )
+IMPL_LINK_NOARG(SwInsertSectionTabPage, ChangePasswdHdl, weld::Button&, void)
 {
-    CheckBox* pBox = static_cast<CheckBox*>(pButton);
-    if( pBox->IsChecked() )
+    ChangePasswd(true);
+}
+
+
+IMPL_LINK_NOARG(SwInsertSectionTabPage, NameEditHdl, weld::ComboBox&, void)
+{
+    const OUString aName = m_xCurName->get_active_text();
+    GetDialogController()->GetOKButton().set_sensitive(!aName.isEmpty() &&
+            m_xCurName->find_text(aName) == -1);
+}
+
+IMPL_LINK(SwInsertSectionTabPage, UseFileHdl, weld::ToggleButton&, rButton, void)
+{
+    if (rButton.get_active())
     {
         if (m_pWrtSh->HasSelection())
         {
-            std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+            std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
                                                            VclMessageType::Question, VclButtonsType::YesNo,
                                                            SwResId(STR_QUERY_CONNECT)));
             if (RET_NO == xQueryBox->run())
-                pBox->Check( false );
+                rButton.set_active(false);
         }
     }
 
-    bool bFile = pBox->IsChecked();
-    m_pFileNameFT->Enable(bFile);
-    m_pFileNameED->Enable(bFile);
-    m_pFilePB->Enable(bFile);
-    m_pSubRegionFT->Enable(bFile);
-    m_pSubRegionED->Enable(bFile);
-    m_pDDECommandFT->Enable(bFile);
-    m_pDDECB->Enable(bFile);
-    if( bFile )
-    {
-        m_pFileNameED->GrabFocus();
-        m_pProtectCB->Check();
+    bool bFile = rButton.get_active();
+    m_xFileNameFT->set_sensitive(bFile);
+    m_xFileNameED->set_sensitive(bFile);
+    m_xFilePB->set_sensitive(bFile);
+    m_xSubRegionFT->set_sensitive(bFile);
+    m_xSubRegionED->set_sensitive(bFile);
+    m_xDDECommandFT->set_sensitive(bFile);
+    m_xDDECB->set_sensitive(bFile);
+    if (bFile)
+    {
+        m_xFileNameED->grab_focus();
+        m_xProtectCB->set_active(true);
     }
     else
     {
-        m_pDDECB->Check(false);
-        DDEHdl(m_pDDECB);
+        m_xDDECB->set_active(false);
+        DDEHdl(*m_xDDECB);
     }
 }
 
-IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl, Button*, void)
+IMPL_LINK_NOARG(SwInsertSectionTabPage, FileSearchHdl, weld::Button&, void)
 {
-    m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter"));
+    m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetDialogFrameWeld(), "swriter"));
     m_pDocInserter->StartExecuteModal( LINK( this, SwInsertSectionTabPage, DlgClosedHdl ) );
 }
 
-IMPL_LINK( SwInsertSectionTabPage, DDEHdl, Button*, pButton, void )
+IMPL_LINK( SwInsertSectionTabPage, DDEHdl, weld::ToggleButton&, rButton, void )
 {
-    CheckBox* pBox = static_cast<CheckBox*>(pButton);
-    bool bDDE = pBox->IsChecked();
-    bool bFile = m_pFileCB->IsChecked();
-    m_pFilePB->Enable(!bDDE && bFile);
-    if(bDDE)
-    {
-        m_pFileNameFT->Hide();
-        m_pDDECommandFT->Enable(bDDE);
-        m_pDDECommandFT->Show();
-        m_pSubRegionFT->Hide();
-        m_pSubRegionED->Hide();
-        m_pFileNameED->SetAccessibleName(m_pDDECommandFT->GetText());
+    bool bDDE = rButton.get_active();
+    bool bFile = m_xFileCB->get_active();
+    m_xFilePB->set_sensitive(!bDDE && bFile);
+    if (bDDE)
+    {
+        m_xFileNameFT->hide();
+        m_xDDECommandFT->set_sensitive(bDDE);
+        m_xDDECommandFT->show();
+        m_xSubRegionFT->hide();
+        m_xSubRegionED->hide();
+        m_xFileNameED->set_accessible_name(m_xDDECommandFT->get_label());
     }
     else
     {
-        m_pDDECommandFT->Hide();
-        m_pFileNameFT->Enable(bFile);
-        m_pFileNameFT->Show();
-        m_pSubRegionFT->Show();
-        m_pSubRegionED->Show();
-        m_pSubRegionED->Enable(bFile);
-        m_pFileNameED->SetAccessibleName(m_pFileNameFT->GetText());
+        m_xDDECommandFT->hide();
+        m_xFileNameFT->set_sensitive(bFile);
+        m_xFileNameFT->show();
+        m_xSubRegionFT->show();
+        m_xSubRegionED->show();
+        m_xSubRegionED->set_sensitive(bFile);
+        m_xFileNameED->set_accessible_name(m_xFileNameFT->get_label());
     }
 }
 
@@ -1805,9 +1873,9 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil
             const SfxPoolItem* pItem;
             if ( SfxItemState::SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, false, &pItem ) )
                 m_sFilePasswd = static_cast<const SfxStringItem*>(pItem)->GetValue();
-            m_pFileNameED->SetText( INetURLObject::decode(
+            m_xFileNameED->set_text( INetURLObject::decode(
                 m_sFileName, INetURLObject::DecodeMechanism::Unambiguous ) );
-            ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
+            ::lcl_ReadSections(*pMedium, *m_xSubRegionED);
         }
     }
     else
diff --git a/sw/source/uibase/inc/condedit.hxx b/sw/source/uibase/inc/condedit.hxx
index 972e9574bbce..4efdbff7f867 100644
--- a/sw/source/uibase/inc/condedit.hxx
+++ b/sw/source/uibase/inc/condedit.hxx
@@ -71,6 +71,7 @@ public:
     OUString get_text() const { return m_xControl->get_text(); }
     bool get_sensitive() const { return m_xControl->get_sensitive(); }
     void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
+    void hide() { m_xControl->hide(); }
     weld::Entry& get_widget() { return *m_xControl; }
 
     void ShowBrackets(bool bShow) { bBrackets = bShow; }
diff --git a/sw/source/uibase/inc/regionsw.hxx b/sw/source/uibase/inc/regionsw.hxx
index fb9cf0d66db7..822f46e8b820 100644
--- a/sw/source/uibase/inc/regionsw.hxx
+++ b/sw/source/uibase/inc/regionsw.hxx
@@ -133,28 +133,6 @@ public:
 // dialog "insert region"
 class SwInsertSectionTabPage : public SfxTabPage
 {
-    VclPtr<ComboBox>       m_pCurName;
-
-    VclPtr<CheckBox>       m_pFileCB;
-    VclPtr<CheckBox>       m_pDDECB;
-    VclPtr<FixedText>      m_pDDECommandFT;
-    VclPtr<FixedText>      m_pFileNameFT;
-    VclPtr<Edit>           m_pFileNameED;
-    VclPtr<PushButton>     m_pFilePB;
-    VclPtr<FixedText>      m_pSubRegionFT;
-    VclPtr<ComboBox>       m_pSubRegionED;
-
-    VclPtr<CheckBox>       m_pProtectCB;
-    VclPtr<CheckBox>       m_pPasswdCB;
-    VclPtr<PushButton>     m_pPasswdPB;
-
-    VclPtr<CheckBox>       m_pHideCB;
-    VclPtr<FixedText>      m_pConditionFT;
-    VclPtr<ConditionEdit>  m_pConditionED;
-
-    // #114856# edit in readonly sections
-    VclPtr<CheckBox>       m_pEditInReadonlyCB;
-
     OUString        m_sFileName;
     OUString        m_sFilterName;
     OUString        m_sFilePasswd;
@@ -163,19 +141,39 @@ class SwInsertSectionTabPage : public SfxTabPage
     SwWrtShell*             m_pWrtSh;
     std::unique_ptr<sfx2::DocumentInserter> m_pDocInserter;
 
-    DECL_LINK( ChangeHideHdl, Button *, void );
-    DECL_LINK( ChangeProtectHdl, Button *, void );
-    DECL_LINK( ChangePasswdHdl, Button *, void );
-    DECL_LINK( NameEditHdl, Edit&, void );
-    DECL_LINK( UseFileHdl, Button*, void );
-    DECL_LINK( FileSearchHdl, Button*, void );
-    DECL_LINK( DDEHdl, Button*, void );
+    std::unique_ptr<weld::EntryTreeView> m_xCurName;
+    std::unique_ptr<weld::CheckButton> m_xFileCB;
+    std::unique_ptr<weld::CheckButton> m_xDDECB;
+    std::unique_ptr<weld::Label> m_xDDECommandFT;
+    std::unique_ptr<weld::Label> m_xFileNameFT;
+    std::unique_ptr<weld::Entry> m_xFileNameED;
+    std::unique_ptr<weld::Button> m_xFilePB;
+    std::unique_ptr<weld::Label> m_xSubRegionFT;
+    std::unique_ptr<weld::ComboBox> m_xSubRegionED;
+    std::unique_ptr<weld::CheckButton> m_xProtectCB;
+    std::unique_ptr<weld::CheckButton> m_xPasswdCB;
+    std::unique_ptr<weld::Button> m_xPasswdPB;
+    std::unique_ptr<weld::CheckButton> m_xHideCB;
+    std::unique_ptr<weld::Label> m_xConditionFT;
+    std::unique_ptr<SwConditionEdit> m_xConditionED;
+    // #114856# edit in readonly sections
+    std::unique_ptr<weld::CheckButton> m_xEditInReadonlyCB;
+
+    void ChangePasswd(bool bChange);
+
+    DECL_LINK( ChangeHideHdl, weld::ToggleButton&, void );
+    DECL_LINK( ChangeProtectHdl, weld::ToggleButton&, void );
+    DECL_LINK( ChangePasswdHdl, weld::Button&, void );
+    DECL_LINK( TogglePasswdHdl, weld::ToggleButton&, void );
+    DECL_LINK( NameEditHdl, weld::ComboBox&, void );
+    DECL_LINK( UseFileHdl, weld::ToggleButton&, void );
+    DECL_LINK( FileSearchHdl, weld::Button&, void );
+    DECL_LINK( DDEHdl, weld::ToggleButton&, void );
     DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper*, void );
 
 public:
-    SwInsertSectionTabPage(vcl::Window *pParent, const SfxItemSet &rAttrSet);
+    SwInsertSectionTabPage(TabPageParent pParent, const SfxItemSet &rAttrSet);
     virtual ~SwInsertSectionTabPage() override;
-    virtual void dispose() override;
 
     void    SetWrtShell(SwWrtShell& rSh);
 
diff --git a/sw/uiconfig/swriter/ui/sectionpage.ui b/sw/uiconfig/swriter/ui/sectionpage.ui
index 90a51f5997ad..d28d3002ec38 100644
--- a/sw/uiconfig/swriter/ui/sectionpage.ui
+++ b/sw/uiconfig/swriter/ui/sectionpage.ui
@@ -1,8 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkGrid" id="SectionPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -27,18 +34,62 @@
             <property name="top_padding">6</property>
             <property name="left_padding">12</property>
             <child>
-              <object class="VclComboBoxText" id="sectionnames">
+              <object class="GtkGrid" id="sectionnames">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="has_entry">True</property>
-                <property name="dropdown">False</property>
-                <property name="max_width_chars">18</property>
-                <child internal-child="entry">
-                  <object class="GtkEntry" id="comboboxtext-entry">
+                <property name="row_spacing">3</property>
+                <child>
+                  <object class="GtkScrolledWindow">
+                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="sectionnames-list">
+                        <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>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="sectionnames-entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="activates_default">True</property>
                   </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
                 </child>
               </object>
             </child>
@@ -125,10 +176,10 @@
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
                         <property name="label" translatable="yes" context="sectionpage|sectionlabel">_Section</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">sectionname</property>
+                        <property name="xalign">0</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -149,16 +200,16 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="VclComboBoxText" id="sectionname">
+                      <object class="GtkComboBoxText" id="sectionname">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
                         <property name="can_focus">False</property>
                         <property name="hexpand">True</property>
                         <property name="has_entry">True</property>
-                        <property name="max_width_chars">18</property>
                         <child internal-child="entry">
                           <object class="GtkEntry" id="comboboxtext-entry1">
-                            <property name="can_focus">False</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
                           </object>
                         </child>
                       </object>
@@ -177,10 +228,10 @@
                             <property name="visible">True</property>
                             <property name="sensitive">False</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
                             <property name="label" translatable="yes" context="sectionpage|filelabel">_File name</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">filename</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -192,10 +243,10 @@
                           <object class="GtkLabel" id="ddelabel">
                             <property name="can_focus">False</property>
                             <property name="no_show_all">True</property>
-                            <property name="xalign">0</property>
                             <property name="label" translatable="yes" context="sectionpage|ddelabel">DDE _command</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">filename</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -355,7 +406,7 @@
                     <property name="row_spacing">6</property>
                     <property name="column_spacing">12</property>
                     <child>
-                      <object class="swlo-ConditionEdit" id="withcond">
+                      <object class="GtkEntry" id="withcond">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
                         <property name="can_focus">True</property>
@@ -388,10 +439,10 @@
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
                         <property name="label" translatable="yes" context="sectionpage|condlabel">_With Condition</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">withcond</property>
+                        <property name="xalign">0</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>


More information about the Libreoffice-commits mailing list