[Libreoffice-commits] core.git: include/sfx2 sfx2/source sfx2/uiconfig sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 20 11:58:29 UTC 2018


 include/sfx2/basedlgs.hxx           |   33 +++++++++++
 sfx2/source/dialog/basedlgs.cxx     |  108 ++++++++++++++++++++++++++++++++++++
 sfx2/uiconfig/ui/singletabdialog.ui |   11 ++-
 sw/inc/swabstdlg.hxx                |    2 
 sw/source/ui/chrdlg/drpcps.cxx      |   11 ++-
 sw/source/ui/dialog/swdlgfact.cxx   |   39 ++++++++++++-
 sw/source/ui/dialog/swdlgfact.hxx   |   16 +++++
 sw/source/uibase/inc/drpcps.hxx     |    4 -
 sw/source/uibase/shells/txtattr.cxx |    2 
 9 files changed, 210 insertions(+), 16 deletions(-)

New commits:
commit 6b5b2bbdf88aec54fc648a019e544addabdece6b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 20 10:48:14 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 20 13:58:04 2018 +0200

    weld SwDropCapsDlg
    
    Change-Id: Ibd01c0fb54f0e3b361d5e1f196bfeb44a1fcb99c
    Reviewed-on: https://gerrit.libreoffice.org/60805
    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/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index 58657fc58e8b..39f74dc024e8 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -27,6 +27,7 @@
 #include <vcl/dialog.hxx>
 #include <vcl/floatwin.hxx>
 #include <vcl/timer.hxx>
+#include <vcl/weld.hxx>
 
 class TabPage;
 class SfxTabPage;
@@ -189,6 +190,38 @@ private:
     std::unique_ptr<SingleTabDlgImpl>   pImpl;
 };
 
+class SFX2_DLLPUBLIC SfxSingleTabDialogController : public weld::GenericDialogController
+{
+private:
+    VclPtr<SfxTabPage>          m_xSfxPage;
+    std::unique_ptr<SfxItemSet> m_xOutputSet;
+    const SfxItemSet* m_pInputSet;
+
+public:
+    SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rOptionsSet,
+        const OUString& rUIXMLDescription = OUString("sfx/ui/singletabdialog.ui"),
+        const OString& rID = OString("SingleTabDialog"));
+
+    virtual weld::Container* get_content_area() { return m_xContainer.get(); }
+
+    virtual             ~SfxSingleTabDialogController() override;
+
+    void                SetTabPage(SfxTabPage* pTabPage);
+    SfxTabPage*         GetTabPage() const { return m_xSfxPage; }
+    weld::Button&       GetOKButton() const { return *m_xOKBtn; }
+
+    const SfxItemSet*   GetOutputItemSet() const { return m_xOutputSet.get(); }
+    const SfxItemSet*   GetInputItemSet() const { return m_pInputSet; }
+
+protected:
+    std::unique_ptr<weld::Container> m_xContainer;
+    std::unique_ptr<weld::Button> m_xOKBtn;
+    std::unique_ptr<weld::Button> m_xHelpBtn;
+
+    void                CreateOutputItemSet(const SfxItemSet& rInput);
+    DECL_DLLPRIVATE_LINK(OKHdl_Impl, weld::Button&, void);
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 0868350ec74e..bb944a05e89b 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -733,4 +733,112 @@ void SfxSingleTabDialog::SetTabPage(SfxTabPage* pTabPage)
     }
 }
 
+SfxSingleTabDialogController::SfxSingleTabDialogController(weld::Window *pParent, const SfxItemSet& rSet,
+    const OUString& rUIXMLDescription, const OString& rID)
+    : GenericDialogController(pParent, rUIXMLDescription, rID)
+    , m_pInputSet(&rSet)
+    , m_xContainer(m_xDialog->weld_content_area())
+    , m_xOKBtn(m_xBuilder->weld_button("ok"))
+    , m_xHelpBtn(m_xBuilder->weld_button("help"))
+{
+    m_xOKBtn->connect_clicked(LINK(this, SfxSingleTabDialogController, OKHdl_Impl));
+}
+
+SfxSingleTabDialogController::~SfxSingleTabDialogController()
+{
+    m_xSfxPage.disposeAndClear();
+}
+
+/*  [Description]
+
+    Insert a (new) TabPage; an existing page is deleted.
+    The passed on page is initialized with the initially given Itemset
+    through calling Reset().
+*/
+void SfxSingleTabDialogController::SetTabPage(SfxTabPage* pTabPage)
+{
+    m_xSfxPage.disposeAndClear();
+    m_xSfxPage = pTabPage;
+
+    if (m_xSfxPage)
+    {
+        // First obtain the user data, only then Reset()
+        OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(), RTL_TEXTENCODING_UTF8);
+        SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId);
+        Any aUserItem = aPageOpt.GetUserItem( USERITEM_NAME );
+        OUString sUserData;
+        aUserItem >>= sUserData;
+        m_xSfxPage->SetUserData(sUserData);
+        m_xSfxPage->Reset(GetInputItemSet());
+//TODO        m_xSfxPage->Show();
+
+        m_xHelpBtn->show(Help::IsContextHelpEnabled());
+
+        // Set TabPage text in the Dialog if there is any
+        OUString sTitle(m_xSfxPage->GetText());
+        if (!sTitle.isEmpty())
+            m_xDialog->set_title(sTitle);
+
+        // Dialog receives the HelpId of TabPage if there is any
+        OString sHelpId(m_xSfxPage->GetHelpId());
+        if (!sHelpId.isEmpty())
+            m_xDialog->set_help_id(sHelpId);
+    }
+}
+
+/*  [Description]
+
+    Ok_Handler; FillItemSet() is called for setting of Page.
+*/
+IMPL_LINK_NOARG(SfxSingleTabDialogController, OKHdl_Impl, weld::Button&, void)
+{
+    const SfxItemSet* pInputSet = GetInputItemSet();
+    if (!pInputSet)
+    {
+        // TabPage without ItemSet
+        m_xDialog->response(RET_OK);
+        return;
+    }
+
+    if (!GetOutputItemSet())
+    {
+        CreateOutputItemSet(*pInputSet);
+    }
+
+    bool bModified = false;
+
+    if (m_xSfxPage->HasExchangeSupport())
+    {
+        DeactivateRC nRet = m_xSfxPage->DeactivatePage(m_xOutputSet.get());
+        if (nRet != DeactivateRC::LeavePage)
+            return;
+        else
+            bModified = m_xOutputSet->Count() > 0;
+    }
+    else
+        bModified = m_xSfxPage->FillItemSet(m_xOutputSet.get());
+
+    if (bModified)
+    {
+        // Save user data in IniManager.
+        m_xSfxPage->FillUserData();
+        OUString sData(m_xSfxPage->GetUserData());
+
+        OUString sConfigId = OStringToOUString(m_xSfxPage->GetConfigId(),
+            RTL_TEXTENCODING_UTF8);
+        SvtViewOptions aPageOpt(EViewType::TabPage, sConfigId);
+        aPageOpt.SetUserItem( USERITEM_NAME, makeAny( sData ) );
+        m_xDialog->response(RET_OK);
+    }
+    else
+        m_xDialog->response(RET_CANCEL);
+}
+
+void SfxSingleTabDialogController::CreateOutputItemSet(const SfxItemSet& rSet)
+{
+    assert(!m_xOutputSet && "Double creation of OutputSet!");
+    m_xOutputSet.reset(new SfxItemSet(rSet));
+    m_xOutputSet->ClearItem();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/uiconfig/ui/singletabdialog.ui b/sfx2/uiconfig/ui/singletabdialog.ui
index f4adba48d7d9..254638b10b91 100644
--- a/sfx2/uiconfig/ui/singletabdialog.ui
+++ b/sfx2/uiconfig/ui/singletabdialog.ui
@@ -1,21 +1,25 @@
 <?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"/>
   <object class="GtkDialog" id="SingleTabDialog">
     <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="ok">
                 <property name="label">gtk-ok</property>
@@ -58,6 +62,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 3761fab25739..a39ab9f80a76 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -361,7 +361,7 @@ public:
 
     virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog( vcl::Window* pParent,
                                                  const SfxItemSet& rAttr) = 0;
-    virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(vcl::Window* pParent, const SfxItemSet& rSet) = 0;
+    virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(weld::Window* pParent, const SfxItemSet& rSet) = 0;
     virtual VclPtr<SfxAbstractDialog> CreateSwBackgroundDialog(vcl::Window* pParent, const SfxItemSet& rSet) = 0;
 
     virtual VclPtr<AbstractSwWordCountFloatDlg> CreateSwWordCountDialog(SfxBindings* pBindings,
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index 9395eae6ba55..94143c79e721 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -448,12 +448,13 @@ void SwDropCapsPict::InitPrinter_()
     }
 }
 
-SwDropCapsDlg::SwDropCapsDlg(vcl::Window *pParent, const SfxItemSet &rSet )
-    : SfxSingleTabDialog(pParent, rSet)
+SwDropCapsDlg::SwDropCapsDlg(weld::Window *pParent, const SfxItemSet &rSet)
+    : SfxSingleTabDialogController(pParent, rSet)
 {
-    VclPtr<SwDropCapsPage> pNewPage( static_cast<SwDropCapsPage*>( SwDropCapsPage::Create(get_content_area(), &rSet).get() ) );
-    pNewPage->SetFormat(false);
-    SetTabPage(pNewPage);
+    TabPageParent pPageParent(get_content_area(), this);
+    VclPtr<SwDropCapsPage> xNewPage(static_cast<SwDropCapsPage*>(SwDropCapsPage::Create(pPageParent, &rSet).get()));
+    xNewPage->SetFormat(false);
+    SetTabPage(xNewPage);
 }
 
 SwDropCapsPage::SwDropCapsPage(TabPageParent pParent, const SfxItemSet &rSet)
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index d61bb53c4f90..aabfaff6a42c 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -90,56 +90,76 @@ using namespace css::uno;
 IMPL_ABSTDLG_BASE(AbstractSwWordCountFloatDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractSwInsertAbstractDlg_Impl);
 IMPL_ABSTDLG_BASE(SwAbstractSfxDialog_Impl);
+
+short SwAbstractSfxController_Impl::Execute()
+{
+    return m_xDlg->run();
+}
+
 short AbstractSwAsciiFilterDlg_Impl::Execute()
 {
     return m_xDlg->run();
 }
+
 IMPL_ABSTDLG_BASE(VclAbstractDialog_Impl);
+
 short AbstractSplitTableDialog_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractSwBreakDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractSwTableWidthDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractSwTableHeightDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractSwMergeTableDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractGenericDialog_Impl::Execute()
 {
     return m_xDlg->run();
 }
+
 bool AbstractGenericDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
 {
     return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
 }
+
 short AbstractSwSortDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractMultiTOXMarkDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 short AbstractTabController_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl);
+
 short AbstractSwConvertTableDlg_Impl::Execute()
 {
     return m_xDlg->run();
 }
+
 IMPL_ABSTDLG_BASE(AbstractSwInsertDBColAutoPilot_Impl);
 
 short AbstractDropDownFieldDialog_Impl::Execute()
@@ -153,15 +173,19 @@ short AbstractSwLabDlg_Impl::Execute()
 }
 
 IMPL_ABSTDLG_BASE(AbstractSwSelGlossaryDlg_Impl);
+
 short AbstractSwAutoFormatDlg_Impl::Execute()
 {
     return m_xDlg->execute();
 }
+
 IMPL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl);
+
 short AbstractSwRenameXNamedDlg_Impl::Execute()
 {
     return m_xDlg->run();
 }
+
 IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl);
 IMPL_ABSTDLG_BASE(AbstractGlossaryDlg_Impl);
 
@@ -295,6 +319,16 @@ void SwAbstractSfxDialog_Impl::SetText( const OUString& rStr )
     pDlg->SetText( rStr );
 }
 
+const SfxItemSet* SwAbstractSfxController_Impl::GetOutputItemSet() const
+{
+    return m_xDlg->GetOutputItemSet();
+}
+
+void SwAbstractSfxController_Impl::SetText(const OUString& rStr)
+{
+    m_xDlg->set_title(rStr);
+}
+
 void AbstractSwAsciiFilterDlg_Impl::FillOptions( SwAsciiOptions& rOptions )
 {
     m_xDlg->FillOptions(rOptions);
@@ -724,11 +758,10 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwAddressAbstractD
     return VclPtr<SwAbstractSfxDialog_Impl>::Create(pDlg);
 }
 
-VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwDropCapsDialog( vcl::Window* pParent,
+VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwDropCapsDialog(weld::Window* pParent,
                                                                   const SfxItemSet& rSet)
 {
-    VclPtr<SfxModalDialog> pDlg = VclPtr<SwDropCapsDlg>::Create(pParent, rSet);
-    return VclPtr<SwAbstractSfxDialog_Impl>::Create( pDlg );
+    return VclPtr<SwAbstractSfxController_Impl>::Create(o3tl::make_unique<SwDropCapsDlg>(pParent, rSet));
 }
 
 VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwBackgroundDialog( vcl::Window* pParent,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 5c8fad67722e..27dacb7c419e 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -94,6 +94,20 @@ class SwAbstractSfxDialog_Impl :public SfxAbstractDialog
     virtual void        SetText( const OUString& rStr ) override;
 };
 
+class SwAbstractSfxController_Impl : public SfxAbstractDialog
+{
+protected:
+    std::unique_ptr<SfxSingleTabDialogController> m_xDlg;
+public:
+    explicit SwAbstractSfxController_Impl(std::unique_ptr<SfxSingleTabDialogController> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
+    virtual const SfxItemSet* GetOutputItemSet() const override;
+    virtual void SetText(const OUString& rStr) override;
+};
+
 class AbstractSwAsciiFilterDlg_Impl : public AbstractSwAsciiFilterDlg
 {
 protected:
@@ -560,7 +574,7 @@ public:
     virtual ~SwAbstractDialogFactory_Impl() {}
 
     virtual VclPtr<SfxAbstractDialog> CreateNumFormatDialog(vcl::Window* pParent, const SfxItemSet& rAttr) override;
-    virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(vcl::Window* pParent, const SfxItemSet& rSet) override;
+    virtual VclPtr<SfxAbstractDialog> CreateSwDropCapsDialog(weld::Window* pParent, const SfxItemSet& rSet) override;
     virtual VclPtr<SfxAbstractDialog> CreateSwBackgroundDialog(vcl::Window* pParent, const SfxItemSet& rSet) override;
     virtual VclPtr<AbstractSwWordCountFloatDlg> CreateSwWordCountDialog(SfxBindings* pBindings,
         SfxChildWindow* pChild, vcl::Window *pParent, SfxChildWinInfo* pInfo) override;
diff --git a/sw/source/uibase/inc/drpcps.hxx b/sw/source/uibase/inc/drpcps.hxx
index 222f67a16991..e7bdaa00e84e 100644
--- a/sw/source/uibase/inc/drpcps.hxx
+++ b/sw/source/uibase/inc/drpcps.hxx
@@ -36,10 +36,10 @@
 
 class SwWrtShell;
 
-class SwDropCapsDlg : public SfxSingleTabDialog
+class SwDropCapsDlg : public SfxSingleTabDialogController
 {
 public:
-    SwDropCapsDlg(vcl::Window *pParent, const SfxItemSet &rSet );
+    SwDropCapsDlg(weld::Window *pParent, const SfxItemSet &rSet);
 };
 
 class SwDropCapsPage;
diff --git a/sw/source/uibase/shells/txtattr.cxx b/sw/source/uibase/shells/txtattr.cxx
index 1788e6fad01d..f1fe48c922c2 100644
--- a/sw/source/uibase/shells/txtattr.cxx
+++ b/sw/source/uibase/shells/txtattr.cxx
@@ -479,7 +479,7 @@ void SwTextShell::ExecParaAttrArgs(SfxRequest &rReq)
                                            HINT_END, HINT_END>{});
                 rSh.GetCurAttr(aSet);
                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-                ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateSwDropCapsDialog(GetView().GetWindow(), aSet));
+                ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateSwDropCapsDialog(GetView().GetFrameWeld(), aSet));
                 if (pDlg->Execute() == RET_OK)
                 {
                     rSh.StartAction();


More information about the Libreoffice-commits mailing list