summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-10-25 12:04:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-10-25 12:04:26 +0100
commit7b45dfe09772a216df4953c580302569c1835f73 (patch)
treee7a9feac4444db93b2916733159a8391e1ce8642 /vcl
parentc7bac4da02d51f8180aaad5b3768f4ff5bd80d4d (diff)
convert Mnemonic markup automatically
Change-Id: I55b6bf11468ce958aea7c98894d3a76343b53a9a
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/builder.cxx8
-rw-r--r--vcl/source/window/window2.cxx50
2 files changed, 37 insertions, 21 deletions
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 51e6fcb74fe7..8c330d083a08 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1528,13 +1528,7 @@ void VclBuilder::collectProperty(xmlreader::XmlReader &reader, const OString &rI
if (!sProperty.isEmpty())
{
sProperty = sProperty.replace('_', '-');
- //replace '_' with '-' except for property values that
- //refer to widget ids themselves. TO-DO, drop conversion
- //and just use foo_bar properties throughout ?
- if (sProperty == "group")
- rMap[sProperty] = sValue;
- else
- rMap[sProperty] = sValue.replace('_', '-');
+ rMap[sProperty] = sValue;
}
}
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index ba04bb6fc8f9..69d580bd5966 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -1284,22 +1284,22 @@ Window* Window::ImplGetTopmostFrameWindow()
return pTopmostParent->mpWindowImpl->mpFrameWindow;
}
-void Window::SetHelpId( const rtl::OString& rHelpId )
+void Window::SetHelpId( const OString& rHelpId )
{
mpWindowImpl->maHelpId = rHelpId;
}
-const rtl::OString& Window::GetHelpId() const
+const OString& Window::GetHelpId() const
{
return mpWindowImpl->maHelpId;
}
-void Window::SetUniqueId( const rtl::OString& rUniqueId )
+void Window::SetUniqueId( const OString& rUniqueId )
{
mpWindowImpl->maUniqId = rUniqueId;
}
-const rtl::OString& Window::GetUniqueId() const
+const OString& Window::GetUniqueId() const
{
return mpWindowImpl->maUniqId;
}
@@ -1938,7 +1938,7 @@ void Window::take_properties(Window &rOther)
namespace
{
- VclAlign toAlign(const rtl::OString &rValue)
+ VclAlign toAlign(const OString &rValue)
{
VclAlign eRet = VCL_ALIGN_FILL;
@@ -1954,12 +1954,36 @@ namespace
}
}
-bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
+namespace
{
- if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("label")))
- SetText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
- else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("title")))
- SetText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
+ OString convertMnemonicMarkup(const OString &rIn)
+ {
+ OStringBuffer aRet(rIn);
+ for (sal_Int32 nI = 0; nI < aRet.getLength(); ++nI)
+ {
+ if (aRet[nI] == '_')
+ {
+ if (aRet[nI+1] != '_')
+ aRet[nI] = '~';
+ else
+ aRet.remove(nI, 1);
+ ++nI;
+ }
+ }
+ return aRet.makeStringAndClear();
+ }
+}
+
+bool Window::set_property(const OString &rKey, const OString &rValue)
+{
+ if (
+ (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("label"))) ||
+ (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("title"))) ||
+ (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("text")))
+ )
+ {
+ SetText(OStringToOUString(convertMnemonicMarkup(rValue), RTL_TEXTENCODING_UTF8));
+ }
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("visible")))
Show(toBool(rValue));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("sensitive")))
@@ -2010,8 +2034,6 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
nBits |= WB_WORDBREAK;
SetStyle(nBits);
}
- else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("text")))
- SetText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("height-request")))
set_height_request(rValue.toInt32());
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("width-request")))
@@ -2025,9 +2047,9 @@ bool Window::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("valign")))
set_valign(toAlign(rValue));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-markup")))
- SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
+ SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("tooltip-text")))
- SetQuickHelpText(rtl::OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
+ SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("border-width")))
set_border_width(rValue.toInt32());
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("margin-left")))