diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-24 14:14:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-27 09:54:08 +0200 |
commit | 28fc0962b10519ab84654d189d2ad0cca8f84f95 (patch) | |
tree | ff2b008cb13f69724abfff62157c6a4e133135a2 /sw/source/ui/envelp | |
parent | 3d97c9d292d80cb82391bdb416a9c6217a8e16e4 (diff) |
weld SwLabDlg
Change-Id: I55c543776c03b1d1da0331552b98e6e281e35937
Reviewed-on: https://gerrit.libreoffice.org/53488
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/label1.cxx | 76 | ||||
-rw-r--r-- | sw/source/ui/envelp/labfmt.cxx | 20 | ||||
-rw-r--r-- | sw/source/ui/envelp/labfmt.hxx | 4 | ||||
-rw-r--r-- | sw/source/ui/envelp/labprt.hxx | 2 | ||||
-rw-r--r-- | sw/source/ui/envelp/swuilabimp.hxx | 2 |
5 files changed, 51 insertions, 53 deletions
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx index edca19a60979..c8768e85b995 100644 --- a/sw/source/ui/envelp/label1.cxx +++ b/sw/source/ui/envelp/label1.cxx @@ -75,11 +75,11 @@ void SwLabDlg::ReplaceGroup_( const OUString &rMake ) aLstGroup = rMake; } -void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) +void SwLabDlg::PageCreated(const OString &rId, SfxTabPage &rPage) { - if (nId == m_nLabelId) + if (rId == "labels") { - if(m_bLabel) + if (m_bLabel) { static_cast<SwLabPage*>(&rPage)->SetDBManager(pDBManager); static_cast<SwLabPage*>(&rPage)->InitDatabaseBox(); @@ -87,43 +87,21 @@ void SwLabDlg::PageCreated(sal_uInt16 nId, SfxTabPage &rPage) else static_cast<SwLabPage*>(&rPage)->SetToBusinessCard(); } - else if (nId == m_nOptionsId) + else if (rId == "options") pPrtPage = static_cast<SwLabPrtPage*>(&rPage); } -SwLabDlg::SwLabDlg(vcl::Window* pParent, const SfxItemSet& rSet, +SwLabDlg::SwLabDlg(weld::Window* pParent, const SfxItemSet& rSet, SwDBManager* pDBManager_, bool bLabel) - : SfxTabDialog(pParent, "LabelDialog", - "modules/swriter/ui/labeldialog.ui", &rSet) + : SfxTabDialogController(pParent, "modules/swriter/ui/labeldialog.ui", "LabelDialog", &rSet) , pDBManager(pDBManager_) , pPrtPage(nullptr) , aTypeIds(50, 10) , m_pRecs(new SwLabRecs) , m_bLabel(bLabel) - , m_nOptionsId(0) - , m_nLabelId(0) { - WaitObject aWait( pParent ); + weld::WaitObject aWait(pParent); - AddTabPage("format", SwLabFormatPage::Create, nullptr); - m_nOptionsId = AddTabPage("options", SwLabPrtPage::Create, nullptr); - m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS); - - if (m_bLabel) - { - RemoveTabPage("business"); - RemoveTabPage("private"); - RemoveTabPage("medium"); - m_nLabelId = AddTabPage("labels", SwLabPage::Create, nullptr); - } - else - { - RemoveTabPage("labels"); - m_nLabelId = AddTabPage("medium", SwLabPage::Create, nullptr); - AddTabPage("business", SwBusinessDataPage::Create, nullptr ); - AddTabPage("private", SwPrivateDataPage::Create, nullptr); - SetText(m_sBusinessCardDlg); - } // Read user label from writer.cfg SwLabItem aItem(static_cast<const SwLabItem&>(rSet.Get( FN_LABEL ))); std::unique_ptr<SwLabRec> pRec(new SwLabRec); @@ -159,18 +137,33 @@ SwLabDlg::SwLabDlg(vcl::Window* pParent, const SfxItemSet& rSet, if (m_pExampleSet) m_pExampleSet->Put(aItem); -} -SwLabDlg::~SwLabDlg() -{ - disposeOnce(); + AddTabPage("format", SwLabFormatPage::Create, nullptr); + AddTabPage("options", SwLabPrtPage::Create, nullptr); + m_sBusinessCardDlg = SwResId(STR_BUSINESS_CARDS); + + if (m_bLabel) + { + RemoveTabPage("business"); + RemoveTabPage("private"); + RemoveTabPage("medium"); + AddTabPage("labels", SwLabPage::Create, nullptr); + } + else + { + RemoveTabPage("labels"); + AddTabPage("medium", SwLabPage::Create, nullptr); + AddTabPage("business", SwBusinessDataPage::Create, nullptr ); + AddTabPage("private", SwPrivateDataPage::Create, nullptr); + m_xDialog->set_title(m_sBusinessCardDlg); + } + + pParent->set_busy_cursor(false); } -void SwLabDlg::dispose() +SwLabDlg::~SwLabDlg() { delete m_pRecs; - pPrtPage.clear(); - SfxTabDialog::dispose(); } void SwLabDlg::GetLabItem(SwLabItem &rItem) @@ -267,6 +260,9 @@ SwLabPage::SwLabPage(TabPageParent pParent, const SfxItemSet& rSet) m_xInsertBT->set_sensitive(false); m_xContButton->connect_toggled(LINK(this, SwLabPage, PageHdl)); m_xSheetButton->connect_toggled(LINK(this, SwLabPage, PageHdl)); + auto nMaxWidth = m_xMakeBox->get_approximate_digit_width() * 32; + m_xMakeBox->set_size_request(nMaxWidth, -1); + m_xTypeBox->set_size_request(nMaxWidth, -1); m_xMakeBox->connect_changed(LINK(this, SwLabPage, MakeHdl)); m_xTypeBox->connect_changed(LINK(this, SwLabPage, TypeHdl)); @@ -302,7 +298,7 @@ IMPL_LINK( SwLabPage, DatabaseHdl, weld::ComboBoxText&, rListBox, void ) { sActDBName = m_xDatabaseLB->get_active_text(); - WaitObject aObj( GetParentSwLabDlg() ); + weld::WaitObject aObj(GetParentSwLabDlg()->getDialog()); if (&rListBox == m_xDatabaseLB.get()) GetDBManager()->GetTableNames(*m_xTableLB, sActDBName); @@ -337,7 +333,7 @@ IMPL_LINK_NOARG(SwLabPage, PageHdl, weld::ToggleButton&, void) IMPL_LINK_NOARG(SwLabPage, MakeHdl, weld::ComboBoxText&, void) { - WaitObject aWait( GetParentSwLabDlg() ); + weld::WaitObject aWait(GetParentSwLabDlg()->getDialog()); m_xTypeBox->clear(); m_xHiddenSortTypeBox->clear(); @@ -595,7 +591,7 @@ DeactivateRC SwPrivateDataPage::DeactivatePage(SfxItemSet* _pSet) bool SwPrivateDataPage::FillItemSet(SfxItemSet* rSet) { - SwLabItem aItem = static_cast<const SwLabItem&>( GetTabDialog()->GetExampleSet()->Get(FN_LABEL) ); + SwLabItem aItem = static_cast<const SwLabItem&>(GetDialogController()->GetExampleSet()->Get(FN_LABEL)); aItem.m_aPrivFirstName = m_xFirstNameED->get_text(); aItem.m_aPrivName = m_xNameED->get_text(); aItem.m_aPrivShortCut = m_xShortCutED->get_text(); @@ -685,7 +681,7 @@ DeactivateRC SwBusinessDataPage::DeactivatePage(SfxItemSet* _pSet) bool SwBusinessDataPage::FillItemSet(SfxItemSet* rSet) { - SwLabItem aItem = static_cast<const SwLabItem&>( GetTabDialog()->GetExampleSet()->Get(FN_LABEL) ); + SwLabItem aItem = static_cast<const SwLabItem&>(GetDialogController()->GetExampleSet()->Get(FN_LABEL)); aItem.m_aCompCompany = m_xCompanyED->get_text(); aItem.m_aCompCompanyExt= m_xCompanyExtED->get_text(); diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx index 8c4d038aed5f..b016700362f0 100644 --- a/sw/source/ui/envelp/labfmt.cxx +++ b/sw/source/ui/envelp/labfmt.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <svtools/unitconv.hxx> #include <tools/poly.hxx> #include <vcl/weld.hxx> #include <vcl/settings.hxx> @@ -153,6 +154,7 @@ IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.SetFont(aFont); rRenderContext.SetBackground(Wallpaper(rWinColor)); + rRenderContext.Erase(); rRenderContext.SetLineColor(rWinColor); rRenderContext.SetFillColor(m_aGrayColor); @@ -301,14 +303,14 @@ SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet) // Metrics FieldUnit aMetric = ::GetDfltMetric(false); - SetMetric(*m_xHDistField, aMetric); - SetMetric(*m_xVDistField , aMetric); - SetMetric(*m_xWidthField , aMetric); - SetMetric(*m_xHeightField, aMetric); - SetMetric(*m_xLeftField , aMetric); - SetMetric(*m_xUpperField , aMetric); - SetMetric(*m_xPWidthField , aMetric); - SetMetric(*m_xPHeightField, aMetric); + ::SetFieldUnit(*m_xHDistField, aMetric); + ::SetFieldUnit(*m_xVDistField , aMetric); + ::SetFieldUnit(*m_xWidthField , aMetric); + ::SetFieldUnit(*m_xHeightField, aMetric); + ::SetFieldUnit(*m_xLeftField , aMetric); + ::SetFieldUnit(*m_xUpperField , aMetric); + ::SetFieldUnit(*m_xPWidthField , aMetric); + ::SetFieldUnit(*m_xPHeightField, aMetric); // Install handlers Link<weld::MetricSpinButton&,void> aLk = LINK(this, SwLabFormatPage, MetricModifyHdl); @@ -509,7 +511,7 @@ IMPL_LINK_NOARG(SwLabFormatPage, SaveHdl, weld::Button&, void) } SwSaveLabelDlg::SwSaveLabelDlg(SwLabDlg* pParent, SwLabRec& rRec) - : GenericDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog") + : GenericDialogController(pParent->getDialog(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog") , bSuccess(false) , m_pLabDialog(pParent) , rLabRec(rRec) diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx index 81e79351ce16..1be3737a1e0b 100644 --- a/sw/source/ui/envelp/labfmt.hxx +++ b/sw/source/ui/envelp/labfmt.hxx @@ -108,13 +108,13 @@ public: virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} }; class SwSaveLabelDlg : public weld::GenericDialogController { bool bSuccess; - VclPtr<SwLabDlg> m_pLabDialog; + SwLabDlg* m_pLabDialog; SwLabRec& rLabRec; std::unique_ptr<weld::ComboBoxText> m_xMakeCB; diff --git a/sw/source/ui/envelp/labprt.hxx b/sw/source/ui/envelp/labprt.hxx index d4dc36d0dfab..aecc2d7b8b64 100644 --- a/sw/source/ui/envelp/labprt.hxx +++ b/sw/source/ui/envelp/labprt.hxx @@ -44,7 +44,7 @@ class SwLabPrtPage : public SfxTabPage DECL_LINK( CountHdl, weld::Button&, void ); - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} using TabPage::ActivatePage; using TabPage::DeactivatePage; diff --git a/sw/source/ui/envelp/swuilabimp.hxx b/sw/source/ui/envelp/swuilabimp.hxx index a2057557461e..8fe65957ee95 100644 --- a/sw/source/ui/envelp/swuilabimp.hxx +++ b/sw/source/ui/envelp/swuilabimp.hxx @@ -69,7 +69,7 @@ public: virtual bool FillItemSet(SfxItemSet* rSet) override; virtual void Reset(const SfxItemSet* rSet) override; - SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());} + SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetDialogController());} void SetToBusinessCard(); |