[Libreoffice-commits] core.git: sd/inc sd/qa sd/source sd/uiconfig

Caolán McNamara caolanm at redhat.com
Mon Apr 30 10:28:27 UTC 2018


 sd/inc/sdabstdlg.hxx                       |    4 --
 sd/qa/unit/dialogs-test.cxx                |    3 +
 sd/source/ui/dlg/masterlayoutdlg.cxx       |   54 +++++++++++------------------
 sd/source/ui/dlg/sddlgfact.cxx             |   15 ++++++--
 sd/source/ui/dlg/sddlgfact.hxx             |   16 ++++++--
 sd/source/ui/inc/masterlayoutdlg.hxx       |   22 ++++-------
 sd/source/ui/view/drviews3.cxx             |    3 +
 sd/uiconfig/simpress/ui/masterlayoutdlg.ui |    3 +
 8 files changed, 62 insertions(+), 58 deletions(-)

New commits:
commit 5fa87d266ef2a593b9b948787781200600f4f3da
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 30 10:12:31 2018 +0100

    weld MasterLayoutDialog
    
    Change-Id: Iab0a2c1565f109886596a1c15179fdf497633752
    Reviewed-on: https://gerrit.libreoffice.org/53650
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sd/inc/sdabstdlg.hxx b/sd/inc/sdabstdlg.hxx
index 35b7233eea73..0f96f96ea62e 100644
--- a/sd/inc/sdabstdlg.hxx
+++ b/sd/inc/sdabstdlg.hxx
@@ -200,9 +200,7 @@ public:
     virtual VclPtr<AbstractSdVectorizeDlg>     CreateSdVectorizeDlg( vcl::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell ) = 0;
     virtual VclPtr<AbstractSdPublishingDlg>    CreateSdPublishingDlg( vcl::Window* pWindow, DocumentType eDocType) = 0;
 
-    virtual VclPtr<VclAbstractDialog>          CreateMasterLayoutDialog( vcl::Window* pParent,
-                                                                  SdDrawDocument* pDoc,
-                                                                  SdPage* ) = 0;
+    virtual VclPtr<VclAbstractDialog>          CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) = 0;
 
     virtual VclPtr<AbstractHeaderFooterDialog> CreateHeaderFooterDialog( sd::ViewShell* pViewShell,
                                                                   vcl::Window* pParent,
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 478f91b324e8..3fac39df3ed5 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -563,8 +563,9 @@ VclPtr<VclAbstractDialog> SdDialogsTest::createDialogByID(sal_uInt32 nID)
             CPPUNIT_ASSERT(pDrawDoc);
             SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
             CPPUNIT_ASSERT(pSdPage);
+            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateMasterLayoutDialog(
-                Application::GetDefDialogParent(),
+                parent == nullptr ? nullptr : parent->GetFrameWeld(),
                 pDrawDoc,
                 pSdPage);
             break;
diff --git a/sd/source/ui/dlg/masterlayoutdlg.cxx b/sd/source/ui/dlg/masterlayoutdlg.cxx
index a0ec4298f54c..83d8d38c8c8e 100644
--- a/sd/source/ui/dlg/masterlayoutdlg.cxx
+++ b/sd/source/ui/dlg/masterlayoutdlg.cxx
@@ -24,17 +24,16 @@
 
 using namespace ::sd;
 
-MasterLayoutDialog::MasterLayoutDialog( vcl::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage )
-    : ModalDialog(pParent, "MasterLayoutDialog", "modules/simpress/ui/masterlayoutdlg.ui")
+MasterLayoutDialog::MasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
+    : GenericDialogController(pParent, "modules/simpress/ui/masterlayoutdlg.ui", "MasterLayoutDialog")
     , mpDoc(pDoc)
     , mpCurrentPage(pCurrentPage)
+    , mxCBDate(m_xBuilder->weld_check_button("datetime"))
+    , mxCBPageNumber(m_xBuilder->weld_check_button("pagenumber"))
+    , mxCBSlideNumber(m_xBuilder->weld_check_button("slidenumber"))
+    , mxCBHeader(m_xBuilder->weld_check_button("header"))
+    , mxCBFooter(m_xBuilder->weld_check_button("footer"))
 {
-    get(mpCBDate, "datetime");
-    get(mpCBPageNumber, "pagenumber");
-    get(mpCBSlideNumber, "slidenumber");
-    get(mpCBHeader, "header");
-    get(mpCBFooter, "footer");
-
     if( mpCurrentPage && !mpCurrentPage->IsMasterPage() )
     {
         mpCurrentPage = static_cast<SdPage*>(&(mpCurrentPage->TRG_GetMasterPage()));
@@ -50,8 +49,8 @@ MasterLayoutDialog::MasterLayoutDialog( vcl::Window* pParent, SdDrawDocument* pD
     {
         case PageKind::Standard:
         {
-            mpCBHeader->Enable(false);
-            mpCBPageNumber->SetText(mpCBSlideNumber->GetText());
+            mxCBHeader->set_sensitive(false);
+            mxCBPageNumber->set_label(mxCBSlideNumber->get_label());
             break;
         }
         case PageKind::Notes:
@@ -65,39 +64,28 @@ MasterLayoutDialog::MasterLayoutDialog( vcl::Window* pParent, SdDrawDocument* pD
     mbOldFooter = mpCurrentPage->GetPresObj( PRESOBJ_FOOTER ) != nullptr;
     mbOldPageNumber = mpCurrentPage->GetPresObj( PRESOBJ_SLIDENUMBER ) != nullptr;
 
-    mpCBHeader->Check( mbOldHeader );
-    mpCBDate->Check( mbOldDate );
-    mpCBFooter->Check( mbOldFooter );
-    mpCBPageNumber->Check( mbOldPageNumber );
+    mxCBHeader->set_active( mbOldHeader );
+    mxCBDate->set_active( mbOldDate );
+    mxCBFooter->set_active( mbOldFooter );
+    mxCBPageNumber->set_active( mbOldPageNumber );
 }
 
 MasterLayoutDialog::~MasterLayoutDialog()
 {
-    disposeOnce();
-}
-
-void MasterLayoutDialog::dispose()
-{
-    mpCBDate.clear();
-    mpCBPageNumber.clear();
-    mpCBSlideNumber.clear();
-    mpCBHeader.clear();
-    mpCBFooter.clear();
-    ModalDialog::dispose();
 }
 
-short MasterLayoutDialog::Execute()
+short MasterLayoutDialog::execute()
 {
-    if ( ModalDialog::Execute() )
+    if (m_xDialog->run() == RET_OK)
         applyChanges();
-    return 1;
+    return RET_OK;
 }
 
 void MasterLayoutDialog::applyChanges()
 {
-    mpDoc->BegUndo(GetText());
+    mpDoc->BegUndo(m_xDialog->get_title());
 
-    if( (mpCurrentPage->GetPageKind() != PageKind::Standard) && (mbOldHeader != mpCBHeader->IsChecked() ) )
+    if( (mpCurrentPage->GetPageKind() != PageKind::Standard) && (mbOldHeader != mxCBHeader->get_active() ) )
     {
         if( mbOldHeader )
             remove( PRESOBJ_HEADER );
@@ -105,7 +93,7 @@ void MasterLayoutDialog::applyChanges()
             create( PRESOBJ_HEADER );
     }
 
-    if( mbOldFooter != mpCBFooter->IsChecked() )
+    if( mbOldFooter != mxCBFooter->get_active() )
     {
         if( mbOldFooter )
             remove( PRESOBJ_FOOTER );
@@ -113,7 +101,7 @@ void MasterLayoutDialog::applyChanges()
             create( PRESOBJ_FOOTER );
     }
 
-    if( mbOldDate != mpCBDate->IsChecked() )
+    if( mbOldDate != mxCBDate->get_active() )
     {
         if( mbOldDate )
             remove( PRESOBJ_DATETIME );
@@ -121,7 +109,7 @@ void MasterLayoutDialog::applyChanges()
             create( PRESOBJ_DATETIME );
     }
 
-    if( mbOldPageNumber != mpCBPageNumber->IsChecked() )
+    if( mbOldPageNumber != mxCBPageNumber->get_active() )
     {
         if( mbOldPageNumber )
             remove( PRESOBJ_SLIDENUMBER );
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index 21ce7322b165..8a517760a149 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -74,6 +74,16 @@ short AbstractBreakDlg_Impl::Execute()
     return m_xDlg->execute();
 }
 
+AbstractMasterLayoutDialog_Impl::AbstractMasterLayoutDialog_Impl(::sd::MasterLayoutDialog* pDlg)
+    : m_xDlg(pDlg)
+{
+}
+
+short AbstractMasterLayoutDialog_Impl::Execute()
+{
+    return m_xDlg->execute();
+}
+
 void AbstractCopyDlg_Impl::GetAttr( SfxItemSet& rOutAttrs )
 {
     pDlg->GetAttr( rOutAttrs );
@@ -406,10 +416,9 @@ CreateTabPage SdAbstractDialogFactory_Impl::GetSdOptionsSnapTabPageCreatorFunc()
     return SdTpOptionsSnap::Create;
 }
 
-VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateMasterLayoutDialog( vcl::Window* pParent,
-    SdDrawDocument* pDoc, SdPage* pCurrentPage )
+VclPtr<VclAbstractDialog> SdAbstractDialogFactory_Impl::CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage)
 {
-  return VclPtr<SdVclAbstractDialog_Impl>::Create( VclPtr<::sd::MasterLayoutDialog>::Create( pParent, pDoc, pCurrentPage ));
+  return VclPtr<AbstractMasterLayoutDialog_Impl>::Create(new ::sd::MasterLayoutDialog(pParent, pDoc, pCurrentPage));
 }
 
 VclPtr<AbstractHeaderFooterDialog> SdAbstractDialogFactory_Impl::CreateHeaderFooterDialog( sd::ViewShell* pViewShell,
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 1b9e0fe6cbcb..0186622d399a 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -53,8 +53,9 @@ namespace sd {
     class MorphDlg;
     class CopyDlg;
     class BreakDlg;
+    class HeaderFooterDialog;
+    class MasterLayoutDialog;
     class OutlineBulletDlg;
-        class HeaderFooterDialog;
 }
 
 class Dialog;
@@ -63,6 +64,15 @@ class SdVclAbstractDialog_Impl : public VclAbstractDialog
     DECL_ABSTDLG_BASE(SdVclAbstractDialog_Impl,Dialog)
 };
 
+class AbstractMasterLayoutDialog_Impl : public VclAbstractDialog
+{
+private:
+    std::unique_ptr<sd::MasterLayoutDialog> m_xDlg;
+public:
+    AbstractMasterLayoutDialog_Impl(::sd::MasterLayoutDialog* pDlg);
+    virtual short Execute() override;
+};
+
 class AbstractBreakDlg_Impl : public VclAbstractDialog
 {
 private:
@@ -239,9 +249,7 @@ public:
 
     virtual VclPtr<VclAbstractDialog>          CreateSdPhotoAlbumDialog(vcl::Window* pWindow, SdDrawDocument* pDoc) override;
 
-    virtual VclPtr<VclAbstractDialog>          CreateMasterLayoutDialog( vcl::Window* pParent,
-                                                                  SdDrawDocument* pDoc,
-                                                                  SdPage* ) override;
+    virtual VclPtr<VclAbstractDialog>          CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) override;
 
     virtual VclPtr<AbstractHeaderFooterDialog> CreateHeaderFooterDialog( sd::ViewShell* pViewShell,
                                                                   vcl::Window* pParent,
diff --git a/sd/source/ui/inc/masterlayoutdlg.hxx b/sd/source/ui/inc/masterlayoutdlg.hxx
index 6bc1241cfca8..6bd9dcfd4fad 100644
--- a/sd/source/ui/inc/masterlayoutdlg.hxx
+++ b/sd/source/ui/inc/masterlayoutdlg.hxx
@@ -19,10 +19,7 @@
 #ifndef INCLUDED_SD_SOURCE_UI_INC_MASTERLAYOUTDLG_HXX
 #define INCLUDED_SD_SOURCE_UI_INC_MASTERLAYOUTDLG_HXX
 
-#include <vcl/dialog.hxx>
-
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 
 #include <sdpage.hxx>
 
@@ -31,17 +28,17 @@ class SdDrawDocument;
 namespace sd
 {
 
-class MasterLayoutDialog : public ModalDialog
+class MasterLayoutDialog : public weld::GenericDialogController
 {
 private:
     SdDrawDocument* mpDoc;
     SdPage*         mpCurrentPage;
 
-    VclPtr<CheckBox>       mpCBDate;
-    VclPtr<CheckBox>       mpCBPageNumber;
-    VclPtr<CheckBox>       mpCBSlideNumber;
-    VclPtr<CheckBox>       mpCBHeader;
-    VclPtr<CheckBox>       mpCBFooter;
+    std::unique_ptr<weld::CheckButton> mxCBDate;
+    std::unique_ptr<weld::CheckButton> mxCBPageNumber;
+    std::unique_ptr<weld::CheckButton> mxCBSlideNumber;
+    std::unique_ptr<weld::CheckButton> mxCBHeader;
+    std::unique_ptr<weld::CheckButton> mxCBFooter;
 
     bool            mbOldHeader;
     bool            mbOldFooter;
@@ -53,11 +50,10 @@ private:
     void create( PresObjKind eKind );
 
 public:
-    MasterLayoutDialog( vcl::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage );
+    MasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage);
     virtual ~MasterLayoutDialog() override;
-    virtual void dispose() override;
 
-    virtual short Execute() override;
+    short execute();
 };
 
 }
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index 14f4fac32271..90160c3e521a 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -315,7 +315,8 @@ void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
             SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
             if (pFact)
             {
-                ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage ));
+                vcl::Window* pWin = GetActiveWindow();
+                ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateMasterLayoutDialog(pWin ? pWin->GetFrameWeld() : nullptr, GetDoc(), pPage));
                 pDlg->Execute();
                 Invalidate();
             }
diff --git a/sd/uiconfig/simpress/ui/masterlayoutdlg.ui b/sd/uiconfig/simpress/ui/masterlayoutdlg.ui
index c0471a12d9c8..06e13e407bd0 100644
--- a/sd/uiconfig/simpress/ui/masterlayoutdlg.ui
+++ b/sd/uiconfig/simpress/ui/masterlayoutdlg.ui
@@ -7,6 +7,9 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="masterlayoutdlg|MasterLayoutDialog">Master Elements</property>
     <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">


More information about the Libreoffice-commits mailing list