[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - sfx2/source sw/source vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 22 13:24:51 PDT 2012
sfx2/source/dialog/tabdlg.cxx | 21 ++++++++++-----------
sw/source/ui/misc/linenum.cxx | 38 +++++++++++++++++++-------------------
sw/source/ui/misc/titlepage.cxx | 24 ++++++++++++------------
vcl/inc/vcl/builder.hxx | 34 +++++++++++++++++++++++++++++++++-
vcl/source/window/builder.cxx | 8 ++++----
5 files changed, 78 insertions(+), 47 deletions(-)
New commits:
commit 4c38e508206348a7923d042261c7a9cdeca4f98d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Aug 22 21:18:52 2012 +0100
get_by_name -> get and pretty up widget type casting
Like Noel G points out, it's not like there any other way to get
a widget other than "by_name"
Change-Id: Iefe2a16472e2916dbeba1ba3c0c115cc6416ab5b
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 4b3e06f..f66627a 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -524,8 +524,7 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const String* pUserButtonText,
*/
{
- fprintf(stderr, "BUILDER is %p\n", m_pUIBuilder);
- m_pVBox = m_pUIBuilder ? static_cast<VclVBox*>(m_pUIBuilder->get_by_name("dialog-vbox1")) : NULL;
+ m_pVBox = m_pUIBuilder ? m_pUIBuilder->get<VclVBox>("dialog-vbox1") : NULL;
m_bOwnsVBox = m_pVBox == NULL;
if (m_bOwnsVBox)
{
@@ -533,7 +532,7 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const String* pUserButtonText,
m_pVBox->set_expand(true);
}
- m_pTabCtrl = m_pUIBuilder ? static_cast<TabControl*>(m_pUIBuilder->get_by_name(SAL_STRINGIFY(ID_TABCONTROL))) : NULL;
+ m_pTabCtrl = m_pUIBuilder ? m_pUIBuilder->get<TabControl>(SAL_STRINGIFY(ID_TABCONTROL)) : NULL;
m_bOwnsTabCtrl = m_pTabCtrl == NULL;
if (m_bOwnsTabCtrl)
{
@@ -541,42 +540,42 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const String* pUserButtonText,
m_pTabCtrl->set_expand(true);
}
- m_pActionArea = m_pUIBuilder ? static_cast<VclHButtonBox*>(m_pUIBuilder->get_by_name("dialog-action_area1")) : NULL;
+ m_pActionArea = m_pUIBuilder ? m_pUIBuilder->get<VclHButtonBox>("dialog-action_area1") : NULL;
m_bOwnsActionArea = m_pActionArea == NULL;
if (m_bOwnsActionArea)
m_pActionArea = new VclHButtonBox(m_pVBox);
- m_pOKBtn = m_pUIBuilder ? static_cast<OKButton*>(m_pUIBuilder->get_by_name("ok")) : NULL;
+ m_pOKBtn = m_pUIBuilder ? m_pUIBuilder->get<OKButton>("ok") : NULL;
m_bOwnsOKBtn = m_pOKBtn == NULL;
if (m_bOwnsOKBtn)
m_pOKBtn = new OKButton(m_pActionArea);
- m_pApplyBtn = m_pUIBuilder ? static_cast<PushButton*>(m_pUIBuilder->get_by_name("apply")) : NULL;
+ m_pApplyBtn = m_pUIBuilder ? m_pUIBuilder->get<PushButton>("apply") : NULL;
m_bOwnsApplyBtn = m_pApplyBtn == NULL;
if (m_bOwnsApplyBtn)
m_pApplyBtn = NULL;
- m_pUserBtn = m_pUIBuilder ? static_cast<PushButton*>(m_pUIBuilder->get_by_name("user")) : NULL;
+ m_pUserBtn = m_pUIBuilder ? m_pUIBuilder->get<PushButton>("user") : NULL;
m_bOwnsUserBtn = m_pUserBtn == NULL;
if (m_bOwnsUserBtn)
m_pUserBtn = pUserButtonText ? new PushButton(m_pActionArea) : NULL;
- m_pCancelBtn = m_pUIBuilder ? static_cast<CancelButton*>(m_pUIBuilder->get_by_name("cancel")) : NULL;
+ m_pCancelBtn = m_pUIBuilder ? m_pUIBuilder->get<CancelButton>("cancel") : NULL;
m_bOwnsCancelBtn = m_pCancelBtn == NULL;
if (m_bOwnsCancelBtn)
m_pCancelBtn = new CancelButton(m_pActionArea);
- m_pHelpBtn = m_pUIBuilder ? static_cast<HelpButton*>(m_pUIBuilder->get_by_name("help")) : NULL;
+ m_pHelpBtn = m_pUIBuilder ? m_pUIBuilder->get<HelpButton>("help") : NULL;
m_bOwnsHelpBtn = m_pHelpBtn == NULL;
if (m_bOwnsHelpBtn)
m_pHelpBtn = new HelpButton(m_pActionArea);
- m_pResetBtn = m_pUIBuilder ? static_cast<PushButton*>(m_pUIBuilder->get_by_name("reset")) : NULL;
+ m_pResetBtn = m_pUIBuilder ? m_pUIBuilder->get<PushButton>("reset") : NULL;
m_bOwnsResetBtn = m_pResetBtn == NULL;
if (m_bOwnsResetBtn)
m_pResetBtn = new PushButton(m_pActionArea);
- m_pBaseFmtBtn = m_pUIBuilder ? static_cast<PushButton*>(m_pUIBuilder->get_by_name("standard")) : NULL;
+ m_pBaseFmtBtn = m_pUIBuilder ? m_pUIBuilder->get<PushButton>("standard") : NULL;
m_bOwnsBaseFmtBtn = m_pBaseFmtBtn == NULL;
if (m_bOwnsBaseFmtBtn)
m_pBaseFmtBtn = new PushButton(m_pActionArea);
diff --git a/sw/source/ui/misc/linenum.cxx b/sw/source/ui/misc/linenum.cxx
index c28c631..45ceb9d 100644
--- a/sw/source/ui/misc/linenum.cxx
+++ b/sw/source/ui/misc/linenum.cxx
@@ -50,24 +50,24 @@
#include <IDocumentStylePoolAccess.hxx>
SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
- : SfxModalDialog( &pVw->GetViewFrame()->GetWindow(), rtl::OString("LineNumberingDialog"),
- rtl::OUString("modules/swriter/ui/linenumbering.ui") )
+ : SfxModalDialog( &pVw->GetViewFrame()->GetWindow(), "LineNumberingDialog",
+ "modules/swriter/ui/linenumbering.ui" )
, pSh(pVw->GetWrtShellPtr())
{
- m_pBodyContent = static_cast<VclContainer*>(m_pUIBuilder->get_by_name("content"));
- m_pDivIntervalFT = m_pUIBuilder->get_by_name("every");
- m_pDivIntervalNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("linesspin"));
- m_pDivRowsFT = m_pUIBuilder->get_by_name("lines");
- m_pNumIntervalNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("intervalspin"));
- m_pCharStyleLB = static_cast<ListBox*>(m_pUIBuilder->get_by_name("styledropdown"));
- m_pFormatLB = static_cast<SwNumberingTypeListBox*>(m_pUIBuilder->get_by_name("formatdropdown"));
- m_pPosLB = static_cast<ListBox*>(m_pUIBuilder->get_by_name("positiondropdown"));
- m_pOffsetMF = static_cast<MetricField*>(m_pUIBuilder->get_by_name("spacingspin"));
- m_pDivisorED = static_cast<Edit*>(m_pUIBuilder->get_by_name("textentry"));
- m_pCountEmptyLinesCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("blanklines"));
- m_pCountFrameLinesCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("linesintextframes"));
- m_pRestartEachPageCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("restarteverynewpage"));
- m_pNumberingOnCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("shownumbering"));
+ m_pUIBuilder->get(m_pBodyContent, "content");
+ m_pUIBuilder->get(m_pDivIntervalFT, "every");
+ m_pUIBuilder->get(m_pDivIntervalNF, "linesspin");
+ m_pUIBuilder->get(m_pDivRowsFT, "lines");
+ m_pUIBuilder->get(m_pNumIntervalNF, "intervalspin");
+ m_pUIBuilder->get(m_pCharStyleLB, "styledropdown");
+ m_pUIBuilder->get(m_pFormatLB, "formatdropdown");
+ m_pUIBuilder->get(m_pPosLB, "positiondropdown");
+ m_pUIBuilder->get(m_pOffsetMF, "spacingspin");
+ m_pUIBuilder->get(m_pDivisorED, "textentry");
+ m_pUIBuilder->get(m_pCountEmptyLinesCB, "blanklines");
+ m_pUIBuilder->get(m_pCountFrameLinesCB, "linesintextframes");
+ m_pUIBuilder->get(m_pRestartEachPageCB, "restarteverynewpage");
+ m_pUIBuilder->get(m_pNumberingOnCB, "shownumbering");
String sIntervalName = m_pDivIntervalFT->GetAccessibleName();
sIntervalName += String::CreateFromAscii("(");
@@ -75,8 +75,8 @@ SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
sIntervalName += String::CreateFromAscii(")");
m_pDivIntervalNF->SetAccessibleName(sIntervalName);
- Window *pNumIntervalFT = m_pUIBuilder->get_by_name("interval");
- Window *pNumRowsFT = m_pUIBuilder->get_by_name("intervallines");
+ Window *pNumIntervalFT = m_pUIBuilder->get("interval");
+ Window *pNumRowsFT = m_pUIBuilder->get("intervallines");
sIntervalName = pNumIntervalFT->GetAccessibleName();
sIntervalName += String::CreateFromAscii("(");
sIntervalName += pNumRowsFT->GetAccessibleName();
@@ -139,7 +139,7 @@ SwLineNumberingDlg::SwLineNumberingDlg(SwView *pVw)
ModifyHdl();
LineOnOffHdl();
- PushButton *pOkPB = static_cast<PushButton*>(m_pUIBuilder->get_by_name("ok"));
+ PushButton *pOkPB = m_pUIBuilder->get<PushButton>("ok");
pOkPB->SetClickHdl(LINK(this, SwLineNumberingDlg, OKHdl));
}
diff --git a/sw/source/ui/misc/titlepage.cxx b/sw/source/ui/misc/titlepage.cxx
index bad9f4f..fd9086a 100644
--- a/sw/source/ui/misc/titlepage.cxx
+++ b/sw/source/ui/misc/titlepage.cxx
@@ -156,18 +156,18 @@ SwTitlePageDlg::SwTitlePageDlg( Window *pParent ) :
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("modules/swriter/ui/titlepage.ui")) ),
mpPageFmtDesc(0)
{
- m_pUseExistingPagesRB = static_cast<RadioButton*>(m_pUIBuilder->get_by_name("RB_USE_EXISTING_PAGES"));
- m_pPageCountNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("NF_PAGE_COUNT"));
- m_pDocumentStartRB = static_cast<RadioButton*>(m_pUIBuilder->get_by_name("RB_DOCUMENT_START"));
- m_pPageStartRB = static_cast<RadioButton*>(m_pUIBuilder->get_by_name("RB_PAGE_START"));
- m_pPageStartNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("NF_PAGE_START"));
- m_pRestartNumberingCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("CB_RESTART_NUMBERING"));
- m_pRestartNumberingNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("NF_RESTART_NUMBERING"));
- m_pSetPageNumberCB = static_cast<CheckBox*>(m_pUIBuilder->get_by_name("CB_SET_PAGE_NUMBER"));
- m_pSetPageNumberNF = static_cast<NumericField*>(m_pUIBuilder->get_by_name("NF_SET_PAGE_NUMBER"));
- m_pPagePropertiesLB = static_cast<ListBox*>(m_pUIBuilder->get_by_name("LB_PAGE_PROPERTIES"));
- m_pPagePropertiesPB = static_cast<PushButton*>(m_pUIBuilder->get_by_name("PB_PAGE_PROPERTIES"));
- m_pOkPB = static_cast<OKButton*>(m_pUIBuilder->get_by_name("PB_OK"));
+ m_pUIBuilder->get(m_pUseExistingPagesRB, "RB_USE_EXISTING_PAGES");
+ m_pUIBuilder->get(m_pPageCountNF, "NF_PAGE_COUNT");
+ m_pUIBuilder->get(m_pDocumentStartRB, "RB_DOCUMENT_START");
+ m_pUIBuilder->get(m_pPageStartRB, "RB_PAGE_START");
+ m_pUIBuilder->get(m_pPageStartNF, "NF_PAGE_START");
+ m_pUIBuilder->get(m_pRestartNumberingCB, "CB_RESTART_NUMBERING");
+ m_pUIBuilder->get(m_pRestartNumberingNF, "NF_RESTART_NUMBERING");
+ m_pUIBuilder->get(m_pSetPageNumberCB, "CB_SET_PAGE_NUMBER");
+ m_pUIBuilder->get(m_pSetPageNumberNF, "NF_SET_PAGE_NUMBER");
+ m_pUIBuilder->get(m_pPagePropertiesLB, "LB_PAGE_PROPERTIES");
+ m_pUIBuilder->get(m_pPagePropertiesPB, "PB_PAGE_PROPERTIES");
+ m_pUIBuilder->get(m_pOkPB, "PB_OK");
m_pOkPB->SetClickHdl(LINK(this, SwTitlePageDlg, OKHdl));
m_pRestartNumberingCB->SetClickHdl(LINK(this, SwTitlePageDlg, RestartNumberingHdl));
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 48e8a47..f8703cc 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -124,11 +124,43 @@ private:
rtl::OString m_sID;
rtl::OString m_sHelpRoot;
Window *m_pParent;
+
+ Window *get_by_name(rtl::OString sID);
public:
VclBuilder(Window *pParent, rtl::OUString sUIRootDir, rtl::OUString sUIFile, rtl::OString sID = rtl::OString());
~VclBuilder();
Window *get_widget_root();
- Window *get_by_name(rtl::OString sID);
+ template <typename T> T* get(T*& ret, rtl::OString sID)
+ {
+ Window *w = get_by_name(sID);
+ ret = static_cast<T*>(w);
+
+#if OSL_DEBUG_LEVEL > 0
+ if (w)
+ {
+ ret = dynamic_cast<T*>(w);
+ assert(ret);
+ }
+#endif
+
+ return ret;
+ }
+ template <typename T=Window> T* get(rtl::OString sID)
+ {
+ Window *w = get_by_name(sID);
+ T* ret = static_cast<T*>(w);
+
+#if OSL_DEBUG_LEVEL > 0
+ if (w)
+ {
+ ret = dynamic_cast<T*>(w);
+ assert(ret);
+ }
+#endif
+
+ return ret;
+ }
+
rtl::OString get_by_window(const Window *pWindow) const;
//for the purposes of retrofitting this to the existing code
//look up sID, clone its properties into replacement and
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index b51ab9a..2fa0f6f 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -87,8 +87,8 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF
for (std::vector<RadioButtonGroupMap>::iterator aI = m_aGroupMaps.begin(),
aEnd = m_aGroupMaps.end(); aI != aEnd; ++aI)
{
- RadioButton *pOne = static_cast<RadioButton*>(get_by_name(aI->m_sID));
- RadioButton *pOther = static_cast<RadioButton*>(get_by_name(aI->m_sValue));
+ RadioButton *pOne = get<RadioButton>(aI->m_sID);
+ RadioButton *pOther = get<RadioButton>(aI->m_sValue);
SAL_WARN_IF(!pOne || !pOther, "vcl", "missing member of radiobutton group");
if (pOne && pOther)
pOne->group(*pOther);
@@ -100,7 +100,7 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF
for (std::vector<ComboBoxModelMap>::iterator aI = m_aModelMaps.begin(),
aEnd = m_aModelMaps.end(); aI != aEnd; ++aI)
{
- ListBox *pTarget = static_cast<ListBox*>(get_by_name(aI->m_sID));
+ ListBox *pTarget = get<ListBox>(aI->m_sID);
ListStore *pStore = get_model_by_name(aI->m_sValue);
SAL_WARN_IF(!pTarget || !pStore, "vcl", "missing elements of combobox/liststore");
if (pTarget && pStore)
@@ -119,7 +119,7 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIF
for (std::vector<SpinButtonAdjustmentMap>::iterator aI = m_aAdjustmentMaps.begin(),
aEnd = m_aAdjustmentMaps.end(); aI != aEnd; ++aI)
{
- NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get_by_name(aI->m_sID));
+ NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get(aI->m_sID));
Adjustment *pAdjustment = get_adjustment_by_name(aI->m_sValue);
SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of spinbutton/adjustment");
if (pTarget && pAdjustment)
More information about the Libreoffice-commits
mailing list