[Libreoffice-commits] core.git: cui/source cui/uiconfig editeng/source extras/source include/editeng include/vcl solenv/sanitizers vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 20 07:57:24 UTC 2018


 cui/source/dialogs/hyphen.cxx                  |  188 ++++++++++---------------
 cui/source/factory/dlgfact.cxx                 |   19 +-
 cui/source/factory/dlgfact.hxx                 |   14 +
 cui/source/inc/hyphen.hxx                      |   57 +++----
 cui/uiconfig/ui/hyphenate.ui                   |   17 +-
 editeng/source/misc/splwrap.cxx                |    6 
 extras/source/glade/libreoffice-catalog.xml.in |    3 
 include/editeng/edtdlg.hxx                     |    6 
 include/vcl/edit.hxx                           |    1 
 include/vcl/weld.hxx                           |    4 
 solenv/sanitizers/ui/cui.suppr                 |    2 
 vcl/source/app/salvtables.cxx                  |   20 ++
 vcl/source/window/builder.cxx                  |    4 
 vcl/unx/gtk3/gtk3gtkinst.cxx                   |   19 ++
 14 files changed, 191 insertions(+), 169 deletions(-)

New commits:
commit 41db073808566641a3c364e6490f33b7f204d0b0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 19 13:47:11 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 20 09:56:54 2018 +0200

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

diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx
index ba55b4c3bc26..c519f755e3d6 100644
--- a/cui/source/dialogs/hyphen.cxx
+++ b/cui/source/dialogs/hyphen.cxx
@@ -33,49 +33,31 @@
 
 using namespace css;
 
-HyphenEdit::HyphenEdit(vcl::Window* pParent)
-    : Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK|WB_TABSTOP)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, CursorChangeHdl_Impl, weld::Entry&, void)
 {
+    int nStart, nEnd;
+    m_xWordEdit->get_selection_bounds(nStart, nEnd);
+    if (nStart == m_nOldPos && nEnd == m_nOldPos + 1)
+        return;
+    bool bReSelect;
+    if (nStart <= m_nOldPos)
+        bReSelect = !SelLeft();
+    else
+        bReSelect = !SelRight();
+    if (bReSelect)
+        select_region(m_nOldPos, m_nOldPos + 1);
 }
 
-VCL_BUILDER_FACTORY(HyphenEdit)
-
-void HyphenEdit::KeyInput( const KeyEvent& rKEvt )
-{
-    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
-
-    switch ( nCode )
-    {
-        case KEY_LEFT:
-            static_cast<SvxHyphenWordDialog*>( GetParentDialog() )->SelLeft();
-            break;
-
-        case KEY_RIGHT:
-            static_cast<SvxHyphenWordDialog*>( GetParentDialog() )->SelRight();
-            break;
-
-        case KEY_TAB:
-        case KEY_ESCAPE:
-        case KEY_RETURN:
-            Edit::KeyInput(rKEvt);
-            break;
-        default:
-            Control::KeyInput( rKEvt ); // pass on to the dialog
-            break;
-    }
-}
-
-
 void SvxHyphenWordDialog::EnableLRBtn_Impl()
 {
     const sal_Int32 nLen = m_aEditWord.getLength();
 
-    m_pRightBtn->Disable();
+    m_xRightBtn->set_sensitive(false);
     for ( sal_Int32 i = m_nOldPos + 2; i < nLen; ++i )
     {
         if ( m_aEditWord[ i ] == sal_Unicode( HYPH_POS_CHAR ) )
         {
-            m_pRightBtn->Enable();
+            m_xRightBtn->set_sensitive(true);
             break;
         }
     }
@@ -83,18 +65,17 @@ void SvxHyphenWordDialog::EnableLRBtn_Impl()
     DBG_ASSERT(m_nOldPos < nLen, "nOldPos out of range");
     if (m_nOldPos >= nLen)
         m_nOldPos = nLen - 1;
-    m_pLeftBtn->Disable();
+    m_xLeftBtn->set_sensitive(false);
     for ( sal_Int32 i = m_nOldPos;  i-- > 0; )
     {
         if ( m_aEditWord[ i ] == sal_Unicode( HYPH_POS_CHAR ) )
         {
-            m_pLeftBtn->Enable();
+            m_xLeftBtn->set_sensitive(true);
             break;
         }
     }
 }
 
-
 OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl()
 {
     // returns a String showing only those hyphen positions which will result
@@ -195,7 +176,6 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl()
     return aTxt;
 }
 
-
 void SvxHyphenWordDialog::InitControls_Impl()
 {
     m_xPossHyph = nullptr;
@@ -207,14 +187,13 @@ void SvxHyphenWordDialog::InitControls_Impl()
         if (m_xPossHyph.is())
             m_aEditWord = EraseUnusableHyphens_Impl();
     }
-    m_pWordEdit->SetText( m_aEditWord );
+    m_xWordEdit->set_text(m_aEditWord);
 
     m_nOldPos = m_aEditWord.getLength();
     SelLeft();
     EnableLRBtn_Impl();
 }
 
-
 void SvxHyphenWordDialog::ContinueHyph_Impl( sal_Int32 nInsPos )
 {
     if ( nInsPos >= 0 && m_xPossHyph.is() )
@@ -266,14 +245,14 @@ void SvxHyphenWordDialog::ContinueHyph_Impl( sal_Int32 nInsPos )
     }
     else
     {
-        m_pCloseBtn->Disable();
-        EndDialog(RET_OK);
+        m_xCloseBtn->set_sensitive(false);
+        m_xDialog->response(RET_OK);
     }
 }
 
-
-void SvxHyphenWordDialog::SelLeft()
+bool SvxHyphenWordDialog::SelLeft()
 {
+    bool bRet = false;
     DBG_ASSERT( m_nOldPos > 0, "invalid hyphenation position" );
     if (m_nOldPos > 0)
     {
@@ -286,19 +265,21 @@ void SvxHyphenWordDialog::SelLeft()
                 aTxt = aTxt.replaceAt( i, 1, OUString( CUR_HYPH_POS_CHAR ) );
 
                 m_nOldPos = i;
-                m_pWordEdit->SetText( aTxt );
-                m_pWordEdit->GrabFocus();
-                m_pWordEdit->SetSelection( Selection( i, i + 1 ) );
+                m_xWordEdit->set_text(aTxt);
+                select_region(i, i + 1);
+                m_xWordEdit->grab_focus();
+                bRet = true;
                 break;
             }
         }
         EnableLRBtn_Impl();
     }
+    return bRet;
 }
 
-
-void SvxHyphenWordDialog::SelRight()
+bool SvxHyphenWordDialog::SelRight()
 {
+    bool bRet = false;
     OUString aTxt( m_aEditWord );
     for ( sal_Int32 i = m_nOldPos + 1;  i < aTxt.getLength();  ++i )
     {
@@ -307,17 +288,18 @@ void SvxHyphenWordDialog::SelRight()
             aTxt = aTxt.replaceAt( i, 1, OUString( CUR_HYPH_POS_CHAR ) );
 
             m_nOldPos = i;
-            m_pWordEdit->SetText( aTxt );
-            m_pWordEdit->GrabFocus();
-            m_pWordEdit->SetSelection( Selection( i, i + 1 ) );
+            m_xWordEdit->set_text(aTxt);
+            select_region(i, i + 1);
+            m_xWordEdit->grab_focus();
+            bRet = true;
             break;
         }
     }
     EnableLRBtn_Impl();
+    return bRet;
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, CutHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, CutHdl_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -327,8 +309,7 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, CutHdl_Impl, Button*, void)
     }
 }
 
-
-IMPL_LINK_NOARG( SvxHyphenWordDialog, HyphenateAllHdl_Impl, Button *, void )
+IMPL_LINK_NOARG(SvxHyphenWordDialog, HyphenateAllHdl_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -351,8 +332,7 @@ IMPL_LINK_NOARG( SvxHyphenWordDialog, HyphenateAllHdl_Impl, Button *, void )
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, DeleteHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, DeleteHdl_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -362,8 +342,7 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, DeleteHdl_Impl, Button*, void)
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, ContinueHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, ContinueHdl_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -373,19 +352,17 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, ContinueHdl_Impl, Button*, void)
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, CancelHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, CancelHdl_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
         m_bBusy = true;
-        EndDialog();
+        m_xDialog->response(RET_CANCEL);
         m_bBusy = false;
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, Left_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, Left_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -395,8 +372,7 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, Left_Impl, Button*, void)
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, Right_Impl, Button*, void)
+IMPL_LINK_NOARG(SvxHyphenWordDialog, Right_Impl, weld::Button&, void)
 {
     if( !m_bBusy )
     {
@@ -406,21 +382,30 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, Right_Impl, Button*, void)
     }
 }
 
-
-IMPL_LINK_NOARG(SvxHyphenWordDialog, GetFocusHdl_Impl, Control&, void)
+void SvxHyphenWordDialog::select_region(int nStart, int nEnd)
 {
-    m_pWordEdit->SetSelection( Selection( m_nOldPos, m_nOldPos + 1 ) );
+    int nScrollPos = nStart + m_nWordEditWidth/2;
+    if (nScrollPos > m_aEditWord.getLength())
+        nScrollPos = m_aEditWord.getLength() - m_nWordEditWidth/2;
+    if (nScrollPos < 0)
+        nScrollPos = 0;
+    m_xWordEdit->set_position(nScrollPos);
+    m_xWordEdit->select_region(nStart, nEnd);
 }
 
+IMPL_LINK_NOARG(SvxHyphenWordDialog, GetFocusHdl_Impl, weld::Widget&, void)
+{
+    select_region(m_nOldPos, m_nOldPos + 1);
+}
 
 // class SvxHyphenWordDialog ---------------------------------------------
 
 SvxHyphenWordDialog::SvxHyphenWordDialog(
     const OUString &rWord, LanguageType nLang,
-    vcl::Window* pParent,
+    weld::Window* pParent,
     uno::Reference< linguistic2::XHyphenator > const &xHyphen,
     SvxSpellWrapper* pWrapper)
-    : SfxModalDialog(pParent, "HyphenateDialog", "cui/ui/hyphenate.ui")
+    : weld::GenericDialogController(pParent, "cui/ui/hyphenate.ui", "HyphenateDialog")
     , m_pHyphWrapper(pWrapper)
     , m_aActWord(rWord)
     , m_nActLanguage(nLang)
@@ -428,17 +413,17 @@ SvxHyphenWordDialog::SvxHyphenWordDialog(
     , m_nOldPos(0)
     , m_nHyphenationPositionsOffset(0)
     , m_bBusy(false)
+    , m_xWordEdit(m_xBuilder->weld_entry("worded"))
+    , m_xLeftBtn(m_xBuilder->weld_button("left"))
+    , m_xRightBtn(m_xBuilder->weld_button("right"))
+    , m_xOkBtn(m_xBuilder->weld_button("ok"))
+    , m_xContBtn(m_xBuilder->weld_button("continue"))
+    , m_xDelBtn(m_xBuilder->weld_button("delete"))
+    , m_xHyphAll(m_xBuilder->weld_button("hyphall"))
+    , m_xCloseBtn(m_xBuilder->weld_button("close"))
 {
-    get(m_pWordEdit, "worded");
-    get(m_pLeftBtn, "left");
-    get(m_pRightBtn, "right");
-    get(m_pOkBtn, "ok");
-    get(m_pContBtn, "continue");
-    get(m_pDelBtn, "delete");
-    get(m_pHyphAll, "hyphall");
-    get(m_pCloseBtn, "close");
-
-    m_aLabel = GetText();
+    m_nWordEditWidth = m_xWordEdit->get_width_chars();
+    m_aLabel = m_xDialog->get_title();
     m_xHyphenator = xHyphen;
 
     uno::Reference< linguistic2::XHyphenatedWord >  xHyphWord( m_pHyphWrapper ?
@@ -452,47 +437,34 @@ SvxHyphenWordDialog::SvxHyphenWordDialog(
     }
 
     InitControls_Impl();
-    m_pWordEdit->GrabFocus();
-
-    m_pLeftBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, Left_Impl ) );
-    m_pRightBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, Right_Impl ) );
-    m_pOkBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, CutHdl_Impl ) );
-    m_pContBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, ContinueHdl_Impl ) );
-    m_pDelBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, DeleteHdl_Impl ) );
-    m_pHyphAll->SetClickHdl( LINK( this, SvxHyphenWordDialog, HyphenateAllHdl_Impl ) );
-    m_pCloseBtn->SetClickHdl( LINK( this, SvxHyphenWordDialog, CancelHdl_Impl ) );
-    m_pWordEdit->SetGetFocusHdl( LINK( this, SvxHyphenWordDialog, GetFocusHdl_Impl ) );
+    m_xWordEdit->grab_focus();
+
+    m_xLeftBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, Left_Impl ) );
+    m_xRightBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, Right_Impl ) );
+    m_xOkBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, CutHdl_Impl ) );
+    m_xContBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, ContinueHdl_Impl ) );
+    m_xDelBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, DeleteHdl_Impl ) );
+    m_xHyphAll->connect_clicked( LINK( this, SvxHyphenWordDialog, HyphenateAllHdl_Impl ) );
+    m_xCloseBtn->connect_clicked( LINK( this, SvxHyphenWordDialog, CancelHdl_Impl ) );
+    m_xWordEdit->connect_focus_in( LINK( this, SvxHyphenWordDialog, GetFocusHdl_Impl ) );
+    m_xWordEdit->connect_cursor_position( LINK( this, SvxHyphenWordDialog, CursorChangeHdl_Impl ) );
 
     SetWindowTitle( nLang );
 
     // disable controls if service is not available
     if (!m_xHyphenator.is())
-        Enable( false );
+        m_xDialog->set_sensitive(false);
 }
 
 SvxHyphenWordDialog::~SvxHyphenWordDialog()
 {
-    disposeOnce();
-}
-
-void SvxHyphenWordDialog::dispose()
-{
-    if (m_pCloseBtn->IsEnabled())
+    if (m_xCloseBtn->get_sensitive())
         m_pHyphWrapper->SpellEnd();
-    m_pWordEdit.clear();
-    m_pLeftBtn.clear();
-    m_pRightBtn.clear();
-    m_pOkBtn.clear();
-    m_pContBtn.clear();
-    m_pDelBtn.clear();
-    m_pHyphAll.clear();
-    m_pCloseBtn.clear();
-    SfxModalDialog::dispose();
 }
 
-void SvxHyphenWordDialog::SetWindowTitle( LanguageType nLang )
+void SvxHyphenWordDialog::SetWindowTitle(LanguageType nLang)
 {
-    SetText( m_aLabel + " (" + SvtLanguageTable::GetLanguageString( nLang ) + ")" );
+    m_xDialog->set_title(m_aLabel + " (" + SvtLanguageTable::GetLanguageString(nLang) + ")");
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 2af171c3b6f2..fa44f29ac581 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -104,7 +104,12 @@ IMPL_ABSTDLG_BASE(CuiAbstractTabDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractSvxDistributeDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractHangulHanjaConversionDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractFmShowColsDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractHyphenWordDialog_Impl)
+
+short AbstractHyphenWordDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
+
 IMPL_ABSTDLG_BASE(AbstractThesaurusDialog_Impl)
 
 short AbstractSvxZoomDialog_Impl::Execute()
@@ -478,11 +483,6 @@ OUString AbstractThesaurusDialog_Impl::GetWord()
     return pDlg->GetWord();
 };
 
-vcl::Window* AbstractHyphenWordDialog_Impl::GetWindow()
-{
-    return pDlg;
-}
-
 Reference < css::embed::XEmbeddedObject > AbstractInsertObjectDialog_Impl::GetObject()
 {
    return m_xDlg->GetObject();
@@ -1050,13 +1050,12 @@ VclPtr<AbstractThesaurusDialog> AbstractDialogFactory_Impl::CreateThesaurusDialo
     return VclPtr<AbstractThesaurusDialog_Impl>::Create( pDlg );
 }
 
-VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDialog( vcl::Window* pParent,
+VclPtr<AbstractHyphenWordDialog> AbstractDialogFactory_Impl::CreateHyphenWordDialog(weld::Window* pParent,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
-                                                SvxSpellWrapper* pWrapper )
+                                                SvxSpellWrapper* pWrapper)
 {
-    VclPtrInstance<SvxHyphenWordDialog> pDlg( rWord, nLang, pParent, xHyphen, pWrapper );
-    return VclPtr<AbstractHyphenWordDialog_Impl>::Create( pDlg );
+    return VclPtr<AbstractHyphenWordDialog_Impl>::Create(o3tl::make_unique<SvxHyphenWordDialog>(rWord, nLang, pParent, xHyphen, pWrapper));
 }
 
 VclPtr<AbstractFmShowColsDialog> AbstractDialogFactory_Impl::CreateFmShowColsDialog()
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 07b202371d26..55bcfa009b31 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -190,8 +190,14 @@ class AbstractThesaurusDialog_Impl : public AbstractThesaurusDialog
 
 class AbstractHyphenWordDialog_Impl: public AbstractHyphenWordDialog
 {
-    DECL_ABSTDLG_BASE(AbstractHyphenWordDialog_Impl,SvxHyphenWordDialog)
-    virtual vcl::Window* GetWindow() override;
+protected:
+    std::unique_ptr<SvxHyphenWordDialog> m_xDlg;
+public:
+    explicit AbstractHyphenWordDialog_Impl(std::unique_ptr<SvxHyphenWordDialog> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short Execute() override;
 };
 
 class FmShowColsDialog;
@@ -680,10 +686,10 @@ public:
     virtual VclPtr<AbstractThesaurusDialog>  CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
                                                 const OUString &rWord, LanguageType nLanguage ) override;
 
-    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog( vcl::Window*,
+    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog(weld::Window*,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
-                                                SvxSpellWrapper* pWrapper ) override;
+                                                SvxSpellWrapper* pWrapper) override;
 
     virtual VclPtr<AbstractFmShowColsDialog> CreateFmShowColsDialog() override;
     virtual VclPtr<AbstractSvxZoomDialog> CreateSvxZoomDialog(weld::Window* pParent, const SfxItemSet& rCoreSet) override;
diff --git a/cui/source/inc/hyphen.hxx b/cui/source/inc/hyphen.hxx
index 4e756c019c82..50b88db023d7 100644
--- a/cui/source/inc/hyphen.hxx
+++ b/cui/source/inc/hyphen.hxx
@@ -21,9 +21,7 @@
 
 #include <memory>
 
-#include <vcl/edit.hxx>
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 #include <sfx2/basedlgs.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/linguistic2/XHyphenator.hpp>
@@ -40,16 +38,8 @@ protected:
     virtual void KeyInput(const KeyEvent &rKEvt) override;
 };
 
-class SvxHyphenWordDialog : public SfxModalDialog
+class SvxHyphenWordDialog : public weld::GenericDialogController
 {
-    VclPtr<HyphenEdit>         m_pWordEdit;
-    VclPtr<PushButton>         m_pLeftBtn;
-    VclPtr<PushButton>         m_pRightBtn;
-    VclPtr<PushButton>         m_pOkBtn;
-    VclPtr<PushButton>         m_pContBtn;
-    VclPtr<PushButton>         m_pDelBtn;
-    VclPtr<PushButton>         m_pHyphAll;
-    VclPtr<CloseButton>        m_pCloseBtn;
     OUString            m_aLabel;
     SvxSpellWrapper     *const m_pHyphWrapper;
     css::uno::Reference< css::linguistic2::XHyphenator >        m_xHyphenator;
@@ -60,37 +50,48 @@ class SvxHyphenWordDialog : public SfxModalDialog
     sal_Int16           m_nMaxHyphenationPos; // right most valid hyphenation pos
     sal_Int32           m_nOldPos;
     sal_Int32           m_nHyphenationPositionsOffset;
+    int                 m_nWordEditWidth;
     bool                m_bBusy;
 
+    std::unique_ptr<weld::Entry> m_xWordEdit;
+    std::unique_ptr<weld::Button> m_xLeftBtn;
+    std::unique_ptr<weld::Button> m_xRightBtn;
+    std::unique_ptr<weld::Button> m_xOkBtn;
+    std::unique_ptr<weld::Button> m_xContBtn;
+    std::unique_ptr<weld::Button> m_xDelBtn;
+    std::unique_ptr<weld::Button> m_xHyphAll;
+    std::unique_ptr<weld::Button> m_xCloseBtn;
+
     void            EnableLRBtn_Impl();
     OUString        EraseUnusableHyphens_Impl();
 
     void            InitControls_Impl();
     void            ContinueHyph_Impl( sal_Int32 nInsPos = -1 ); // continue by default
 
-    DECL_LINK(Left_Impl, Button*, void);
-    DECL_LINK(Right_Impl, Button*, void);
-    DECL_LINK(CutHdl_Impl, Button*, void);
-    DECL_LINK(ContinueHdl_Impl, Button*, void);
-    DECL_LINK(DeleteHdl_Impl, Button*, void);
-    DECL_LINK( HyphenateAllHdl_Impl, Button*, void );
-    DECL_LINK(CancelHdl_Impl, Button*, void);
-    DECL_LINK(GetFocusHdl_Impl, Control&, void);
+    void            select_region(int nStart, int nEnd);
+
+    DECL_LINK(Left_Impl, weld::Button&, void);
+    DECL_LINK(Right_Impl, weld::Button&, void);
+    DECL_LINK(CutHdl_Impl, weld::Button&, void);
+    DECL_LINK(ContinueHdl_Impl, weld::Button&, void);
+    DECL_LINK(DeleteHdl_Impl, weld::Button&, void);
+    DECL_LINK(HyphenateAllHdl_Impl, weld::Button&, void);
+    DECL_LINK(CancelHdl_Impl, weld::Button&, void);
+    DECL_LINK(GetFocusHdl_Impl, weld::Widget&, void);
+    DECL_LINK(CursorChangeHdl_Impl, weld::Entry&, void);
 
 public:
-    SvxHyphenWordDialog( const OUString &rWord, LanguageType nLang,
-                         vcl::Window* pParent,
-                         css::uno::Reference< css::linguistic2::XHyphenator > const &xHyphen,
-                         SvxSpellWrapper* pWrapper );
+    SvxHyphenWordDialog(const OUString &rWord, LanguageType nLang,
+                        weld::Window* pParent,
+                        css::uno::Reference<css::linguistic2::XHyphenator> const &xHyphen,
+                        SvxSpellWrapper* pWrapper);
     virtual ~SvxHyphenWordDialog() override;
-    virtual void    dispose() override;
 
     void            SetWindowTitle( LanguageType nLang );
-    void            SelLeft();
-    void            SelRight();
+    bool            SelLeft();
+    bool            SelRight();
 };
 
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/uiconfig/ui/hyphenate.ui b/cui/uiconfig/ui/hyphenate.ui
index d097ccd27ead..ca2aee78fe40 100644
--- a/cui/uiconfig/ui/hyphenate.ui
+++ b/cui/uiconfig/ui/hyphenate.ui
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkImage" id="image1">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -18,7 +17,13 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="hyphenate|HyphenateDialog">Hyphenation</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>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -98,6 +103,7 @@
                     <property name="label" translatable="yes" context="hyphenate|ok">Hyphenate</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
                     <property name="has_default">True</property>
                     <property name="receives_default">True</property>
                   </object>
@@ -144,9 +150,10 @@
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="hyphenate|label1">Word:</property>
                 <property name="use_underline">True</property>
+                <property name="mnemonic_widget">worded</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -162,10 +169,12 @@
                 <property name="row_spacing">6</property>
                 <property name="column_spacing">12</property>
                 <child>
-                  <object class="cuilo-HyphenEdit" id="worded">
+                  <object class="GtkEntry" id="worded">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="hexpand">True</property>
+                    <property name="editable">False</property>
+                    <property name="activates_default">True</property>
                     <property name="width_chars">32</property>
                   </object>
                   <packing>
diff --git a/editeng/source/misc/splwrap.cxx b/editeng/source/misc/splwrap.cxx
index 6e2175a8f269..1a4e8568351b 100644
--- a/editeng/source/misc/splwrap.cxx
+++ b/editeng/source/misc/splwrap.cxx
@@ -273,18 +273,16 @@ void SvxSpellWrapper::SpellDocument( )
     {
         Reference< XHyphenatedWord >        xHyphWord( GetLast(), UNO_QUERY );
 
-        vcl::Window *pOld = pWin;
         if (xHyphWord.is())
         {
             EditAbstractDialogFactory* pFact = EditAbstractDialogFactory::Create();
-            ScopedVclPtr<AbstractHyphenWordDialog> pDlg(pFact->CreateHyphenWordDialog( pWin,
+            ScopedVclPtr<AbstractHyphenWordDialog> pDlg(pFact->CreateHyphenWordDialog(
+                            pWin ? pWin->GetFrameWeld() : nullptr,
                             xHyphWord->getWord(),
                             LanguageTag( xHyphWord->getLocale() ).getLanguageType(),
                             xHyph, this ));
-            pWin = pDlg->GetWindow();
             pDlg->Execute();
         }
-        pWin = pOld;
     }
 }
 
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 8c4ce8b7d652..48e210444259 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -42,9 +42,6 @@
     <glade-widget-class title="Condition Edit" name="rptuilo-ConditionField"
                         generic-name="ConditionEdit" parent="GtkEntry"
                         icon-name="widget-gtk-comboboxtext"/>
-    <glade-widget-class title="Hyphen Edit" name="cuilo-HyphenEdit"
-                        generic-name="HyphenEdit" parent="GtkEntry"
-                        icon-name="widget-gtk-textentry"/>
     <glade-widget-class title="OSQL NameEdit" name="dbulo-OSQLNameEdit"
                         generic-name="OSQLNameEdit" parent="GtkEntry"
                         icon-name="widget-gtk-textentry"/>
diff --git a/include/editeng/edtdlg.hxx b/include/editeng/edtdlg.hxx
index be4722bc31b0..caacc97b9ac0 100644
--- a/include/editeng/edtdlg.hxx
+++ b/include/editeng/edtdlg.hxx
@@ -50,8 +50,6 @@ class AbstractHyphenWordDialog : public VclAbstractDialog
 {
 protected:
     virtual ~AbstractHyphenWordDialog() override = default;
-public:
-    virtual vcl::Window* GetWindow() = 0;
 };
 
 class AbstractHangulHanjaConversionDialog : public VclAbstractTerminatedDialog
@@ -93,10 +91,10 @@ public:
     virtual VclPtr<AbstractThesaurusDialog>  CreateThesaurusDialog( vcl::Window*, css::uno::Reference< css::linguistic2::XThesaurus >  xThesaurus,
                                                 const OUString &rWord, LanguageType nLanguage ) = 0;
 
-    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog( vcl::Window*,
+    virtual VclPtr<AbstractHyphenWordDialog> CreateHyphenWordDialog(weld::Window*,
                                                 const OUString &rWord, LanguageType nLang,
                                                 css::uno::Reference< css::linguistic2::XHyphenator >  &xHyphen,
-                                                SvxSpellWrapper* pWrapper ) = 0;
+                                                SvxSpellWrapper* pWrapper) = 0;
     virtual VclPtr<AbstractHangulHanjaConversionDialog> CreateHangulHanjaConversionDialog( vcl::Window* _pParent,
                                             editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection ) = 0;
 };
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index bee63aae0488..bc05f65bbf2a 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -212,6 +212,7 @@ public:
     virtual sal_Int32   GetMaxTextLen() const { return mnMaxTextLen; }
 
     void                SetWidthInChars(sal_Int32 nWidthInChars);
+    sal_Int32           GetWidthInChars() const { return mnWidthInChars; }
 
     void                setMaxWidthChars(sal_Int32 nWidth);
 
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index dc69721bb66e..f2ec98049023 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -505,11 +505,13 @@ public:
     virtual void set_text(const OUString& rText) = 0;
     virtual OUString get_text() const = 0;
     virtual void set_width_chars(int nChars) = 0;
+    virtual int get_width_chars() const = 0;
     virtual void set_max_length(int nChars) = 0;
     // nEndPos can be -1 in order to select all text
     virtual void select_region(int nStartPos, int nEndPos) = 0;
     virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
     virtual void set_position(int nCursorPos) = 0;
+    virtual int get_position() const = 0;
     virtual void set_editable(bool bEditable) = 0;
     virtual bool get_editable() const = 0;
     virtual void set_error(bool bShowError) = 0;
@@ -670,6 +672,8 @@ public:
     {
         m_xEntry->select_region(nStartPos, nEndPos);
     }
+    //if not text was selected, both rStartPos and rEndPos will be identical
+    //and false will be returned
     virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) override
     {
         return m_xEntry->get_selection_bounds(rStartPos, rEndPos);
diff --git a/solenv/sanitizers/ui/cui.suppr b/solenv/sanitizers/ui/cui.suppr
index a68a1e078850..f084489e8c2d 100644
--- a/solenv/sanitizers/ui/cui.suppr
+++ b/solenv/sanitizers/ui/cui.suppr
@@ -244,8 +244,6 @@ cui/uiconfig/ui/hatchpage.ui://GtkMenuButton[@id='linecolorlb'] button-no-label
 cui/uiconfig/ui/hatchpage.ui://GtkMenuButton[@id='backgroundcolorlb'] button-no-label
 cui/uiconfig/ui/hyperlinkdocpage.ui://GtkLabel[@id='url_label'] orphan-label
 cui/uiconfig/ui/hyperlinkdocpage.ui://GtkLabel[@id='url'] orphan-label
-cui/uiconfig/ui/hyphenate.ui://GtkLabel[@id='label1'] orphan-label
-cui/uiconfig/ui/hyphenate.ui://cuilo-HyphenEdit[@id='worded'] no-labelled-by
 cui/uiconfig/ui/hyphenate.ui://GtkButton[@id='left'] button-no-label
 cui/uiconfig/ui/hyphenate.ui://GtkButton[@id='right'] button-no-label
 cui/uiconfig/ui/iconchangedialog.ui://GtkTextView[@id='addrTextview'] no-labelled-by
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index f68ac1b3b996..f6827975dc61 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1462,7 +1462,9 @@ public:
 
     virtual void set_text(const OUString& rText) override
     {
+        disable_notify_events();
         m_xEntry->SetText(rText);
+        enable_notify_events();
     }
 
     virtual OUString get_text() const override
@@ -1475,6 +1477,11 @@ public:
         m_xEntry->SetWidthInChars(nChars);
     }
 
+    virtual int get_width_chars() const override
+    {
+        return m_xEntry->GetWidthInChars();
+    }
+
     virtual void set_max_length(int nChars) override
     {
         m_xEntry->SetMaxTextLen(nChars);
@@ -1482,7 +1489,9 @@ public:
 
     virtual void select_region(int nStartPos, int nEndPos) override
     {
+        disable_notify_events();
         m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
+        enable_notify_events();
     }
 
     bool get_selection_bounds(int& rStartPos, int &rEndPos) override
@@ -1495,10 +1504,17 @@ public:
 
     virtual void set_position(int nCursorPos) override
     {
+        disable_notify_events();
         if (nCursorPos < 0)
             m_xEntry->SetCursorAtLast();
         else
             m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos));
+        enable_notify_events();
+    }
+
+    virtual int get_position() const override
+    {
+        return m_xEntry->GetSelection().Max();
     }
 
     virtual void set_editable(bool bEditable) override
@@ -1562,6 +1578,8 @@ IMPL_LINK_NOARG(SalInstanceEntry, ChangeHdl, Edit&, void)
 
 IMPL_LINK(SalInstanceEntry, CursorListener, VclWindowEvent&, rEvent, void)
 {
+    if (notify_events_disabled())
+        return;
     if (rEvent.GetId() == VclEventId::EditSelectionChanged || rEvent.GetId() == VclEventId::EditCaretChanged)
         signal_cursor_position();
 }
@@ -1930,7 +1948,9 @@ public:
 
     virtual void select_region(int nStartPos, int nEndPos) override
     {
+        disable_notify_events();
         m_xTextView->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
+        enable_notify_events();
     }
 
     virtual void set_editable(bool bEditable) override
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 395596b7f5d5..9ccabc6412e3 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1846,7 +1846,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
     }
     else if (name == "GtkEntry")
     {
-        xWindow = VclPtr<Edit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
+        xWindow = VclPtr<Edit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK|WB_NOHIDESELECTION);
         BuilderUtils::ensureDefaultWidthChars(rMap);
     }
     else if (name == "GtkNotebook")
@@ -1862,7 +1862,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
     {
         extractBuffer(id, rMap);
 
-        WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT;
+        WinBits nWinStyle = WB_CLIPCHILDREN|WB_LEFT|WB_NOHIDESELECTION;
         OUString sBorder = BuilderUtils::extractCustomProperty(rMap);
         if (!sBorder.isEmpty())
             nWinStyle |= WB_BORDER;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 3fbe2608f9c7..2abff266abe6 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3365,6 +3365,7 @@ private:
     gulong m_nChangedSignalId;
     gulong m_nInsertTextSignalId;
     gulong m_nCursorPosSignalId;
+    gulong m_nSelectionPosSignalId;
 
     static void signalChanged(GtkEntry*, gpointer widget)
     {
@@ -3410,6 +3411,7 @@ public:
         , m_nChangedSignalId(g_signal_connect(pEntry, "changed", G_CALLBACK(signalChanged), this))
         , m_nInsertTextSignalId(g_signal_connect(pEntry, "insert-text", G_CALLBACK(signalInsertText), this))
         , m_nCursorPosSignalId(g_signal_connect(pEntry, "notify::cursor-position", G_CALLBACK(signalCursorPosition), this))
+        , m_nSelectionPosSignalId(g_signal_connect(pEntry, "notify::selection-bound", G_CALLBACK(signalCursorPosition), this))
     {
     }
 
@@ -3434,6 +3436,11 @@ public:
         enable_notify_events();
     }
 
+    virtual int get_width_chars() const override
+    {
+        return gtk_entry_get_width_chars(m_pEntry);
+    }
+
     virtual void set_max_length(int nChars) override
     {
         disable_notify_events();
@@ -3455,7 +3462,14 @@ public:
 
     virtual void set_position(int nCursorPos) override
     {
+        disable_notify_events();
         gtk_editable_set_position(GTK_EDITABLE(m_pEntry), nCursorPos);
+        enable_notify_events();
+    }
+
+    virtual int get_position() const override
+    {
+        return gtk_editable_get_position(GTK_EDITABLE(m_pEntry));
     }
 
     virtual void set_editable(bool bEditable) override
@@ -3478,6 +3492,8 @@ public:
 
     virtual void disable_notify_events() override
     {
+        g_signal_handler_block(m_pEntry, m_nSelectionPosSignalId);
+        g_signal_handler_block(m_pEntry, m_nCursorPosSignalId);
         g_signal_handler_block(m_pEntry, m_nInsertTextSignalId);
         g_signal_handler_block(m_pEntry, m_nChangedSignalId);
         GtkInstanceWidget::disable_notify_events();
@@ -3488,6 +3504,8 @@ public:
         GtkInstanceWidget::enable_notify_events();
         g_signal_handler_unblock(m_pEntry, m_nChangedSignalId);
         g_signal_handler_unblock(m_pEntry, m_nInsertTextSignalId);
+        g_signal_handler_unblock(m_pEntry, m_nCursorPosSignalId);
+        g_signal_handler_unblock(m_pEntry, m_nSelectionPosSignalId);
     }
 
     virtual vcl::Font get_font() override
@@ -3579,6 +3597,7 @@ public:
 
     virtual ~GtkInstanceEntry() override
     {
+        g_signal_handler_disconnect(m_pEntry, m_nSelectionPosSignalId);
         g_signal_handler_disconnect(m_pEntry, m_nCursorPosSignalId);
         g_signal_handler_disconnect(m_pEntry, m_nInsertTextSignalId);
         g_signal_handler_disconnect(m_pEntry, m_nChangedSignalId);


More information about the Libreoffice-commits mailing list