[Libreoffice-commits] core.git: cui/source cui/uiconfig include/svx include/vcl sc/source sw/inc sw/source vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Mon Apr 16 12:50:54 UTC 2018


 cui/source/dialogs/postdlg.cxx       |  129 ++++++++++++++---------------------
 cui/source/factory/dlgfact.cxx       |   51 ++++++++-----
 cui/source/factory/dlgfact.hxx       |   29 ++++---
 cui/source/inc/postdlg.hxx           |   77 ++++++++++----------
 cui/uiconfig/ui/comment.ui           |   54 +++++++-------
 include/svx/svxdlg.hxx               |   13 +--
 include/vcl/weld.hxx                 |   13 ++-
 sc/source/ui/docshell/docsh3.cxx     |    2 
 sc/source/ui/inc/docsh.hxx           |    2 
 sc/source/ui/inc/redcom.hxx          |    4 -
 sc/source/ui/miscdlgs/acredlin.cxx   |    2 
 sc/source/ui/miscdlgs/redcom.cxx     |    2 
 sc/source/ui/view/tabvwsh3.cxx       |    2 
 sw/inc/viewsh.hxx                    |    5 +
 sw/source/core/view/viewsh.cxx       |    8 +-
 sw/source/uibase/misc/redlndlg.cxx   |    6 -
 sw/source/uibase/shells/textfld.cxx  |    4 -
 sw/source/uibase/uiview/viewport.cxx |   20 ++++-
 vcl/source/app/salvtables.cxx        |   26 +++++--
 vcl/unx/gtk3/gtk3gtkinst.cxx         |   22 ++++-
 20 files changed, 264 insertions(+), 207 deletions(-)

New commits:
commit 77a59cabf33d5d6ccc80ea62ee07162abc1b4e52
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Apr 14 21:15:28 2018 +0100

    weld SvxPostItDialog
    
    Change-Id: I0aa88270aa604180223f2b35829b45e5828f792a
    Reviewed-on: https://gerrit.libreoffice.org/52896
    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/cui/source/dialogs/postdlg.cxx b/cui/source/dialogs/postdlg.cxx
index 36338937ed67..dbf6436e14d0 100644
--- a/cui/source/dialogs/postdlg.cxx
+++ b/cui/source/dialogs/postdlg.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <tools/date.hxx>
+#include <tools/lineend.hxx>
 #include <tools/time.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -32,54 +33,49 @@
 
 // class SvxPostItDialog -------------------------------------------------
 
-SvxPostItDialog::SvxPostItDialog(vcl::Window* pParent, const SfxItemSet& rCoreSet,
+SvxPostItDialog::SvxPostItDialog(weld::Window* pParent, const SfxItemSet& rCoreSet,
     bool bPrevNext)
-    : SfxModalDialog(pParent, "CommentDialog", "cui/ui/comment.ui")
-    , rSet(rCoreSet)
-    , pOutSet(nullptr)
+    : GenericDialogController(pParent, "cui/ui/comment.ui", "CommentDialog")
+    , m_rSet(rCoreSet)
+    , m_xLastEditFT(m_xBuilder->weld_label("lastedit"))
+    , m_xAltTitle(m_xBuilder->weld_label("alttitle"))
+    , m_xEditED(m_xBuilder->weld_text_view("edit"))
+    , m_xInsertAuthor(m_xBuilder->weld_widget("insertauthor"))
+    , m_xAuthorBtn(m_xBuilder->weld_button("author"))
+    , m_xOKBtn(m_xBuilder->weld_button("ok"))
+    , m_xPrevBtn(m_xBuilder->weld_button("previous"))
+    , m_xNextBtn(m_xBuilder->weld_button("next"))
 {
-    get(m_pLastEditFT, "lastedit");
-    get(m_pInsertAuthor, "insertauthor");
-    get(m_pAuthorBtn, "author");
-    get(m_pOKBtn, "ok");
-    get(m_pPrevBtn, "previous");
-    get(m_pNextBtn, "next");
-    get(m_pEditED, "edit");
-
-    m_pPrevBtn->SetClickHdl( LINK( this, SvxPostItDialog, PrevHdl ) );
-    m_pNextBtn->SetClickHdl( LINK( this, SvxPostItDialog, NextHdl ) );
-    m_pAuthorBtn->SetClickHdl( LINK( this, SvxPostItDialog, Stamp ) );
-    m_pOKBtn->SetClickHdl( LINK( this, SvxPostItDialog, OKHdl ) );
-
-    vcl::Font aFont( m_pEditED->GetFont() );
-    aFont.SetWeight( WEIGHT_LIGHT );
-    m_pEditED->SetFont( aFont );
+    m_xPrevBtn->connect_clicked( LINK( this, SvxPostItDialog, PrevHdl ) );
+    m_xNextBtn->connect_clicked( LINK( this, SvxPostItDialog, NextHdl ) );
+    m_xAuthorBtn->connect_clicked( LINK( this, SvxPostItDialog, Stamp ) );
+    m_xOKBtn->connect_clicked( LINK( this, SvxPostItDialog, OKHdl ) );
 
     bool bNew = true;
     sal_uInt16 nWhich = 0;
 
-    m_pPrevBtn->Show(bPrevNext);
-    m_pNextBtn->Show(bPrevNext);
+    m_xPrevBtn->show(bPrevNext);
+    m_xNextBtn->show(bPrevNext);
 
-    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
+    nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR );
     OUString aAuthorStr, aDateStr;
 
-    if ( rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
+    if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT)
     {
         bNew = false;
         const SvxPostItAuthorItem& rAuthor =
-            static_cast<const SvxPostItAuthorItem&>(rSet.Get( nWhich ));
+            static_cast<const SvxPostItAuthorItem&>(m_rSet.Get(nWhich));
         aAuthorStr = rAuthor.GetValue();
     }
     else
         aAuthorStr = SvtUserOptions().GetID();
 
-    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
+    nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE );
 
-    if ( rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
+    if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT)
     {
         const SvxPostItDateItem& rDate =
-            static_cast<const SvxPostItDateItem&>(rSet.Get( nWhich ));
+            static_cast<const SvxPostItDateItem&>(m_rSet.Get( nWhich ));
         aDateStr = rDate.GetValue();
     }
     else
@@ -88,56 +84,38 @@ SvxPostItDialog::SvxPostItDialog(vcl::Window* pParent, const SfxItemSet& rCoreSe
         aDateStr = rLocaleWrapper.getDate( Date( Date::SYSTEM ) );
     }
 
-    nWhich = rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
+    nWhich = m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT );
 
     OUString aTextStr;
-    if ( rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT )
+    if (m_rSet.GetItemState( nWhich ) >= SfxItemState::DEFAULT)
     {
         const SvxPostItTextItem& rText =
-            static_cast<const SvxPostItTextItem&>(rSet.Get( nWhich ));
+            static_cast<const SvxPostItTextItem&>(m_rSet.Get( nWhich ));
         aTextStr = rText.GetValue();
     }
 
     ShowLastAuthor(aAuthorStr, aDateStr);
 
     //lock to an initial size before replacing contents
-    m_pEditED->set_width_request(m_pEditED->approximate_char_width() * 40);
-    m_pEditED->set_height_request(m_pEditED->GetTextHeight() * 10);
-
-    m_pEditED->SetText(convertLineEnd(aTextStr, GetSystemLineEnd()));
+    m_xEditED->set_size_request(m_xEditED->get_approximate_digit_width() * 32,
+                                m_xEditED->get_height_rows(10));
+    m_xEditED->set_text(convertLineEnd(aTextStr, GetSystemLineEnd()));
 
     if (!bNew)
-        SetText( get<FixedText>("alttitle")->GetText() );
+        m_xDialog->set_title(m_xAltTitle->get_label());
 }
 
 
 SvxPostItDialog::~SvxPostItDialog()
 {
-    disposeOnce();
 }
 
-void SvxPostItDialog::dispose()
-{
-    delete pOutSet;
-    pOutSet = nullptr;
-    m_pLastEditFT.clear();
-    m_pEditED.clear();
-    m_pInsertAuthor.clear();
-    m_pAuthorBtn.clear();
-    m_pOKBtn.clear();
-    m_pPrevBtn.clear();
-    m_pNextBtn.clear();
-    SfxModalDialog::dispose();
-}
-
-
 void SvxPostItDialog::ShowLastAuthor(const OUString& rAuthor, const OUString& rDate)
 {
     OUString sTxt = rAuthor + ", " + rDate;
-    m_pLastEditFT->SetText( sTxt );
+    m_xLastEditFT->set_label( sTxt );
 }
 
-
 const sal_uInt16* SvxPostItDialog::GetRanges()
 {
     static const sal_uInt16 pRanges[] =
@@ -149,31 +127,29 @@ const sal_uInt16* SvxPostItDialog::GetRanges()
     return pRanges;
 }
 
-
 void SvxPostItDialog::EnableTravel(bool bNext, bool bPrev)
 {
-    m_pPrevBtn->Enable(bPrev);
-    m_pNextBtn->Enable(bNext);
+    m_xPrevBtn->set_sensitive(bPrev);
+    m_xNextBtn->set_sensitive(bNext);
 }
 
-
-IMPL_LINK_NOARG(SvxPostItDialog, PrevHdl, Button*, void)
+IMPL_LINK_NOARG(SvxPostItDialog, PrevHdl, weld::Button&, void)
 {
-    aPrevHdlLink.Call( *this );
+    m_aPrevHdlLink.Call( *this );
 }
 
-IMPL_LINK_NOARG(SvxPostItDialog, NextHdl, Button*, void)
+IMPL_LINK_NOARG(SvxPostItDialog, NextHdl, weld::Button&, void)
 {
-    aNextHdlLink.Call( *this );
+    m_aNextHdlLink.Call( *this );
 }
 
-IMPL_LINK_NOARG(SvxPostItDialog, Stamp, Button*, void)
+IMPL_LINK_NOARG(SvxPostItDialog, Stamp, weld::Button&, void)
 {
     Date aDate( Date::SYSTEM );
     tools::Time aTime( tools::Time::SYSTEM );
     OUString aTmp( SvtUserOptions().GetID() );
     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
-    OUString aStr( m_pEditED->GetText() );
+    OUString aStr( m_xEditED->get_text() );
     aStr += "\n---- ";
 
     if ( !aTmp.isEmpty() )
@@ -183,24 +159,23 @@ IMPL_LINK_NOARG(SvxPostItDialog, Stamp, Button*, void)
     aStr += rLocaleWrapper.getDate(aDate) + ", " + rLocaleWrapper.getTime(aTime, false) + " ----\n";
     aStr = convertLineEnd(aStr, GetSystemLineEnd());
 
-    m_pEditED->SetText(aStr);
+    m_xEditED->set_text(aStr);
     sal_Int32 nLen = aStr.getLength();
-    m_pEditED->GrabFocus();
-    m_pEditED->SetSelection( Selection( nLen, nLen ) );
+    m_xEditED->grab_focus();
+    m_xEditED->select_region(nLen, nLen);
 }
 
-
-IMPL_LINK_NOARG(SvxPostItDialog, OKHdl, Button*, void)
+IMPL_LINK_NOARG(SvxPostItDialog, OKHdl, weld::Button&, void)
 {
     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
-    pOutSet = new SfxItemSet( rSet );
-    pOutSet->Put( SvxPostItAuthorItem( SvtUserOptions().GetID(),
-                                         rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
-    pOutSet->Put( SvxPostItDateItem( rLocaleWrapper.getDate( Date( Date::SYSTEM ) ),
-                                     rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
-    pOutSet->Put( SvxPostItTextItem( m_pEditED->GetText(),
-                                     rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
-    EndDialog( RET_OK );
+    m_xOutSet.reset(new SfxItemSet(m_rSet));
+    m_xOutSet->Put( SvxPostItAuthorItem(SvtUserOptions().GetID(),
+                                        m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_AUTHOR ) ) );
+    m_xOutSet->Put( SvxPostItDateItem(rLocaleWrapper.getDate( Date( Date::SYSTEM ) ),
+                                       m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_DATE ) ) );
+    m_xOutSet->Put( SvxPostItTextItem(m_xEditED->get_text(),
+                                      m_rSet.GetPool()->GetWhich( SID_ATTR_POSTIT_TEXT ) ) );
+    m_xDialog->response(RET_OK);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 590c16867805..dc7ecab87fb5 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -171,7 +171,11 @@ short AbstractInsertObjectDialog_Impl::Execute()
 
 IMPL_ABSTDLG_BASE(AbstractLinksDialog_Impl);
 IMPL_ABSTDLG_BASE(AbstractSpellDialog_Impl);
-IMPL_ABSTDLG_BASE(AbstractSvxPostItDialog_Impl);
+
+short AbstractSvxPostItDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 
 short AbstractPasswordToOpenModifyDialog_Impl::Execute()
 {
@@ -783,63 +787,75 @@ void AbstractSvxAreaTabDialog_Impl::SetText( const OUString& rStr )
 
 void AbstractSvxPostItDialog_Impl::SetText( const OUString& rStr )
 {
-    pDlg->SetText( rStr );
+    m_xDlg->set_title(rStr);
 }
+
 const SfxItemSet* AbstractSvxPostItDialog_Impl::GetOutputItemSet() const
 {
-    return pDlg->GetOutputItemSet();
+    return m_xDlg->GetOutputItemSet();
 }
+
 void AbstractSvxPostItDialog_Impl::EnableTravel(bool bNext, bool bPrev)
 {
-    pDlg->EnableTravel( bNext, bPrev );
+    m_xDlg->EnableTravel( bNext, bPrev );
 }
+
 OUString AbstractSvxPostItDialog_Impl::GetNote()
 {
-    return pDlg->GetNote();
+    return m_xDlg->GetNote();
 }
+
 void AbstractSvxPostItDialog_Impl::SetNote(const OUString& rTxt)
 {
-    pDlg->SetNote( rTxt );
+    m_xDlg->SetNote( rTxt );
 }
+
 void AbstractSvxPostItDialog_Impl::ShowLastAuthor(const OUString& rAuthor, const OUString& rDate)
 {
-    pDlg->ShowLastAuthor( rAuthor, rDate );
+    m_xDlg->ShowLastAuthor( rAuthor, rDate );
 }
+
 void AbstractSvxPostItDialog_Impl::DontChangeAuthor()
 {
-    pDlg->DontChangeAuthor();
+    m_xDlg->DontChangeAuthor();
 }
+
 void AbstractSvxPostItDialog_Impl::HideAuthor()
 {
-    pDlg->HideAuthor();
+    m_xDlg->HideAuthor();
 }
+
 void AbstractSvxPostItDialog_Impl::SetNextHdl( const Link<AbstractSvxPostItDialog&,void>& rLink )
 {
     aNextHdl = rLink;
     if( rLink.IsSet() )
-        pDlg->SetNextHdl( LINK(this, AbstractSvxPostItDialog_Impl, NextHdl ) );
+        m_xDlg->SetNextHdl( LINK(this, AbstractSvxPostItDialog_Impl, NextHdl ) );
     else
-        pDlg->SetNextHdl( Link<SvxPostItDialog&,void>() );
+        m_xDlg->SetNextHdl( Link<SvxPostItDialog&,void>() );
 }
+
 void AbstractSvxPostItDialog_Impl::SetPrevHdl( const Link<AbstractSvxPostItDialog&,void>& rLink )
 {
     aPrevHdl = rLink;
     if( rLink.IsSet() )
-        pDlg->SetPrevHdl( LINK(this, AbstractSvxPostItDialog_Impl, PrevHdl ) );
+        m_xDlg->SetPrevHdl( LINK(this, AbstractSvxPostItDialog_Impl, PrevHdl ) );
     else
-        pDlg->SetPrevHdl( Link<SvxPostItDialog&,void>() );
+        m_xDlg->SetPrevHdl( Link<SvxPostItDialog&,void>() );
 }
+
 IMPL_LINK_NOARG(AbstractSvxPostItDialog_Impl, NextHdl, SvxPostItDialog&, void)
 {
     aNextHdl.Call(*this);
 }
+
 IMPL_LINK_NOARG(AbstractSvxPostItDialog_Impl, PrevHdl, SvxPostItDialog&, void)
 {
     aPrevHdl.Call(*this);
 }
-vcl::Window * AbstractSvxPostItDialog_Impl::GetWindow()
+
+std::shared_ptr<weld::Dialog> AbstractSvxPostItDialog_Impl::GetDialog()
 {
-    return static_cast<vcl::Window *>(pDlg);
+    return m_xDlg->GetDialog();
 }
 
 OUString AbstractPasswordToOpenModifyDialog_Impl::GetPasswordToOpen() const
@@ -1308,12 +1324,11 @@ VclPtr<SfxAbstractDialog> AbstractDialogFactory_Impl::CreateSfxDialog( vcl::Wind
     return nullptr;
 }
 
-VclPtr<AbstractSvxPostItDialog> AbstractDialogFactory_Impl::CreateSvxPostItDialog( vcl::Window* pParent,
+VclPtr<AbstractSvxPostItDialog> AbstractDialogFactory_Impl::CreateSvxPostItDialog( weld::Window* pParent,
                                                                         const SfxItemSet& rCoreSet,
                                                                         bool bPrevNext )
 {
-    VclPtrInstance<SvxPostItDialog> pDlg( pParent, rCoreSet, bPrevNext );
-    return VclPtr<AbstractSvxPostItDialog_Impl>::Create( pDlg );
+    return VclPtr<AbstractSvxPostItDialog_Impl>::Create(new SvxPostItDialog(pParent, rCoreSet, bPrevNext));
 }
 
 class SvxMacroAssignDialog : public VclAbstractDialog
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 940a0b2ae580..923d74d1e55e 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -477,18 +477,25 @@ public:
 class SvxPostItDialog;
 class AbstractSvxPostItDialog_Impl :public AbstractSvxPostItDialog
 {
-    DECL_ABSTDLG_BASE( AbstractSvxPostItDialog_Impl, SvxPostItDialog )
+private:
+    std::unique_ptr<SvxPostItDialog> m_xDlg;
+public:
+    AbstractSvxPostItDialog_Impl(SvxPostItDialog* pDlg)
+        : m_xDlg(pDlg)
+    {
+    }
+    virtual short               Execute() override;
     virtual void                SetText( const OUString& rStr ) override;  //From class Window
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual void                SetPrevHdl( const Link<AbstractSvxPostItDialog&,void>& rLink ) override ;
-    virtual void                SetNextHdl( const Link<AbstractSvxPostItDialog&,void>& rLink ) override ;
-    virtual void                EnableTravel(bool bNext, bool bPrev) override ;
-    virtual OUString            GetNote() override ;
-    virtual void                SetNote(const OUString& rTxt) override ;
-    virtual void                ShowLastAuthor(const OUString& rAuthor, const OUString& rDate) override ;
-    virtual void                DontChangeAuthor() override ;
-    virtual void                HideAuthor() override ;
-    virtual vcl::Window *       GetWindow() override;
+    virtual void                SetPrevHdl( const Link<AbstractSvxPostItDialog&,void>& rLink ) override;
+    virtual void                SetNextHdl( const Link<AbstractSvxPostItDialog&,void>& rLink ) override;
+    virtual void                EnableTravel(bool bNext, bool bPrev) override;
+    virtual OUString            GetNote() override;
+    virtual void                SetNote(const OUString& rTxt) override;
+    virtual void                ShowLastAuthor(const OUString& rAuthor, const OUString& rDate) override;
+    virtual void                DontChangeAuthor() override;
+    virtual void                HideAuthor() override;
+    virtual std::shared_ptr<weld::Dialog> GetDialog() override;
 private:
     Link<AbstractSvxPostItDialog&,void> aNextHdl;
     Link<AbstractSvxPostItDialog&,void> aPrevHdl;
@@ -698,7 +705,7 @@ public:
                                                                  SdrModel* pModel,
                                                                  const SdrObject* pObj,
                                                                  bool bHasObj ) override;
-    virtual VclPtr<AbstractSvxPostItDialog>        CreateSvxPostItDialog( vcl::Window* pParent,
+    virtual VclPtr<AbstractSvxPostItDialog>        CreateSvxPostItDialog( weld::Window* pParent,
                                                                         const SfxItemSet& rCoreSet,
                                                                         bool bPrevNext = false ) override;
 
diff --git a/cui/source/inc/postdlg.hxx b/cui/source/inc/postdlg.hxx
index 9c33e4ab9dd6..0434f19b1f9d 100644
--- a/cui/source/inc/postdlg.hxx
+++ b/cui/source/inc/postdlg.hxx
@@ -19,12 +19,7 @@
 #ifndef INCLUDED_CUI_SOURCE_INC_POSTDLG_HXX
 #define INCLUDED_CUI_SOURCE_INC_POSTDLG_HXX
 
-#include <vcl/button.hxx>
-#include <vcl/edit.hxx>
-#include <vcl/group.hxx>
-#include <vcl/layout.hxx>
-#include <sfx2/basedlgs.hxx>
-#include <svtools/svmedit.hxx>
+#include <vcl/weld.hxx>
 
 // class SvxPostItDialog -------------------------------------------------
 /*
@@ -39,64 +34,68 @@
     <SvxPostItTextItem><SID_ATTR_POSTIT_TEXT>
 */
 
-class SvxPostItDialog : public SfxModalDialog
+class SvxPostItDialog : public weld::GenericDialogController
 {
 public:
-    SvxPostItDialog(vcl::Window* pParent, const SfxItemSet& rCoreSet,
+    SvxPostItDialog(weld::Window* pParent, const SfxItemSet& rCoreSet,
                      bool bPrevNext);
     virtual ~SvxPostItDialog() override;
-    virtual void dispose() override;
 
     static const sal_uInt16*      GetRanges();
-    const SfxItemSet*   GetOutputItemSet() const { return pOutSet; }
+    const SfxItemSet*   GetOutputItemSet() { return m_xOutSet.get(); }
 
     void                SetPrevHdl( const Link<SvxPostItDialog&,void>& rLink )
-                            { aPrevHdlLink = rLink; }
+                            { m_aPrevHdlLink = rLink; }
     void                SetNextHdl( const Link<SvxPostItDialog&,void>& rLink )
-                            { aNextHdlLink = rLink; }
+                            { m_aNextHdlLink = rLink; }
 
     void EnableTravel(bool bNext, bool bPrev);
-    OUString GetNote()
+    OUString GetNote() const
     {
-        return m_pEditED->GetText();
+        return m_xEditED->get_text();
     }
     void SetNote(const OUString& rTxt)
     {
-        m_pEditED->SetText(rTxt);
+        m_xEditED->set_text(rTxt);
     }
     void ShowLastAuthor(const OUString& rAuthor, const OUString& rDate);
     void DontChangeAuthor()
     {
-        m_pAuthorBtn->Enable(false);
+        m_xAuthorBtn->set_sensitive(false);
     }
     void HideAuthor()
     {
-        m_pInsertAuthor->Hide();
+        m_xInsertAuthor->hide();
+    }
+    void set_title(const OUString& rTitle)
+    {
+        m_xDialog->set_title(rTitle);
+    }
+    std::shared_ptr<weld::Dialog> GetDialog()
+    {
+        return m_xDialog;
     }
 
 private:
-    VclPtr<FixedText>          m_pLastEditFT;
-
-    VclPtr<VclMultiLineEdit>   m_pEditED;
-
-    VclPtr<VclContainer>       m_pInsertAuthor;
-    VclPtr<PushButton>         m_pAuthorBtn;
-
-    VclPtr<OKButton>           m_pOKBtn;
-
-    VclPtr<PushButton>         m_pPrevBtn;
-    VclPtr<PushButton>         m_pNextBtn;
-
-    const SfxItemSet&   rSet;
-    SfxItemSet*         pOutSet;
-
-    Link<SvxPostItDialog&,void>  aPrevHdlLink;
-    Link<SvxPostItDialog&,void>  aNextHdlLink;
-
-    DECL_LINK(Stamp, Button*, void);
-    DECL_LINK(OKHdl, Button*, void);
-    DECL_LINK(PrevHdl, Button*, void);
-    DECL_LINK(NextHdl, Button*, void);
+    const SfxItemSet&   m_rSet;
+    std::unique_ptr<SfxItemSet>     m_xOutSet;
+
+    Link<SvxPostItDialog&,void>  m_aPrevHdlLink;
+    Link<SvxPostItDialog&,void>  m_aNextHdlLink;
+
+    std::unique_ptr<weld::Label>    m_xLastEditFT;
+    std::unique_ptr<weld::Label>    m_xAltTitle;
+    std::unique_ptr<weld::TextView> m_xEditED;
+    std::unique_ptr<weld::Widget>   m_xInsertAuthor;
+    std::unique_ptr<weld::Button>   m_xAuthorBtn;
+    std::unique_ptr<weld::Button>   m_xOKBtn;
+    std::unique_ptr<weld::Button>   m_xPrevBtn;
+    std::unique_ptr<weld::Button>   m_xNextBtn;
+
+    DECL_LINK(Stamp, weld::Button&, void);
+    DECL_LINK(OKHdl, weld::Button&, void);
+    DECL_LINK(PrevHdl, weld::Button&, void);
+    DECL_LINK(NextHdl, weld::Button&, void);
 };
 
 #endif
diff --git a/cui/uiconfig/ui/comment.ui b/cui/uiconfig/ui/comment.ui
index 17c2f80bb763..20d2c5d1b7e7 100644
--- a/cui/uiconfig/ui/comment.ui
+++ b/cui/uiconfig/ui/comment.ui
@@ -1,20 +1,34 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
 <interface domain="cui">
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkImage" id="image2">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-go-back</property>
+  </object>
+  <object class="GtkImage" id="image3">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="stock">gtk-go-forward</property>
+  </object>
   <object class="GtkDialog" id="CommentDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="comment|CommentDialog">Insert Comment</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">
         <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>
@@ -59,6 +73,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
@@ -82,8 +97,6 @@
                   <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>
@@ -98,8 +111,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,8 +160,8 @@
                           <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="comment|label2">Author</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -181,10 +192,10 @@
                       <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
                         <property name="label" translatable="yes" context="comment|label4">_Text</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">edit:border</property>
+                        <property name="mnemonic_widget">edit</property>
+                        <property name="xalign">0</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -200,7 +211,7 @@
                         <property name="vexpand">True</property>
                         <property name="shadow_type">in</property>
                         <child>
-                          <object class="GtkTextView" id="edit:border">
+                          <object class="GtkTextView" id="edit">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="hexpand">True</property>
@@ -210,7 +221,7 @@
                         </child>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
+                        <property name="expand">True</property>
                         <property name="fill">True</property>
                         <property name="position">2</property>
                       </packing>
@@ -224,16 +235,14 @@
                           <object class="GtkLabel" id="label5">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
                             <property name="label" translatable="yes" context="comment|label5">_Insert</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">author</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>
@@ -246,8 +255,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>
@@ -297,15 +304,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
-  </object>
-  <object class="GtkImage" id="image2">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="stock">gtk-go-back</property>
-  </object>
-  <object class="GtkImage" id="image3">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="stock">gtk-go-forward</property>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 511677c923ba..9603739f8807 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -60,7 +60,10 @@ typedef const sal_uInt16*  (*DialogGetRanges)();
 typedef ::std::vector< OUString > TargetList;
 
 namespace svx{ class SpellDialogChildWindow;}
-namespace weld{ class Window; }
+namespace weld{
+    class Dialog;
+    class Window;
+}
 
 class AbstractSvxDistributeDialog :public VclAbstractDialog
 {
@@ -279,7 +282,7 @@ public:
     virtual void SetValidateFramePosLink( const Link<SvxSwFrameValidation&,void>& rLink ) = 0;
 };
 
-class AbstractSvxPostItDialog :public VclAbstractDialog
+class AbstractSvxPostItDialog : public VclAbstractDialog
 {
 protected:
     virtual ~AbstractSvxPostItDialog() override = default;
@@ -294,7 +297,7 @@ public:
     virtual void                ShowLastAuthor(const OUString& rAuthor, const OUString& rDate) = 0;
     virtual void                DontChangeAuthor() = 0;
     virtual void                HideAuthor() = 0;
-    virtual vcl::Window *            GetWindow() = 0;
+    virtual std::shared_ptr<weld::Dialog> GetDialog() = 0;
 };
 
 class SvxAbstractSplitTableDialog : public VclAbstractDialog
@@ -441,9 +444,7 @@ public:
     virtual VclPtr<SfxAbstractDialog>       CreateEventConfigDialog( vcl::Window* pParent,
                                                                         const SfxItemSet& rAttr,
                                     const css::uno::Reference< css::frame::XFrame >& _rxFrame )=0;
-    virtual VclPtr<AbstractSvxPostItDialog>    CreateSvxPostItDialog( vcl::Window* pParent,
-                                                                        const SfxItemSet& rCoreSet,
-                                                                        bool bPrevNext = false) = 0;
+    virtual VclPtr<AbstractSvxPostItDialog>    CreateSvxPostItDialog(weld::Window* pParent, const SfxItemSet& rCoreSet, bool bPrevNext = false) = 0;
     virtual VclPtr<VclAbstractDialog>          CreateSvxScriptOrgDialog( vcl::Window* pParent, const OUString& rLanguage ) override = 0;
 
     virtual DialogGetRanges                    GetDialogGetRangesFunc() = 0;
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 97bea2941fac..52585c65b506 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -143,6 +143,8 @@ public:
     virtual OUString get_title() const = 0;
     virtual void set_busy_cursor(bool bBusy) = 0;
     virtual void window_move(int x, int y) = 0;
+    virtual bool get_extents_relative_to(Window& rRelative, int& x, int& y, int& width, int& height)
+        = 0;
 
     virtual css::uno::Reference<css::awt::XWindow> GetXWindow() = 0;
 
@@ -606,9 +608,14 @@ class VCL_DLLPUBLIC TextView : virtual public Container
 public:
     virtual void set_text(const OUString& rText) = 0;
     virtual OUString get_text() const = 0;
-    virtual Selection get_selection() const = 0;
-    virtual void set_selection(const Selection&) = 0;
+    virtual void select_region(int nStartPos, int nEndPos) = 0;
+    virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
     virtual void set_editable(bool bEditable) = 0;
+    int get_height_rows(int nRows) const
+    {
+        //can improve this if needed
+        return get_text_height() * nRows;
+    }
 };
 
 class VCL_DLLPUBLIC Expander : virtual public Container
@@ -745,7 +752,7 @@ private:
 
 protected:
     std::unique_ptr<weld::Builder> m_xBuilder;
-    std::unique_ptr<weld::Dialog> m_xDialog;
+    std::shared_ptr<weld::Dialog> m_xDialog;
 
 public:
     GenericDialogController(weld::Widget* pParent, const OUString& rUIFile,
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index e59bf0ea2d3c..4ec58646fc21 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -630,7 +630,7 @@ void ScDocShell::SetChangeComment( ScChangeAction* pAction, const OUString& rCom
     }
 }
 
-void ScDocShell::ExecuteChangeCommentDialog( ScChangeAction* pAction, vcl::Window* pParent, bool bPrevNext)
+void ScDocShell::ExecuteChangeCommentDialog( ScChangeAction* pAction, weld::Window* pParent, bool bPrevNext)
 {
     if (!pAction) return;           // without action is nothing..
 
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 8b53fa802fed..bad57292ce9e 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -237,7 +237,7 @@ public:
 
     ScChangeAction* GetChangeAction( const ScAddress& rPos );
     void            SetChangeComment( ScChangeAction* pAction, const OUString& rComment );
-    void            ExecuteChangeCommentDialog( ScChangeAction* pAction, vcl::Window* pParent, bool bPrevNext = true );
+    void            ExecuteChangeCommentDialog( ScChangeAction* pAction, weld::Window* pParent, bool bPrevNext = true );
                     /// Protect/unprotect ChangeTrack and return <TRUE/> if
                     /// protection was successfully changed.
                     /// If bJustQueryIfProtected==sal_True protection is not
diff --git a/sc/source/ui/inc/redcom.hxx b/sc/source/ui/inc/redcom.hxx
index 622ac2ea7e02..245e25915851 100644
--- a/sc/source/ui/inc/redcom.hxx
+++ b/sc/source/ui/inc/redcom.hxx
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_SC_SOURCE_UI_INC_REDCOM_HXX
 #define INCLUDED_SC_SOURCE_UI_INC_REDCOM_HXX
 
-#include <vcl/dialog.hxx>
+#include <vcl/weld.hxx>
 #include <chgtrack.hxx>
 
 class ScDocShell;
@@ -44,7 +44,7 @@ class ScRedComDialog final
 
 public:
 
-    ScRedComDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet,
+    ScRedComDialog( weld::Window* pParent, const SfxItemSet& rCoreSet,
                     ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext);
     ~ScRedComDialog();
 
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 03f89b69f955..b40d198397fa 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -1692,7 +1692,7 @@ IMPL_LINK_NOARG(ScAcceptChgDlg, CommandHdl, SvSimpleTable*, void)
                         ScChangeAction* pScChangeAction=
                                 static_cast<ScChangeAction*>(pEntryData->pData);
 
-                        pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,false);
+                        pViewData->GetDocShell()->ExecuteChangeCommentDialog(pScChangeAction, GetFrameWeld(), false);
                     }
                 }
             }
diff --git a/sc/source/ui/miscdlgs/redcom.cxx b/sc/source/ui/miscdlgs/redcom.cxx
index 45c90f0f9680..9753c2e8306d 100644
--- a/sc/source/ui/miscdlgs/redcom.cxx
+++ b/sc/source/ui/miscdlgs/redcom.cxx
@@ -25,7 +25,7 @@
 #include <svx/svxdlg.hxx>
 #include <svx/dialogs.hrc>
 
-ScRedComDialog::ScRedComDialog( vcl::Window* pParent, const SfxItemSet& rCoreSet,
+ScRedComDialog::ScRedComDialog( weld::Window* pParent, const SfxItemSet& rCoreSet,
                     ScDocShell *pShell, ScChangeAction *pAction, bool bPrevNext)
     : pChangeAction(nullptr)
     , pDocShell(nullptr)
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index a31a91fc538d..5c4d1b0bbdb2 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1016,7 +1016,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                     }
                     else
                     {
-                        pDocSh->ExecuteChangeCommentDialog( pAction, GetDialogParent() );
+                        pDocSh->ExecuteChangeCommentDialog(pAction, GetFrameWeld());
                         rReq.Done();
                     }
                 }
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index c7931d76f8be..f8b37a622301 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -28,6 +28,7 @@
 #include <vcl/mapmod.hxx>
 #include <vcl/vclptr.hxx>
 #include <vcl/lazydelete.hxx>
+#include <vcl/weld.hxx>
 
 namespace com { namespace sun { namespace star { namespace accessibility {
            class XAccessible; } } } }
@@ -168,6 +169,7 @@ class SW_DLLPUBLIC SwViewShell : public sw::Ring<SwViewShell>
 protected:
     static ShellResource*      mpShellRes;      ///< Resources for the Shell.
     static vcl::DeleteOnDeinit< VclPtr<vcl::Window> > mpCareWindow;    ///< Avoid this window.
+    static vcl::DeleteOnDeinit< std::shared_ptr<weld::Dialog> > mpCareDialog;    ///< Avoid this window.
 
     SwRect                  maVisArea;       ///< The modern version of VisArea.
     rtl::Reference<SwDoc>   mxDoc;          ///< The document; never 0.
@@ -429,6 +431,9 @@ public:
     static vcl::Window*   GetCareWin(SwViewShell const & rVSh)
                           { return (*mpCareWindow.get()) ? mpCareWindow.get()->get() : CareChildWin(rVSh); }
     static vcl::Window*   CareChildWin(SwViewShell const & rVSh);
+    static void           SetCareDialog(const std::shared_ptr<weld::Dialog>& rNew);
+    static weld::Dialog*  GetCareDialog()
+                          { return (*mpCareDialog.get()) ? mpCareDialog.get()->get() : nullptr; }
 
     SfxViewShell   *GetSfxViewShell() const { return mpSfxViewShell; }
     void           SetSfxViewShell(SfxViewShell *pNew) { mpSfxViewShell = pNew; }
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 7c536e86117f..609afdfa7170 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -91,6 +91,7 @@
 bool SwViewShell::mbLstAct = false;
 ShellResource *SwViewShell::mpShellRes = nullptr;
 vcl::DeleteOnDeinit< VclPtr<vcl::Window> > SwViewShell::mpCareWindow(new VclPtr<vcl::Window>);
+vcl::DeleteOnDeinit<std::shared_ptr<weld::Dialog>> SwViewShell::mpCareDialog(new std::shared_ptr<weld::Dialog>);
 
 static bool bInSizeNotify = false;
 
@@ -566,7 +567,7 @@ const SwRect& SwViewShell::VisArea() const
 
 void SwViewShell::MakeVisible( const SwRect &rRect )
 {
-    if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) )
+    if ( !VisArea().IsInside( rRect ) || IsScrollMDI( this, rRect ) || GetCareWin(*this) || GetCareDialog() )
     {
         if ( !IsViewLocked() )
         {
@@ -2468,6 +2469,11 @@ void SwViewShell::SetCareWin( vcl::Window* pNew )
     (*mpCareWindow.get()) = pNew;
 }
 
+void SwViewShell::SetCareDialog(const std::shared_ptr<weld::Dialog>& rNew)
+{
+    (*mpCareDialog.get()) = rNew;
+}
+
 sal_uInt16 SwViewShell::GetPageCount() const
 {
     return GetLayout() ? GetLayout()->GetPageNum() : 1;
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index 6d1c67493655..29747e913a49 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -1088,7 +1088,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl, SvSimpleTable*, void)
                         rRedline.GetRedlineData().GetTimeStamp() ),
                         SID_ATTR_POSTIT_DATE ));
 
-            ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact->CreateSvxPostItDialog( m_pParentDlg, aSet ));
+            ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact->CreateSvxPostItDialog(m_pParentDlg->GetFrameWeld(), aSet));
             OSL_ENSURE(pDlg, "Dialog creation failed!");
 
             pDlg->HideAuthor();
@@ -1116,7 +1116,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl, SvSimpleTable*, void)
                 sTitle += SwResId(pResId);
             pDlg->SetText(sTitle);
 
-            SwViewShell::SetCareWin(pDlg->GetWindow());
+            SwViewShell::SetCareDialog(pDlg->GetDialog());
 
             if ( pDlg->Execute() == RET_OK )
             {
@@ -1129,7 +1129,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl, SvSimpleTable*, void)
             }
 
             pDlg.disposeAndClear();
-            SwViewShell::SetCareWin(nullptr);
+            SwViewShell::SetCareDialog(nullptr);
         }
     }
     else if (nRet)
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index e65646e48443..bb2131fcc500 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -592,7 +592,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
 
                     SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create();
                     assert(pFact2 && "Dialog creation failed!");
-                    ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact2->CreateSvxPostItDialog( pMDI, aSet, bTravel ));
+                    ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact2->CreateSvxPostItDialog(pMDI->GetFrameWeld(), aSet, bTravel));
                     assert(pDlg && "Dialog creation failed!");
                     pDlg->HideAuthor();
 
@@ -605,7 +605,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
                         pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl));
                     }
 
-                    SwViewShell::SetCareWin(pDlg->GetWindow());
+                    SwViewShell::SetCareDialog(pDlg->GetDialog());
                     g_bNoInterrupt = true;
 
                     if ( pDlg->Execute() == RET_OK )
diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx
index dba6610de692..affe271e5e6f 100644
--- a/sw/source/uibase/uiview/viewport.cxx
+++ b/sw/source/uibase/uiview/viewport.cxx
@@ -401,10 +401,22 @@ void SwView::Scroll( const tools::Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt
     long nDiffY = 0;
 
     vcl::Window* pCareWn = SwViewShell::GetCareWin(GetWrtShell());
-    if ( pCareWn )
+    weld::Dialog* pCareDialog = SwViewShell::GetCareDialog();
+    if (pCareWn || pCareDialog)
     {
-        tools::Rectangle aDlgRect( GetEditWin().PixelToLogic(
-                pCareWn->GetWindowExtentsRelative( &GetEditWin() ) ) );
+        int x, y, width, height;
+        tools::Rectangle aDlgRect;
+        if (pCareWn)
+        {
+            aDlgRect = GetEditWin().PixelToLogic(pCareWn->GetWindowExtentsRelative(&GetEditWin()));
+        }
+        else if (pCareDialog && pCareDialog->get_extents_relative_to(*GetEditWin().GetFrameWeld(), x, y, width, height))
+        {
+            Point aTopLeft(GetEditWin().GetSystemWindow()->OutputToAbsoluteScreenPixel(Point(x, y)));
+            aTopLeft = GetEditWin().AbsoluteScreenToOutputPixel(aTopLeft);
+            aDlgRect = GetEditWin().PixelToLogic(tools::Rectangle(aTopLeft, Size(width, height)));
+        }
+
         // Only if the dialogue is not the VisArea right or left:
         if ( aDlgRect.Left() < m_aVisArea.Right() &&
              aDlgRect.Right() > m_aVisArea.Left() )
@@ -505,7 +517,7 @@ void SwView::Scroll( const tools::Rectangle &rRect, sal_uInt16 nRangeX, sal_uInt
         aPnt.setX( std::max( (GetLeftMargin( *this ) - lMin) + nLeftOfst, aPnt.X() ) );
     }
     m_aVisArea = aOldVisArea;
-    if( pCareWn )
+    if (pCareWn || pCareDialog)
     {   // If we want to avoid only a dialogue, we do
         // not want to go beyond the end of the document.
         aPnt.setY( SetVScrollMax( aPnt.Y() ) );
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 56da3de4c49b..d06590dace91 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -528,6 +528,21 @@ public:
         m_xWindow->SetPosPixel(Point(x, y));
     }
 
+    SystemWindow* getWindow()
+    {
+        return m_xWindow.get();
+    }
+
+    virtual bool get_extents_relative_to(Window& rRelative, int& x, int &y, int& width, int &height) override
+    {
+        tools::Rectangle aRect(m_xWindow->GetWindowExtentsRelative(dynamic_cast<SalInstanceWindow&>(rRelative).getWindow()));
+        x = aRect.Left();
+        y = aRect.Top();
+        width = aRect.GetWidth();
+        height = aRect.GetHeight();
+        return true;
+    }
+
     virtual ~SalInstanceWindow() override
     {
         clear_child_help(m_xWindow);
@@ -1373,14 +1388,17 @@ public:
         return m_xTextView->GetText();
     }
 
-    virtual Selection get_selection() const override
+    bool get_selection_bounds(int& rStartPos, int &rEndPos) override
     {
-        return m_xTextView->GetSelection();
+        const Selection& rSelection = m_xTextView->GetSelection();
+        rStartPos = rSelection.Min();
+        rEndPos = rSelection.Max();
+        return rSelection.Len();
     }
 
-    virtual void set_selection(const Selection& rSelection) override
+    virtual void select_region(int nStartPos, int nEndPos) override
     {
-        m_xTextView->SetSelection(rSelection);
+        m_xTextView->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
     }
 
     virtual void set_editable(bool bEditable) override
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 9425d93fa63e..3eded538f3cb 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1700,6 +1700,16 @@ public:
         gtk_window_move(m_pWindow, x, y);
     }
 
+    virtual bool get_extents_relative_to(Window& rRelative, int& x, int &y, int& width, int &height) override
+    {
+        //this is sadly futile under wayland, so we can't tell where a dialog is in order to allow
+        //the document underneath to auto-scroll to place content in a visible location
+        gboolean ret = gtk_widget_translate_coordinates(dynamic_cast<GtkInstanceWindow&>(rRelative).getWidget(), m_pWidget, 0, 0, &x, &y);
+        width = gtk_widget_get_allocated_width(m_pWidget);
+        height = gtk_widget_get_allocated_height(m_pWidget);
+        return ret;
+    }
+
     virtual ~GtkInstanceWindow() override
     {
         if (m_xWindow.is())
@@ -3176,20 +3186,22 @@ public:
         return sRet;
     }
 
-    virtual Selection get_selection() const override
+    virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override
     {
         GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(m_pTextView);
         GtkTextIter start, end;
         gtk_text_buffer_get_selection_bounds(pBuffer, &start, &end);
-        return Selection(gtk_text_iter_get_offset(&start), gtk_text_iter_get_offset(&end));
+        rStartPos = gtk_text_iter_get_offset(&start);
+        rEndPos = gtk_text_iter_get_offset(&end);
+        return rStartPos != rEndPos;
     }
 
-    virtual void set_selection(const Selection& rSelection) override
+    virtual void select_region(int nStartPos, int nEndPos) override
     {
         GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(m_pTextView);
         GtkTextIter start, end;
-        gtk_text_buffer_get_iter_at_offset(pBuffer, &start, rSelection.Min());
-        gtk_text_buffer_get_iter_at_offset(pBuffer, &end, rSelection.Max());
+        gtk_text_buffer_get_iter_at_offset(pBuffer, &start, nStartPos);
+        gtk_text_buffer_get_iter_at_offset(pBuffer, &end, nEndPos);
         gtk_text_buffer_select_range(pBuffer, &start, &end);
         GtkTextMark* mark = gtk_text_buffer_create_mark(pBuffer, "scroll", &end, true);
         gtk_text_view_scroll_mark_onscreen(m_pTextView, mark);


More information about the Libreoffice-commits mailing list