Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/gdi/WidgetDefinitionReader.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 */
10
11
#include <frozen/bits/defines.h>
12
#include <frozen/bits/elsa_std.h>
13
#include <frozen/unordered_map.h>
14
15
#include <unordered_map>
16
#include <utility>
17
18
#include <widgetdraw/WidgetDefinitionReader.hxx>
19
20
#include <sal/config.h>
21
#include <osl/file.hxx>
22
#include <tools/stream.hxx>
23
#include <o3tl/string_view.hxx>
24
#include <o3tl/numeric.hxx>
25
26
namespace vcl
27
{
28
namespace
29
{
30
bool lcl_fileExists(OUString const& sFilename)
31
0
{
32
0
    osl::File aFile(sFilename);
33
0
    osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
34
0
    return osl::FileBase::E_None == eRC;
35
0
}
36
37
bool readSetting(OString const& rInputString, OString& rOutputString)
38
0
{
39
0
    if (!rInputString.isEmpty())
40
0
        rOutputString = rInputString;
41
0
    return true;
42
0
}
43
44
OString getValueOrAny(OString const& rInputString)
45
0
{
46
0
    if (rInputString.isEmpty())
47
0
        return "any"_ostr;
48
0
    return rInputString;
49
0
}
50
51
ControlPart xmlStringToControlPart(std::string_view sPart)
52
0
{
53
0
    if (o3tl::equalsIgnoreAsciiCase(sPart, "NONE"))
54
0
        return ControlPart::NONE;
55
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Entire"))
56
0
        return ControlPart::Entire;
57
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ListboxWindow"))
58
0
        return ControlPart::ListboxWindow;
59
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Button"))
60
0
        return ControlPart::Button;
61
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ButtonUp"))
62
0
        return ControlPart::ButtonUp;
63
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ButtonDown"))
64
0
        return ControlPart::ButtonDown;
65
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ButtonLeft"))
66
0
        return ControlPart::ButtonLeft;
67
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ButtonRight"))
68
0
        return ControlPart::ButtonRight;
69
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "AllButtons"))
70
0
        return ControlPart::AllButtons;
71
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "SeparatorHorz"))
72
0
        return ControlPart::SeparatorHorz;
73
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "SeparatorVert"))
74
0
        return ControlPart::SeparatorVert;
75
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackHorzLeft"))
76
0
        return ControlPart::TrackHorzLeft;
77
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackVertUpper"))
78
0
        return ControlPart::TrackVertUpper;
79
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackHorzRight"))
80
0
        return ControlPart::TrackHorzRight;
81
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackVertLower"))
82
0
        return ControlPart::TrackVertLower;
83
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackHorzArea"))
84
0
        return ControlPart::TrackHorzArea;
85
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TrackVertArea"))
86
0
        return ControlPart::TrackVertArea;
87
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Arrow"))
88
0
        return ControlPart::Arrow;
89
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ThumbHorz"))
90
0
        return ControlPart::ThumbHorz;
91
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "ThumbVert"))
92
0
        return ControlPart::ThumbVert;
93
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "MenuItem"))
94
0
        return ControlPart::MenuItem;
95
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "MenuItemCheckMark"))
96
0
        return ControlPart::MenuItemCheckMark;
97
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "MenuItemRadioMark"))
98
0
        return ControlPart::MenuItemRadioMark;
99
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Separator"))
100
0
        return ControlPart::Separator;
101
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "SubmenuArrow"))
102
0
        return ControlPart::SubmenuArrow;
103
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "SubEdit"))
104
0
        return ControlPart::SubEdit;
105
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "DrawBackgroundHorz"))
106
0
        return ControlPart::DrawBackgroundHorz;
107
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "DrawBackgroundVert"))
108
0
        return ControlPart::DrawBackgroundVert;
109
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "TabsDrawRtl"))
110
0
        return ControlPart::TabsDrawRtl;
111
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "HasBackgroundTexture"))
112
0
        return ControlPart::HasBackgroundTexture;
113
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "HasThreeButtons"))
114
0
        return ControlPart::HasThreeButtons;
115
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "BackgroundWindow"))
116
0
        return ControlPart::BackgroundWindow;
117
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "BackgroundDialog"))
118
0
        return ControlPart::BackgroundDialog;
119
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Border"))
120
0
        return ControlPart::Border;
121
0
    else if (o3tl::equalsIgnoreAsciiCase(sPart, "Focus"))
122
0
        return ControlPart::Focus;
123
0
    return ControlPart::NONE;
124
0
}
125
126
bool getControlTypeForXmlString(std::string_view rString, ControlType& reType)
127
0
{
128
0
    static constexpr auto aPartMap = frozen::make_unordered_map<std::string_view, ControlType>({
129
0
        { "pushbutton", ControlType::Pushbutton },
130
0
        { "radiobutton", ControlType::Radiobutton },
131
0
        { "checkbox", ControlType::Checkbox },
132
0
        { "combobox", ControlType::Combobox },
133
0
        { "editbox", ControlType::Editbox },
134
0
        { "listbox", ControlType::Listbox },
135
0
        { "scrollbar", ControlType::Scrollbar },
136
0
        { "spinbox", ControlType::Spinbox },
137
0
        { "slider", ControlType::Slider },
138
0
        { "fixedline", ControlType::Fixedline },
139
0
        { "progress", ControlType::Progress },
140
0
        { "levelbar", ControlType::LevelBar },
141
0
        { "tabitem", ControlType::TabItem },
142
0
        { "tabheader", ControlType::TabHeader },
143
0
        { "tabpane", ControlType::TabPane },
144
0
        { "tabbody", ControlType::TabBody },
145
0
        { "frame", ControlType::Frame },
146
0
        { "windowbackground", ControlType::WindowBackground },
147
0
        { "toolbar", ControlType::Toolbar },
148
0
        { "listnode", ControlType::ListNode },
149
0
        { "listnet", ControlType::ListNet },
150
0
        { "listheader", ControlType::ListHeader },
151
0
        { "menubar", ControlType::Menubar },
152
0
        { "menupopup", ControlType::MenuPopup },
153
0
        { "tooltip", ControlType::Tooltip },
154
0
    });
155
156
0
    auto const aIterator = aPartMap.find(rString);
157
0
    if (aIterator != aPartMap.end())
158
0
    {
159
0
        reType = aIterator->second;
160
0
        return true;
161
0
    }
162
0
    return false;
163
0
}
164
165
} // end anonymous namespace
166
167
WidgetDefinitionReader::WidgetDefinitionReader(OUString aDefinitionFile, OUString aResourcePath)
168
0
    : m_rDefinitionFile(std::move(aDefinitionFile))
169
0
    , m_rResourcePath(std::move(aResourcePath))
170
0
{
171
0
}
172
173
void WidgetDefinitionReader::readDrawingDefinition(
174
    tools::XmlWalker& rWalker, const std::shared_ptr<WidgetDefinitionState>& rpState)
175
0
{
176
0
    rWalker.children();
177
0
    while (rWalker.isValid())
178
0
    {
179
0
        if (rWalker.name() == "rect")
180
0
        {
181
0
            Color aStrokeColor;
182
0
            color::createFromString(rWalker.attribute("stroke"_ostr), aStrokeColor);
183
0
            Color aFillColor;
184
0
            color::createFromString(rWalker.attribute("fill"_ostr), aFillColor);
185
0
            OString sStrokeWidth = rWalker.attribute("stroke-width"_ostr);
186
0
            sal_Int32 nStrokeWidth = -1;
187
0
            if (!sStrokeWidth.isEmpty())
188
0
                nStrokeWidth = sStrokeWidth.toInt32();
189
190
0
            sal_Int32 nRx = -1;
191
0
            OString sRx = rWalker.attribute("rx"_ostr);
192
0
            if (!sRx.isEmpty())
193
0
                nRx = sRx.toInt32();
194
195
0
            sal_Int32 nRy = -1;
196
0
            OString sRy = rWalker.attribute("ry"_ostr);
197
0
            if (!sRy.isEmpty())
198
0
                nRy = sRy.toInt32();
199
200
0
            OString sX1 = rWalker.attribute("x1"_ostr);
201
0
            float fX1 = sX1.isEmpty() ? 0.0 : sX1.toFloat();
202
203
0
            OString sY1 = rWalker.attribute("y1"_ostr);
204
0
            float fY1 = sY1.isEmpty() ? 0.0 : sY1.toFloat();
205
206
0
            OString sX2 = rWalker.attribute("x2"_ostr);
207
0
            float fX2 = sX2.isEmpty() ? 1.0 : sX2.toFloat();
208
209
0
            OString sY2 = rWalker.attribute("y2"_ostr);
210
0
            float fY2 = sY2.isEmpty() ? 1.0 : sY2.toFloat();
211
212
0
            rpState->addDrawRectangle(aStrokeColor, nStrokeWidth, aFillColor, fX1, fY1, fX2, fY2,
213
0
                                      nRx, nRy);
214
0
        }
215
0
        else if (rWalker.name() == "line")
216
0
        {
217
0
            Color aStrokeColor;
218
0
            color::createFromString(rWalker.attribute("stroke"_ostr), aStrokeColor);
219
220
0
            OString sStrokeWidth = rWalker.attribute("stroke-width"_ostr);
221
0
            sal_Int32 nStrokeWidth = -1;
222
0
            if (!sStrokeWidth.isEmpty())
223
0
                nStrokeWidth = sStrokeWidth.toInt32();
224
225
0
            OString sX1 = rWalker.attribute("x1"_ostr);
226
0
            float fX1 = sX1.isEmpty() ? -1.0 : sX1.toFloat();
227
228
0
            OString sY1 = rWalker.attribute("y1"_ostr);
229
0
            float fY1 = sY1.isEmpty() ? -1.0 : sY1.toFloat();
230
231
0
            OString sX2 = rWalker.attribute("x2"_ostr);
232
0
            float fX2 = sX2.isEmpty() ? -1.0 : sX2.toFloat();
233
234
0
            OString sY2 = rWalker.attribute("y2"_ostr);
235
0
            float fY2 = sY2.isEmpty() ? -1.0 : sY2.toFloat();
236
237
0
            rpState->addDrawLine(aStrokeColor, nStrokeWidth, fX1, fY1, fX2, fY2);
238
0
        }
239
0
        else if (rWalker.name() == "image")
240
0
        {
241
0
            OString sSource = rWalker.attribute("source"_ostr);
242
0
            rpState->addDrawImage(m_rResourcePath
243
0
                                  + OStringToOUString(sSource, RTL_TEXTENCODING_UTF8));
244
0
        }
245
0
        else if (rWalker.name() == "external")
246
0
        {
247
0
            OString sSource = rWalker.attribute("source"_ostr);
248
0
            rpState->addDrawExternal(m_rResourcePath
249
0
                                     + OStringToOUString(sSource, RTL_TEXTENCODING_UTF8));
250
0
        }
251
0
        rWalker.next();
252
0
    }
253
0
    rWalker.parent();
254
0
}
255
256
void WidgetDefinitionReader::readDefinition(tools::XmlWalker& rWalker,
257
                                            WidgetDefinition& rWidgetDefinition, ControlType eType)
258
0
{
259
0
    rWalker.children();
260
0
    while (rWalker.isValid())
261
0
    {
262
0
        if (rWalker.name() == "part")
263
0
        {
264
0
            OString sPart = rWalker.attribute("value"_ostr);
265
0
            ControlPart ePart = xmlStringToControlPart(sPart);
266
267
0
            std::shared_ptr<WidgetDefinitionPart> pPart = std::make_shared<WidgetDefinitionPart>();
268
269
0
            OString sWidth = rWalker.attribute("width"_ostr);
270
0
            if (!sWidth.isEmpty())
271
0
            {
272
0
                sal_Int32 nWidth = sWidth.isEmpty() ? 0 : sWidth.toInt32();
273
0
                pPart->mnWidth = nWidth;
274
0
            }
275
276
0
            OString sHeight = rWalker.attribute("height"_ostr);
277
0
            if (!sHeight.isEmpty())
278
0
            {
279
0
                sal_Int32 nHeight = sHeight.isEmpty() ? 0 : sHeight.toInt32();
280
0
                pPart->mnHeight = nHeight;
281
0
            }
282
283
0
            OString sMarginHeight = rWalker.attribute("margin-height"_ostr);
284
0
            if (!sMarginHeight.isEmpty())
285
0
            {
286
0
                sal_Int32 nMarginHeight = sMarginHeight.isEmpty() ? 0 : sMarginHeight.toInt32();
287
0
                pPart->mnMarginHeight = nMarginHeight;
288
0
            }
289
290
0
            OString sMarginWidth = rWalker.attribute("margin-width"_ostr);
291
0
            if (!sMarginWidth.isEmpty())
292
0
            {
293
0
                sal_Int32 nMarginWidth = sMarginWidth.isEmpty() ? 0 : sMarginWidth.toInt32();
294
0
                pPart->mnMarginWidth = nMarginWidth;
295
0
            }
296
297
0
            OString sOrientation = rWalker.attribute("orientation"_ostr);
298
0
            if (!sOrientation.isEmpty())
299
0
            {
300
0
                pPart->msOrientation = sOrientation;
301
0
            }
302
303
0
            rWidgetDefinition.maDefinitions.emplace(ControlTypeAndPart(eType, ePart), pPart);
304
0
            readPart(rWalker, pPart);
305
0
        }
306
0
        rWalker.next();
307
0
    }
308
0
    rWalker.parent();
309
0
}
310
311
void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
312
                                      const std::shared_ptr<WidgetDefinitionPart>& rpPart)
313
0
{
314
0
    rWalker.children();
315
0
    while (rWalker.isValid())
316
0
    {
317
0
        if (rWalker.name() == "state")
318
0
        {
319
0
            OString sEnabled = getValueOrAny(rWalker.attribute("enabled"_ostr));
320
0
            OString sFocused = getValueOrAny(rWalker.attribute("focused"_ostr));
321
0
            OString sPressed = getValueOrAny(rWalker.attribute("pressed"_ostr));
322
0
            OString sRollover = getValueOrAny(rWalker.attribute("rollover"_ostr));
323
0
            OString sDefault = getValueOrAny(rWalker.attribute("default"_ostr));
324
0
            OString sSelected = getValueOrAny(rWalker.attribute("selected"_ostr));
325
0
            OString sButtonValue = getValueOrAny(rWalker.attribute("button-value"_ostr));
326
0
            OString sExtra = getValueOrAny(rWalker.attribute("extra"_ostr));
327
328
0
            std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(
329
0
                sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue, sExtra);
330
331
0
            rpPart->maStates.push_back(pState);
332
0
            readDrawingDefinition(rWalker, pState);
333
0
        }
334
0
        rWalker.next();
335
0
    }
336
0
    rWalker.parent();
337
0
}
338
339
bool WidgetDefinitionReader::read(WidgetDefinition& rWidgetDefinition)
340
0
{
341
0
    if (!lcl_fileExists(m_rDefinitionFile))
342
0
        return false;
343
344
0
    rWidgetDefinition.mpStyle = std::make_shared<WidgetDefinitionStyle>();
345
346
0
    std::unordered_map<std::string_view, Color*> aStyleColorMap = {
347
0
        { "faceColor", &rWidgetDefinition.mpStyle->maFaceColor },
348
0
        { "checkedColor", &rWidgetDefinition.mpStyle->maCheckedColor },
349
0
        { "lightColor", &rWidgetDefinition.mpStyle->maLightColor },
350
0
        { "lightBorderColor", &rWidgetDefinition.mpStyle->maLightBorderColor },
351
0
        { "shadowColor", &rWidgetDefinition.mpStyle->maShadowColor },
352
0
        { "darkShadowColor", &rWidgetDefinition.mpStyle->maDarkShadowColor },
353
0
        { "buttonTextColor", &rWidgetDefinition.mpStyle->maButtonTextColor },
354
0
        { "defaultActionButtonTextColor",
355
0
          &rWidgetDefinition.mpStyle->maDefaultActionButtonTextColor },
356
0
        { "actionButtonTextColor", &rWidgetDefinition.mpStyle->maActionButtonTextColor },
357
0
        { "actionButtonRolloverTextColor",
358
0
          &rWidgetDefinition.mpStyle->maActionButtonRolloverTextColor },
359
0
        { "buttonRolloverTextColor", &rWidgetDefinition.mpStyle->maButtonRolloverTextColor },
360
0
        { "radioCheckTextColor", &rWidgetDefinition.mpStyle->maRadioCheckTextColor },
361
0
        { "groupTextColor", &rWidgetDefinition.mpStyle->maGroupTextColor },
362
0
        { "labelTextColor", &rWidgetDefinition.mpStyle->maLabelTextColor },
363
0
        { "windowColor", &rWidgetDefinition.mpStyle->maWindowColor },
364
0
        { "windowTextColor", &rWidgetDefinition.mpStyle->maWindowTextColor },
365
0
        { "dialogColor", &rWidgetDefinition.mpStyle->maDialogColor },
366
0
        { "dialogTextColor", &rWidgetDefinition.mpStyle->maDialogTextColor },
367
0
        { "workspaceColor", &rWidgetDefinition.mpStyle->maWorkspaceColor },
368
0
        { "monoColor", &rWidgetDefinition.mpStyle->maMonoColor },
369
0
        { "fieldColor", &rWidgetDefinition.mpStyle->maFieldColor },
370
0
        { "fieldTextColor", &rWidgetDefinition.mpStyle->maFieldTextColor },
371
0
        { "fieldRolloverTextColor", &rWidgetDefinition.mpStyle->maFieldRolloverTextColor },
372
0
        { "activeColor", &rWidgetDefinition.mpStyle->maActiveColor },
373
0
        { "activeTextColor", &rWidgetDefinition.mpStyle->maActiveTextColor },
374
0
        { "activeBorderColor", &rWidgetDefinition.mpStyle->maActiveBorderColor },
375
0
        { "deactiveColor", &rWidgetDefinition.mpStyle->maDeactiveColor },
376
0
        { "deactiveTextColor", &rWidgetDefinition.mpStyle->maDeactiveTextColor },
377
0
        { "deactiveBorderColor", &rWidgetDefinition.mpStyle->maDeactiveBorderColor },
378
0
        { "menuColor", &rWidgetDefinition.mpStyle->maMenuColor },
379
0
        { "menuBarColor", &rWidgetDefinition.mpStyle->maMenuBarColor },
380
0
        { "menuBarRolloverColor", &rWidgetDefinition.mpStyle->maMenuBarRolloverColor },
381
0
        { "menuBorderColor", &rWidgetDefinition.mpStyle->maMenuBorderColor },
382
0
        { "menuTextColor", &rWidgetDefinition.mpStyle->maMenuTextColor },
383
0
        { "menuBarTextColor", &rWidgetDefinition.mpStyle->maMenuBarTextColor },
384
0
        { "menuBarRolloverTextColor", &rWidgetDefinition.mpStyle->maMenuBarRolloverTextColor },
385
0
        { "menuBarHighlightTextColor", &rWidgetDefinition.mpStyle->maMenuBarHighlightTextColor },
386
0
        { "menuHighlightColor", &rWidgetDefinition.mpStyle->maMenuHighlightColor },
387
0
        { "menuHighlightTextColor", &rWidgetDefinition.mpStyle->maMenuHighlightTextColor },
388
0
        { "highlightColor", &rWidgetDefinition.mpStyle->maHighlightColor },
389
0
        { "highlightTextColor", &rWidgetDefinition.mpStyle->maHighlightTextColor },
390
0
        { "activeTabColor", &rWidgetDefinition.mpStyle->maActiveTabColor },
391
0
        { "inactiveTabColor", &rWidgetDefinition.mpStyle->maInactiveTabColor },
392
0
        { "tabTextColor", &rWidgetDefinition.mpStyle->maTabTextColor },
393
0
        { "tabRolloverTextColor", &rWidgetDefinition.mpStyle->maTabRolloverTextColor },
394
0
        { "tabHighlightTextColor", &rWidgetDefinition.mpStyle->maTabHighlightTextColor },
395
0
        { "disableColor", &rWidgetDefinition.mpStyle->maDisableColor },
396
0
        { "helpColor", &rWidgetDefinition.mpStyle->maHelpColor },
397
0
        { "helpTextColor", &rWidgetDefinition.mpStyle->maHelpTextColor },
398
0
        { "linkColor", &rWidgetDefinition.mpStyle->maLinkColor },
399
0
        { "visitedLinkColor", &rWidgetDefinition.mpStyle->maVisitedLinkColor },
400
0
        { "toolTextColor", &rWidgetDefinition.mpStyle->maToolTextColor },
401
0
    };
402
403
0
    rWidgetDefinition.mpSettings = std::make_shared<WidgetDefinitionSettings>();
404
405
0
    std::unordered_map<std::string_view, OString*> aSettingMap = {
406
0
        { "noActiveTabTextRaise", &rWidgetDefinition.mpSettings->msNoActiveTabTextRaise },
407
0
        { "centeredTabs", &rWidgetDefinition.mpSettings->msCenteredTabs },
408
0
        { "listBoxEntryMargin", &rWidgetDefinition.mpSettings->msListBoxEntryMargin },
409
0
        { "defaultFontSize", &rWidgetDefinition.mpSettings->msDefaultFontSize },
410
0
        { "titleHeight", &rWidgetDefinition.mpSettings->msTitleHeight },
411
0
        { "floatTitleHeight", &rWidgetDefinition.mpSettings->msFloatTitleHeight },
412
0
        { "listBoxPreviewDefaultLogicWidth",
413
0
          &rWidgetDefinition.mpSettings->msListBoxPreviewDefaultLogicWidth },
414
0
        { "listBoxPreviewDefaultLogicHeight",
415
0
          &rWidgetDefinition.mpSettings->msListBoxPreviewDefaultLogicHeight },
416
0
    };
417
418
0
    SvFileStream aFileStream(m_rDefinitionFile, StreamMode::READ);
419
420
0
    tools::XmlWalker aWalker;
421
0
    if (!aWalker.open(&aFileStream))
422
0
        return false;
423
424
0
    if (aWalker.name() != "widgets")
425
0
        return false;
426
427
0
    aWalker.children();
428
0
    while (aWalker.isValid())
429
0
    {
430
0
        ControlType eType;
431
0
        if (aWalker.name() == "style")
432
0
        {
433
0
            aWalker.children();
434
0
            while (aWalker.isValid())
435
0
            {
436
0
                auto pair = aStyleColorMap.find(aWalker.name());
437
0
                if (pair != aStyleColorMap.end())
438
0
                {
439
0
                    color::createFromString(aWalker.attribute("value"_ostr), *pair->second);
440
0
                }
441
0
                aWalker.next();
442
0
            }
443
0
            aWalker.parent();
444
0
        }
445
0
        if (aWalker.name() == "settings")
446
0
        {
447
0
            aWalker.children();
448
0
            while (aWalker.isValid())
449
0
            {
450
0
                auto pair = aSettingMap.find(aWalker.name());
451
0
                if (pair != aSettingMap.end())
452
0
                {
453
0
                    readSetting(aWalker.attribute("value"_ostr), *pair->second);
454
0
                }
455
0
                aWalker.next();
456
0
            }
457
0
            aWalker.parent();
458
0
        }
459
0
        else if (getControlTypeForXmlString(aWalker.name(), eType))
460
0
        {
461
0
            readDefinition(aWalker, rWidgetDefinition, eType);
462
0
        }
463
0
        aWalker.next();
464
0
    }
465
0
    aWalker.parent();
466
467
0
    return true;
468
0
}
469
470
} // end vcl namespace
471
472
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */