Kaydet (Commit) 1a89020f authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Use a unordered_map for mapping of xml element to control type

Change-Id: Id0409f35a21307ed41a0da27c625c4b7784811d6
Reviewed-on: https://gerrit.libreoffice.org/68718
Tested-by: Jenkins
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 36df3593
......@@ -132,39 +132,20 @@ ControlPart xmlStringToControlPart(OString const& sPart)
bool getControlTypeForXmlString(OString const& rString, ControlType& reType)
{
bool bReturn = false;
if (rString == "pushbutton")
{
reType = ControlType::Pushbutton;
bReturn = true;
}
else if (rString == "radiobutton")
{
reType = ControlType::Radiobutton;
bReturn = true;
}
else if (rString == "editbox")
{
reType = ControlType::Editbox;
bReturn = true;
}
else if (rString == "checkbox")
{
reType = ControlType::Checkbox;
bReturn = true;
}
else if (rString == "combobox")
{
reType = ControlType::Combobox;
bReturn = true;
}
else if (rString == "spinbox")
static std::unordered_map<OString, ControlType> aPartMap = {
{ "pushbutton", ControlType::Pushbutton }, { "radiobutton", ControlType::Radiobutton },
{ "checkbox", ControlType::Checkbox }, { "combobox", ControlType::Combobox },
{ "editbox", ControlType::Editbox }, { "scrollbar", ControlType::Scrollbar },
{ "spinbox", ControlType::Spinbox },
};
auto const& rIterator = aPartMap.find(rString);
if (rIterator != aPartMap.end())
{
reType = ControlType::Spinbox;
bReturn = true;
reType = rIterator->second;
return true;
}
return bReturn;
return false;
}
} // end anonymous namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment