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: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
6cd3cb41d9
commit
4b6e00f08a
@@ -132,39 +132,20 @@ ControlPart xmlStringToControlPart(OString const& sPart)
|
|||||||
|
|
||||||
bool getControlTypeForXmlString(OString const& rString, ControlType& reType)
|
bool getControlTypeForXmlString(OString const& rString, ControlType& reType)
|
||||||
{
|
{
|
||||||
bool bReturn = false;
|
static std::unordered_map<OString, ControlType> aPartMap = {
|
||||||
if (rString == "pushbutton")
|
{ "pushbutton", ControlType::Pushbutton }, { "radiobutton", ControlType::Radiobutton },
|
||||||
{
|
{ "checkbox", ControlType::Checkbox }, { "combobox", ControlType::Combobox },
|
||||||
reType = ControlType::Pushbutton;
|
{ "editbox", ControlType::Editbox }, { "scrollbar", ControlType::Scrollbar },
|
||||||
bReturn = true;
|
{ "spinbox", ControlType::Spinbox },
|
||||||
}
|
};
|
||||||
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")
|
|
||||||
{
|
|
||||||
reType = ControlType::Spinbox;
|
|
||||||
bReturn = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bReturn;
|
auto const& rIterator = aPartMap.find(rString);
|
||||||
|
if (rIterator != aPartMap.end())
|
||||||
|
{
|
||||||
|
reType = rIterator->second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
Reference in New Issue
Block a user