diff options
-rw-r--r-- | sw/inc/swabstdlg.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 14 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 13 | ||||
-rw-r--r-- | sw/source/ui/misc/bookmark.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/utlui/swrenamexnameddlg.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/inc/swrenamexnameddlg.hxx | 29 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 2 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/renameobjectdialog.ui | 18 |
8 files changed, 66 insertions, 63 deletions
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index d7d95a1fc4fe..c0e2484a4d75 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -441,7 +441,7 @@ public: virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) = 0; virtual VclPtr<SfxAbstractDialog> CreateSwFieldEditDlg ( SwView& rVw ) = 0; - virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(vcl::Window* pParent, + virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(weld::Window* pParent, css::uno::Reference< css::container::XNamed > & xNamed, css::uno::Reference< css::container::XNameAccess > & xNameAccess) = 0; virtual VclPtr<AbstractSwModalRedlineAcceptDlg> CreateSwModalRedlineAcceptDlg(vcl::Window *pParent) = 0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 1d1ad97285a2..eae34ddfb912 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -137,7 +137,10 @@ short AbstractSwAutoFormatDlg_Impl::Execute() return m_xDlg->execute(); } IMPL_ABSTDLG_BASE(AbstractSwFieldDlg_Impl); -IMPL_ABSTDLG_BASE(AbstractSwRenameXNamedDlg_Impl); +short AbstractSwRenameXNamedDlg_Impl::Execute() +{ + return m_xDlg->run(); +} IMPL_ABSTDLG_BASE(AbstractSwModalRedlineAcceptDlg_Impl); IMPL_ABSTDLG_BASE(AbstractGlossaryDlg_Impl); IMPL_ABSTDLG_BASE(AbstractFieldInputDlg_Impl); @@ -400,14 +403,14 @@ void AbstractSwFieldDlg_Impl::ShowReferencePage() void AbstractSwRenameXNamedDlg_Impl::SetForbiddenChars( const OUString& rSet ) { - pDlg->SetForbiddenChars( rSet ); + m_xDlg->SetForbiddenChars( rSet ); } void AbstractSwRenameXNamedDlg_Impl::SetAlternativeAccess( css::uno::Reference< css::container::XNameAccess > & xSecond, css::uno::Reference< css::container::XNameAccess > & xThird ) { - pDlg->SetAlternativeAccess( xSecond, xThird); + m_xDlg->SetAlternativeAccess( xSecond, xThird); } void AbstractSwModalRedlineAcceptDlg_Impl::AcceptAll( bool bAccept ) @@ -877,12 +880,11 @@ VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwFieldEditDlg ( return VclPtr<SwAbstractSfxDialog_Impl>::Create( pDlg ); } -VclPtr<AbstractSwRenameXNamedDlg> SwAbstractDialogFactory_Impl::CreateSwRenameXNamedDlg(vcl::Window* pParent, +VclPtr<AbstractSwRenameXNamedDlg> SwAbstractDialogFactory_Impl::CreateSwRenameXNamedDlg(weld::Window* pParent, css::uno::Reference< css::container::XNamed > & xNamed, css::uno::Reference< css::container::XNameAccess > & xNameAccess) { - VclPtr<SwRenameXNamedDlg> pDlg = VclPtr<SwRenameXNamedDlg>::Create( pParent,xNamed, xNameAccess); - return VclPtr<AbstractSwRenameXNamedDlg_Impl>::Create( pDlg ); + return VclPtr<AbstractSwRenameXNamedDlg_Impl>::Create(new SwRenameXNamedDlg(pParent,xNamed, xNameAccess)); } VclPtr<AbstractSwModalRedlineAcceptDlg> SwAbstractDialogFactory_Impl::CreateSwModalRedlineAcceptDlg(vcl::Window *pParent) diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 882a5ffb2003..d2e1f5e342a8 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -306,8 +306,15 @@ class AbstractSwFieldDlg_Impl : public AbstractSwFieldDlg class AbstractSwRenameXNamedDlg_Impl : public AbstractSwRenameXNamedDlg { - DECL_ABSTDLG_BASE(AbstractSwRenameXNamedDlg_Impl,SwRenameXNamedDlg ) - virtual void SetForbiddenChars( const OUString& rSet ) override; +protected: + std::unique_ptr<SwRenameXNamedDlg> m_xDlg; +public: + explicit AbstractSwRenameXNamedDlg_Impl(SwRenameXNamedDlg* p) + : m_xDlg(p) + { + } + virtual short Execute() override; + virtual void SetForbiddenChars( const OUString& rSet ) override; virtual void SetAlternativeAccess( css::uno::Reference< css::container::XNameAccess > & xSecond, css::uno::Reference< css::container::XNameAccess > & xThird ) override; @@ -531,7 +538,7 @@ public: const SfxItemSet* pItemSet, SwWrtShell* pSh) override; virtual VclPtr<AbstractSwFieldDlg> CreateSwFieldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, vcl::Window *pParent) override; virtual VclPtr<SfxAbstractDialog> CreateSwFieldEditDlg ( SwView& rVw ) override; - virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(vcl::Window* pParent, + virtual VclPtr<AbstractSwRenameXNamedDlg> CreateSwRenameXNamedDlg(weld::Window* pParent, css::uno::Reference< css::container::XNamed > & xNamed, css::uno::Reference< css::container::XNameAccess > & xNameAccess) override; virtual VclPtr<AbstractSwModalRedlineAcceptDlg> CreateSwModalRedlineAcceptDlg(vcl::Window *pParent) override; diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 3720dba23a86..9a7bd9472710 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -193,7 +193,7 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, RenameHdl, Button*, void) uno::Reference<container::XNamed> xNamed(xTmp, uno::UNO_QUERY); SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(pFact->CreateSwRenameXNamedDlg(this, xNamed, xNameAccess)); + ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(pFact->CreateSwRenameXNamedDlg(GetFrameWeld(), xNamed, xNameAccess)); OSL_ENSURE(pDlg, "Dialog creation failed!"); pDlg->SetForbiddenChars(BookmarkTable::aForbiddenChars + OUStringLiteral1(BookmarkTable::cSeparator)); diff --git a/sw/source/ui/utlui/swrenamexnameddlg.cxx b/sw/source/ui/utlui/swrenamexnameddlg.cxx index 1b0fabe8be06..1d6a250ac3d8 100644 --- a/sw/source/ui/utlui/swrenamexnameddlg.cxx +++ b/sw/source/ui/utlui/swrenamexnameddlg.cxx @@ -47,59 +47,52 @@ using namespace ::com::sun::star; -SwRenameXNamedDlg::SwRenameXNamedDlg( vcl::Window* pWin, +SwRenameXNamedDlg::SwRenameXNamedDlg(weld::Window* pWin, uno::Reference< container::XNamed > & xN, uno::Reference< container::XNameAccess > & xNA ) - : ModalDialog(pWin, "RenameObjectDialog", - "modules/swriter/ui/renameobjectdialog.ui") + : GenericDialogController(pWin, "modules/swriter/ui/renameobjectdialog.ui", "RenameObjectDialog") , xNamed(xN) , xNameAccess(xNA) + , m_xNewNameED(m_xBuilder->weld_entry("entry")) + , m_xOk(m_xBuilder->weld_button("ok")) { - get(m_pNewNameED, "entry"); - m_pNewNameED->SetTextFilter(&m_aTextFilter); - get(m_pOk, "ok"); + m_xNewNameED->connect_insert_text(LINK(this, SwRenameXNamedDlg, TextFilterHdl)); - OUString sTmp(GetText()); - m_pNewNameED->SetText(xNamed->getName()); - m_pNewNameED->SetSelection(Selection(SELECTION_MIN, SELECTION_MAX)); + OUString sTmp(m_xDialog->get_title()); + m_xNewNameED->set_text(xNamed->getName()); + m_xNewNameED->select_region(0, -1); sTmp += xNamed->getName(); - SetText(sTmp); + m_xDialog->set_title(sTmp); - m_pOk->SetClickHdl(LINK(this, SwRenameXNamedDlg, OkHdl)); - m_pNewNameED->SetModifyHdl(LINK(this, SwRenameXNamedDlg, ModifyHdl)); - m_pOk->Enable(false); + m_xOk->connect_clicked(LINK(this, SwRenameXNamedDlg, OkHdl)); + m_xNewNameED->connect_changed(LINK(this, SwRenameXNamedDlg, ModifyHdl)); + m_xOk->set_sensitive(false); } -SwRenameXNamedDlg::~SwRenameXNamedDlg() +IMPL_LINK(SwRenameXNamedDlg, TextFilterHdl, OUString&, rTest, bool) { - disposeOnce(); + rTest = m_aTextFilter.filter(rTest); + return true; } -void SwRenameXNamedDlg::dispose() -{ - m_pNewNameED.clear(); - m_pOk.clear(); - ModalDialog::dispose(); -} - -IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl, Button*, void) +IMPL_LINK_NOARG(SwRenameXNamedDlg, OkHdl, weld::Button&, void) { try { - xNamed->setName(m_pNewNameED->GetText()); + xNamed->setName(m_xNewNameED->get_text()); } catch (const uno::RuntimeException&) { OSL_FAIL("name wasn't changed"); } - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } -IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, Edit&, rEdit, void) +IMPL_LINK(SwRenameXNamedDlg, ModifyHdl, weld::Entry&, rEdit, void) { - OUString sTmp(rEdit.GetText()); + OUString sTmp(rEdit.get_text()); - m_pOk->Enable(!sTmp.isEmpty() + m_xOk->set_sensitive(!sTmp.isEmpty() && !xNameAccess->hasByName(sTmp) && (!xSecondAccess.is() || !xSecondAccess->hasByName(sTmp)) && (!xThirdAccess.is() || !xThirdAccess->hasByName(sTmp)) diff --git a/sw/source/uibase/inc/swrenamexnameddlg.hxx b/sw/source/uibase/inc/swrenamexnameddlg.hxx index a0e6552fabde..14bfcab89754 100644 --- a/sw/source/uibase/inc/swrenamexnameddlg.hxx +++ b/sw/source/uibase/inc/swrenamexnameddlg.hxx @@ -19,34 +19,31 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWRENAMEXNAMEDDLG_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_SWRENAMEXNAMEDDLG_HXX -#include <vcl/dialog.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/button.hxx> +#include <vcl/weld.hxx> #include "actctrl.hxx" #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNamed.hpp> -class SwRenameXNamedDlg : public ModalDialog +class SwRenameXNamedDlg : public weld::GenericDialogController { - VclPtr<Edit> m_pNewNameED; - TextFilter m_aTextFilter; - VclPtr<OKButton> m_pOk; - css::uno::Reference< css::container::XNamed > & xNamed; css::uno::Reference< css::container::XNameAccess > & xNameAccess; css::uno::Reference< css::container::XNameAccess > xSecondAccess; css::uno::Reference< css::container::XNameAccess > xThirdAccess; - DECL_LINK(OkHdl, Button*, void); - DECL_LINK(ModifyHdl, Edit&, void); + TextFilter m_aTextFilter; + + std::shared_ptr<weld::Entry> m_xNewNameED; + std::shared_ptr<weld::Button> m_xOk; + + DECL_LINK(TextFilterHdl, OUString&, bool); + DECL_LINK(OkHdl, weld::Button&, void); + DECL_LINK(ModifyHdl, weld::Entry&, void); public: - SwRenameXNamedDlg( vcl::Window* pParent, - css::uno::Reference< css::container::XNamed > & xNamed, - css::uno::Reference< css::container::XNameAccess > & xNameAccess ); - virtual ~SwRenameXNamedDlg() override; - virtual void dispose() override; + SwRenameXNamedDlg(weld::Window* pParent, + css::uno::Reference< css::container::XNamed > & xNamed, + css::uno::Reference< css::container::XNameAccess > & xNameAccess ); void SetForbiddenChars(const OUString& rSet) { diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 8c451e3a9a97..6c927b7f287e 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3375,7 +3375,7 @@ void SwContentTree::EditEntry(SvTreeListEntry const * pEntry, EditEntryMode nMod SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(pFact->CreateSwRenameXNamedDlg(this, xNamed, xNameAccess)); + ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(pFact->CreateSwRenameXNamedDlg(GetFrameWeld(), xNamed, xNameAccess)); OSL_ENSURE(pDlg, "Dialog creation failed!"); if(xSecond.is()) pDlg->SetAlternativeAccess( xSecond, xThird); diff --git a/sw/uiconfig/swriter/ui/renameobjectdialog.ui b/sw/uiconfig/swriter/ui/renameobjectdialog.ui index 32a480637bb9..2fc8006e66ac 100644 --- a/sw/uiconfig/swriter/ui/renameobjectdialog.ui +++ b/sw/uiconfig/swriter/ui/renameobjectdialog.ui @@ -1,11 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.20.4 --> <interface domain="sw"> - <!-- interface-requires gtk+ 3.0 --> - <!-- interface-requires LibreOffice 1.0 --> + <requires lib="gtk+" version="3.18"/> + <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="RenameObjectDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="renameobjectdialog|RenameObjectDialog">Rename object: </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"> @@ -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> @@ -96,16 +101,14 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="renameobjectdialog|label2">New name</property> <property name="use_underline">True</property> <property name="mnemonic_widget">entry</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -117,8 +120,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -149,5 +150,8 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> |