[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/Library_vcl.mk vcl/qa vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Mar 4 18:09:42 UTC 2019
vcl/Library_vcl.mk | 1
vcl/inc/FileDefinitionWidgetDraw.hxx | 2
vcl/inc/widgetdraw/WidgetDefinition.hxx | 187 ++++++++
vcl/inc/widgetdraw/WidgetDefinitionReader.hxx | 172 -------
vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx | 29 -
vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 128 ++---
vcl/source/gdi/WidgetDefinition.cxx | 235 ++++++++++
vcl/source/gdi/WidgetDefinitionReader.cxx | 346 ++-------------
8 files changed, 566 insertions(+), 534 deletions(-)
New commits:
commit a69ce55133b3d4dd763300ed678f30a05830c23a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jan 25 17:44:13 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Mar 4 19:09:25 2019 +0100
move WidgetDefinition{Part,State} into its own file
to separate it completely from WidgetDefinitionReader and make it
independent..
Change-Id: If3d6f0e8826b39be28ae18ddf74f2643d1084ec4
Reviewed-on: https://gerrit.libreoffice.org/68689
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index c22cc2cdf2eb..7265eb39811f 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -262,6 +262,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/embeddedfontshelper \
vcl/source/gdi/FileDefinitionWidgetDraw \
vcl/source/gdi/WidgetDefinitionReader \
+ vcl/source/gdi/WidgetDefinition \
vcl/source/gdi/extoutdevdata \
vcl/source/gdi/gdimtf \
vcl/source/gdi/mtfxmldump \
diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx
new file mode 100644
index 000000000000..423ab1d970c3
--- /dev/null
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
+#define INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
+
+#include <vcl/dllapi.h>
+#include <memory>
+#include <rtl/ustring.hxx>
+#include <tools/color.hxx>
+#include <unordered_map>
+#include <vector>
+#include <vcl/salnativewidgets.hxx>
+
+namespace vcl
+{
+enum class DrawCommandType
+{
+ RECTANGLE,
+ CIRCLE,
+ LINE
+};
+
+class VCL_DLLPUBLIC DrawCommand
+{
+public:
+ DrawCommand(DrawCommandType aType)
+ : maType(aType)
+ , mnStrokeWidth(-1)
+ , mnMargin(0)
+ {
+ }
+
+ DrawCommandType maType;
+
+ Color maStrokeColor;
+ Color maFillColor;
+ sal_Int32 mnStrokeWidth;
+ sal_Int32 mnMargin;
+};
+
+class VCL_DLLPUBLIC RectangleDrawCommand : public DrawCommand
+{
+public:
+ sal_Int32 mnRx;
+ sal_Int32 mnRy;
+
+ RectangleDrawCommand()
+ : DrawCommand(DrawCommandType::RECTANGLE)
+ , mnRx(0)
+ , mnRy(0)
+ {
+ }
+};
+
+class VCL_DLLPUBLIC CircleDrawCommand : public DrawCommand
+{
+public:
+ CircleDrawCommand()
+ : DrawCommand(DrawCommandType::CIRCLE)
+ {
+ }
+};
+
+class VCL_DLLPUBLIC LineDrawCommand : public DrawCommand
+{
+public:
+ float mfX1;
+ float mfY1;
+ float mfX2;
+ float mfY2;
+
+ LineDrawCommand()
+ : DrawCommand(DrawCommandType::LINE)
+ {
+ }
+};
+
+class VCL_DLLPUBLIC WidgetDefinitionState
+{
+public:
+ OString msEnabled;
+ OString msFocused;
+ OString msPressed;
+ OString msRollover;
+ OString msDefault;
+ OString msSelected;
+ OString msButtonValue;
+
+ WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
+ OString const& sRollover, OString const& sDefault,
+ OString const& sSelected, OString const& sButtonValue);
+
+ std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
+
+ void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
+ sal_Int32 nRx, sal_Int32 nRy, sal_Int32 nMargin);
+ void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
+ sal_Int32 nMargin);
+ void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
+ float fY2);
+};
+
+class VCL_DLLPUBLIC WidgetDefinitionPart
+{
+public:
+ std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
+ ImplControlValue const& rValue);
+
+ std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
+};
+
+class VCL_DLLPUBLIC WidgetDefinition
+{
+public:
+ Color maFaceColor;
+ Color maCheckedColor;
+ Color maLightColor;
+ Color maLightBorderColor;
+ Color maShadowColor;
+ Color maDarkShadowColor;
+ Color maButtonTextColor;
+ Color maButtonRolloverTextColor;
+ Color maRadioCheckTextColor;
+ Color maGroupTextColor;
+ Color maLabelTextColor;
+ Color maWindowColor;
+ Color maWindowTextColor;
+ Color maDialogColor;
+ Color maDialogTextColor;
+ Color maWorkspaceColor;
+ Color maMonoColor;
+ Color maFieldColor;
+ Color maFieldTextColor;
+ Color maFieldRolloverTextColor;
+ Color maActiveColor;
+ Color maActiveTextColor;
+ Color maActiveBorderColor;
+ Color maDeactiveColor;
+ Color maDeactiveTextColor;
+ Color maDeactiveBorderColor;
+ Color maMenuColor;
+ Color maMenuBarColor;
+ Color maMenuBarRolloverColor;
+ Color maMenuBorderColor;
+ Color maMenuTextColor;
+ Color maMenuBarTextColor;
+ Color maMenuBarRolloverTextColor;
+ Color maMenuBarHighlightTextColor;
+ Color maMenuHighlightColor;
+ Color maMenuHighlightTextColor;
+ Color maHighlightColor;
+ Color maHighlightTextColor;
+ Color maActiveTabColor;
+ Color maInactiveTabColor;
+ Color maTabTextColor;
+ Color maTabRolloverTextColor;
+ Color maTabHighlightTextColor;
+ Color maDisableColor;
+ Color maHelpColor;
+ Color maHelpTextColor;
+ Color maLinkColor;
+ Color maVisitedLinkColor;
+ Color maToolTextColor;
+ Color maFontColor;
+
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maPushButtonDefinitions;
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maRadioButtonDefinitions;
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maEditboxDefinitions;
+
+ std::shared_ptr<WidgetDefinitionPart> getPushButtonDefinition(ControlPart ePart);
+ std::shared_ptr<WidgetDefinitionPart> getRadioButtonDefinition(ControlPart ePart);
+ std::shared_ptr<WidgetDefinitionPart> getEditboxDefinition(ControlPart ePart);
+};
+
+} // end vcl namespace
+
+#endif // INCLUDED_VCL_INC_WIDGETDEFINITION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
index 4d9caddce374..1cb577c08c4d 100644
--- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
@@ -12,175 +12,13 @@
#define INCLUDED_VCL_INC_WIDGETDEFINITIONREADER_HXX
#include <vcl/dllapi.h>
+#include <widgetdraw/WidgetDefinition.hxx>
#include <memory>
#include <rtl/ustring.hxx>
-#include <tools/color.hxx>
#include <tools/XmlWalker.hxx>
-#include <unordered_map>
-#include <vector>
-#include <vcl/salnativewidgets.hxx>
namespace vcl
{
-enum class DrawCommandType
-{
- RECTANGLE,
- CIRCLE,
- LINE
-};
-
-class VCL_DLLPUBLIC DrawCommand
-{
-public:
- DrawCommand(DrawCommandType aType)
- : maType(aType)
- , mnStrokeWidth(-1)
- , mnMargin(0)
- {
- }
-
- DrawCommandType maType;
-
- Color maStrokeColor;
- Color maFillColor;
- sal_Int32 mnStrokeWidth;
- sal_Int32 mnMargin;
-};
-
-class VCL_DLLPUBLIC RectangleDrawCommand : public DrawCommand
-{
-public:
- sal_Int32 mnRx;
- sal_Int32 mnRy;
-
- RectangleDrawCommand()
- : DrawCommand(DrawCommandType::RECTANGLE)
- , mnRx(0)
- , mnRy(0)
- {
- }
-};
-
-class VCL_DLLPUBLIC CircleDrawCommand : public DrawCommand
-{
-public:
- CircleDrawCommand()
- : DrawCommand(DrawCommandType::CIRCLE)
- {
- }
-};
-
-class VCL_DLLPUBLIC LineDrawCommand : public DrawCommand
-{
-public:
- float mfX1;
- float mfY1;
- float mfX2;
- float mfY2;
-
- LineDrawCommand()
- : DrawCommand(DrawCommandType::LINE)
- {
- }
-};
-
-class VCL_DLLPUBLIC WidgetDefinitionState
-{
-public:
- OString msEnabled;
- OString msFocused;
- OString msPressed;
- OString msRollover;
- OString msDefault;
- OString msSelected;
- OString msButtonValue;
-
- WidgetDefinitionState(OString const& sEnabled, OString const& sFocused, OString const& sPressed,
- OString const& sRollover, OString const& sDefault,
- OString const& sSelected, OString const& sButtonValue);
-
- std::vector<std::shared_ptr<DrawCommand>> mpDrawCommands;
-
- void addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
- sal_Int32 nRx, sal_Int32 nRy, sal_Int32 nMargin);
- void addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth, Color aFillColor,
- sal_Int32 nMargin);
- void addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1, float fY1, float fX2,
- float fY2);
-};
-
-class VCL_DLLPUBLIC WidgetDefinitionPart
-{
-public:
- std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
- ImplControlValue const& rValue);
-
- std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
-};
-
-class VCL_DLLPUBLIC WidgetDefinition
-{
-public:
- Color maFaceColor;
- Color maCheckedColor;
- Color maLightColor;
- Color maLightBorderColor;
- Color maShadowColor;
- Color maDarkShadowColor;
- Color maButtonTextColor;
- Color maButtonRolloverTextColor;
- Color maRadioCheckTextColor;
- Color maGroupTextColor;
- Color maLabelTextColor;
- Color maWindowColor;
- Color maWindowTextColor;
- Color maDialogColor;
- Color maDialogTextColor;
- Color maWorkspaceColor;
- Color maMonoColor;
- Color maFieldColor;
- Color maFieldTextColor;
- Color maFieldRolloverTextColor;
- Color maActiveColor;
- Color maActiveTextColor;
- Color maActiveBorderColor;
- Color maDeactiveColor;
- Color maDeactiveTextColor;
- Color maDeactiveBorderColor;
- Color maMenuColor;
- Color maMenuBarColor;
- Color maMenuBarRolloverColor;
- Color maMenuBorderColor;
- Color maMenuTextColor;
- Color maMenuBarTextColor;
- Color maMenuBarRolloverTextColor;
- Color maMenuBarHighlightTextColor;
- Color maMenuHighlightColor;
- Color maMenuHighlightTextColor;
- Color maHighlightColor;
- Color maHighlightTextColor;
- Color maActiveTabColor;
- Color maInactiveTabColor;
- Color maTabTextColor;
- Color maTabRolloverTextColor;
- Color maTabHighlightTextColor;
- Color maDisableColor;
- Color maHelpColor;
- Color maHelpTextColor;
- Color maLinkColor;
- Color maVisitedLinkColor;
- Color maToolTextColor;
- Color maFontColor;
-
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maPushButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maRadioButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maEditboxDefinitions;
-
- std::shared_ptr<WidgetDefinitionPart> getPushButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinitionPart> getRadioButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinitionPart> getEditboxDefinition(ControlPart ePart);
-};
-
class VCL_DLLPUBLIC WidgetDefinitionReader
{
private:
@@ -202,6 +40,6 @@ public:
} // end vcl namespace
-#endif
+#endif // INCLUDED_VCL_INC_WIDGETDEFINITIONREADER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/WidgetDefinition.cxx b/vcl/source/gdi/WidgetDefinition.cxx
new file mode 100644
index 000000000000..e5fc5e8ae8f2
--- /dev/null
+++ b/vcl/source/gdi/WidgetDefinition.cxx
@@ -0,0 +1,235 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <widgetdraw/WidgetDefinition.hxx>
+
+#include <sal/config.h>
+#include <tools/stream.hxx>
+#include <unordered_map>
+
+namespace vcl
+{
+namespace
+{
+OString xmlControlPart(ControlPart ePart)
+{
+ switch (ePart)
+ {
+ case ControlPart::NONE:
+ return "NONE";
+ case ControlPart::Entire:
+ return "Entire";
+ case ControlPart::ListboxWindow:
+ return "ListboxWindow";
+ case ControlPart::Button:
+ return "NONE";
+ case ControlPart::ButtonUp:
+ return "NONE";
+ case ControlPart::ButtonDown:
+ return "NONE";
+ case ControlPart::ButtonLeft:
+ return "NONE";
+ case ControlPart::ButtonRight:
+ return "NONE";
+ case ControlPart::AllButtons:
+ return "NONE";
+ case ControlPart::SeparatorHorz:
+ return "NONE";
+ case ControlPart::SeparatorVert:
+ return "NONE";
+ case ControlPart::TrackHorzLeft:
+ return "NONE";
+ case ControlPart::TrackVertUpper:
+ return "NONE";
+ case ControlPart::TrackHorzRight:
+ return "NONE";
+ case ControlPart::TrackVertLower:
+ return "NONE";
+ case ControlPart::TrackHorzArea:
+ return "NONE";
+ case ControlPart::TrackVertArea:
+ return "NONE";
+ case ControlPart::Arrow:
+ return "NONE";
+ case ControlPart::ThumbHorz:
+ return "NONE";
+ case ControlPart::ThumbVert:
+ return "NONE";
+ case ControlPart::MenuItem:
+ return "NONE";
+ case ControlPart::MenuItemCheckMark:
+ return "NONE";
+ case ControlPart::MenuItemRadioMark:
+ return "NONE";
+ case ControlPart::Separator:
+ return "NONE";
+ case ControlPart::SubmenuArrow:
+ return "NONE";
+ case ControlPart::SubEdit:
+ return "NONE";
+ case ControlPart::DrawBackgroundHorz:
+ return "NONE";
+ case ControlPart::DrawBackgroundVert:
+ return "NONE";
+ case ControlPart::TabsDrawRtl:
+ return "NONE";
+ case ControlPart::HasBackgroundTexture:
+ return "NONE";
+ case ControlPart::HasThreeButtons:
+ return "NONE";
+ case ControlPart::BackgroundWindow:
+ return "NONE";
+ case ControlPart::BackgroundDialog:
+ return "NONE";
+ case ControlPart::Border:
+ return "NONE";
+ case ControlPart::Focus:
+ return "FOCUS";
+
+ default:
+ break;
+ }
+ return "NONE";
+}
+
+} // end anonymous namespace
+
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getPushButtonDefinition(ControlPart ePart)
+{
+ auto aIterator = maPushButtonDefinitions.find(xmlControlPart(ePart));
+
+ if (aIterator != maPushButtonDefinitions.end())
+ return aIterator->second;
+ return std::shared_ptr<WidgetDefinitionPart>();
+}
+
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getRadioButtonDefinition(ControlPart ePart)
+{
+ auto aIterator = maRadioButtonDefinitions.find(xmlControlPart(ePart));
+
+ if (aIterator != maRadioButtonDefinitions.end())
+ return aIterator->second;
+ return std::shared_ptr<WidgetDefinitionPart>();
+}
+
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getEditboxDefinition(ControlPart ePart)
+{
+ auto aIterator = maEditboxDefinitions.find(xmlControlPart(ePart));
+
+ if (aIterator != maEditboxDefinitions.end())
+ return aIterator->second;
+ return std::shared_ptr<WidgetDefinitionPart>();
+}
+
+std::vector<std::shared_ptr<WidgetDefinitionState>>
+WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rValue)
+{
+ std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
+
+ for (auto& state : maStates)
+ {
+ bool bAdd = true;
+
+ if (state->msEnabled != "any"
+ && !((state->msEnabled == "true" && eState & ControlState::ENABLED)
+ || (state->msEnabled == "false" && !(eState & ControlState::ENABLED))))
+ bAdd = false;
+ if (state->msFocused != "any"
+ && !((state->msFocused == "true" && eState & ControlState::FOCUSED)
+ || (state->msFocused == "false" && !(eState & ControlState::FOCUSED))))
+ bAdd = false;
+ if (state->msPressed != "any"
+ && !((state->msPressed == "true" && eState & ControlState::PRESSED)
+ || (state->msPressed == "false" && !(eState & ControlState::PRESSED))))
+ bAdd = false;
+ if (state->msRollover != "any"
+ && !((state->msRollover == "true" && eState & ControlState::ROLLOVER)
+ || (state->msRollover == "false" && !(eState & ControlState::ROLLOVER))))
+ bAdd = false;
+ if (state->msDefault != "any"
+ && !((state->msDefault == "true" && eState & ControlState::DEFAULT)
+ || (state->msDefault == "false" && !(eState & ControlState::DEFAULT))))
+ bAdd = false;
+ if (state->msSelected != "any"
+ && !((state->msSelected == "true" && eState & ControlState::SELECTED)
+ || (state->msSelected == "false" && !(eState & ControlState::SELECTED))))
+ bAdd = false;
+
+ ButtonValue eButtonValue = rValue.getTristateVal();
+
+ if (state->msButtonValue != "any"
+ && !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On)
+ || (state->msButtonValue == "false" && eButtonValue != ButtonValue::On)))
+ bAdd = false;
+
+ if (bAdd)
+ aStatesToAdd.push_back(state);
+ }
+
+ return aStatesToAdd;
+}
+
+WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused,
+ OString const& sPressed, OString const& sRollover,
+ OString const& sDefault, OString const& sSelected,
+ OString const& sButtonValue)
+ : msEnabled(sEnabled)
+ , msFocused(sFocused)
+ , msPressed(sPressed)
+ , msRollover(sRollover)
+ , msDefault(sDefault)
+ , msSelected(sSelected)
+ , msButtonValue(sButtonValue)
+{
+}
+
+void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth,
+ Color aFillColor, sal_Int32 nRx, sal_Int32 nRy,
+ sal_Int32 nMargin)
+{
+ std::shared_ptr<DrawCommand> pCommand(std::make_shared<RectangleDrawCommand>());
+ pCommand->maStrokeColor = aStrokeColor;
+ pCommand->maFillColor = aFillColor;
+ pCommand->mnStrokeWidth = nStrokeWidth;
+ pCommand->mnMargin = nMargin;
+ RectangleDrawCommand& rRectCommand = static_cast<RectangleDrawCommand&>(*pCommand);
+ rRectCommand.mnRx = nRx;
+ rRectCommand.mnRy = nRy;
+ mpDrawCommands.push_back(std::move(pCommand));
+}
+
+void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth,
+ Color aFillColor, sal_Int32 nMargin)
+{
+ std::shared_ptr<DrawCommand> pCommand(std::make_shared<CircleDrawCommand>());
+ pCommand->maStrokeColor = aStrokeColor;
+ pCommand->maFillColor = aFillColor;
+ pCommand->mnStrokeWidth = nStrokeWidth;
+ pCommand->mnMargin = nMargin;
+ mpDrawCommands.push_back(std::move(pCommand));
+}
+
+void WidgetDefinitionState::addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1,
+ float fY1, float fX2, float fY2)
+{
+ std::shared_ptr<DrawCommand> pCommand(std::make_shared<LineDrawCommand>());
+ pCommand->maStrokeColor = aStrokeColor;
+ pCommand->mnStrokeWidth = nStrokeWidth;
+ LineDrawCommand& rLineCommand = static_cast<LineDrawCommand&>(*pCommand);
+ rLineCommand.mfX1 = fX1;
+ rLineCommand.mfY1 = fY1;
+ rLineCommand.mfX2 = fX2;
+ rLineCommand.mfY2 = fY2;
+ mpDrawCommands.push_back(std::move(pCommand));
+}
+
+} // end vcl namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index c3e6b10953da..e9c40d46a2fd 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -292,220 +292,6 @@ bool WidgetDefinitionReader::read(WidgetDefinition& rWidgetDefinition)
return true;
}
-namespace
-{
-OString xmlControlPart(ControlPart ePart)
-{
- switch (ePart)
- {
- case ControlPart::NONE:
- return "NONE";
- case ControlPart::Entire:
- return "Entire";
- case ControlPart::ListboxWindow:
- return "ListboxWindow";
- case ControlPart::Button:
- return "NONE";
- case ControlPart::ButtonUp:
- return "NONE";
- case ControlPart::ButtonDown:
- return "NONE";
- case ControlPart::ButtonLeft:
- return "NONE";
- case ControlPart::ButtonRight:
- return "NONE";
- case ControlPart::AllButtons:
- return "NONE";
- case ControlPart::SeparatorHorz:
- return "NONE";
- case ControlPart::SeparatorVert:
- return "NONE";
- case ControlPart::TrackHorzLeft:
- return "NONE";
- case ControlPart::TrackVertUpper:
- return "NONE";
- case ControlPart::TrackHorzRight:
- return "NONE";
- case ControlPart::TrackVertLower:
- return "NONE";
- case ControlPart::TrackHorzArea:
- return "NONE";
- case ControlPart::TrackVertArea:
- return "NONE";
- case ControlPart::Arrow:
- return "NONE";
- case ControlPart::ThumbHorz:
- return "NONE";
- case ControlPart::ThumbVert:
- return "NONE";
- case ControlPart::MenuItem:
- return "NONE";
- case ControlPart::MenuItemCheckMark:
- return "NONE";
- case ControlPart::MenuItemRadioMark:
- return "NONE";
- case ControlPart::Separator:
- return "NONE";
- case ControlPart::SubmenuArrow:
- return "NONE";
- case ControlPart::SubEdit:
- return "NONE";
- case ControlPart::DrawBackgroundHorz:
- return "NONE";
- case ControlPart::DrawBackgroundVert:
- return "NONE";
- case ControlPart::TabsDrawRtl:
- return "NONE";
- case ControlPart::HasBackgroundTexture:
- return "NONE";
- case ControlPart::HasThreeButtons:
- return "NONE";
- case ControlPart::BackgroundWindow:
- return "NONE";
- case ControlPart::BackgroundDialog:
- return "NONE";
- case ControlPart::Border:
- return "NONE";
- case ControlPart::Focus:
- return "FOCUS";
-
- default:
- break;
- }
- return "NONE";
-}
-
-} // end anonymous namespace
-
-std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getPushButtonDefinition(ControlPart ePart)
-{
- auto aIterator = maPushButtonDefinitions.find(xmlControlPart(ePart));
-
- if (aIterator != maPushButtonDefinitions.end())
- return aIterator->second;
- return std::shared_ptr<WidgetDefinitionPart>();
-}
-
-std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getRadioButtonDefinition(ControlPart ePart)
-{
- auto aIterator = maRadioButtonDefinitions.find(xmlControlPart(ePart));
-
- if (aIterator != maRadioButtonDefinitions.end())
- return aIterator->second;
- return std::shared_ptr<WidgetDefinitionPart>();
-}
-
-std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getEditboxDefinition(ControlPart ePart)
-{
- auto aIterator = maEditboxDefinitions.find(xmlControlPart(ePart));
-
- if (aIterator != maEditboxDefinitions.end())
- return aIterator->second;
- return std::shared_ptr<WidgetDefinitionPart>();
-}
-
-std::vector<std::shared_ptr<WidgetDefinitionState>>
-WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rValue)
-{
- std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
-
- for (auto& state : maStates)
- {
- bool bAdd = true;
-
- if (state->msEnabled != "any"
- && !((state->msEnabled == "true" && eState & ControlState::ENABLED)
- || (state->msEnabled == "false" && !(eState & ControlState::ENABLED))))
- bAdd = false;
- if (state->msFocused != "any"
- && !((state->msFocused == "true" && eState & ControlState::FOCUSED)
- || (state->msFocused == "false" && !(eState & ControlState::FOCUSED))))
- bAdd = false;
- if (state->msPressed != "any"
- && !((state->msPressed == "true" && eState & ControlState::PRESSED)
- || (state->msPressed == "false" && !(eState & ControlState::PRESSED))))
- bAdd = false;
- if (state->msRollover != "any"
- && !((state->msRollover == "true" && eState & ControlState::ROLLOVER)
- || (state->msRollover == "false" && !(eState & ControlState::ROLLOVER))))
- bAdd = false;
- if (state->msDefault != "any"
- && !((state->msDefault == "true" && eState & ControlState::DEFAULT)
- || (state->msDefault == "false" && !(eState & ControlState::DEFAULT))))
- bAdd = false;
- if (state->msSelected != "any"
- && !((state->msSelected == "true" && eState & ControlState::SELECTED)
- || (state->msSelected == "false" && !(eState & ControlState::SELECTED))))
- bAdd = false;
-
- ButtonValue eButtonValue = rValue.getTristateVal();
-
- if (state->msButtonValue != "any"
- && !((state->msButtonValue == "true" && eButtonValue == ButtonValue::On)
- || (state->msButtonValue == "false" && eButtonValue != ButtonValue::On)))
- bAdd = false;
-
- if (bAdd)
- aStatesToAdd.push_back(state);
- }
-
- return aStatesToAdd;
-}
-
-WidgetDefinitionState::WidgetDefinitionState(OString const& sEnabled, OString const& sFocused,
- OString const& sPressed, OString const& sRollover,
- OString const& sDefault, OString const& sSelected,
- OString const& sButtonValue)
- : msEnabled(sEnabled)
- , msFocused(sFocused)
- , msPressed(sPressed)
- , msRollover(sRollover)
- , msDefault(sDefault)
- , msSelected(sSelected)
- , msButtonValue(sButtonValue)
-{
-}
-
-void WidgetDefinitionState::addDrawRectangle(Color aStrokeColor, sal_Int32 nStrokeWidth,
- Color aFillColor, sal_Int32 nRx, sal_Int32 nRy,
- sal_Int32 nMargin)
-{
- std::shared_ptr<DrawCommand> pCommand(std::make_shared<RectangleDrawCommand>());
- pCommand->maStrokeColor = aStrokeColor;
- pCommand->maFillColor = aFillColor;
- pCommand->mnStrokeWidth = nStrokeWidth;
- pCommand->mnMargin = nMargin;
- RectangleDrawCommand& rRectCommand = static_cast<RectangleDrawCommand&>(*pCommand);
- rRectCommand.mnRx = nRx;
- rRectCommand.mnRy = nRy;
- mpDrawCommands.push_back(pCommand);
-}
-
-void WidgetDefinitionState::addDrawCircle(Color aStrokeColor, sal_Int32 nStrokeWidth,
- Color aFillColor, sal_Int32 nMargin)
-{
- std::shared_ptr<DrawCommand> pCommand(std::make_shared<CircleDrawCommand>());
- pCommand->maStrokeColor = aStrokeColor;
- pCommand->maFillColor = aFillColor;
- pCommand->mnStrokeWidth = nStrokeWidth;
- pCommand->mnMargin = nMargin;
- mpDrawCommands.push_back(std::move(pCommand));
-}
-
-void WidgetDefinitionState::addDrawLine(Color aStrokeColor, sal_Int32 nStrokeWidth, float fX1,
- float fY1, float fX2, float fY2)
-{
- std::shared_ptr<DrawCommand> pCommand(std::make_shared<LineDrawCommand>());
- pCommand->maStrokeColor = aStrokeColor;
- pCommand->mnStrokeWidth = nStrokeWidth;
- LineDrawCommand& rLineCommand = static_cast<LineDrawCommand&>(*pCommand);
- rLineCommand.mfX1 = fX1;
- rLineCommand.mfY1 = fY1;
- rLineCommand.mfX2 = fX2;
- rLineCommand.mfY2 = fY2;
- mpDrawCommands.push_back(std::move(pCommand));
-}
-
} // end vcl namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fb6f8a0f15cf4f36e89ec560772ca437f7cb4a4e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jan 25 17:33:33 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Mar 4 19:09:16 2019 +0100
separate WidgetDefinitionReader from the actual WidgetDefinition
This separates the functionallity to read the definition from the
definition itself. This is needed to have both responisibilities
separated so it's easier to work with and test.
Change-Id: Id0dd9c17852a8b7479e9d01d4c1726e915d3dc6e
Reviewed-on: https://gerrit.libreoffice.org/68681
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/inc/FileDefinitionWidgetDraw.hxx b/vcl/inc/FileDefinitionWidgetDraw.hxx
index 97181c17bbcb..ba34cbe13467 100644
--- a/vcl/inc/FileDefinitionWidgetDraw.hxx
+++ b/vcl/inc/FileDefinitionWidgetDraw.hxx
@@ -22,7 +22,7 @@ class FileDefinitionWidgetDraw : public vcl::WidgetDrawInterface
{
private:
SalGraphics& m_rGraphics;
- WidgetDefinitionReader m_WidgetDefinitionReader;
+ WidgetDefinition m_aWidgetDefinition;
public:
FileDefinitionWidgetDraw(SalGraphics& rGraphics);
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
index 77548c72aa0c..4d9caddce374 100644
--- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
@@ -109,7 +109,7 @@ public:
float fY2);
};
-class VCL_DLLPUBLIC WidgetDefinition
+class VCL_DLLPUBLIC WidgetDefinitionPart
{
public:
std::vector<std::shared_ptr<WidgetDefinitionState>> getStates(ControlState eState,
@@ -118,24 +118,8 @@ public:
std::vector<std::shared_ptr<WidgetDefinitionState>> maStates;
};
-class VCL_DLLPUBLIC WidgetDefinitionReader
+class VCL_DLLPUBLIC WidgetDefinition
{
-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);
- void readEditbox(tools::XmlWalker& rWalker);
-
- static void readDrawingDefinition(tools::XmlWalker& rWalker,
- std::shared_ptr<WidgetDefinitionState>& rStates);
-
public:
Color maFaceColor;
Color maCheckedColor;
@@ -188,16 +172,32 @@ public:
Color maToolTextColor;
Color maFontColor;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maPushButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maRadioButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinition>> maEditboxDefinitions;
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maPushButtonDefinitions;
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maRadioButtonDefinitions;
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maEditboxDefinitions;
- std::shared_ptr<WidgetDefinition> getPushButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinition> getRadioButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinition> getEditboxDefinition(ControlPart ePart);
+ std::shared_ptr<WidgetDefinitionPart> getPushButtonDefinition(ControlPart ePart);
+ std::shared_ptr<WidgetDefinitionPart> getRadioButtonDefinition(ControlPart ePart);
+ std::shared_ptr<WidgetDefinitionPart> getEditboxDefinition(ControlPart ePart);
+};
+
+class VCL_DLLPUBLIC WidgetDefinitionReader
+{
+private:
+ OUString m_rFilePath;
+
+ static void
+ readDefinition(tools::XmlWalker& rWalker,
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>>& rDefinition);
+ static void readPart(tools::XmlWalker& rWalker, std::shared_ptr<WidgetDefinitionPart> rpPart);
+
+ static void readDrawingDefinition(tools::XmlWalker& rWalker,
+ std::shared_ptr<WidgetDefinitionState>& rStates);
+
+public:
WidgetDefinitionReader(OUString const& rFilePath);
- bool read();
+ bool read(WidgetDefinition& rWidgetDefinition);
};
} // end vcl namespace
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
index d6dad8dca74a..54ac184651ca 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -37,25 +37,26 @@ public:
void WidgetDefinitionReaderTest::testRead()
{
- vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"));
+ vcl::WidgetDefinition aDefinition;
- CPPUNIT_ASSERT_EQUAL(OUString("000000"), aReader.maFaceColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("000000"), aReader.maCheckedColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("000000"), aReader.maLightColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("000000"), aDefinition.maFaceColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("000000"), aDefinition.maCheckedColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("000000"), aDefinition.maLightColor.AsRGBHexString());
- aReader.read();
+ vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"));
+ aReader.read(aDefinition);
- CPPUNIT_ASSERT_EQUAL(OUString("123456"), aReader.maFaceColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("234567"), aReader.maCheckedColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("345678"), aReader.maLightColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("123456"), aDefinition.maFaceColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("234567"), aDefinition.maCheckedColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("345678"), aDefinition.maLightColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aReader.maVisitedLinkColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aReader.maToolTextColor.AsRGBHexString());
- CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aReader.maFontColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.maVisitedLinkColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.maToolTextColor.AsRGBHexString());
+ CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aDefinition.maFontColor.AsRGBHexString());
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
- = aReader.getPushButtonDefinition(ControlPart::Entire)
+ = aDefinition.getPushButtonDefinition(ControlPart::Entire)
->getStates(ControlState::DEFAULT | ControlState::ENABLED
| ControlState::ROLLOVER,
ImplControlValue());
@@ -70,7 +71,7 @@ void WidgetDefinitionReaderTest::testRead()
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
- = aReader.getRadioButtonDefinition(ControlPart::Entire)
+ = aDefinition.getRadioButtonDefinition(ControlPart::Entire)
->getStates(ControlState::NONE, ImplControlValue(ButtonValue::On));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(2), aStates[0]->mpDrawCommands.size());
@@ -78,7 +79,7 @@ void WidgetDefinitionReaderTest::testRead()
{
std::vector<std::shared_ptr<vcl::WidgetDefinitionState>> aStates
- = aReader.getRadioButtonDefinition(ControlPart::Entire)
+ = aDefinition.getRadioButtonDefinition(ControlPart::Entire)
->getStates(ControlState::NONE, ImplControlValue(ButtonValue::Off));
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates.size());
CPPUNIT_ASSERT_EQUAL(size_t(1), aStates[0]->mpDrawCommands.size());
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 854066694e22..c28967eb9b7f 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -30,9 +30,9 @@ OUString lcl_getThemeDefinitionPath()
FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics)
: m_rGraphics(rGraphics)
- , m_WidgetDefinitionReader(lcl_getThemeDefinitionPath() + "definition.xml")
{
- m_WidgetDefinitionReader.read();
+ WidgetDefinitionReader aReader(lcl_getThemeDefinitionPath() + "definition.xml");
+ aReader.read(m_aWidgetDefinition);
ImplSVData* pSVData = ImplGetSVData();
pSVData->maNWFData.mbNoFocusRects = true;
@@ -196,11 +196,11 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break;
case ControlType::Pushbutton:
{
- std::shared_ptr<WidgetDefinition> pDefinition
- = m_WidgetDefinitionReader.getPushButtonDefinition(ePart);
- if (pDefinition)
+ std::shared_ptr<WidgetDefinitionPart> pPart
+ = m_aWidgetDefinition.getPushButtonDefinition(ePart);
+ if (pPart)
{
- auto aStates = pDefinition->getStates(eState, rValue);
+ auto aStates = pPart->getStates(eState, rValue);
if (!aStates.empty())
{
std::shared_ptr<WidgetDefinitionState> pState = aStates.back();
@@ -215,12 +215,12 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
break;
case ControlType::Radiobutton:
{
- std::shared_ptr<WidgetDefinition> pDefinition
- = m_WidgetDefinitionReader.getRadioButtonDefinition(ePart);
- if (pDefinition)
+ std::shared_ptr<WidgetDefinitionPart> pPart
+ = m_aWidgetDefinition.getRadioButtonDefinition(ePart);
+ if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
- = pDefinition->getStates(eState, rValue).back();
+ = pPart->getStates(eState, rValue).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
@@ -235,12 +235,12 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
case ControlType::EditboxNoBorder:
case ControlType::MultilineEditbox:
{
- std::shared_ptr<WidgetDefinition> pDefinition
- = m_WidgetDefinitionReader.getEditboxDefinition(ePart);
- if (pDefinition)
+ std::shared_ptr<WidgetDefinitionPart> pPart
+ = m_aWidgetDefinition.getEditboxDefinition(ePart);
+ if (pPart)
{
std::shared_ptr<WidgetDefinitionState> pState
- = pDefinition->getStates(eState, rValue).back();
+ = pPart->getStates(eState, rValue).back();
{
munchDrawCommands(pState->mpDrawCommands, m_rGraphics, nX, nY, nWidth, nHeight);
bOK = true;
@@ -294,56 +294,56 @@ bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings)
{
StyleSettings aStyleSet = rSettings.GetStyleSettings();
- aStyleSet.SetFaceColor(m_WidgetDefinitionReader.maFaceColor);
- aStyleSet.SetCheckedColor(m_WidgetDefinitionReader.maCheckedColor);
- aStyleSet.SetLightColor(m_WidgetDefinitionReader.maLightColor);
- aStyleSet.SetLightBorderColor(m_WidgetDefinitionReader.maLightBorderColor);
- aStyleSet.SetShadowColor(m_WidgetDefinitionReader.maShadowColor);
- aStyleSet.SetDarkShadowColor(m_WidgetDefinitionReader.maDarkShadowColor);
- aStyleSet.SetButtonTextColor(m_WidgetDefinitionReader.maButtonTextColor);
- aStyleSet.SetButtonRolloverTextColor(m_WidgetDefinitionReader.maButtonRolloverTextColor);
- aStyleSet.SetRadioCheckTextColor(m_WidgetDefinitionReader.maRadioCheckTextColor);
- aStyleSet.SetGroupTextColor(m_WidgetDefinitionReader.maGroupTextColor);
- aStyleSet.SetLabelTextColor(m_WidgetDefinitionReader.maLabelTextColor);
- aStyleSet.SetWindowColor(m_WidgetDefinitionReader.maWindowColor);
- aStyleSet.SetWindowTextColor(m_WidgetDefinitionReader.maWindowTextColor);
- aStyleSet.SetDialogColor(m_WidgetDefinitionReader.maDialogColor);
- aStyleSet.SetDialogTextColor(m_WidgetDefinitionReader.maDialogTextColor);
- aStyleSet.SetWorkspaceColor(m_WidgetDefinitionReader.maWorkspaceColor);
- aStyleSet.SetMonoColor(m_WidgetDefinitionReader.maMonoColor);
- aStyleSet.SetFieldColor(m_WidgetDefinitionReader.maFieldColor);
- aStyleSet.SetFieldTextColor(m_WidgetDefinitionReader.maFieldTextColor);
- aStyleSet.SetFieldRolloverTextColor(m_WidgetDefinitionReader.maFieldRolloverTextColor);
- aStyleSet.SetActiveColor(m_WidgetDefinitionReader.maActiveColor);
- aStyleSet.SetActiveTextColor(m_WidgetDefinitionReader.maActiveTextColor);
- aStyleSet.SetActiveBorderColor(m_WidgetDefinitionReader.maActiveBorderColor);
- aStyleSet.SetDeactiveColor(m_WidgetDefinitionReader.maDeactiveColor);
- aStyleSet.SetDeactiveTextColor(m_WidgetDefinitionReader.maDeactiveTextColor);
- aStyleSet.SetDeactiveBorderColor(m_WidgetDefinitionReader.maDeactiveBorderColor);
- aStyleSet.SetMenuColor(m_WidgetDefinitionReader.maMenuColor);
- aStyleSet.SetMenuBarColor(m_WidgetDefinitionReader.maMenuBarColor);
- aStyleSet.SetMenuBarRolloverColor(m_WidgetDefinitionReader.maMenuBarRolloverColor);
- aStyleSet.SetMenuBorderColor(m_WidgetDefinitionReader.maMenuBorderColor);
- aStyleSet.SetMenuTextColor(m_WidgetDefinitionReader.maMenuTextColor);
- aStyleSet.SetMenuBarTextColor(m_WidgetDefinitionReader.maMenuBarTextColor);
- aStyleSet.SetMenuBarRolloverTextColor(m_WidgetDefinitionReader.maMenuBarRolloverTextColor);
- aStyleSet.SetMenuBarHighlightTextColor(m_WidgetDefinitionReader.maMenuBarHighlightTextColor);
- aStyleSet.SetMenuHighlightColor(m_WidgetDefinitionReader.maMenuHighlightColor);
- aStyleSet.SetMenuHighlightTextColor(m_WidgetDefinitionReader.maMenuHighlightTextColor);
- aStyleSet.SetHighlightColor(m_WidgetDefinitionReader.maHighlightColor);
- aStyleSet.SetHighlightTextColor(m_WidgetDefinitionReader.maHighlightTextColor);
- aStyleSet.SetActiveTabColor(m_WidgetDefinitionReader.maActiveTabColor);
- aStyleSet.SetInactiveTabColor(m_WidgetDefinitionReader.maInactiveTabColor);
- aStyleSet.SetTabTextColor(m_WidgetDefinitionReader.maTabTextColor);
- aStyleSet.SetTabRolloverTextColor(m_WidgetDefinitionReader.maTabRolloverTextColor);
- aStyleSet.SetTabHighlightTextColor(m_WidgetDefinitionReader.maTabHighlightTextColor);
- aStyleSet.SetDisableColor(m_WidgetDefinitionReader.maDisableColor);
- aStyleSet.SetHelpColor(m_WidgetDefinitionReader.maHelpColor);
- aStyleSet.SetHelpTextColor(m_WidgetDefinitionReader.maHelpTextColor);
- aStyleSet.SetLinkColor(m_WidgetDefinitionReader.maLinkColor);
- aStyleSet.SetVisitedLinkColor(m_WidgetDefinitionReader.maVisitedLinkColor);
- aStyleSet.SetToolTextColor(m_WidgetDefinitionReader.maToolTextColor);
- aStyleSet.SetFontColor(m_WidgetDefinitionReader.maFontColor);
+ aStyleSet.SetFaceColor(m_aWidgetDefinition.maFaceColor);
+ aStyleSet.SetCheckedColor(m_aWidgetDefinition.maCheckedColor);
+ aStyleSet.SetLightColor(m_aWidgetDefinition.maLightColor);
+ aStyleSet.SetLightBorderColor(m_aWidgetDefinition.maLightBorderColor);
+ aStyleSet.SetShadowColor(m_aWidgetDefinition.maShadowColor);
+ aStyleSet.SetDarkShadowColor(m_aWidgetDefinition.maDarkShadowColor);
+ aStyleSet.SetButtonTextColor(m_aWidgetDefinition.maButtonTextColor);
+ aStyleSet.SetButtonRolloverTextColor(m_aWidgetDefinition.maButtonRolloverTextColor);
+ aStyleSet.SetRadioCheckTextColor(m_aWidgetDefinition.maRadioCheckTextColor);
+ aStyleSet.SetGroupTextColor(m_aWidgetDefinition.maGroupTextColor);
+ aStyleSet.SetLabelTextColor(m_aWidgetDefinition.maLabelTextColor);
+ aStyleSet.SetWindowColor(m_aWidgetDefinition.maWindowColor);
+ aStyleSet.SetWindowTextColor(m_aWidgetDefinition.maWindowTextColor);
+ aStyleSet.SetDialogColor(m_aWidgetDefinition.maDialogColor);
+ aStyleSet.SetDialogTextColor(m_aWidgetDefinition.maDialogTextColor);
+ aStyleSet.SetWorkspaceColor(m_aWidgetDefinition.maWorkspaceColor);
+ aStyleSet.SetMonoColor(m_aWidgetDefinition.maMonoColor);
+ aStyleSet.SetFieldColor(m_aWidgetDefinition.maFieldColor);
+ aStyleSet.SetFieldTextColor(m_aWidgetDefinition.maFieldTextColor);
+ aStyleSet.SetFieldRolloverTextColor(m_aWidgetDefinition.maFieldRolloverTextColor);
+ aStyleSet.SetActiveColor(m_aWidgetDefinition.maActiveColor);
+ aStyleSet.SetActiveTextColor(m_aWidgetDefinition.maActiveTextColor);
+ aStyleSet.SetActiveBorderColor(m_aWidgetDefinition.maActiveBorderColor);
+ aStyleSet.SetDeactiveColor(m_aWidgetDefinition.maDeactiveColor);
+ aStyleSet.SetDeactiveTextColor(m_aWidgetDefinition.maDeactiveTextColor);
+ aStyleSet.SetDeactiveBorderColor(m_aWidgetDefinition.maDeactiveBorderColor);
+ aStyleSet.SetMenuColor(m_aWidgetDefinition.maMenuColor);
+ aStyleSet.SetMenuBarColor(m_aWidgetDefinition.maMenuBarColor);
+ aStyleSet.SetMenuBarRolloverColor(m_aWidgetDefinition.maMenuBarRolloverColor);
+ aStyleSet.SetMenuBorderColor(m_aWidgetDefinition.maMenuBorderColor);
+ aStyleSet.SetMenuTextColor(m_aWidgetDefinition.maMenuTextColor);
+ aStyleSet.SetMenuBarTextColor(m_aWidgetDefinition.maMenuBarTextColor);
+ aStyleSet.SetMenuBarRolloverTextColor(m_aWidgetDefinition.maMenuBarRolloverTextColor);
+ aStyleSet.SetMenuBarHighlightTextColor(m_aWidgetDefinition.maMenuBarHighlightTextColor);
+ aStyleSet.SetMenuHighlightColor(m_aWidgetDefinition.maMenuHighlightColor);
+ aStyleSet.SetMenuHighlightTextColor(m_aWidgetDefinition.maMenuHighlightTextColor);
+ aStyleSet.SetHighlightColor(m_aWidgetDefinition.maHighlightColor);
+ aStyleSet.SetHighlightTextColor(m_aWidgetDefinition.maHighlightTextColor);
+ aStyleSet.SetActiveTabColor(m_aWidgetDefinition.maActiveTabColor);
+ aStyleSet.SetInactiveTabColor(m_aWidgetDefinition.maInactiveTabColor);
+ aStyleSet.SetTabTextColor(m_aWidgetDefinition.maTabTextColor);
+ aStyleSet.SetTabRolloverTextColor(m_aWidgetDefinition.maTabRolloverTextColor);
+ aStyleSet.SetTabHighlightTextColor(m_aWidgetDefinition.maTabHighlightTextColor);
+ aStyleSet.SetDisableColor(m_aWidgetDefinition.maDisableColor);
+ aStyleSet.SetHelpColor(m_aWidgetDefinition.maHelpColor);
+ aStyleSet.SetHelpTextColor(m_aWidgetDefinition.maHelpTextColor);
+ aStyleSet.SetLinkColor(m_aWidgetDefinition.maLinkColor);
+ aStyleSet.SetVisitedLinkColor(m_aWidgetDefinition.maVisitedLinkColor);
+ aStyleSet.SetToolTextColor(m_aWidgetDefinition.maToolTextColor);
+ aStyleSet.SetFontColor(m_aWidgetDefinition.maFontColor);
rSettings.SetStyleSettings(aStyleSet);
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index 3a8848f50617..c3e6b10953da 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -146,7 +146,7 @@ void WidgetDefinitionReader::readDrawingDefinition(tools::XmlWalker& rWalker,
void WidgetDefinitionReader::readDefinition(
tools::XmlWalker& rWalker,
- std::unordered_map<OString, std::shared_ptr<WidgetDefinition>>& rDefinition)
+ std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>>& rPart)
{
rWalker.children();
while (rWalker.isValid())
@@ -154,8 +154,8 @@ void WidgetDefinitionReader::readDefinition(
if (rWalker.name() == "part")
{
OString sPart = rWalker.attribute("value");
- std::shared_ptr<WidgetDefinition> pPart = std::make_shared<WidgetDefinition>();
- rDefinition.emplace(sPart, pPart);
+ std::shared_ptr<WidgetDefinitionPart> pPart = std::make_shared<WidgetDefinitionPart>();
+ rPart.emplace(sPart, pPart);
readPart(rWalker, pPart);
}
rWalker.next();
@@ -164,7 +164,7 @@ void WidgetDefinitionReader::readDefinition(
}
void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
- std::shared_ptr<WidgetDefinition> rpPart)
+ std::shared_ptr<WidgetDefinitionPart> rpPart)
{
rWalker.children();
while (rWalker.isValid())
@@ -189,22 +189,7 @@ void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
rWalker.parent();
}
-void WidgetDefinitionReader::readPushButton(tools::XmlWalker& rWalker)
-{
- readDefinition(rWalker, maPushButtonDefinitions);
-}
-
-void WidgetDefinitionReader::readRadioButton(tools::XmlWalker& rWalker)
-{
- readDefinition(rWalker, maRadioButtonDefinitions);
-}
-
-void WidgetDefinitionReader::readEditbox(tools::XmlWalker& rWalker)
-{
- readDefinition(rWalker, maEditboxDefinitions);
-}
-
-bool WidgetDefinitionReader::read()
+bool WidgetDefinitionReader::read(WidgetDefinition& rWidgetDefinition)
{
if (!lcl_fileExists(m_rFilePath))
return false;
@@ -212,56 +197,56 @@ bool WidgetDefinitionReader::read()
SvFileStream aFileStream(m_rFilePath, StreamMode::READ);
std::unordered_map<OString, Color*> aStyleColorMap = {
- { "faceColor", &maFaceColor },
- { "checkedColor", &maCheckedColor },
- { "lightColor", &maLightColor },
- { "lightBorderColor", &maLightBorderColor },
- { "shadowColor", &maShadowColor },
- { "darkShadowColor", &maDarkShadowColor },
- { "buttonTextColor", &maButtonTextColor },
- { "buttonRolloverTextColor", &maButtonRolloverTextColor },
- { "radioCheckTextColor", &maRadioCheckTextColor },
- { "groupTextColor", &maGroupTextColor },
- { "labelTextColor", &maLabelTextColor },
- { "windowColor", &maWindowColor },
- { "windowTextColor", &maWindowTextColor },
- { "dialogColor", &maDialogColor },
- { "dialogTextColor", &maDialogTextColor },
- { "workspaceColor", &maWorkspaceColor },
- { "monoColor", &maMonoColor },
- { "fieldColor", &maFieldColor },
- { "fieldTextColor", &maFieldTextColor },
- { "fieldRolloverTextColor", &maFieldRolloverTextColor },
- { "activeColor", &maActiveColor },
- { "activeTextColor", &maActiveTextColor },
- { "activeBorderColor", &maActiveBorderColor },
- { "deactiveColor", &maDeactiveColor },
- { "deactiveTextColor", &maDeactiveTextColor },
- { "deactiveBorderColor", &maDeactiveBorderColor },
- { "menuColor", &maMenuColor },
- { "menuBarColor", &maMenuBarColor },
- { "menuBarRolloverColor", &maMenuBarRolloverColor },
- { "menuBorderColor", &maMenuBorderColor },
- { "menuTextColor", &maMenuTextColor },
- { "menuBarTextColor", &maMenuBarTextColor },
- { "menuBarRolloverTextColor", &maMenuBarRolloverTextColor },
- { "menuBarHighlightTextColor", &maMenuBarHighlightTextColor },
- { "menuHighlightColor", &maMenuHighlightColor },
- { "menuHighlightTextColor", &maMenuHighlightTextColor },
- { "highlightColor", &maHighlightColor },
- { "highlightTextColor", &maHighlightTextColor },
- { "activeTabColor", &maActiveTabColor },
- { "inactiveTabColor", &maInactiveTabColor },
- { "tabTextColor", &maTabTextColor },
- { "tabRolloverTextColor", &maTabRolloverTextColor },
- { "tabHighlightTextColor", &maTabHighlightTextColor },
- { "disableColor", &maDisableColor },
- { "helpColor", &maHelpColor },
- { "helpTextColor", &maHelpTextColor },
- { "linkColor", &maLinkColor },
- { "visitedLinkColor", &maVisitedLinkColor },
- { "toolTextColor", &maToolTextColor },
- { "fontColor", &maFontColor },
+ { "faceColor", &rWidgetDefinition.maFaceColor },
+ { "checkedColor", &rWidgetDefinition.maCheckedColor },
+ { "lightColor", &rWidgetDefinition.maLightColor },
+ { "lightBorderColor", &rWidgetDefinition.maLightBorderColor },
+ { "shadowColor", &rWidgetDefinition.maShadowColor },
+ { "darkShadowColor", &rWidgetDefinition.maDarkShadowColor },
+ { "buttonTextColor", &rWidgetDefinition.maButtonTextColor },
+ { "buttonRolloverTextColor", &rWidgetDefinition.maButtonRolloverTextColor },
+ { "radioCheckTextColor", &rWidgetDefinition.maRadioCheckTextColor },
+ { "groupTextColor", &rWidgetDefinition.maGroupTextColor },
+ { "labelTextColor", &rWidgetDefinition.maLabelTextColor },
+ { "windowColor", &rWidgetDefinition.maWindowColor },
+ { "windowTextColor", &rWidgetDefinition.maWindowTextColor },
+ { "dialogColor", &rWidgetDefinition.maDialogColor },
+ { "dialogTextColor", &rWidgetDefinition.maDialogTextColor },
+ { "workspaceColor", &rWidgetDefinition.maWorkspaceColor },
+ { "monoColor", &rWidgetDefinition.maMonoColor },
+ { "fieldColor", &rWidgetDefinition.maFieldColor },
+ { "fieldTextColor", &rWidgetDefinition.maFieldTextColor },
+ { "fieldRolloverTextColor", &rWidgetDefinition.maFieldRolloverTextColor },
+ { "activeColor", &rWidgetDefinition.maActiveColor },
+ { "activeTextColor", &rWidgetDefinition.maActiveTextColor },
+ { "activeBorderColor", &rWidgetDefinition.maActiveBorderColor },
+ { "deactiveColor", &rWidgetDefinition.maDeactiveColor },
+ { "deactiveTextColor", &rWidgetDefinition.maDeactiveTextColor },
+ { "deactiveBorderColor", &rWidgetDefinition.maDeactiveBorderColor },
+ { "menuColor", &rWidgetDefinition.maMenuColor },
+ { "menuBarColor", &rWidgetDefinition.maMenuBarColor },
+ { "menuBarRolloverColor", &rWidgetDefinition.maMenuBarRolloverColor },
+ { "menuBorderColor", &rWidgetDefinition.maMenuBorderColor },
+ { "menuTextColor", &rWidgetDefinition.maMenuTextColor },
+ { "menuBarTextColor", &rWidgetDefinition.maMenuBarTextColor },
+ { "menuBarRolloverTextColor", &rWidgetDefinition.maMenuBarRolloverTextColor },
+ { "menuBarHighlightTextColor", &rWidgetDefinition.maMenuBarHighlightTextColor },
+ { "menuHighlightColor", &rWidgetDefinition.maMenuHighlightColor },
+ { "menuHighlightTextColor", &rWidgetDefinition.maMenuHighlightTextColor },
+ { "highlightColor", &rWidgetDefinition.maHighlightColor },
+ { "highlightTextColor", &rWidgetDefinition.maHighlightTextColor },
+ { "activeTabColor", &rWidgetDefinition.maActiveTabColor },
+ { "inactiveTabColor", &rWidgetDefinition.maInactiveTabColor },
+ { "tabTextColor", &rWidgetDefinition.maTabTextColor },
+ { "tabRolloverTextColor", &rWidgetDefinition.maTabRolloverTextColor },
+ { "tabHighlightTextColor", &rWidgetDefinition.maTabHighlightTextColor },
+ { "disableColor", &rWidgetDefinition.maDisableColor },
+ { "helpColor", &rWidgetDefinition.maHelpColor },
+ { "helpTextColor", &rWidgetDefinition.maHelpTextColor },
+ { "linkColor", &rWidgetDefinition.maLinkColor },
+ { "visitedLinkColor", &rWidgetDefinition.maVisitedLinkColor },
+ { "toolTextColor", &rWidgetDefinition.maToolTextColor },
+ { "fontColor", &rWidgetDefinition.maFontColor },
};
tools::XmlWalker aWalker;
@@ -290,15 +275,15 @@ bool WidgetDefinitionReader::read()
}
else if (aWalker.name() == "pushbutton")
{
- readPushButton(aWalker);
+ readDefinition(aWalker, rWidgetDefinition.maPushButtonDefinitions);
}
else if (aWalker.name() == "radiobutton")
{
- readRadioButton(aWalker);
+ readDefinition(aWalker, rWidgetDefinition.maRadioButtonDefinitions);
}
else if (aWalker.name() == "editbox")
{
- readEditbox(aWalker);
+ readDefinition(aWalker, rWidgetDefinition.maEditboxDefinitions);
}
aWalker.next();
}
@@ -392,36 +377,35 @@ OString xmlControlPart(ControlPart ePart)
} // end anonymous namespace
-std::shared_ptr<WidgetDefinition> WidgetDefinitionReader::getPushButtonDefinition(ControlPart ePart)
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getPushButtonDefinition(ControlPart ePart)
{
auto aIterator = maPushButtonDefinitions.find(xmlControlPart(ePart));
if (aIterator != maPushButtonDefinitions.end())
return aIterator->second;
- return std::shared_ptr<WidgetDefinition>();
+ return std::shared_ptr<WidgetDefinitionPart>();
}
-std::shared_ptr<WidgetDefinition>
-WidgetDefinitionReader::getRadioButtonDefinition(ControlPart ePart)
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getRadioButtonDefinition(ControlPart ePart)
{
auto aIterator = maRadioButtonDefinitions.find(xmlControlPart(ePart));
if (aIterator != maRadioButtonDefinitions.end())
return aIterator->second;
- return std::shared_ptr<WidgetDefinition>();
+ return std::shared_ptr<WidgetDefinitionPart>();
}
-std::shared_ptr<WidgetDefinition> WidgetDefinitionReader::getEditboxDefinition(ControlPart ePart)
+std::shared_ptr<WidgetDefinitionPart> WidgetDefinition::getEditboxDefinition(ControlPart ePart)
{
auto aIterator = maEditboxDefinitions.find(xmlControlPart(ePart));
if (aIterator != maEditboxDefinitions.end())
return aIterator->second;
- return std::shared_ptr<WidgetDefinition>();
+ return std::shared_ptr<WidgetDefinitionPart>();
}
std::vector<std::shared_ptr<WidgetDefinitionState>>
-WidgetDefinition::getStates(ControlState eState, ImplControlValue const& rValue)
+WidgetDefinitionPart::getStates(ControlState eState, ImplControlValue const& rValue)
{
std::vector<std::shared_ptr<WidgetDefinitionState>> aStatesToAdd;
More information about the Libreoffice-commits
mailing list