[Libreoffice-commits] core.git: vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 4 11:31:30 UTC 2019
vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 6 +
vcl/source/gdi/WidgetDefinitionReader.cxx | 83 +++++++++-----------------
2 files changed, 36 insertions(+), 53 deletions(-)
New commits:
commit be999e2ec2e5f3bd6875f6e4c9a0811e0a23283f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Jan 24 17:56:44 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Mar 4 12:31:06 2019 +0100
remove code duplication in WidgetDefinitionReader
Change-Id: Iec4694344d324b4d4d7e55efdedf8520dd914d63
Reviewed-on: https://gerrit.libreoffice.org/68656
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
index 01deaee91eb6..2f06c4ffa78a 100644
--- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
@@ -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,
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index edab7b75ae4a..84db52e68ddc 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -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))
More information about the Libreoffice-commits
mailing list