weld SwEnvDlg

Change-Id: Ib92f790030ca6fbf64273cf45c710b2f698f45a4
Reviewed-on: https://gerrit.libreoffice.org/53569
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 4f99e12e..d3fda57 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -232,6 +232,7 @@ protected:
private:
    std::unique_ptr<weld::Button> m_xOKBtn;
    std::unique_ptr<weld::Button> m_xApplyBtn;
    std::unique_ptr<weld::Button> m_xUserBtn;
    std::unique_ptr<weld::Button> m_xCancelBtn;
    std::unique_ptr<weld::Button> m_xResetBtn;

@@ -245,6 +246,7 @@ private:
    DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);
    DECL_DLLPRIVATE_LINK(OkHdl, weld::Button&, void);
    DECL_DLLPRIVATE_LINK(ResetHdl, weld::Button&, void);
    DECL_DLLPRIVATE_LINK(UserHdl, weld::Button&, void);
    DECL_DLLPRIVATE_LINK(CancelHdl, weld::Button&, void);
    SAL_DLLPRIVATE void Init_Impl(bool bFmtFlag);

@@ -283,6 +285,9 @@ public:
    void                SetInputSet( const SfxItemSet* pInSet );
    const SfxItemSet*   GetOutputItemSet() const { return m_pOutSet.get(); }

    const weld::Button* GetUserButton() const { return m_xUserBtn.get(); }
    weld::Button*       GetUserButton() { return m_xUserBtn.get(); }

    short               execute();

    const SfxItemSet*   GetExampleSet() const { return m_pExampleSet; }
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index a39efbd..9fc3151 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1464,6 +1464,7 @@ SfxTabDialogController::SfxTabDialogController
    , m_xTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
    , m_xOKBtn(m_xBuilder->weld_button("ok"))
    , m_xApplyBtn(m_xBuilder->weld_button("apply"))
    , m_xUserBtn(m_xBuilder->weld_button("user"))
    , m_xCancelBtn(m_xBuilder->weld_button("cancel"))
    , m_xResetBtn(m_xBuilder->weld_button("reset"))
    , m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr)
@@ -1487,6 +1488,9 @@ void SfxTabDialogController::Init_Impl(bool /*bFmtFlag*/)
    m_xTabCtrl->connect_leave_page(LINK(this, SfxTabDialogController, DeactivatePageHdl));
    m_xResetBtn->set_help_id(HID_TABDLG_RESET_BTN);

    if (m_xUserBtn)
        m_xUserBtn->connect_clicked(LINK(this, SfxTabDialogController, UserHdl));

    if (m_pSet)
    {
        m_pExampleSet = new SfxItemSet(*m_pSet);
@@ -1509,6 +1513,28 @@ IMPL_LINK_NOARG(SfxTabDialogController, OkHdl, weld::Button&, void)
        m_xDialog->response(Ok());
}

IMPL_LINK_NOARG(SfxTabDialogController, UserHdl, weld::Button&, void)

/*  [Description]

    Handler of the User-Buttons
    This calls the current page <SfxTabPage::DeactivatePage(SfxItemSet *)>.
    returns this <DeactivateRC::LeavePage> and  <SfxTabDialog::Ok()> is called.
    Then the Dialog is ended with the Return value <SfxTabDialog::Ok()>
*/

{
    if (PrepareLeaveCurrentPage())
    {
        short nRet = Ok();
        if (RET_OK == nRet)
            nRet = RET_USER;
        else
            nRet = RET_USER_CANCEL;
        m_xDialog->response(nRet);
    }
}

IMPL_LINK_NOARG(SfxTabDialogController, CancelHdl, weld::Button&, void)
{
    m_xDialog->response(RET_USER_CANCEL);
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 552c3b7..4fb601d 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -388,7 +388,7 @@ public:

    virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh,
        SwField* pField, bool bPrevButton, bool bNextButton) = 0;
    virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) = 0;
    virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) = 0;

    virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
                                                     SwDBManager* pDBManager, bool bLabel) = 0;
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 3df60e9..a0b0d95 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -127,6 +127,10 @@ short AbstractMultiTOXMarkDlg_Impl::Execute()
{
    return m_xDlg->execute();
}
short AbstractTabController_Impl::Execute()
{
    return m_xDlg->execute();
}
IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl);
short AbstractSwConvertTableDlg_Impl::Execute()
{
@@ -212,6 +216,32 @@ void AbstractTabDialog_Impl::SetText( const OUString& rStr )
    pDlg->SetText( rStr );
}

void AbstractTabController_Impl::SetCurPageId( const OString &rName )
{
    m_xDlg->SetCurPageId( rName );
}

const SfxItemSet* AbstractTabController_Impl::GetOutputItemSet() const
{
    return m_xDlg->GetOutputItemSet();
}

const sal_uInt16* AbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
{
    return m_xDlg->GetInputRanges( pItem );
}

void AbstractTabController_Impl::SetInputSet( const SfxItemSet* pInSet )
{
     m_xDlg->SetInputSet( pInSet );
}

//From class Window.
void AbstractTabController_Impl::SetText( const OUString& rStr )
{
    m_xDlg->set_title(rStr);
}

IMPL_LINK_NOARG(AbstractApplyTabDialog_Impl, ApplyHdl, Button*, void)
{
    if (pDlg->Apply())
@@ -758,12 +788,11 @@ VclPtr<AbstractDropDownFieldDialog> SwAbstractDialogFactory_Impl::CreateDropDown
    return VclPtr<AbstractDropDownFieldDialog_Impl>::Create(new sw::DropDownFieldDialog(pParent, rSh, pField, bPrevButton, bNextButton));
}

VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet,
VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet,
                                                                 SwWrtShell* pWrtSh, Printer* pPrt,
                                                                 bool bInsert )
                                                                 bool bInsert)
{
    VclPtr<SfxTabDialog> pDlg = VclPtr<SwEnvDlg>::Create( pParent, rSet, pWrtSh,pPrt, bInsert  );
    return VclPtr<AbstractTabDialog_Impl>::Create( pDlg );
    return VclPtr<AbstractTabController_Impl>::Create(new SwEnvDlg(pParent, rSet, pWrtSh,pPrt, bInsert));
}

VclPtr<AbstractSwLabDlg> SwAbstractDialogFactory_Impl::CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 1be0a93..3afdec1 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -223,6 +223,24 @@ class AbstractTabDialog_Impl : virtual public SfxAbstractTabDialog
    virtual void        SetText( const OUString& rStr ) override;
};

class AbstractTabController_Impl : virtual public SfxAbstractTabDialog
{
protected:
    std::unique_ptr<SfxTabDialogController> m_xDlg;
public:
    explicit AbstractTabController_Impl(SfxTabDialogController* p)
        : m_xDlg(p)
    {
    }
    virtual short Execute() override;
    virtual void                SetCurPageId( const OString &rName ) override;
    virtual const SfxItemSet*   GetOutputItemSet() const override;
    virtual const sal_uInt16*   GetInputRanges( const SfxItemPool& pItem ) override;
    virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
        //From class Window.
    virtual void        SetText( const OUString& rStr ) override;
};

class AbstractApplyTabDialog_Impl : public AbstractTabDialog_Impl, virtual public SfxAbstractApplyTabDialog
{
public:
@@ -550,7 +568,7 @@ public:

    virtual VclPtr<AbstractDropDownFieldDialog> CreateDropDownFieldDialog(weld::Window* pParent, SwWrtShell &rSh,
        SwField* pField, bool bPrevButton, bool bNextButton) override;
    virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg ( vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert ) override;
    virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) override;
    virtual VclPtr<AbstractSwLabDlg> CreateSwLabDlg(weld::Window* pParent, const SfxItemSet& rSet,
                                                     SwDBManager* pDBManager, bool bLabel) override;

diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index a7aaaf4..4d26441 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -241,7 +241,7 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender)
        bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS));
    OSL_ENSURE(pColl, "Text collection missing");

    if (rIdent == "character")
    if (rIdent.startsWith("character"))
    {
        SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);

@@ -253,7 +253,8 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender)
        OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");

        const OUString sFormatStr = pColl->GetName();
        ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr));
        ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(nullptr /*TODO*/, pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr));
        //ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, SwCharDlgMode::Env, &sFormatStr));
        OSL_ENSURE(pDlg, "Dialog creation failed!");
        if (pDlg->Execute() == RET_OK)
        {
@@ -262,7 +263,7 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender)
            pCollSet->Put(aOutputSet);
        }
    }
    else if (rIdent == "paragraph")
    else if (rIdent.startsWith("paragraph"))
    {
        SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender);

@@ -290,7 +291,8 @@ void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender)
        ::PrepareBoxInfo( aTmpSet, *pSh );

        const OUString sFormatStr = pColl->GetName();
        VclPtrInstance< SwParaDlg > pDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr);
        VclPtrInstance< SwParaDlg > pDlg(nullptr /*TODO*/, pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr);
        //VclPtrInstance< SwParaDlg > pDlg(GetParentSwEnvDlg(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &sFormatStr);

        if ( pDlg->Execute() == RET_OK )
        {
diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx
index d5aec67..20d445f 100644
--- a/sw/source/ui/envelp/envfmt.hxx
+++ b/sw/source/ui/envelp/envfmt.hxx
@@ -26,7 +26,7 @@ class SwTextFormatColl;

class SwEnvFormatPage : public SfxTabPage
{
    VclPtr<SwEnvDlg> m_pDialog;
    SwEnvDlg* m_pDialog;
    std::vector<sal_uInt16>  m_aIDs;

    std::unique_ptr<weld::MetricSpinButton>  m_xAddrLeftField;
@@ -59,11 +59,6 @@ class SwEnvFormatPage : public SfxTabPage
public:
    SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet);
    void Init(SwEnvDlg* pDialog);
    virtual void dispose() override
    {
        m_pDialog.clear();
        SfxTabPage::dispose();
    }
    virtual ~SwEnvFormatPage() override;

    static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx
index 28926fb..e7ae5d3 100644
--- a/sw/source/ui/envelp/envlop1.cxx
+++ b/sw/source/ui/envelp/envlop1.cxx
@@ -63,8 +63,6 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
{
    vcl::RenderContext& rRenderContext = aPayload.first;

    //SetMapMode(MapMode(MapUnit::MapPixel));

    const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
    rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor());
    rRenderContext.Erase();
@@ -124,51 +122,43 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void)
    rRenderContext.DrawRect(tools::Rectangle(Point(nStmpX, nStmpY), Size(nStmpW, nStmpH)));
}

SwEnvDlg::SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet,
SwEnvDlg::SwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet,
                    SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert)
    : SfxTabDialog(pParent, "EnvDialog",
        "modules/swriter/ui/envdialog.ui", &rSet)
    : SfxTabDialogController(pParent, "modules/swriter/ui/envdialog.ui", "EnvDialog", &rSet)
    , aEnvItem(static_cast<const SwEnvItem&>( rSet.Get(FN_ENVELOP)))
    , pSh(pWrtSh)
    , pPrinter(pPrt)
    , pAddresseeSet(nullptr)
    , pSenderSet(nullptr)
    , m_nEnvPrintId(0)
    , m_xModify(m_xBuilder->weld_button("modify"))
{
    if (!bInsert)
    {
        GetUserButton()->SetText(get<PushButton>("modify")->GetText());
        GetUserButton()->set_label(m_xModify->get_label());
    }

    m_nEnvAddressId = AddTabPage("envelope", SwEnvPage   ::Create, nullptr);
    m_nEnvFormatId = AddTabPage("format", SwEnvFormatPage::Create, nullptr);
    m_nEnvPrintId = AddTabPage("printer", SwEnvPrtPage::Create, nullptr);
    AddTabPage("envelope", SwEnvPage::Create, nullptr);
    AddTabPage("format", SwEnvFormatPage::Create, nullptr);
    AddTabPage("printer", SwEnvPrtPage::Create, nullptr);
}

SwEnvDlg::~SwEnvDlg()
{
    disposeOnce();
}

void SwEnvDlg::dispose()
{
    delete pAddresseeSet;
    delete pSenderSet;
    pPrinter.clear();
    SfxTabDialog::dispose();
}

void SwEnvDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage)
void SwEnvDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
{
    if (nId == m_nEnvPrintId)
    if (rId == "printer")
    {
        static_cast<SwEnvPrtPage*>(&rPage)->SetPrt(pPrinter);
    }
    else if (nId == m_nEnvAddressId)
    else if (rId == "envelope")
    {
        static_cast<SwEnvPage*>(&rPage)->Init(this);
    }
    else if (nId == m_nEnvFormatId)
    else if (rId == "format")
    {
        static_cast<SwEnvFormatPage*>(&rPage)->Init(this);
    }
@@ -176,7 +166,7 @@ void SwEnvDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage)

short SwEnvDlg::Ok()
{
    short nRet = SfxTabDialog::Ok();
    short nRet = SfxTabDialogController::Ok();

    if (nRet == RET_OK || nRet == RET_USER)
    {
@@ -209,7 +199,7 @@ SwEnvPage::SwEnvPage(TabPageParent pParent, const SfxItemSet& rSet)
    , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview")))
{
    auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10));
    auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 20);
    auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 25);

    m_xAddrEdit->set_size_request(nTextBoxWidth, nTextBoxHeight);
    m_xSenderEdit->set_size_request(nTextBoxWidth, nTextBoxHeight);
diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx
index 94b7d08..a8c093c 100644
--- a/sw/source/ui/envelp/envprt.hxx
+++ b/sw/source/ui/envelp/envprt.hxx
@@ -50,7 +50,7 @@ class SwEnvPrtPage : public SfxTabPage
    DECL_LINK(AlignHdl, weld::ToggleButton&, void);
    DECL_LINK(ButtonHdl, weld::Button&, void );

    SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetTabDialog()); }
    SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetDialogController()); }

    using TabPage::ActivatePage;
    using TabPage::DeactivatePage;
diff --git a/sw/source/uibase/app/appenv.cxx b/sw/source/uibase/app/appenv.cxx
index 3d860da..bcb6932 100644
--- a/sw/source/uibase/app/appenv.cxx
+++ b/sw/source/uibase/app/appenv.cxx
@@ -214,7 +214,7 @@ void SwModule::InsertEnv( SfxRequest& rReq )
        SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
        OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");

        pDlg.disposeAndReset(pFact->CreateSwEnvDlg( pParent, aSet, pOldSh, pTempPrinter, !bEnvChange ));
        pDlg.disposeAndReset(pFact->CreateSwEnvDlg(pParent ? pParent->GetFrameWeld() : nullptr, aSet, pOldSh, pTempPrinter, !bEnvChange));
        OSL_ENSURE(pDlg, "Dialog creation failed!");
        nMode = pDlg->Execute();
    }
diff --git a/sw/source/uibase/inc/envlop.hxx b/sw/source/uibase/inc/envlop.hxx
index 989e50c..4d1b640 100644
--- a/sw/source/uibase/inc/envlop.hxx
+++ b/sw/source/uibase/inc/envlop.hxx
@@ -53,7 +53,7 @@ class SwEnvPreview
{
private:
    std::unique_ptr<weld::DrawingArea> m_xDrawingArea;
    VclPtr<SwEnvDlg> m_pDialog;
    SwEnvDlg* m_pDialog;
    Size m_aSize;

    DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void);
@@ -65,7 +65,7 @@ public:
    void queue_draw() { m_xDrawingArea->queue_draw(); }
};

class SwEnvDlg : public SfxTabDialog
class SwEnvDlg : public SfxTabDialogController
{
friend class SwEnvPage;
friend class SwEnvFormatPage;
@@ -77,22 +77,20 @@ friend class SwEnvPreview;
    VclPtr<Printer> pPrinter;
    SfxItemSet      *pAddresseeSet;
    SfxItemSet      *pSenderSet;
    sal_uInt16      m_nEnvPrintId;
    sal_uInt16      m_nEnvAddressId;
    sal_uInt16      m_nEnvFormatId;

    virtual void    PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override;
    std::unique_ptr<weld::Button> m_xModify;

    virtual void    PageCreated(const OString& rId, SfxTabPage &rPage) override;
    virtual short   Ok() override;

public:
    SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert);
    SwEnvDlg(weld::Window* pParent, const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert);
    virtual ~SwEnvDlg() override;
    virtual void dispose() override;
};

class SwEnvPage : public SfxTabPage
{
    VclPtr<SwEnvDlg> m_pDialog;
    SwEnvDlg* m_pDialog;
    SwWrtShell*   m_pSh;
    OUString      m_sActDBName;

@@ -128,11 +126,6 @@ public:
            void FillItem(SwEnvItem& rItem);
    virtual bool FillItemSet(SfxItemSet* rSet) override;
    virtual void Reset(const SfxItemSet* rSet) override;
    virtual void dispose() override
    {
        m_pDialog.clear();
        SfxTabPage::dispose();
    }
};

#endif
diff --git a/sw/uiconfig/swriter/ui/envaddresspage.ui b/sw/uiconfig/swriter/ui/envaddresspage.ui
index 37e84a2..3f68492 100644
--- a/sw/uiconfig/swriter/ui/envaddresspage.ui
+++ b/sw/uiconfig/swriter/ui/envaddresspage.ui
@@ -1,7 +1,7 @@
<?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"/>
  <object class="GtkImage" id="image1">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -37,7 +37,7 @@
                <property name="vexpand">True</property>
                <property name="shadow_type">in</property>
                <child>
                  <object class="GtkTextView" id="addredit:border">
                  <object class="GtkTextView" id="addredit">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
@@ -48,8 +48,6 @@
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
@@ -57,24 +55,20 @@
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="hexpand">True</property>
                <property name="xalign">0</property>
                <property name="label" translatable="yes" context="envaddresspage|label2">Addr_essee</property>
                <property name="use_underline">True</property>
                <property name="mnemonic_widget">addredit:border</property>
                <property name="mnemonic_widget">addredit</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>
          </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>
@@ -94,16 +88,14 @@
                  <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="envaddresspage|label4">Database</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">database</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>
@@ -111,22 +103,16 @@
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="entry_text_column">0</property>
                    <property name="id_column">1</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">1</property>
                    <property name="width">1</property>
                    <property name="height">1</property>
                  </packing>
                </child>
              </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>
@@ -140,16 +126,14 @@
                  <object class="GtkLabel" id="label7">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="xalign">0</property>
                    <property name="label" translatable="yes" context="envaddresspage|label7">Table</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">table</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>
@@ -157,22 +141,16 @@
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="entry_text_column">0</property>
                    <property name="id_column">1</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">1</property>
                    <property name="width">1</property>
                    <property name="height">1</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
@@ -186,16 +164,14 @@
                  <object class="GtkLabel" id="label8">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="xalign">0</property>
                    <property name="label" translatable="yes" context="envaddresspage|label8">Database field</property>
                    <property name="use_underline">True</property>
                    <property name="mnemonic_widget">field</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>
@@ -203,30 +179,22 @@
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                    <property name="hexpand">True</property>
                    <property name="entry_text_column">0</property>
                    <property name="id_column">1</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="top_attach">1</property>
                    <property name="width">1</property>
                    <property name="height">1</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">2</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
@@ -237,12 +205,11 @@
            <property name="tooltip_text" translatable="yes" context="envaddresspage|insert|tooltip_text">Insert</property>
            <property name="valign">center</property>
            <property name="image">image1</property>
            <property name="always_show_image">True</property>
          </object>
          <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>
@@ -274,7 +241,7 @@
                <property name="vexpand">True</property>
                <property name="shadow_type">in</property>
                <child>
                  <object class="GtkTextView" id="senderedit:border">
                  <object class="GtkTextView" id="senderedit">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="hexpand">True</property>
@@ -288,8 +255,6 @@
              <packing>
                <property name="left_attach">0</property>
                <property name="top_attach">1</property>
                <property name="width">1</property>
                <property name="height">1</property>
              </packing>
            </child>
            <child>
@@ -302,22 +267,18 @@
                <property name="xalign">0</property>
                <property name="draw_indicator">True</property>
                <accessibility>
                  <relation type="label-for" target="senderedit:border"/>
                  <relation type="label-for" target="senderedit"/>
                </accessibility>
              </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>
          </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>
@@ -332,8 +293,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>
        <child>
@@ -349,8 +308,6 @@
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
      </object>
diff --git a/sw/uiconfig/swriter/ui/envdialog.ui b/sw/uiconfig/swriter/ui/envdialog.ui
index e4996a3..cc53d23 100644
--- a/sw/uiconfig/swriter/ui/envdialog.ui
+++ b/sw/uiconfig/swriter/ui/envdialog.ui
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkDialog" id="EnvDialog">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="envdialog|EnvDialog">Envelope</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">
@@ -86,6 +89,7 @@
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">4</property>
                <property name="secondary">True</property>
              </packing>
            </child>
            <child>
@@ -123,6 +127,30 @@
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
              </object>
            </child>
            <child type="tab">
@@ -142,6 +170,30 @@
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
              </object>
              <packing>
                <property name="position">1</property>
@@ -165,6 +217,30 @@
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
                <child>
                  <placeholder/>
                </child>
              </object>
              <packing>
                <property name="position">2</property>
@@ -198,5 +274,8 @@
      <action-widget response="-11">help</action-widget>
      <action-widget response="0">reset</action-widget>
    </action-widgets>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>
diff --git a/sw/uiconfig/swriter/ui/envformatpage.ui b/sw/uiconfig/swriter/ui/envformatpage.ui
index 8e8d742..f49b6ea 100644
--- a/sw/uiconfig/swriter/ui/envformatpage.ui
+++ b/sw/uiconfig/swriter/ui/envformatpage.ui
@@ -34,22 +34,42 @@
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkMenu" id="editmenu">
  <object class="GtkMenu" id="editmenu1">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <child>
      <object class="GtkMenuItem" id="character">
      <object class="GtkMenuItem" id="character1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes" context="envformatpage|character">C_haracter...</property>
        <property name="label" translatable="yes" context="envformatpage|character1">C_haracter...</property>
        <property name="use_underline">True</property>
      </object>
    </child>
    <child>
      <object class="GtkMenuItem" id="paragraph">
      <object class="GtkMenuItem" id="paragraph1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes" context="envformatpage|paragraph">P_aragraph...</property>
        <property name="label" translatable="yes" context="envformatpage|paragraph1">P_aragraph...</property>
        <property name="use_underline">True</property>
      </object>
    </child>
  </object>
  <object class="GtkMenu" id="editmenu2">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <child>
      <object class="GtkMenuItem" id="character2">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes" context="envformatpage|character2">C_haracter...</property>
        <property name="use_underline">True</property>
      </object>
    </child>
    <child>
      <object class="GtkMenuItem" id="paragraph2">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="label" translatable="yes" context="envformatpage|paragraph2">P_aragraph...</property>
        <property name="use_underline">True</property>
      </object>
    </child>
@@ -209,7 +229,7 @@
                                <property name="visible">True</property>
                                <property name="can_focus">True</property>
                                <property name="receives_default">True</property>
                                <property name="popup">editmenu</property>
                                <property name="popup">editmenu1</property>
                                <child>
                                  <placeholder/>
                                </child>
@@ -406,7 +426,7 @@
                                <property name="visible">True</property>
                                <property name="can_focus">True</property>
                                <property name="receives_default">True</property>
                                <property name="popup">editmenu</property>
                                <property name="popup">editmenu2</property>
                                <child>
                                  <placeholder/>
                                </child>
diff --git a/sw/uiconfig/swriter/ui/envprinterpage.ui b/sw/uiconfig/swriter/ui/envprinterpage.ui
index 43f6f7e..165600f 100644
--- a/sw/uiconfig/swriter/ui/envprinterpage.ui
+++ b/sw/uiconfig/swriter/ui/envprinterpage.ui
@@ -7,6 +7,11 @@
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment2">
    <property name="upper">9999</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkImage" id="image1">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -160,6 +165,7 @@
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="activates_default">True</property>
                    <property name="adjustment">adjustment2</property>
                    <property name="digits">2</property>
                  </object>
                  <packing>