diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-25 20:27:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-27 17:07:57 +0200 |
commit | 86b9824312d8de0fa85ec6bfd6cf2b78867ad936 (patch) | |
tree | 524d2409c2555008c801e82e85f9e6441b5c3dd0 /sw/source/ui/envelp | |
parent | a3cbd06872b2f9ee9253e5879f590ff1b9eaf365 (diff) |
weld pages of the insert envelope dialog
SwEnvPrtPage, SwEnvFormatPage, SwEnvPage
Change-Id: I76b0298994fcd663c0b415ae6e29af054a335bbf
Reviewed-on: https://gerrit.libreoffice.org/53503
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui/envelp')
-rw-r--r-- | sw/source/ui/envelp/envfmt.cxx | 260 | ||||
-rw-r--r-- | sw/source/ui/envelp/envfmt.hxx | 49 | ||||
-rw-r--r-- | sw/source/ui/envelp/envlop1.cxx | 227 | ||||
-rw-r--r-- | sw/source/ui/envelp/envprt.cxx | 165 | ||||
-rw-r--r-- | sw/source/ui/envelp/envprt.hxx | 47 |
5 files changed, 349 insertions, 399 deletions
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index c8b5cfc9e3f6..a7aaaf4cbd8c 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -23,6 +23,7 @@ #include <editeng/tstpitem.hxx> #include <editeng/lrspitem.hxx> #include <editeng/brushitem.hxx> +#include <svtools/unitconv.hxx> #include <vcl/menu.hxx> #include <cmdid.h> @@ -113,64 +114,45 @@ namespace { static long lUserW = 5669; // 10 cm static long lUserH = 5669; // 10 cm -SwEnvFormatPage::SwEnvFormatPage(vcl::Window* pParent, const SfxItemSet& rSet) - : SfxTabPage(pParent, "EnvFormatPage", - "modules/swriter/ui/envformatpage.ui", &rSet) +SwEnvFormatPage::SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "modules/swriter/ui/envformatpage.ui", "EnvFormatPage", &rSet) + , m_xAddrLeftField(m_xBuilder->weld_metric_spin_button("leftaddr", FUNIT_CM)) + , m_xAddrTopField(m_xBuilder->weld_metric_spin_button("topaddr", FUNIT_CM)) + , m_xAddrEditButton(m_xBuilder->weld_menu_button("addredit")) + , m_xSendLeftField(m_xBuilder->weld_metric_spin_button("leftsender", FUNIT_CM)) + , m_xSendTopField(m_xBuilder->weld_metric_spin_button("topsender", FUNIT_CM)) + , m_xSendEditButton(m_xBuilder->weld_menu_button("senderedit")) + , m_xSizeFormatBox(m_xBuilder->weld_combo_box_text("format")) + , m_xSizeWidthField(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM)) + , m_xSizeHeightField(m_xBuilder->weld_metric_spin_button("height", FUNIT_CM)) + , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview"))) { - get(m_pAddrLeftField, "leftaddr"); - get(m_pAddrTopField, "topaddr"); - get(m_pSendLeftField,"leftsender"); - get(m_pSendTopField, "topsender"); - get(m_pSizeFormatBox, "format"); - get(m_pSizeWidthField, "width"); - get(m_pSizeHeightField, "height"); - get(m_pPreview, "preview"); - get(m_pAddrEditButton, "addredit"); - get(m_pSendEditButton, "senderedit"); SetExchangeSupport(); // Metrics FieldUnit aMetric = ::GetDfltMetric(false); - SetMetric(*m_pAddrLeftField, aMetric); - SetMetric(*m_pAddrTopField, aMetric); - SetMetric(*m_pSendLeftField, aMetric); - SetMetric(*m_pSendTopField, aMetric); - SetMetric(*m_pSizeWidthField, aMetric); - SetMetric(*m_pSizeHeightField, aMetric); + ::SetFieldUnit(*m_xAddrLeftField, aMetric); + ::SetFieldUnit(*m_xAddrTopField, aMetric); + ::SetFieldUnit(*m_xSendLeftField, aMetric); + ::SetFieldUnit(*m_xSendTopField, aMetric); + ::SetFieldUnit(*m_xSizeWidthField, aMetric); + ::SetFieldUnit(*m_xSizeHeightField, aMetric); // Install handlers - Link<SpinField&,void> aLk = LINK(this, SwEnvFormatPage, ModifyHdl); - m_pAddrLeftField->SetUpHdl( aLk ); - m_pAddrTopField->SetUpHdl( aLk ); - m_pSendLeftField->SetUpHdl( aLk ); - m_pSendTopField->SetUpHdl( aLk ); - m_pSizeWidthField->SetUpHdl( aLk ); - m_pSizeHeightField->SetUpHdl( aLk ); - - m_pAddrLeftField->SetDownHdl( aLk ); - m_pAddrTopField->SetDownHdl( aLk ); - m_pSendLeftField->SetDownHdl( aLk ); - m_pSendTopField->SetDownHdl( aLk ); - m_pSizeWidthField->SetDownHdl( aLk ); - m_pSizeHeightField->SetDownHdl( aLk ); - - Link<Control&,void> aLk3 = LINK(this, SwEnvFormatPage, LoseFocusHdl); - m_pAddrLeftField->SetLoseFocusHdl( aLk3 ); - m_pAddrTopField->SetLoseFocusHdl( aLk3 ); - m_pSendLeftField->SetLoseFocusHdl( aLk3 ); - m_pSendTopField->SetLoseFocusHdl( aLk3 ); - m_pSizeWidthField->SetLoseFocusHdl( aLk3 ); - m_pSizeHeightField->SetLoseFocusHdl( aLk3 ); - - Link<MenuButton *, void> aLk2 = LINK(this, SwEnvFormatPage, EditHdl ); - m_pAddrEditButton->SetSelectHdl( aLk2 ); - m_pSendEditButton->SetSelectHdl( aLk2 ); - - m_pPreview->SetBorderStyle( WindowBorderStyle::MONO ); - - m_pSizeFormatBox->SetSelectHdl(LINK(this, SwEnvFormatPage, FormatHdl)); - - // m_pSizeFormatBox + Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwEnvFormatPage, ModifyHdl); + m_xAddrLeftField->connect_value_changed( aLk ); + m_xAddrTopField->connect_value_changed( aLk ); + m_xSendLeftField->connect_value_changed( aLk ); + m_xSendTopField->connect_value_changed( aLk ); + m_xSizeWidthField->connect_value_changed( aLk ); + m_xSizeHeightField->connect_value_changed( aLk ); + + m_xAddrEditButton->connect_selected(LINK(this, SwEnvFormatPage, AddrEditHdl)); + m_xSendEditButton->connect_selected(LINK(this, SwEnvFormatPage, SendEditHdl)); + + m_xSizeFormatBox->connect_changed(LINK(this, SwEnvFormatPage, FormatHdl)); + + // m_xSizeFormatBox for (sal_uInt16 i = PAPER_A3; i <= PAPER_KAI32BIG; i++) { if (i != PAPER_USER) @@ -181,18 +163,23 @@ SwEnvFormatPage::SwEnvFormatPage(vcl::Window* pParent, const SfxItemSet& rSet) continue; sal_Int32 nPos = 0; - while (nPos < m_pSizeFormatBox->GetEntryCount() && - m_pSizeFormatBox->GetEntry(nPos) < aPaperName) + while (nPos < m_xSizeFormatBox->get_count() && + m_xSizeFormatBox->get_text(nPos) < aPaperName) { ++nPos; } - m_pSizeFormatBox->InsertEntry(aPaperName, nPos); - aIDs.insert( aIDs.begin() + nPos, i); + m_xSizeFormatBox->insert_text(nPos, aPaperName); + m_aIDs.insert( m_aIDs.begin() + nPos, i); } } - m_pSizeFormatBox->InsertEntry(SvxPaperInfo::GetName(PAPER_USER)); - aIDs.push_back( sal_uInt16(PAPER_USER) ); + m_xSizeFormatBox->append_text(SvxPaperInfo::GetName(PAPER_USER)); + m_aIDs.push_back( sal_uInt16(PAPER_USER) ); +} +void SwEnvFormatPage::Init(SwEnvDlg* pDialog) +{ + m_pDialog = pDialog; + m_xPreview->SetDialog(m_pDialog); } SwEnvFormatPage::~SwEnvFormatPage() @@ -200,76 +187,61 @@ SwEnvFormatPage::~SwEnvFormatPage() disposeOnce(); } -void SwEnvFormatPage::dispose() +IMPL_LINK( SwEnvFormatPage, ModifyHdl, weld::MetricSpinButton&, rEdit, void ) { - m_pAddrLeftField.clear(); - m_pAddrTopField.clear(); - m_pAddrEditButton.clear(); - m_pSendLeftField.clear(); - m_pSendTopField.clear(); - m_pSendEditButton.clear(); - m_pSizeFormatBox.clear(); - m_pSizeWidthField.clear(); - m_pSizeHeightField.clear(); - m_pPreview.clear(); - SfxTabPage::dispose(); -} - + int lWVal = getfieldval(*m_xSizeWidthField); + int lHVal = getfieldval(*m_xSizeHeightField); -IMPL_LINK( SwEnvFormatPage, LoseFocusHdl, Control&, rControl, void ) -{ - ModifyHdl(static_cast<SpinField&>(rControl)); -} -IMPL_LINK( SwEnvFormatPage, ModifyHdl, SpinField&, rEdit, void ) -{ - long lWVal = static_cast< long >(GetFieldVal(*m_pSizeWidthField )); - long lHVal = static_cast< long >(GetFieldVal(*m_pSizeHeightField)); + int lWidth = std::max(lWVal, lHVal); + int lHeight = std::min(lWVal, lHVal); - long lWidth = std::max(lWVal, lHVal); - long lHeight = std::min(lWVal, lHVal); - - if (&rEdit == m_pSizeWidthField || &rEdit == m_pSizeHeightField) + if (&rEdit == m_xSizeWidthField.get() || &rEdit == m_xSizeHeightField.get()) { - long nRotatedWidth = lHeight; - long nRotatedHeight = lWidth; + int nRotatedWidth = lHeight; + int nRotatedHeight = lWidth; Paper ePaper = SvxPaperInfo::GetSvxPaper( Size(nRotatedWidth, nRotatedHeight), MapUnit::MapTwip); - for (size_t i = 0; i < aIDs.size(); ++i) - if (aIDs[i] == static_cast<sal_uInt16>(ePaper)) - m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i)); + for (size_t i = 0; i < m_aIDs.size(); ++i) + if (m_aIDs[i] == static_cast<sal_uInt16>(ePaper)) + m_xSizeFormatBox->set_active(i); // remember user size - if (aIDs[m_pSizeFormatBox->GetSelectedEntryPos()] == sal_uInt16(PAPER_USER)) + if (m_aIDs[m_xSizeFormatBox->get_active()] == sal_uInt16(PAPER_USER)) { lUserW = lWidth ; lUserH = lHeight; } - m_pSizeFormatBox->GetSelectHdl().Call(*m_pSizeFormatBox); + FormatHdl(*m_xSizeFormatBox); } else { FillItem(GetParentSwEnvDlg()->aEnvItem); SetMinMax(); - m_pPreview->Invalidate(); + m_xPreview->queue_draw(); } } -IMPL_LINK( SwEnvFormatPage, EditHdl, MenuButton *, pButton, void ) +IMPL_LINK(SwEnvFormatPage, AddrEditHdl, const OString&, rIdent, void) +{ + Edit(rIdent, true); +} + +IMPL_LINK(SwEnvFormatPage, SendEditHdl, const OString&, rIdent, void) +{ + Edit(rIdent, false); +} + +void SwEnvFormatPage::Edit(const OString& rIdent, bool bSender) { SwWrtShell* pSh = GetParentSwEnvDlg()->pSh; OSL_ENSURE(pSh, "Shell missing"); - // determine collection-ptr - bool bSender = pButton != m_pAddrEditButton; - SwTextFormatColl* pColl = pSh->GetTextCollFromPool( static_cast< sal_uInt16 >( bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS)); OSL_ENSURE(pColl, "Text collection missing"); - OString sIdent(pButton->GetCurItemIdent()); - - if (sIdent == "character") + if (rIdent == "character") { SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); @@ -290,7 +262,7 @@ IMPL_LINK( SwEnvFormatPage, EditHdl, MenuButton *, pButton, void ) pCollSet->Put(aOutputSet); } } - else if (sIdent == "paragraph") + else if (rIdent == "paragraph") { SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); @@ -380,7 +352,7 @@ SfxItemSet *SwEnvFormatPage::GetCollItemSet(SwTextFormatColl const * pColl, bool return pAddrSet; } -IMPL_LINK_NOARG(SwEnvFormatPage, FormatHdl, ListBox&, void) +IMPL_LINK_NOARG(SwEnvFormatPage, FormatHdl, weld::ComboBoxText&, void) { long lWidth; long lHeight; @@ -389,7 +361,7 @@ IMPL_LINK_NOARG(SwEnvFormatPage, FormatHdl, ListBox&, void) long lAddrFromLeft; long lAddrFromTop; - const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectedEntryPos()]; + const sal_uInt16 nPaper = m_aIDs[m_xSizeFormatBox->get_active()]; if (nPaper != sal_uInt16(PAPER_USER)) { Size aSz = SvxPaperInfo::GetPaperSize(static_cast<Paper>(nPaper)); @@ -407,60 +379,42 @@ IMPL_LINK_NOARG(SwEnvFormatPage, FormatHdl, ListBox&, void) lAddrFromLeft = lWidth / 2; lAddrFromTop = lHeight / 2; - SetFieldVal(*m_pAddrLeftField, lAddrFromLeft); - SetFieldVal(*m_pAddrTopField , lAddrFromTop ); - SetFieldVal(*m_pSendLeftField, lSendFromLeft); - SetFieldVal(*m_pSendTopField , lSendFromTop ); + setfieldval(*m_xAddrLeftField, lAddrFromLeft); + setfieldval(*m_xAddrTopField , lAddrFromTop ); + setfieldval(*m_xSendLeftField, lSendFromLeft); + setfieldval(*m_xSendTopField , lSendFromTop ); - SetFieldVal(*m_pSizeWidthField , lWidth ); - SetFieldVal(*m_pSizeHeightField, lHeight); + setfieldval(*m_xSizeWidthField , lWidth ); + setfieldval(*m_xSizeHeightField, lHeight); SetMinMax(); FillItem(GetParentSwEnvDlg()->aEnvItem); - m_pPreview->Invalidate(); + m_xPreview->queue_draw(); } void SwEnvFormatPage::SetMinMax() { - long lWVal = static_cast< long >(GetFieldVal(*m_pSizeWidthField )); - long lHVal = static_cast< long >(GetFieldVal(*m_pSizeHeightField)); + long lWVal = static_cast< long >(getfieldval(*m_xSizeWidthField )); + long lHVal = static_cast< long >(getfieldval(*m_xSizeHeightField)); long lWidth = std::max(lWVal, lHVal), lHeight = std::min(lWVal, lHVal); // Min and Max - m_pAddrLeftField->SetMin(long(100) * (GetFieldVal(*m_pSendLeftField) + 566), FUNIT_TWIP); - m_pAddrLeftField->SetMax(long(100) * (lWidth - 2 * 566), FUNIT_TWIP); - m_pAddrTopField->SetMin(long(100) * (GetFieldVal(*m_pSendTopField ) + 2 * 566), FUNIT_TWIP); - m_pAddrTopField->SetMax(long(100) * (lHeight - 2 * 566), FUNIT_TWIP); - m_pSendLeftField->SetMin(long(100) * 566, FUNIT_TWIP); - m_pSendLeftField->SetMax(long(100) * (GetFieldVal(*m_pAddrLeftField) - 566), FUNIT_TWIP); - m_pSendTopField->SetMin(long(100) * 566, FUNIT_TWIP); - m_pSendTopField->SetMax(long(100) * (GetFieldVal(*m_pAddrTopField ) - 2 * 566), FUNIT_TWIP); - - // First and last - m_pAddrLeftField->SetFirst(m_pAddrLeftField->GetMin()); - m_pAddrLeftField->SetLast(m_pAddrLeftField->GetMax()); - m_pAddrTopField->SetFirst(m_pAddrTopField->GetMin()); - m_pAddrTopField->SetLast(m_pAddrTopField->GetMax()); - m_pSendLeftField->SetFirst(m_pSendLeftField->GetMin()); - m_pSendLeftField->SetLast(m_pSendLeftField->GetMax()); - m_pSendTopField->SetFirst(m_pSendTopField->GetMin()); - m_pSendTopField->SetLast(m_pSendTopField->GetMax()); - - // Reformat fields - m_pAddrLeftField->Reformat(); - m_pAddrTopField->Reformat(); - m_pSendLeftField->Reformat(); - m_pSendTopField->Reformat(); - m_pSizeWidthField->Reformat(); - m_pSizeHeightField->Reformat(); + m_xAddrLeftField->set_range(100 * (getfieldval(*m_xSendLeftField) + 566), + 100 * (lWidth - 2 * 566), FUNIT_TWIP); + m_xAddrTopField->set_range(100 * (getfieldval(*m_xSendTopField ) + 2 * 566), + 100 * (lHeight - 2 * 566), FUNIT_TWIP); + m_xSendLeftField->set_range(100 * 566, + 100 * (getfieldval(*m_xAddrLeftField) - 566), FUNIT_TWIP); + m_xSendTopField->set_range(100 * 566, + 100 * (getfieldval(*m_xAddrTopField ) - 2 * 566), FUNIT_TWIP); } VclPtr<SfxTabPage> SwEnvFormatPage::Create(TabPageParent pParent, const SfxItemSet* rSet) { - return VclPtr<SwEnvFormatPage>::Create(pParent.pParent, *rSet); + return VclPtr<SwEnvFormatPage>::Create(pParent, *rSet); } void SwEnvFormatPage::ActivatePage(const SfxItemSet& rSet) @@ -479,16 +433,16 @@ DeactivateRC SwEnvFormatPage::DeactivatePage(SfxItemSet* _pSet) void SwEnvFormatPage::FillItem(SwEnvItem& rItem) { - rItem.m_nAddrFromLeft = static_cast< sal_Int32 >(GetFieldVal(*m_pAddrLeftField)); - rItem.m_nAddrFromTop = static_cast< sal_Int32 >(GetFieldVal(*m_pAddrTopField )); - rItem.m_nSendFromLeft = static_cast< sal_Int32 >(GetFieldVal(*m_pSendLeftField)); - rItem.m_nSendFromTop = static_cast< sal_Int32 >(GetFieldVal(*m_pSendTopField )); + rItem.m_nAddrFromLeft = static_cast< sal_Int32 >(getfieldval(*m_xAddrLeftField)); + rItem.m_nAddrFromTop = static_cast< sal_Int32 >(getfieldval(*m_xAddrTopField )); + rItem.m_nSendFromLeft = static_cast< sal_Int32 >(getfieldval(*m_xSendLeftField)); + rItem.m_nSendFromTop = static_cast< sal_Int32 >(getfieldval(*m_xSendTopField )); - const sal_uInt16 nPaper = aIDs[m_pSizeFormatBox->GetSelectedEntryPos()]; + const sal_uInt16 nPaper = m_aIDs[m_xSizeFormatBox->get_active()]; if (nPaper == sal_uInt16(PAPER_USER)) { - long lWVal = static_cast< long >(GetFieldVal(*m_pSizeWidthField )); - long lHVal = static_cast< long >(GetFieldVal(*m_pSizeHeightField)); + long lWVal = static_cast< long >(getfieldval(*m_xSizeWidthField )); + long lHVal = static_cast< long >(getfieldval(*m_xSizeHeightField)); rItem.m_nWidth = std::max(lWVal, lHVal); rItem.m_nHeight = std::min(lWVal, lHVal); } @@ -515,17 +469,17 @@ void SwEnvFormatPage::Reset(const SfxItemSet* rSet) Paper ePaper = SvxPaperInfo::GetSvxPaper( Size( std::min(rItem.m_nWidth, rItem.m_nHeight), std::max(rItem.m_nWidth, rItem.m_nHeight)), MapUnit::MapTwip); - for (size_t i = 0; i < aIDs.size(); ++i) - if (aIDs[i] == static_cast<sal_uInt16>(ePaper)) - m_pSizeFormatBox->SelectEntryPos(static_cast<sal_Int32>(i)); + for (size_t i = 0; i < m_aIDs.size(); ++i) + if (m_aIDs[i] == static_cast<sal_uInt16>(ePaper)) + m_xSizeFormatBox->set_active(i); // Metric fields - SetFieldVal(*m_pAddrLeftField, rItem.m_nAddrFromLeft); - SetFieldVal(*m_pAddrTopField, rItem.m_nAddrFromTop ); - SetFieldVal(*m_pSendLeftField, rItem.m_nSendFromLeft); - SetFieldVal(*m_pSendTopField, rItem.m_nSendFromTop ); - SetFieldVal(*m_pSizeWidthField , std::max(rItem.m_nWidth, rItem.m_nHeight)); - SetFieldVal(*m_pSizeHeightField , std::min(rItem.m_nWidth, rItem.m_nHeight)); + setfieldval(*m_xAddrLeftField, rItem.m_nAddrFromLeft); + setfieldval(*m_xAddrTopField, rItem.m_nAddrFromTop ); + setfieldval(*m_xSendLeftField, rItem.m_nSendFromLeft); + setfieldval(*m_xSendTopField, rItem.m_nSendFromTop ); + setfieldval(*m_xSizeWidthField , std::max(rItem.m_nWidth, rItem.m_nHeight)); + setfieldval(*m_xSizeHeightField , std::min(rItem.m_nWidth, rItem.m_nHeight)); SetMinMax(); DELETEZ(GetParentSwEnvDlg()->pSenderSet); diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx index 1d3593e2e91a..d5aec6713fe5 100644 --- a/sw/source/ui/envelp/envfmt.hxx +++ b/sw/source/ui/envelp/envfmt.hxx @@ -19,47 +19,52 @@ #ifndef INCLUDED_SW_SOURCE_UI_ENVELP_ENVFMT_HXX #define INCLUDED_SW_SOURCE_UI_ENVELP_ENVFMT_HXX -#include <vcl/field.hxx> -#include <vcl/menubtn.hxx> -#include <vcl/group.hxx> - +#include <vcl/weld.hxx> #include <envlop.hxx> class SwTextFormatColl; class SwEnvFormatPage : public SfxTabPage { - VclPtr<MetricField> m_pAddrLeftField; - VclPtr<MetricField> m_pAddrTopField; - VclPtr<MenuButton> m_pAddrEditButton; - VclPtr<MetricField> m_pSendLeftField; - VclPtr<MetricField> m_pSendTopField; - VclPtr<MenuButton> m_pSendEditButton; - VclPtr<ListBox> m_pSizeFormatBox; - VclPtr<MetricField> m_pSizeWidthField; - VclPtr<MetricField> m_pSizeHeightField; - VclPtr<SwEnvPreview> m_pPreview; + VclPtr<SwEnvDlg> m_pDialog; + std::vector<sal_uInt16> m_aIDs; - std::vector<sal_uInt16> aIDs; + std::unique_ptr<weld::MetricSpinButton> m_xAddrLeftField; + std::unique_ptr<weld::MetricSpinButton> m_xAddrTopField; + std::unique_ptr<weld::MenuButton> m_xAddrEditButton; + std::unique_ptr<weld::MetricSpinButton> m_xSendLeftField; + std::unique_ptr<weld::MetricSpinButton> m_xSendTopField; + std::unique_ptr<weld::MenuButton> m_xSendEditButton; + std::unique_ptr<weld::ComboBoxText> m_xSizeFormatBox; + std::unique_ptr<weld::MetricSpinButton> m_xSizeWidthField; + std::unique_ptr<weld::MetricSpinButton> m_xSizeHeightField; + std::unique_ptr<SwEnvPreview> m_xPreview; - DECL_LINK( ModifyHdl, SpinField&, void ); - DECL_LINK( LoseFocusHdl, Control&, void ); - DECL_LINK( EditHdl, MenuButton *, void ); - DECL_LINK(FormatHdl, ListBox&, void); + DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); + DECL_LINK(AddrEditHdl, const OString&, void); + DECL_LINK(SendEditHdl, const OString&, void); + DECL_LINK(FormatHdl, weld::ComboBoxText&, void); void SetMinMax(); SfxItemSet *GetCollItemSet(SwTextFormatColl const * pColl, bool bSender); - SwEnvDlg *GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetParentDialog());} + void Edit(const OString& rIdent, bool bSender); + + SwEnvDlg *GetParentSwEnvDlg() { return m_pDialog; } using TabPage::ActivatePage; using TabPage::DeactivatePage; public: - SwEnvFormatPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet); + void Init(SwEnvDlg* pDialog); + virtual void dispose() override + { + m_pDialog.clear(); + SfxTabPage::dispose(); + } virtual ~SwEnvFormatPage() override; - virtual void dispose() 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 002518c47d27..28926fb9b2dd 100644 --- a/sw/source/ui/envelp/envlop1.cxx +++ b/sw/source/ui/envelp/envlop1.cxx @@ -20,6 +20,7 @@ #include <dbmgr.hxx> #include <sfx2/app.hxx> #include <vcl/builderfactory.hxx> +#include <vcl/print.hxx> #include <vcl/settings.hxx> #include <swwait.hxx> @@ -43,39 +44,39 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; -SwEnvPreview::SwEnvPreview(vcl::Window* pParent, WinBits nStyle) - : Window(pParent, nStyle) +SwEnvPreview::SwEnvPreview(weld::DrawingArea* pDrawingArea) + : m_xDrawingArea(pDrawingArea) + , m_pDialog(nullptr) { - SetMapMode(MapMode(MapUnit::MapPixel)); + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 20, + m_xDrawingArea->get_text_height() * 8); + m_xDrawingArea->connect_size_allocate(LINK(this, SwEnvPreview, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, SwEnvPreview, DoPaint)); } -Size SwEnvPreview::GetOptimalSize() const +IMPL_LINK(SwEnvPreview, DoResize, const Size&, rSize, void) { - return LogicToPixel(Size(84 , 63), MapMode(MapUnit::MapAppFont)); + m_aSize = rSize; } -VCL_BUILDER_FACTORY_ARGS(SwEnvPreview, 0) - -void SwEnvPreview::DataChanged( const DataChangedEvent& rDCEvt ) +IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { - Window::DataChanged( rDCEvt ); - if (DataChangedEventType::SETTINGS == rDCEvt.GetType()) - Invalidate(); -} + vcl::RenderContext& rRenderContext = aPayload.first; + + //SetMapMode(MapMode(MapUnit::MapPixel)); -void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle &) -{ const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); - SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor()); + rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor()); + rRenderContext.Erase(); - const SwEnvItem& rItem = static_cast<SwEnvDlg*>(GetParentDialog())->aEnvItem; + const SwEnvItem& rItem = m_pDialog->aEnvItem; const long nPageW = std::max(rItem.m_nWidth, rItem.m_nHeight); const long nPageH = std::min(rItem.m_nWidth, rItem.m_nHeight); const double f = 0.8 * std::min( - double(GetOutputSizePixel().Width()) / double(nPageW), - double(GetOutputSizePixel().Height()) / double(nPageH)); + double(m_aSize.Width()) / double(nPageW), + double(m_aSize.Height()) / double(nPageH)); Color aBack = rSettings.GetWindowColor(); Color aFront = SwViewOption::GetFontColor(); @@ -88,8 +89,8 @@ void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan // Envelope const long nW = static_cast<long>(f * nPageW); const long nH = static_cast<long>(f * nPageH); - const long nX = (GetOutputSizePixel().Width () - nW) / 2; - const long nY = (GetOutputSizePixel().Height() - nH) / 2; + const long nX = (m_aSize.Width () - nW) / 2; + const long nY = (m_aSize.Height() - nH) / 2; rRenderContext.SetFillColor(aBack); rRenderContext.DrawRect(tools::Rectangle(Point(nX, nY), Size(nW, nH))); @@ -139,8 +140,8 @@ SwEnvDlg::SwEnvDlg(vcl::Window* pParent, const SfxItemSet& rSet, GetUserButton()->SetText(get<PushButton>("modify")->GetText()); } - AddTabPage("envelope", SwEnvPage ::Create, nullptr); - AddTabPage("format", SwEnvFormatPage::Create, nullptr); + m_nEnvAddressId = AddTabPage("envelope", SwEnvPage ::Create, nullptr); + m_nEnvFormatId = AddTabPage("format", SwEnvFormatPage::Create, nullptr); m_nEnvPrintId = AddTabPage("printer", SwEnvPrtPage::Create, nullptr); } @@ -163,6 +164,14 @@ void SwEnvDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) { static_cast<SwEnvPrtPage*>(&rPage)->SetPrt(pPrinter); } + else if (nId == m_nEnvAddressId) + { + static_cast<SwEnvPage*>(&rPage)->Init(this); + } + else if (nId == m_nEnvFormatId) + { + static_cast<SwEnvFormatPage*>(&rPage)->Init(this); + } } short SwEnvDlg::Ok() @@ -186,44 +195,47 @@ short SwEnvDlg::Ok() return nRet; } -SwEnvPage::SwEnvPage(vcl::Window* pParent, const SfxItemSet& rSet) - : SfxTabPage(pParent, "EnvAddressPage", - "modules/swriter/ui/envaddresspage.ui", &rSet) +SwEnvPage::SwEnvPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "modules/swriter/ui/envaddresspage.ui", "EnvAddressPage", &rSet) + , m_pDialog(nullptr) + , m_pSh(nullptr) + , m_xAddrEdit(m_xBuilder->weld_text_view("addredit")) + , m_xDatabaseLB(m_xBuilder->weld_combo_box_text("database")) + , m_xTableLB(m_xBuilder->weld_combo_box_text("table")) + , m_xDBFieldLB(m_xBuilder->weld_combo_box_text("field")) + , m_xInsertBT(m_xBuilder->weld_button("insert")) + , m_xSenderBox(m_xBuilder->weld_check_button("sender")) + , m_xSenderEdit(m_xBuilder->weld_text_view("senderedit")) + , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview"))) { - get(m_pAddrEdit, "addredit"); - get(m_pDatabaseLB, "database"); - get(m_pTableLB, "table"); - get(m_pDBFieldLB, "field"); - get(m_pInsertBT, "insert"); - get(m_pSenderBox, "sender"); - get(m_pSenderEdit, "senderedit"); - get(m_pPreview, "preview"); - - long nTextBoxHeight(m_pAddrEdit->GetTextHeight() * 10); - long nTextBoxWidth(m_pAddrEdit->approximate_char_width() * 25); - - m_pAddrEdit->set_height_request(nTextBoxHeight); - m_pAddrEdit->set_width_request(nTextBoxWidth); - m_pSenderEdit->set_height_request(nTextBoxHeight); - m_pSenderEdit->set_width_request(nTextBoxWidth); - - long nListBoxWidth = approximate_char_width() * 30; - m_pTableLB->set_width_request(nListBoxWidth); - m_pDatabaseLB->set_width_request(nListBoxWidth); - m_pDBFieldLB->set_width_request(nListBoxWidth); + auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10)); + auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 20); + + m_xAddrEdit->set_size_request(nTextBoxWidth, nTextBoxHeight); + m_xSenderEdit->set_size_request(nTextBoxWidth, nTextBoxHeight); + + auto nListBoxWidth = m_xTableLB->get_approximate_digit_width() * 25; + m_xTableLB->set_size_request(nListBoxWidth, -1); + m_xDatabaseLB->set_size_request(nListBoxWidth, -1); + m_xDBFieldLB->set_size_request(nListBoxWidth, -1); SetExchangeSupport(); - pSh = GetParentSwEnvDlg()->pSh; +} + +void SwEnvPage::Init(SwEnvDlg* pDialog) +{ + m_pDialog = pDialog; + m_pSh = m_pDialog->pSh; + m_xPreview->SetDialog(pDialog); // Install handlers - m_pDatabaseLB->SetSelectHdl(LINK(this, SwEnvPage, DatabaseHdl )); - m_pTableLB->SetSelectHdl(LINK(this, SwEnvPage, DatabaseHdl )); - m_pInsertBT->SetClickHdl (LINK(this, SwEnvPage, FieldHdl )); - m_pSenderBox->SetClickHdl (LINK(this, SwEnvPage, SenderHdl )); - m_pPreview->SetBorderStyle( WindowBorderStyle::MONO ); - - SwDBData aData = pSh->GetDBData(); - sActDBName = aData.sDataSource + OUStringLiteral1(DB_DELIM) + aData.sCommand; + m_xDatabaseLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl)); + m_xTableLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl)); + m_xInsertBT->connect_clicked(LINK(this, SwEnvPage, FieldHdl)); + m_xSenderBox->connect_clicked(LINK(this, SwEnvPage, SenderHdl)); + + SwDBData aData = m_pSh->GetDBData(); + m_sActDBName = aData.sDataSource + OUStringLiteral1(DB_DELIM) + aData.sCommand; InitDatabaseBox(); } @@ -232,91 +244,78 @@ SwEnvPage::~SwEnvPage() disposeOnce(); } -void SwEnvPage::dispose() +IMPL_LINK( SwEnvPage, DatabaseHdl, weld::ComboBoxText&, rListBox, void ) { - m_pAddrEdit.clear(); - m_pDatabaseLB.clear(); - m_pTableLB.clear(); - m_pDBFieldLB.clear(); - m_pInsertBT.clear(); - m_pSenderBox.clear(); - m_pSenderEdit.clear(); - m_pPreview.clear(); - SfxTabPage::dispose(); -} - -IMPL_LINK( SwEnvPage, DatabaseHdl, ListBox&, rListBox, void ) -{ - SwWait aWait( *pSh->GetView().GetDocShell(), true ); + SwWait aWait( *m_pSh->GetView().GetDocShell(), true ); - if (&rListBox == m_pDatabaseLB) + if (&rListBox == m_xDatabaseLB.get()) { - sActDBName = rListBox.GetSelectedEntry(); - pSh->GetDBManager()->GetTableNames(m_pTableLB, sActDBName); - sActDBName += OUStringLiteral1(DB_DELIM); + m_sActDBName = rListBox.get_active_text(); + m_pSh->GetDBManager()->GetTableNames(*m_xTableLB, m_sActDBName); + m_sActDBName += OUStringLiteral1(DB_DELIM); } else { - sActDBName = comphelper::string::setToken(sActDBName, 1, DB_DELIM, m_pTableLB->GetSelectedEntry()); + m_sActDBName = comphelper::string::setToken(m_sActDBName, 1, DB_DELIM, m_xTableLB->get_active_text()); } - pSh->GetDBManager()->GetColumnNames(m_pDBFieldLB, m_pDatabaseLB->GetSelectedEntry(), - m_pTableLB->GetSelectedEntry()); + m_pSh->GetDBManager()->GetColumnNames(*m_xDBFieldLB, m_xDatabaseLB->get_active_text(), + m_xTableLB->get_active_text()); } -IMPL_LINK_NOARG(SwEnvPage, FieldHdl, Button*, void) +IMPL_LINK_NOARG(SwEnvPage, FieldHdl, weld::Button&, void) { - OUString aStr("<" + m_pDatabaseLB->GetSelectedEntry() + "." + - m_pTableLB->GetSelectedEntry() + "." + - OUString(m_pTableLB->GetSelectedEntryData() == nullptr ? '0' : '1') + "." + - m_pDBFieldLB->GetSelectedEntry() + ">"); - m_pAddrEdit->ReplaceSelected(aStr); - Selection aSel = m_pAddrEdit->GetSelection(); - m_pAddrEdit->GrabFocus(); - m_pAddrEdit->SetSelection(aSel); + OUString aStr("<" + m_xDatabaseLB->get_active_text() + "." + + m_xTableLB->get_active_text() + "." + + m_xTableLB->get_active_id() + "." + + m_xDBFieldLB->get_active_text() + ">"); + m_xAddrEdit->replace_selection(aStr); + int nStartPos, nEndPos; + m_xAddrEdit->get_selection_bounds(nStartPos, nEndPos); + m_xAddrEdit->grab_focus(); + m_xAddrEdit->select_region(nStartPos, nEndPos); } -IMPL_LINK_NOARG(SwEnvPage, SenderHdl, Button*, void) +IMPL_LINK_NOARG(SwEnvPage, SenderHdl, weld::Button&, void) { - const bool bEnable = m_pSenderBox->IsChecked(); + const bool bEnable = m_xSenderBox->get_active(); GetParentSwEnvDlg()->aEnvItem.m_bSend = bEnable; - m_pSenderEdit->Enable(bEnable); - if ( bEnable ) + m_xSenderEdit->set_sensitive(bEnable); + if (bEnable) { - m_pSenderEdit->GrabFocus(); - if(m_pSenderEdit->GetText().isEmpty()) - m_pSenderEdit->SetText(MakeSender()); + m_xSenderEdit->grab_focus(); + if (m_xSenderEdit->get_text().isEmpty()) + m_xSenderEdit->set_text(MakeSender()); } - m_pPreview->Invalidate(); + m_xPreview->queue_draw(); } void SwEnvPage::InitDatabaseBox() { - if (pSh->GetDBManager()) + if (m_pSh->GetDBManager()) { - m_pDatabaseLB->Clear(); + m_xDatabaseLB->clear(); Sequence<OUString> aDataNames = SwDBManager::GetExistingDatabaseNames(); const OUString* pDataNames = aDataNames.getConstArray(); - for (sal_Int32 i = 0; i < aDataNames.getLength(); i++) - m_pDatabaseLB->InsertEntry(pDataNames[i]); + for (sal_Int32 i = 0; i < aDataNames.getLength(); ++i) + m_xDatabaseLB->append_text(pDataNames[i]); - OUString sDBName = sActDBName.getToken( 0, DB_DELIM ); - OUString sTableName = sActDBName.getToken( 1, DB_DELIM ); - m_pDatabaseLB->SelectEntry(sDBName); - if (pSh->GetDBManager()->GetTableNames(m_pTableLB, sDBName)) + OUString sDBName = m_sActDBName.getToken( 0, DB_DELIM ); + OUString sTableName = m_sActDBName.getToken( 1, DB_DELIM ); + m_xDatabaseLB->set_active(sDBName); + if (m_pSh->GetDBManager()->GetTableNames(*m_xTableLB, sDBName)) { - m_pTableLB->SelectEntry(sTableName); - pSh->GetDBManager()->GetColumnNames(m_pDBFieldLB, sDBName, sTableName); + m_xTableLB->append_text(sTableName); + m_pSh->GetDBManager()->GetColumnNames(*m_xDBFieldLB, sDBName, sTableName); } else - m_pDBFieldLB->Clear(); - + m_xDBFieldLB->clear(); } } VclPtr<SfxTabPage> SwEnvPage::Create(TabPageParent pParent, const SfxItemSet* rSet) { - return VclPtr<SwEnvPage>::Create(pParent.pParent, *rSet); + return VclPtr<SwEnvPage>::Create(pParent, *rSet); } void SwEnvPage::ActivatePage(const SfxItemSet& rSet) @@ -336,9 +335,9 @@ DeactivateRC SwEnvPage::DeactivatePage(SfxItemSet* _pSet) void SwEnvPage::FillItem(SwEnvItem& rItem) { - rItem.m_aAddrText = m_pAddrEdit->GetText(); - rItem.m_bSend = m_pSenderBox->IsChecked(); - rItem.m_aSendText = m_pSenderEdit->GetText(); + rItem.m_aAddrText = m_xAddrEdit->get_text(); + rItem.m_bSend = m_xSenderBox->get_active(); + rItem.m_aSendText = m_xSenderEdit->get_text(); } bool SwEnvPage::FillItemSet(SfxItemSet* rSet) @@ -351,10 +350,10 @@ bool SwEnvPage::FillItemSet(SfxItemSet* rSet) void SwEnvPage::Reset(const SfxItemSet* rSet) { SwEnvItem aItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP)); - m_pAddrEdit->SetText(convertLineEnd(aItem.m_aAddrText, GetSystemLineEnd())); - m_pSenderEdit->SetText(convertLineEnd(aItem.m_aSendText, GetSystemLineEnd())); - m_pSenderBox->Check (aItem.m_bSend); - m_pSenderBox->GetClickHdl().Call(m_pSenderBox); + m_xAddrEdit->set_text(convertLineEnd(aItem.m_aAddrText, GetSystemLineEnd())); + m_xSenderEdit->set_text(convertLineEnd(aItem.m_aSendText, GetSystemLineEnd())); + m_xSenderBox->set_active(aItem.m_bSend); + SenderHdl(*m_xSenderBox); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/envelp/envprt.cxx b/sw/source/ui/envelp/envprt.cxx index 7605bd485354..fee13aabad94 100644 --- a/sw/source/ui/envelp/envprt.cxx +++ b/sw/source/ui/envelp/envprt.cxx @@ -19,6 +19,7 @@ #include <vcl/print.hxx> #include <svtools/prnsetup.hxx> +#include <svtools/unitconv.hxx> #include <swtypes.hxx> #include <cmdid.h> @@ -28,42 +29,49 @@ #include <bitmaps.hlst> -SwEnvPrtPage::SwEnvPrtPage(vcl::Window* pParent, const SfxItemSet& rSet) - : SfxTabPage(pParent, "EnvPrinterPage", - "modules/swriter/ui/envprinterpage.ui", &rSet) - , pPrt(nullptr) +SwEnvPrtPage::SwEnvPrtPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "modules/swriter/ui/envprinterpage.ui", "EnvPrinterPage", &rSet) + , m_xUpper(m_xBuilder->weld_widget("upper")) + , m_xLower(m_xBuilder->weld_widget("lower")) + , m_xTopButton(m_xBuilder->weld_radio_button("top")) + , m_xBottomButton(m_xBuilder->weld_radio_button("bottom")) + , m_xRightField(m_xBuilder->weld_metric_spin_button("right", FUNIT_CM)) + , m_xDownField(m_xBuilder->weld_metric_spin_button("down", FUNIT_CM)) + , m_xPrinterInfo(m_xBuilder->weld_label("printername")) + , m_xPrtSetup(m_xBuilder->weld_button("setup")) + , m_aIdsL { std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horileftl")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horicenterl")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horirightl")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertleftl")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertcenterl")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertrightl")) } + , m_aIdsU { std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horileftu")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horicenteru")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("horirightu")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertleftu")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertcenteru")), + std::unique_ptr<weld::RadioButton>(m_xBuilder->weld_radio_button("vertrightu")) } { - get(m_pAlignBox, "alignbox"); - get(m_pTopButton, "top"); - get(m_pBottomButton, "bottom"); - get(m_pRightField, "right"); - get(m_pDownField, "down"); - get(m_pPrinterInfo, "printername"); - get(m_pPrtSetup, "setup"); SetExchangeSupport(); // Metrics FieldUnit eUnit = ::GetDfltMetric(false); - SetMetric(*m_pRightField, eUnit); - SetMetric(*m_pDownField, eUnit); + ::SetFieldUnit(*m_xRightField, eUnit); + ::SetFieldUnit(*m_xDownField, eUnit); // Install handlers - m_pTopButton->SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl)); - m_pBottomButton->SetClickHdl(LINK(this, SwEnvPrtPage, ClickHdl)); + m_xTopButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl)); + m_xBottomButton->connect_toggled(LINK(this, SwEnvPrtPage, ClickHdl)); - m_pPrtSetup->SetClickHdl(LINK(this, SwEnvPrtPage, ButtonHdl)); + m_xPrtSetup->connect_clicked(LINK(this, SwEnvPrtPage, ButtonHdl)); + + for (auto& a : m_aIdsL) + a->connect_toggled(LINK(this, SwEnvPrtPage, LowerHdl)); + for (auto& a : m_aIdsU) + a->connect_toggled(LINK(this, SwEnvPrtPage, UpperHdl)); // Bitmaps - m_pBottomButton->GetClickHdl().Call(m_pBottomButton); - - // ToolBox - m_pAlignBox->SetClickHdl(LINK(this, SwEnvPrtPage, AlignHdl)); - m_aIds[ENV_HOR_LEFT] = m_pAlignBox->GetItemId("horileft"); - m_aIds[ENV_HOR_CNTR] = m_pAlignBox->GetItemId("horicenter"); - m_aIds[ENV_HOR_RGHT] = m_pAlignBox->GetItemId("horiright"); - m_aIds[ENV_VER_LEFT] = m_pAlignBox->GetItemId("vertleft"); - m_aIds[ENV_VER_CNTR] = m_pAlignBox->GetItemId("vertcenter"); - m_aIds[ENV_VER_RGHT] = m_pAlignBox->GetItemId("vertright"); + ClickHdl(*m_xBottomButton); } SwEnvPrtPage::~SwEnvPrtPage() @@ -71,84 +79,63 @@ SwEnvPrtPage::~SwEnvPrtPage() disposeOnce(); } -void SwEnvPrtPage::dispose() +IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl, weld::ToggleButton&, void) { - m_pAlignBox.clear(); - m_pTopButton.clear(); - m_pBottomButton.clear(); - m_pRightField.clear(); - m_pDownField.clear(); - m_pPrinterInfo.clear(); - m_pPrtSetup.clear(); - pPrt.clear(); - SfxTabPage::dispose(); + // Envelope from bottom, otherwise Envelope from top + const bool bLowerActive = m_xBottomButton->get_active(); + m_xUpper->show(!bLowerActive); + m_xLower->show(bLowerActive); } -IMPL_LINK_NOARG(SwEnvPrtPage, ClickHdl, Button*, void) +IMPL_LINK(SwEnvPrtPage, LowerHdl, weld::ToggleButton&, rButton, void) { - if (m_pBottomButton->IsChecked()) - { - // Envelope from bottom - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(BitmapEx(BMP_HOR_LEFT_LOWER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(BitmapEx(BMP_HOR_CNTR_LOWER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(BitmapEx(BMP_HOR_RGHT_LOWER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(BitmapEx(BMP_VER_LEFT_LOWER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(BitmapEx(BMP_VER_CNTR_LOWER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(BitmapEx(BMP_VER_RGHT_LOWER))); - } - else + for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i) { - // Envelope from top - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_LEFT], Image(BitmapEx(BMP_HOR_LEFT_UPPER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_CNTR], Image(BitmapEx(BMP_HOR_CNTR_UPPER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_HOR_RGHT], Image(BitmapEx(BMP_HOR_RGHT_UPPER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_LEFT], Image(BitmapEx(BMP_VER_LEFT_UPPER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_CNTR], Image(BitmapEx(BMP_VER_CNTR_UPPER))); - m_pAlignBox->SetItemImage(m_aIds[ENV_VER_RGHT], Image(BitmapEx(BMP_VER_RGHT_UPPER))); + if (&rButton == m_aIdsL[i].get()) + { + m_aIdsU[i]->set_active(m_aIdsL[i]->get_active()); + break; + } } } -IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn, void ) +IMPL_LINK(SwEnvPrtPage, UpperHdl, weld::ToggleButton&, rButton, void) { - if (pBtn == m_pPrtSetup) + for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i) { - // Call printer setup - if (pPrt) + if (&rButton == m_aIdsU[i].get()) { - PrinterSetupDialog aDlg(GetFrameWeld()); - aDlg.SetPrinter(pPrt); - aDlg.execute(); - GrabFocus(); - m_pPrinterInfo->SetText(pPrt->GetName()); + m_aIdsL[i]->set_active(m_aIdsU[i]->get_active()); + break; } } } -IMPL_LINK_NOARG(SwEnvPrtPage, AlignHdl, ToolBox *, void) +IMPL_LINK(SwEnvPrtPage, ButtonHdl, weld::Button&, rBtn, void) { - if (m_pAlignBox->GetCurItemId()) - { - for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i) - m_pAlignBox->CheckItem(m_aIds[i], false); - m_pAlignBox->CheckItem(m_pAlignBox->GetCurItemId()); - } - else + if (&rBtn == m_xPrtSetup.get()) { - // GetCurItemId() == 0 is possible! - const SwEnvItem& rItem = static_cast<const SwEnvItem&>( GetItemSet().Get(FN_ENVELOP) ); - m_pAlignBox->CheckItem(m_aIds[rItem.m_eAlign]); + // Call printer setup + if (m_xPrt) + { + PrinterSetupDialog aDlg(GetTabDialog()->GetFrameWeld()); + aDlg.SetPrinter(m_xPrt); + aDlg.execute(); + rBtn.grab_focus(); + m_xPrinterInfo->set_label(m_xPrt->GetName()); + } } } VclPtr<SfxTabPage> SwEnvPrtPage::Create(TabPageParent pParent, const SfxItemSet* rSet) { - return VclPtr<SwEnvPrtPage>::Create(pParent.pParent, *rSet); + return VclPtr<SwEnvPrtPage>::Create(pParent, *rSet); } void SwEnvPrtPage::ActivatePage(const SfxItemSet&) { - if (pPrt) - m_pPrinterInfo->SetText(pPrt->GetName()); + if (m_xPrt) + m_xPrinterInfo->set_label(m_xPrt->GetName()); } DeactivateRC SwEnvPrtPage::DeactivatePage(SfxItemSet* _pSet) @@ -163,7 +150,8 @@ void SwEnvPrtPage::FillItem(SwEnvItem& rItem) int nOrient = 0; for (int i = ENV_HOR_LEFT; i <= ENV_VER_RGHT; ++i) { - if (m_pAlignBox->IsItemChecked(m_aIds[i])) + assert(m_aIdsL[i]->get_active() == m_aIdsU[i]->get_active()); + if (m_aIdsL[i]->get_active()) { nOrient = i; break; @@ -171,9 +159,9 @@ void SwEnvPrtPage::FillItem(SwEnvItem& rItem) } rItem.m_eAlign = static_cast<SwEnvAlign>(nOrient); - rItem.m_bPrintFromAbove = m_pTopButton->IsChecked(); - rItem.m_nShiftRight = static_cast< sal_Int32 >(GetFieldVal(*m_pRightField)); - rItem.m_nShiftDown = static_cast< sal_Int32 >(GetFieldVal(*m_pDownField )); + rItem.m_bPrintFromAbove = m_xTopButton->get_active(); + rItem.m_nShiftRight = getfieldval(*m_xRightField); + rItem.m_nShiftDown = getfieldval(*m_xDownField); } bool SwEnvPrtPage::FillItemSet(SfxItemSet* rSet) @@ -187,18 +175,19 @@ void SwEnvPrtPage::Reset(const SfxItemSet* rSet) { // Read item const SwEnvItem& rItem = static_cast<const SwEnvItem&>( rSet->Get(FN_ENVELOP) ); - m_pAlignBox->CheckItem(m_aIds[rItem.m_eAlign]); + m_aIdsL[rItem.m_eAlign]->set_active(true); + m_aIdsU[rItem.m_eAlign]->set_active(true); if (rItem.m_bPrintFromAbove) - m_pTopButton->Check(); + m_xTopButton->set_active(true); else - m_pBottomButton->Check(); + m_xBottomButton->set_active(true); - SetFieldVal(*m_pRightField, rItem.m_nShiftRight); - SetFieldVal(*m_pDownField , rItem.m_nShiftDown ); + setfieldval(*m_xRightField, rItem.m_nShiftRight); + setfieldval(*m_xDownField , rItem.m_nShiftDown ); ActivatePage(*rSet); - ClickHdl(m_pTopButton); + ClickHdl(*m_xTopButton); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/envelp/envprt.hxx b/sw/source/ui/envelp/envprt.hxx index 8d70bb97c89b..94b7d0886eef 100644 --- a/sw/source/ui/envelp/envprt.hxx +++ b/sw/source/ui/envelp/envprt.hxx @@ -21,12 +21,7 @@ #define INCLUDED_SW_SOURCE_UI_ENVELP_ENVPRT_HXX #include <sfx2/tabdlg.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/field.hxx> -#include <vcl/fixed.hxx> -#include <vcl/group.hxx> -#include <vcl/button.hxx> -#include <vcl/print.hxx> +#include <vcl/weld.hxx> #include <envimg.hxx> #include <envlop.hxx> @@ -35,31 +30,39 @@ class SwEnvDlg; class SwEnvPrtPage : public SfxTabPage { - VclPtr<ToolBox> m_pAlignBox; - VclPtr<RadioButton> m_pTopButton; - VclPtr<RadioButton> m_pBottomButton; - VclPtr<MetricField> m_pRightField; - VclPtr<MetricField> m_pDownField; - VclPtr<FixedText> m_pPrinterInfo; - VclPtr<PushButton> m_pPrtSetup; + std::unique_ptr<weld::Widget> m_xUpper; + std::unique_ptr<weld::Widget> m_xLower; + std::unique_ptr<weld::RadioButton> m_xTopButton; + std::unique_ptr<weld::RadioButton> m_xBottomButton; + std::unique_ptr<weld::MetricSpinButton> m_xRightField; + std::unique_ptr<weld::MetricSpinButton> m_xDownField; + std::unique_ptr<weld::Label> m_xPrinterInfo; + std::unique_ptr<weld::Button> m_xPrtSetup; - sal_uInt16 m_aIds[ENV_VER_RGHT-ENV_HOR_LEFT+1]; + std::unique_ptr<weld::RadioButton> m_aIdsL[ENV_VER_RGHT-ENV_HOR_LEFT+1]; + std::unique_ptr<weld::RadioButton> m_aIdsU[ENV_VER_RGHT-ENV_HOR_LEFT+1]; - VclPtr<Printer> pPrt; + VclPtr<Printer> m_xPrt; - DECL_LINK(ClickHdl, Button*, void); - DECL_LINK(AlignHdl, ToolBox *, void); - DECL_LINK(ButtonHdl, Button *, void ); + DECL_LINK(LowerHdl, weld::ToggleButton&, void); + DECL_LINK(UpperHdl, weld::ToggleButton&, void); + DECL_LINK(ClickHdl, weld::ToggleButton&, void); + DECL_LINK(AlignHdl, weld::ToggleButton&, void); + DECL_LINK(ButtonHdl, weld::Button&, void ); - SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>( GetParentDialog());} + SwEnvDlg* GetParentSwEnvDlg() {return static_cast<SwEnvDlg*>(GetTabDialog()); } using TabPage::ActivatePage; using TabPage::DeactivatePage; public: - SwEnvPrtPage(vcl::Window* pParent, const SfxItemSet& rSet); + SwEnvPrtPage(TabPageParent pParent, const SfxItemSet& rSet); + virtual void dispose() override + { + m_xPrt.clear(); + SfxTabPage::dispose(); + } virtual ~SwEnvPrtPage() override; - virtual void dispose() override; static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet); @@ -69,7 +72,7 @@ public: virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - void SetPrt(Printer* pPrinter) { pPrt = pPrinter; } + void SetPrt(Printer* pPrinter) { m_xPrt = pPrinter; } }; #endif |