remove code duplication in WidgetDefinitionReader
Change-Id: Iec4694344d324b4d4d7e55efdedf8520dd914d63 Reviewed-on: https://gerrit.libreoffice.org/68656 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
b07a71e09a
commit
be999e2ec2
@@ -106,6 +106,12 @@ class VCL_DLLPUBLIC WidgetDefinitionReader
|
||||
private:
|
||||
OUString m_rFilePath;
|
||||
|
||||
static void
|
||||
readDefinition(tools::XmlWalker& rWalker,
|
||||
std::unordered_map<OString, std::shared_ptr<WidgetDefinition>>& rDefinition);
|
||||
|
||||
static void readPart(tools::XmlWalker& rWalker, std::shared_ptr<WidgetDefinition> rpPart);
|
||||
|
||||
void readPushButton(tools::XmlWalker& rWalker);
|
||||
void readRadioButton(tools::XmlWalker& rWalker);
|
||||
static void readDrawingDefinition(tools::XmlWalker& rWalker,
|
||||
|
@@ -119,7 +119,9 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker,
|
||||
rWalker.parent();
|
||||
}
|
||||
|
||||
void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker)
|
||||
void WidgetDefinitionReader::readDefinition(
|
||||
tools::XmlWalker& rWalker,
|
||||
std::unordered_map<OString, std::shared_ptr<WidgetDefinition>>& rDefinition)
|
||||
{
|
||||
rWalker.children();
|
||||
while (rWalker.isValid())
|
||||
@@ -128,75 +130,50 @@ void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker)
|
||||
{
|
||||
OString sPart = rWalker.attribute("value");
|
||||
std::shared_ptr<WidgetDefinition> pPart = std::make_shared<WidgetDefinition>();
|
||||
maPushButtonDefinitions.emplace(sPart, pPart);
|
||||
rWalker.children();
|
||||
while (rWalker.isValid())
|
||||
{
|
||||
if (rWalker.name() == "state")
|
||||
{
|
||||
OString sEnabled = rWalker.attribute("enabled");
|
||||
OString sFocused = rWalker.attribute("focused");
|
||||
OString sPressed = rWalker.attribute("pressed");
|
||||
OString sRollover = rWalker.attribute("rollover");
|
||||
OString sDefault = rWalker.attribute("default");
|
||||
OString sSelected = rWalker.attribute("selected");
|
||||
OString sButtonValue = rWalker.attribute("button-value");
|
||||
|
||||
std::shared_ptr<WidgetDefinitionState> pState
|
||||
= std::make_shared<WidgetDefinitionState>(sEnabled, sFocused, sPressed,
|
||||
sRollover, sDefault, sSelected,
|
||||
sButtonValue);
|
||||
pPart->maStates.push_back(pState);
|
||||
readDrawingDefinition(rWalker, pState);
|
||||
}
|
||||
rWalker.next();
|
||||
}
|
||||
rWalker.parent();
|
||||
rDefinition.emplace(sPart, pPart);
|
||||
readPart(rWalker, pPart);
|
||||
}
|
||||
rWalker.next();
|
||||
}
|
||||
rWalker.parent();
|
||||
}
|
||||
|
||||
void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker)
|
||||
void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
|
||||
std::shared_ptr<WidgetDefinition> rpPart)
|
||||
{
|
||||
rWalker.children();
|
||||
while (rWalker.isValid())
|
||||
{
|
||||
if (rWalker.name() == "part")
|
||||
if (rWalker.name() == "state")
|
||||
{
|
||||
OString sPart = rWalker.attribute("value");
|
||||
std::shared_ptr<WidgetDefinition> pPart = std::make_shared<WidgetDefinition>();
|
||||
maRadioButtonDefinitions.emplace(sPart, pPart);
|
||||
rWalker.children();
|
||||
while (rWalker.isValid())
|
||||
{
|
||||
if (rWalker.name() == "state")
|
||||
{
|
||||
OString sEnabled = rWalker.attribute("enabled");
|
||||
OString sFocused = rWalker.attribute("focused");
|
||||
OString sPressed = rWalker.attribute("pressed");
|
||||
OString sRollover = rWalker.attribute("rollover");
|
||||
OString sDefault = rWalker.attribute("default");
|
||||
OString sSelected = rWalker.attribute("selected");
|
||||
OString sButtonValue = rWalker.attribute("button-value");
|
||||
sButtonValue = sButtonValue.isEmpty() ? "any" : sButtonValue;
|
||||
std::shared_ptr<WidgetDefinitionState> pState
|
||||
= std::make_shared<WidgetDefinitionState>(sEnabled, sFocused, sPressed,
|
||||
sRollover, sDefault, sSelected,
|
||||
sButtonValue);
|
||||
pPart->maStates.push_back(pState);
|
||||
readDrawingDefinition(rWalker, pState);
|
||||
}
|
||||
rWalker.next();
|
||||
}
|
||||
rWalker.parent();
|
||||
OString sEnabled = rWalker.attribute("enabled");
|
||||
OString sFocused = rWalker.attribute("focused");
|
||||
OString sPressed = rWalker.attribute("pressed");
|
||||
OString sRollover = rWalker.attribute("rollover");
|
||||
OString sDefault = rWalker.attribute("default");
|
||||
OString sSelected = rWalker.attribute("selected");
|
||||
OString sButtonValue = rWalker.attribute("button-value");
|
||||
|
||||
std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(
|
||||
sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue);
|
||||
rpPart->maStates.push_back(pState);
|
||||
readDrawingDefinition(rWalker, pState);
|
||||
}
|
||||
rWalker.next();
|
||||
}
|
||||
rWalker.parent();
|
||||
}
|
||||
|
||||
void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker)
|
||||
{
|
||||
readDefinition(rWalker, maPushButtonDefinitions);
|
||||
}
|
||||
|
||||
void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker)
|
||||
{
|
||||
readDefinition(rWalker, maRadioButtonDefinitions);
|
||||
}
|
||||
|
||||
bool WidgetDefinitionReader::read()
|
||||
{
|
||||
if (!lcl_fileExists(m_rFilePath))
|
||||
|
Reference in New Issue
Block a user