[Libreoffice-commits] core.git: 2 commits - extras/source sfx2/source solenv/bin sw/source sw/uiconfig vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 22 18:40:57 UTC 2019


 extras/source/glade/libreoffice-catalog.xml.in |    3 
 sfx2/source/dialog/backingcomp.cxx             |   10 +
 solenv/bin/native-code.py                      |    1 
 sw/source/ui/dbui/mailmergewizard.cxx          |    2 
 sw/source/ui/dbui/mmaddressblockpage.cxx       |  201 ++++++++++++-------------
 sw/source/ui/dbui/mmaddressblockpage.hxx       |   59 ++++---
 sw/source/uibase/dbui/mailmergehelper.cxx      |    9 +
 sw/source/uibase/inc/mailmergehelper.hxx       |    5 
 sw/uiconfig/swriter/ui/mmaddressblockpage.ui   |   38 ++++
 vcl/source/control/button.cxx                  |   10 +
 vcl/source/window/bufferdevice.cxx             |    2 
 vcl/source/window/bufferdevice.hxx             |    1 
 vcl/source/window/menubarwindow.cxx            |   16 +
 13 files changed, 218 insertions(+), 139 deletions(-)

New commits:
commit b5f2f32defd22c8ec0c47c0100836a8d5bb132ea
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Aug 22 17:15:44 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Aug 22 20:40:07 2019 +0200

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

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index eef7bdd744b6..a86845bd17d1 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -159,9 +159,6 @@
     <glade-widget-class title="NUP Preview" name="vcllo-ShowNupOrderWindow"
                         generic-name="NUP Preview" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
-    <glade-widget-class title="Address Preview" name="swlo-SwAddressPreview"
-                        generic-name="Address Preview" parent="GtkDrawingArea"
-                        icon-name="widget-gtk-drawingarea"/>
     <glade-widget-class title="Tree List" name="vcllo-SvTreeListBox"
                         generic-name="Tree List" parent="GtkTreeView"
                         icon-name="widget-gtk-treeview">
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index a58a30654a06..45a3fee13118 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -512,7 +512,6 @@ custom_widgets = [
     'SvxRelativeField',
     'SvxTextEncodingBox',
     'SvxTextEncodingBox',
-    'SwAddressPreview',
     'SwNavHelpToolBox',
     'TableValueSet',
     'TemplateDefaultView',
diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index 49ea7c661fc9..6ca8822cbfc3 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -106,7 +106,7 @@ VclPtr<TabPage> SwMailMergeWizard::createPage(WizardState _nState)
             SetRoadmapHelpId("modules/swriter/ui/mmoutputtypepage/MMOutputTypePage");
         break;
         case MM_ADDRESSBLOCKPAGE   :
-            pRet = VclPtr<SwMailMergeAddressBlockPage>::Create(this);
+            pRet = VclPtr<SwMailMergeAddressBlockPage>::Create(this, TabPageParent(this));
             SetRoadmapHelpId("modules/swriter/ui/mmaddressblockpage/MMAddressBlockPage");
         break;
         case MM_GREETINGSPAGE      :
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index dd12860e54ca..0edb9bddee1f 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -57,46 +57,46 @@ using namespace ::com::sun::star::sdb;
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::sdbcx;
 
-SwMailMergeAddressBlockPage::SwMailMergeAddressBlockPage( SwMailMergeWizard* _pParent) :
-    vcl::OWizardPage(_pParent, "MMAddressBlockPage",
-        "modules/swriter/ui/mmaddressblockpage.ui")
-    , m_pWizard(_pParent)
-{
-    get(m_pAddressListPB, "addresslist");
-    get(m_pCurrentAddressFI, "currentaddress");
-    get(m_pStep2, "step2");
-    get(m_pStep3, "step3");
-    get(m_pStep4, "step4");
-    get(m_pSettingsFI, "settingsft");
-    get(m_pAddressCB, "address");
-    get(m_pSettingsWIN, "settingspreview");
+SwMailMergeAddressBlockPage::SwMailMergeAddressBlockPage(SwMailMergeWizard* pWizard, TabPageParent pParent)
+    : vcl::OWizardPage(pParent, "modules/swriter/ui/mmaddressblockpage.ui", "MMAddressBlockPage")
+    , m_pWizard(pWizard)
+    , m_xAddressListPB(m_xBuilder->weld_button("addresslist"))
+    , m_xCurrentAddressFI(m_xBuilder->weld_label("currentaddress"))
+    , m_xStep2(m_xBuilder->weld_container("step2"))
+    , m_xStep3(m_xBuilder->weld_container("step3"))
+    , m_xStep4(m_xBuilder->weld_container("step4"))
+    , m_xSettingsFI(m_xBuilder->weld_label("settingsft"))
+    , m_xAddressCB(m_xBuilder->weld_check_button("address"))
+    , m_xSettingsPB(m_xBuilder->weld_button("settings"))
+    , m_xHideEmptyParagraphsCB(m_xBuilder->weld_check_button("hideempty"))
+    , m_xAssignPB(m_xBuilder->weld_button("assign"))
+    , m_xDocumentIndexFI(m_xBuilder->weld_label("documentindex"))
+    , m_xPrevSetIB(m_xBuilder->weld_button("prev"))
+    , m_xNextSetIB(m_xBuilder->weld_button("next"))
+    , m_xDifferentlist(m_xBuilder->weld_label("differentlist"))
+    , m_xSettings(new AddressPreview(m_xBuilder->weld_scrolled_window("settingspreviewwin")))
+    , m_xPreview(new AddressPreview(m_xBuilder->weld_scrolled_window("addresspreviewwin")))
+    , m_xSettingsWIN(new weld::CustomWeld(*m_xBuilder, "settingspreview", *m_xSettings))
+    , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "addresspreview", *m_xPreview))
+{
     Size aSize(LogicToPixel(Size(164 , 45), MapMode(MapUnit::MapAppFont)));
-    m_pSettingsWIN->set_width_request(aSize.Width());
-    m_pSettingsWIN->set_height_request(aSize.Height());
-    get(m_pSettingsPB, "settings");
-    get(m_pHideEmptyParagraphsCB, "hideempty");
-    get(m_pAssignPB, "assign");
-    get(m_pPreviewWIN, "addresspreview");
+    m_xSettingsWIN->set_size_request(aSize.Width(), aSize.Height());
     aSize = LogicToPixel(Size(176, 46), MapMode(MapUnit::MapAppFont));
-    m_pPreviewWIN->set_width_request(aSize.Width());
-    m_pPreviewWIN->set_height_request(aSize.Height());
-    get(m_pDocumentIndexFI, "documentindex");
-    get(m_pPrevSetIB, "prev");
-    get(m_pNextSetIB, "next");
-    m_sDocument = m_pDocumentIndexFI->GetText();
-    m_sChangeAddress = get<Button>("differentlist")->GetText();
-
-    m_sCurrentAddress = m_pCurrentAddressFI->GetText();
-    m_pAddressListPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressListHdl_Impl));
-    m_pSettingsPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, SettingsHdl_Impl));
-    m_pAssignPB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AssignHdl_Impl ));
-    m_pAddressCB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockHdl_Impl));
-    m_pSettingsWIN->SetSelectHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl));
-    m_pHideEmptyParagraphsCB->SetClickHdl(LINK(this, SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl));
-
-    Link<Button*,void> aLink = LINK(this, SwMailMergeAddressBlockPage, InsertDataHdl_Impl);
-    m_pPrevSetIB->SetClickHdl(aLink);
-    m_pNextSetIB->SetClickHdl(aLink);
+    m_xPreviewWIN->set_size_request(aSize.Width(), aSize.Height());
+    m_sChangeAddress = m_xDifferentlist->get_label();
+    m_sDocument = m_xDocumentIndexFI->get_label();
+
+    m_sCurrentAddress = m_xCurrentAddressFI->get_label();
+    m_xAddressListPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, AddressListHdl_Impl));
+    m_xSettingsPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, SettingsHdl_Impl));
+    m_xAssignPB->connect_clicked(LINK(this, SwMailMergeAddressBlockPage, AssignHdl_Impl ));
+    m_xAddressCB->connect_toggled(LINK(this, SwMailMergeAddressBlockPage, AddressBlockHdl_Impl));
+    m_xSettings->SetSelectHdl(LINK(this, SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl));
+    m_xHideEmptyParagraphsCB->connect_toggled(LINK(this, SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl));
+
+    Link<weld::Button&,void> aLink = LINK(this, SwMailMergeAddressBlockPage, InsertDataHdl_Impl);
+    m_xPrevSetIB->connect_clicked(aLink);
+    m_xNextSetIB->connect_clicked(aLink);
 }
 
 SwMailMergeAddressBlockPage::~SwMailMergeAddressBlockPage()
@@ -106,21 +106,11 @@ SwMailMergeAddressBlockPage::~SwMailMergeAddressBlockPage()
 
 void SwMailMergeAddressBlockPage::dispose()
 {
-    m_pAddressListPB.clear();
-    m_pCurrentAddressFI.clear();
-    m_pStep2.clear();
-    m_pStep3.clear();
-    m_pStep4.clear();
-    m_pSettingsFI.clear();
-    m_pAddressCB.clear();
-    m_pSettingsWIN.clear();
-    m_pSettingsPB.clear();
-    m_pHideEmptyParagraphsCB.clear();
-    m_pAssignPB.clear();
-    m_pPreviewWIN.clear();
-    m_pDocumentIndexFI.clear();
-    m_pPrevSetIB.clear();
-    m_pNextSetIB.clear();
+    m_xPreviewWIN.reset();
+    m_xSettingsWIN.reset();
+    m_xPreview.reset();
+    m_xSettings.reset();
+
     m_pWizard.clear();
     vcl::OWizardPage::dispose();
 }
@@ -136,25 +126,25 @@ void SwMailMergeAddressBlockPage::ActivatePage()
     bool bIsLetter = rConfigItem.IsOutputToLetter();
 
     //no address block is created for e-Mail
-    m_pStep2->Show(bIsLetter);
-    m_pStep3->Show(bIsLetter);
-    m_pStep4->Show(bIsLetter);
+    m_xStep2->set_visible(bIsLetter);
+    m_xStep3->set_visible(bIsLetter);
+    m_xStep4->set_visible(bIsLetter);
 
     if (bIsLetter)
     {
-        m_pHideEmptyParagraphsCB->Check( rConfigItem.IsHideEmptyParagraphs() );
-        m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", "1"));
+        m_xHideEmptyParagraphsCB->set_active( rConfigItem.IsHideEmptyParagraphs() );
+        m_xDocumentIndexFI->set_label(m_sDocument.replaceFirst("%1", "1"));
 
-        m_pSettingsWIN->Clear();
+        m_xSettings->Clear();
         const uno::Sequence< OUString> aBlocks =
                     m_pWizard->GetConfigItem().GetAddressBlocks();
         for(const auto& rAddress : aBlocks)
-            m_pSettingsWIN->AddAddress(rAddress);
-        m_pSettingsWIN->SelectAddress(static_cast<sal_uInt16>(rConfigItem.GetCurrentAddressBlockIndex()));
-        m_pAddressCB->Check(rConfigItem.IsAddressBlock());
-        AddressBlockHdl_Impl(m_pAddressCB);
-        m_pSettingsWIN->SetLayout(1, 2);
-        InsertDataHdl_Impl(nullptr);
+            m_xSettings->AddAddress(rAddress);
+        m_xSettings->SelectAddress(static_cast<sal_uInt16>(rConfigItem.GetCurrentAddressBlockIndex()));
+        m_xAddressCB->set_active(rConfigItem.IsAddressBlock());
+        AddressBlockHdl_Impl(*m_xAddressCB);
+        m_xSettings->SetLayout(1, 2);
+        InsertDataHdl(nullptr);
     }
 }
 
@@ -163,7 +153,7 @@ bool SwMailMergeAddressBlockPage::commitPage( ::vcl::WizardTypes::CommitPageReas
     return ::vcl::WizardTypes::eTravelForward != _eReason || m_pWizard->GetConfigItem().GetResultSet().is();
 }
 
-IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, weld::Button&, void)
 {
     try
     {
@@ -178,7 +168,7 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, Button*, void)
                             aAddrDialog.GetDBData());
             OUString sFilter = aAddrDialog.GetFilter();
             rConfigItem.SetFilter( sFilter );
-            InsertDataHdl_Impl(nullptr);
+            InsertDataHdl(nullptr);
             GetWizard()->UpdateRoadmap();
             GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
         }
@@ -192,39 +182,39 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, Button*, void)
     }
 }
 
-IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, SettingsHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, SettingsHdl_Impl, weld::Button&, void)
 {
     SwSelectAddressBlockDialog aDlg(GetFrameWeld(), m_pWizard->GetConfigItem());
     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
-    aDlg.SetAddressBlocks(rConfig.GetAddressBlocks(), m_pSettingsWIN->GetSelectedAddress());
+    aDlg.SetAddressBlocks(rConfig.GetAddressBlocks(), m_xSettings->GetSelectedAddress());
     aDlg.SetSettings(rConfig.IsIncludeCountry(), rConfig.GetExcludeCountry());
     if (aDlg.run() == RET_OK)
     {
         //the dialog provides the selected address at the first position!
         const uno::Sequence< OUString> aBlocks = aDlg.GetAddressBlocks();
         rConfig.SetAddressBlocks(aBlocks);
-        m_pSettingsWIN->Clear();
+        m_xSettings->Clear();
         for(const auto& rAddress : aBlocks)
-            m_pSettingsWIN->AddAddress(rAddress);
-        m_pSettingsWIN->SelectAddress(0);
-        m_pSettingsWIN->Invalidate();    // #i40408
+            m_xSettings->AddAddress(rAddress);
+        m_xSettings->SelectAddress(0);
+        m_xSettings->Invalidate();    // #i40408
         rConfig.SetCountrySettings(aDlg.IsIncludeCountry(), aDlg.GetCountry());
-        InsertDataHdl_Impl(nullptr);
+        InsertDataHdl(nullptr);
     }
     GetWizard()->UpdateRoadmap();
     GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
 }
 
-IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, Button*, pButton, void)
+IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AssignHdl_Impl, weld::Button&, void)
 {
     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+    const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
     const uno::Sequence< OUString> aBlocks = rConfigItem.GetAddressBlocks();
-    SwAssignFieldsDialog aDlg(pButton->GetFrameWeld(), m_pWizard->GetConfigItem(), aBlocks[nSel], true);
+    SwAssignFieldsDialog aDlg(m_pWizard->GetFrameWeld(), m_pWizard->GetConfigItem(), aBlocks[nSel], true);
     if(RET_OK == aDlg.run())
     {
         //preview update
-        InsertDataHdl_Impl(nullptr);
+        InsertDataHdl(nullptr);
         GetWizard()->UpdateRoadmap();
         GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
     }
@@ -232,44 +222,44 @@ IMPL_LINK(SwMailMergeAddressBlockPage, AssignHdl_Impl, Button*, pButton, void)
 
 void SwMailMergeAddressBlockPage::EnableAddressBlock(bool bAll, bool bSelective)
 {
-    m_pSettingsFI->Enable(bAll);
-    m_pAddressCB->Enable(bAll);
+    m_xSettingsFI->set_sensitive(bAll);
+    m_xAddressCB->set_sensitive(bAll);
     bSelective &= bAll;
-    m_pHideEmptyParagraphsCB->Enable(bSelective);
-    m_pSettingsWIN->Enable(bSelective);
-    m_pSettingsPB->Enable(bSelective);
-    m_pStep3->Enable(bSelective);
-    m_pStep4->Enable(bSelective);
+    m_xHideEmptyParagraphsCB->set_sensitive(bSelective);
+    m_xSettingsWIN->set_sensitive(bSelective);
+    m_xSettingsPB->set_sensitive(bSelective);
+    m_xStep3->set_sensitive(bSelective);
+    m_xStep4->set_sensitive(bSelective);
 }
 
-IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, Button*, pBox, void)
+IMPL_LINK(SwMailMergeAddressBlockPage, AddressBlockHdl_Impl, weld::ToggleButton&, rBox, void)
 {
-    EnableAddressBlock(pBox->IsEnabled(), static_cast<CheckBox*>(pBox)->IsChecked());
+    EnableAddressBlock(rBox.get_sensitive(), rBox.get_active());
     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    rConfigItem.SetAddressBlock(m_pAddressCB->IsChecked());
+    rConfigItem.SetAddressBlock(m_xAddressCB->get_active());
     m_pWizard->UpdateRoadmap();
     GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
 }
 
 IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressBlockSelectHdl_Impl, LinkParamNone*, void)
 {
-    const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+    const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
     const uno::Sequence< OUString> aBlocks =
                 m_pWizard->GetConfigItem().GetAddressBlocks();
-    m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel],
+    m_xPreview->SetAddress(SwAddressPreview::FillData(aBlocks[nSel],
                                                          m_pWizard->GetConfigItem()));
     m_pWizard->GetConfigItem().SetCurrentAddressBlockIndex( nSel );
     GetWizard()->UpdateRoadmap();
     GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
 }
 
-IMPL_LINK(SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl, Button*, pBox, void)
+IMPL_LINK(SwMailMergeAddressBlockPage, HideParagraphsHdl_Impl, weld::ToggleButton&, rBox, void)
 {
     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    rConfigItem.SetHideEmptyParagraphs( static_cast<CheckBox*>(pBox)->IsChecked() );
+    rConfigItem.SetHideEmptyParagraphs(rBox.get_active());
 }
 
-IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, Button*, pButton, void)
+void SwMailMergeAddressBlockPage::InsertDataHdl(weld::Button* pButton)
 {
     //if no pButton is given, the first set has to be pre-set
     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
@@ -280,7 +270,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, Button*, pButton, voi
     }
     else
     {
-        bool bNext = pButton == m_pNextSetIB;
+        bool bNext = pButton == m_xNextSetIB.get();
         sal_Int32 nPos = rConfig.GetResultSetPosition();
         rConfig.MoveResultSet( bNext ? ++nPos : --nPos);
     }
@@ -295,27 +285,32 @@ IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, Button*, pButton, voi
     else
     {
         //if output type is letter
-        if(m_pSettingsWIN->IsVisible())
+        if (m_xSettings->IsVisible())
         {
             //Fill data into preview
-            const sal_uInt16 nSel = m_pSettingsWIN->GetSelectedAddress();
+            const sal_uInt16 nSel = m_xSettings->GetSelectedAddress();
             const uno::Sequence< OUString> aBlocks =
                         m_pWizard->GetConfigItem().GetAddressBlocks();
-            m_pPreviewWIN->SetAddress(SwAddressPreview::FillData(aBlocks[nSel], rConfig));
+            m_xPreview->SetAddress(SwAddressPreview::FillData(aBlocks[nSel], rConfig));
         }
     }
-    m_pPrevSetIB->Enable(bEnable);
-    m_pDocumentIndexFI->SetText(m_sDocument.replaceFirst("%1", OUString::number(nPos)));
+    m_xPrevSetIB->set_sensitive(bEnable);
+    m_xDocumentIndexFI->set_label(m_sDocument.replaceFirst("%1", OUString::number(nPos)));
 
     GetWizard()->enableButtons(WizardButtonFlags::NEXT, GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
     bool bHasResultSet = rConfig.GetResultSet().is();
-    m_pCurrentAddressFI->Show(bHasResultSet);
+    m_xCurrentAddressFI->set_visible(bHasResultSet);
     if(bHasResultSet)
     {
-        m_pCurrentAddressFI->SetText(m_sCurrentAddress.replaceFirst("%1", rConfig.GetCurrentDBData().sDataSource));
-        m_pAddressListPB->SetText(m_sChangeAddress);
+        m_xCurrentAddressFI->set_label(m_sCurrentAddress.replaceFirst("%1", rConfig.GetCurrentDBData().sDataSource));
+        m_xAddressListPB->set_label(m_sChangeAddress);
     }
-    EnableAddressBlock(bHasResultSet, m_pAddressCB->IsChecked());
+    EnableAddressBlock(bHasResultSet, m_xAddressCB->get_active());
+}
+
+IMPL_LINK(SwMailMergeAddressBlockPage, InsertDataHdl_Impl, weld::Button&, rButton, void)
+{
+    InsertDataHdl(&rButton);
 }
 
 SwSelectAddressBlockDialog::SwSelectAddressBlockDialog(weld::Window* pParent, SwMailMergeConfigItem& rConfig)
diff --git a/sw/source/ui/dbui/mmaddressblockpage.hxx b/sw/source/ui/dbui/mmaddressblockpage.hxx
index 1bf08e55c2df..8d719ae1aa71 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.hxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.hxx
@@ -34,39 +34,46 @@ class SwMailMergeConfigItem;
 
 class SwMailMergeAddressBlockPage : public vcl::OWizardPage
 {
-    VclPtr<PushButton>         m_pAddressListPB;
-    VclPtr<FixedText>          m_pCurrentAddressFI;
+    OUString            m_sDocument;
+    OUString            m_sCurrentAddress;
+    OUString            m_sChangeAddress;
 
-    VclPtr<VclContainer>       m_pStep2;
-    VclPtr<VclContainer>       m_pStep3;
-    VclPtr<VclContainer>       m_pStep4;
+    VclPtr<SwMailMergeWizard>  m_pWizard;
 
-    VclPtr<FixedText>          m_pSettingsFI;
-    VclPtr<CheckBox>           m_pAddressCB;
-    VclPtr<SwAddressPreview>   m_pSettingsWIN;
-    VclPtr<PushButton>         m_pSettingsPB;
-    VclPtr<CheckBox>           m_pHideEmptyParagraphsCB;
+    std::unique_ptr<weld::Button> m_xAddressListPB;
+    std::unique_ptr<weld::Label> m_xCurrentAddressFI;
 
-    VclPtr<PushButton>         m_pAssignPB;
+    std::unique_ptr<weld::Container> m_xStep2;
+    std::unique_ptr<weld::Container> m_xStep3;
+    std::unique_ptr<weld::Container> m_xStep4;
 
-    VclPtr<SwAddressPreview>   m_pPreviewWIN;
-    VclPtr<FixedText>          m_pDocumentIndexFI;
-    VclPtr<PushButton>         m_pPrevSetIB;
-    VclPtr<PushButton>         m_pNextSetIB;
+    std::unique_ptr<weld::Label> m_xSettingsFI;
+    std::unique_ptr<weld::CheckButton> m_xAddressCB;
+    std::unique_ptr<weld::Button> m_xSettingsPB;
+    std::unique_ptr<weld::CheckButton> m_xHideEmptyParagraphsCB;
 
-    OUString            m_sDocument;
-    OUString            m_sCurrentAddress;
-    OUString            m_sChangeAddress;
+    std::unique_ptr<weld::Button> m_xAssignPB;
 
-    VclPtr<SwMailMergeWizard>  m_pWizard;
+    std::unique_ptr<weld::Label> m_xDocumentIndexFI;
+    std::unique_ptr<weld::Button> m_xPrevSetIB;
+    std::unique_ptr<weld::Button> m_xNextSetIB;
+
+    std::unique_ptr<weld::Label> m_xDifferentlist;
+
+    std::unique_ptr<AddressPreview> m_xSettings;
+    std::unique_ptr<AddressPreview> m_xPreview;
+    std::unique_ptr<weld::CustomWeld> m_xSettingsWIN;
+    std::unique_ptr<weld::CustomWeld> m_xPreviewWIN;
+
+    void InsertDataHdl(weld::Button* pButton);
 
-    DECL_LINK(AddressListHdl_Impl, Button *, void);
-    DECL_LINK(SettingsHdl_Impl, Button*, void);
-    DECL_LINK(AssignHdl_Impl, Button*, void);
-    DECL_LINK(AddressBlockHdl_Impl, Button*, void);
-    DECL_LINK(InsertDataHdl_Impl, Button*, void);
+    DECL_LINK(AddressListHdl_Impl, weld::Button&, void);
+    DECL_LINK(SettingsHdl_Impl, weld::Button&, void);
+    DECL_LINK(AssignHdl_Impl, weld::Button&, void);
+    DECL_LINK(AddressBlockHdl_Impl, weld::ToggleButton&, void);
+    DECL_LINK(InsertDataHdl_Impl, weld::Button&, void);
     DECL_LINK(AddressBlockSelectHdl_Impl, LinkParamNone*, void);
-    DECL_LINK(HideParagraphsHdl_Impl, Button*, void);
+    DECL_LINK(HideParagraphsHdl_Impl, weld::ToggleButton&, void);
 
     void                EnableAddressBlock(bool bAll, bool bSelective);
 
@@ -75,7 +82,7 @@ class SwMailMergeAddressBlockPage : public vcl::OWizardPage
     virtual bool        canAdvance() const override;
 
 public:
-    SwMailMergeAddressBlockPage(SwMailMergeWizard* _pParent);
+    SwMailMergeAddressBlockPage(SwMailMergeWizard* pWizard, TabPageParent pParent);
     virtual ~SwMailMergeAddressBlockPage() override;
     virtual void dispose() override;
     SwMailMergeWizard* GetWizard() { return m_pWizard; }
diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx
index f65eb9c96620..bbf60a49dd63 100644
--- a/sw/source/uibase/dbui/mailmergehelper.cxx
+++ b/sw/source/uibase/dbui/mailmergehelper.cxx
@@ -573,6 +573,13 @@ void AddressPreview::SelectAddress(sal_uInt16 nSelect)
         m_xVScrollBar->vadjustment_set_value(nSelectRow);
 }
 
+void AddressPreview::Clear()
+{
+    pImpl->aAddresses.clear();
+    pImpl->nSelectedAddress = 0;
+    UpdateScrollBar();
+}
+
 void AddressPreview::ReplaceSelectedAddress(const OUString& rNew)
 {
     pImpl->aAddresses[pImpl->nSelectedAddress] = rNew;
@@ -683,6 +690,7 @@ bool AddressPreview::MouseButtonDown( const MouseEvent& rMEvt )
                 pImpl->nSelectedAddress != static_cast<sal_uInt16>(nSelect))
         {
             pImpl->nSelectedAddress = static_cast<sal_uInt16>(nSelect);
+            m_aSelectHdl.Call(nullptr);
         }
         Invalidate();
     }
@@ -726,6 +734,7 @@ bool AddressPreview::KeyInput( const KeyEvent& rKEvt )
                 pImpl->nSelectedAddress != static_cast<sal_uInt16>(nSelect))
         {
             pImpl->nSelectedAddress = static_cast<sal_uInt16>(nSelect);
+            m_aSelectHdl.Call(nullptr);
             Invalidate();
         }
     }
diff --git a/sw/source/uibase/inc/mailmergehelper.hxx b/sw/source/uibase/inc/mailmergehelper.hxx
index f93161a7108c..ae356c0b844d 100644
--- a/sw/source/uibase/inc/mailmergehelper.hxx
+++ b/sw/source/uibase/inc/mailmergehelper.hxx
@@ -113,6 +113,7 @@ class SW_DLLPUBLIC AddressPreview : public weld::CustomWidgetController
 {
     std::unique_ptr<SwAddressPreview_Impl> pImpl;
     std::unique_ptr<weld::ScrolledWindow> m_xVScrollBar;
+    Link<LinkParamNone*,void> m_aSelectHdl;
 
     void DrawText_Impl(vcl::RenderContext& rRenderContext, const OUString& rAddress,
                        const Point& rTopLeft, const Size& rSize, bool bIsSelected);
@@ -138,6 +139,8 @@ public:
     void AddAddress(const OUString& rAddress);
     //  for preview mode - replaces the currently used address by the given one
     void SetAddress(const OUString& rAddress);
+    // removes all addresses
+    void Clear();
 
     // returns the selected address
     sal_uInt16 GetSelectedAddress() const;
@@ -148,6 +151,8 @@ public:
     // set the number of rows and columns of addresses
     void SetLayout(sal_uInt16 nRows, sal_uInt16 nColumns);
     void EnableScrollBar();
+
+    void SetSelectHdl (const Link<LinkParamNone*,void>& rLink) { m_aSelectHdl = rLink; }
 };
 
 
diff --git a/sw/uiconfig/swriter/ui/mmaddressblockpage.ui b/sw/uiconfig/swriter/ui/mmaddressblockpage.ui
index 643f5b737ec9..ebecf2aad090 100644
--- a/sw/uiconfig/swriter/ui/mmaddressblockpage.ui
+++ b/sw/uiconfig/swriter/ui/mmaddressblockpage.ui
@@ -319,11 +319,27 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="swlo-SwAddressPreview" id="settingspreview:border">
+                                  <object class="GtkScrolledWindow" id="settingspreviewwin">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="hexpand">True</property>
                                     <property name="vexpand">True</property>
+                                    <property name="hscrollbar_policy">never</property>
+                                    <property name="shadow_type">in</property>
+                                    <child>
+                                      <object class="GtkViewport">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <child>
+                                          <object class="GtkDrawingArea" id="settingspreview">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="hexpand">True</property>
+                                            <property name="vexpand">True</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                    </child>
                                   </object>
                                   <packing>
                                     <property name="left_attach">0</property>
@@ -397,11 +413,27 @@
                             <property name="vexpand">True</property>
                             <property name="row_spacing">6</property>
                             <child>
-                              <object class="swlo-SwAddressPreview" id="addresspreview:border">
+                              <object class="GtkScrolledWindow" id="addresspreviewwin">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
+                                <property name="can_focus">False</property>
                                 <property name="hexpand">True</property>
                                 <property name="vexpand">True</property>
+                                <property name="hscrollbar_policy">never</property>
+                                <property name="shadow_type">in</property>
+                                <child>
+                                  <object class="GtkViewport">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <child>
+                                      <object class="GtkDrawingArea" id="addresspreview">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="hexpand">True</property>
+                                        <property name="vexpand">True</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
                               </object>
                               <packing>
                                 <property name="left_attach">0</property>
commit d5c7657c541c1f6d17bfe5e605594c235eecfcdb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Aug 22 17:30:43 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Aug 22 20:40:01 2019 +0200

    tdf#71087 sfx2: avoid flicker in the start center
    
    There were a couple of problems here:
    
    1) BackingWindow now does double-buffering to avoid flicker when e.g.
    navigating with the keyboard in sfx2::RecentDocsView
    
    2) But then the menu background turned into white (instead of the
    gradient), so MenuBarWindow needs to differentiate between doing its own
    buffering vs painting into a buffer.
    
    3) The focus rectangles were always painted directly, so keyboard
    navigation in the startcenter lost focus rectangles, making it hard to
    see which button is active currently. Fix this by explicitly painting a
    tracking rectangle in PushButton::ImplDrawPushButton().
    
    This brings an improvement for the Windows GDI and Linux gen backends.
    Windows GL and Linux gtk3 is meant to be unchanged, they were already
    flicker-free here.
    
    Change-Id: Ib01e330c244c2b38a5b5c52399692e19ff811de3
    Reviewed-on: https://gerrit.libreoffice.org/77969
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx
index 1de9a2daa698..a810f0be9fda 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -576,6 +576,12 @@ void SAL_CALL BackingComp::dispose()
     {
         m_xWindow->removeEventListener(this);
         m_xWindow->removeKeyListener(this);
+        VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(m_xWindow);
+        auto pBack = dynamic_cast<BackingWindow*>(pWindow.get());
+        if (pBack)
+        {
+            pBack->RequestDoubleBuffering(false);
+        }
         m_xWindow.clear();
     }
 
@@ -660,6 +666,10 @@ void SAL_CALL BackingComp::initialize( /*IN*/ const css::uno::Sequence< css::uno
     // create the component window
     VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow);
     VclPtr<vcl::Window> pWindow = VclPtr<BackingWindow>::Create(pParent);
+    if (!pWindow->IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Focus))
+    {
+        pWindow->RequestDoubleBuffering(true);
+    }
     m_xWindow = VCLUnoHelper::GetInterface(pWindow);
 
     if (!m_xWindow.is())
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 8669e655479f..27b6bd4f9b0e 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -1080,7 +1080,13 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
                                   aInRect, bDrawMenuSep, nButtonStyle);
 
         if (HasFocus())
+        {
             ShowFocus(ImplGetFocusRect());
+            if (SupportsDoubleBuffering())
+            {
+                rRenderContext.Invert(ImplGetFocusRect(), InvertFlags::TrackFrame);
+            }
+        }
     }
 
     if (!bNativeOK)
@@ -1107,6 +1113,10 @@ void PushButton::ImplDrawPushButton(vcl::RenderContext& rRenderContext)
         if (HasFocus())
         {
             ShowFocus(ImplGetFocusRect());
+            if (SupportsDoubleBuffering())
+            {
+                rRenderContext.Invert(ImplGetFocusRect(), InvertFlags::TrackFrame);
+            }
         }
     }
 }
diff --git a/vcl/source/window/bufferdevice.cxx b/vcl/source/window/bufferdevice.cxx
index d1480588d48f..ccdf5415fb6b 100644
--- a/vcl/source/window/bufferdevice.cxx
+++ b/vcl/source/window/bufferdevice.cxx
@@ -31,6 +31,8 @@ BufferDevice::~BufferDevice()
 vcl::RenderContext* BufferDevice::operator->() { return m_pBuffer.get(); }
 
 vcl::RenderContext& BufferDevice::operator*() { return *m_pBuffer; }
+
+vcl::RenderContext& BufferDevice::GetRenderContext() { return *m_pBuffer; }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/bufferdevice.hxx b/vcl/source/window/bufferdevice.hxx
index 26bf28e615fa..75e89f92e657 100644
--- a/vcl/source/window/bufferdevice.hxx
+++ b/vcl/source/window/bufferdevice.hxx
@@ -25,6 +25,7 @@ class BufferDevice
 public:
     BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext);
     ~BufferDevice();
+    vcl::RenderContext& GetRenderContext();
 
     vcl::RenderContext* operator->();
     vcl::RenderContext& operator*();
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 2cff7f1f52cd..ba9025a3367c 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -914,8 +914,20 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
         return;
     }
 
-    // Make sure that all actual rendering happens in one go to avoid flicker.
-    vcl::BufferDevice pBuffer(this, rRenderContext);
+    vcl::RenderContext* pBuffer = nullptr;
+    std::unique_ptr<vcl::BufferDevice> pBufferDevice;
+    if (SupportsDoubleBuffering())
+    {
+        // No need to buffer twice, just set up the background.
+        pBuffer = &rRenderContext;
+        pBuffer->Erase(tools::Rectangle(Point(GetOutOffXPixel(), GetOutOffYPixel()), GetOutputSizePixel()));
+    }
+    else
+    {
+        // Make sure that all actual rendering happens in one go to avoid flicker.
+        pBufferDevice.reset(new vcl::BufferDevice(this, rRenderContext));
+        pBuffer = &pBufferDevice->GetRenderContext();
+    }
 
     if (rRenderContext.IsNativeControlSupported(ControlType::Menubar, ControlPart::Entire))
     {


More information about the Libreoffice-commits mailing list