diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-03-09 14:50:57 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-03-10 08:40:20 +0100 |
commit | e9393e392e95ec8fcab77662790482aa0adf0f78 (patch) | |
tree | cde3abd435cf5b1d119572eb6af36aacfc8ed6ef /vcl | |
parent | 32437e53a653c32c8f2e298e0a86fac086ae35f4 (diff) |
only read and parse widget definition once from the file
Change-Id: I71c095e5e5dd21650663e6fb717bcb22958a597f
Reviewed-on: https://gerrit.libreoffice.org/68976
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/FileDefinitionWidgetDraw.hxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 34 |
2 files changed, 25 insertions, 11 deletions
diff --git a/vcl/inc/FileDefinitionWidgetDraw.hxx b/vcl/inc/FileDefinitionWidgetDraw.hxx index dc3ee7f8967c..24b9e0ab8a26 100644 --- a/vcl/inc/FileDefinitionWidgetDraw.hxx +++ b/vcl/inc/FileDefinitionWidgetDraw.hxx @@ -22,7 +22,7 @@ class FileDefinitionWidgetDraw : public vcl::WidgetDrawInterface { private: SalGraphics& m_rGraphics; - WidgetDefinition m_aWidgetDefinition; + std::shared_ptr<WidgetDefinition> m_pWidgetDefinition; bool resolveDefinition(ControlType eType, ControlPart ePart, ControlState eState, const ImplControlValue& rValue, long nX, long nY, long nWidth, diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index bc2636491829..17b7c2c833db 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -44,14 +44,28 @@ OUString lcl_getThemeDefinitionPath() return sPath; } +std::shared_ptr<WidgetDefinition> setWidgetDefinition(OUString const& rDefinitionFile, + OUString const& rDefinitionResourcesPath) +{ + static std::shared_ptr<WidgetDefinition> spDefinition; + if (!spDefinition) + { + spDefinition = std::make_shared<WidgetDefinition>(); + WidgetDefinitionReader aReader(rDefinitionFile, rDefinitionResourcesPath); + aReader.read(*spDefinition); + } + return spDefinition; +} + } // end anonymous namespace FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics) : m_rGraphics(rGraphics) { OUString sDefinitionBasePath = lcl_getThemeDefinitionPath(); - WidgetDefinitionReader aReader(sDefinitionBasePath + "definition.xml", sDefinitionBasePath); - aReader.read(m_aWidgetDefinition); + + m_pWidgetDefinition + = setWidgetDefinition(sDefinitionBasePath + "definition.xml", sDefinitionBasePath); ImplSVData* pSVData = ImplGetSVData(); pSVData->maNWFData.mbNoFocusRects = true; @@ -385,7 +399,7 @@ bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart long nWidth, long nHeight) { bool bOK = false; - auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ePart); + auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart); if (pPart) { auto const& aStates = pPart->getStates(eType, eState, rValue); @@ -588,13 +602,13 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( case ControlType::Spinbox: { auto const& pButtonUpPart - = m_aWidgetDefinition.getDefinition(eType, ControlPart::ButtonUp); + = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonUp); if (!pButtonUpPart) return false; Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight); auto const& pButtonDownPart - = m_aWidgetDefinition.getDefinition(eType, ControlPart::ButtonDown); + = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown); if (!pButtonDownPart) return false; Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight); @@ -679,7 +693,7 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( break; case ControlType::Checkbox: { - auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire); + auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); if (!pPart) return false; @@ -689,7 +703,7 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( } case ControlType::Radiobutton: { - auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire); + auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); if (!pPart) return false; @@ -699,7 +713,7 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( } case ControlType::TabItem: { - auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::Entire); + auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire); if (!pPart) return false; @@ -743,7 +757,7 @@ bool FileDefinitionWidgetDraw::getNativeControlRegion( case ControlType::Combobox: case ControlType::Listbox: { - auto const& pPart = m_aWidgetDefinition.getDefinition(eType, ControlPart::ButtonDown); + auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown); Size aComboButtonSize(pPart->mnWidth, pPart->mnHeight); if (ePart == ControlPart::ButtonDown) @@ -786,7 +800,7 @@ bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings) { StyleSettings aStyleSet = rSettings.GetStyleSettings(); - auto pDefinitionStyle = m_aWidgetDefinition.mpStyle; + auto pDefinitionStyle = m_pWidgetDefinition->mpStyle; aStyleSet.SetFaceColor(pDefinitionStyle->maFaceColor); aStyleSet.SetCheckedColor(pDefinitionStyle->maCheckedColor); |