diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-12-11 21:07:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-12-11 21:17:09 +0000 |
commit | 7c29452986dc1c25f56d79e68b88dad0ee2ecc45 (patch) | |
tree | 5e38d0af39537483da5dcf660303b10e3f08f076 | |
parent | a67906259a748b658daa6ee33f23a04755e21b66 (diff) |
warn if a .ui has buttons but none of them is set as the default button
can probably only do this for full dialogs rather than .ui snippets
Change-Id: Ic8269e1c909fee3acec6ac06c36b9107cb6ff5db
-rw-r--r-- | vcl/source/window/builder.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 2bba9f4d2085..6308b06a2434 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -117,6 +117,23 @@ void VclBuilder::loadTranslations(const com::sun::star::lang::Locale &rLocale, c } } +#if defined SAL_LOG_WARN +namespace +{ + bool isButtonType(WindowType nType) + { + return nType == WINDOW_PUSHBUTTON || + nType == WINDOW_OKBUTTON || + nType == WINDOW_CANCELBUTTON || + nType == WINDOW_HELPBUTTON || + nType == WINDOW_IMAGEBUTTON || + nType == WINDOW_MENUBUTTON || + nType == WINDOW_MOREBUTTON || + nType == WINDOW_SPINBUTTON; + } +} +#endif + VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OString sID) : m_sID(sID) , m_sHelpRoot(OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8)) @@ -262,6 +279,28 @@ VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OStri SAL_WARN_IF(!m_sID.isEmpty() && (!m_bToplevelParentFound && !get_by_name(m_sID)), "vcl.layout", "Requested top level widget \"" << m_sID.getStr() << "\" not found in " << sUIFile); + +#if defined SAL_LOG_WARN + if (m_bToplevelParentFound && m_pParent->IsDialog()) + { + int nButtons = 0; + bool bHasDefButton = false; + for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(), + aEnd = m_aChildren.end(); aI != aEnd; ++aI) + { + if (isButtonType(aI->m_pWindow->GetType())) + { + ++nButtons; + if (aI->m_pWindow->GetStyle() & WB_DEFBUTTON) + { + bHasDefButton = true; + break; + } + } + } + SAL_WARN_IF(nButtons && !bHasDefButton, "vcl.layout", "No default button defined"); + } +#endif } VclBuilder::~VclBuilder() |