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 <sal/config.h>
12 
13 #include <string_view>
14 
15 #include <FileDefinitionWidgetDraw.hxx>
16 #include <widgetdraw/WidgetDefinitionReader.hxx>
17 
18 #include <svdata.hxx>
19 #include <rtl/bootstrap.hxx>
20 #include <config_folders.h>
21 #include <osl/file.hxx>
22 
23 #include <basegfx/range/b2drectangle.hxx>
24 #include <basegfx/polygon/b2dpolygontools.hxx>
25 #include <basegfx/tuple/b2dtuple.hxx>
26 #include <basegfx/matrix/b2dhommatrixtools.hxx>
27 
28 #include <tools/stream.hxx>
29 #include <vcl/bitmapex.hxx>
30 #include <vcl/BitmapTools.hxx>
31 #include <vcl/gradient.hxx>
32 
33 #include <comphelper/seqstream.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include <comphelper/lok.hxx>
36 #include <comphelper/string.hxx>
37 
38 #include <com/sun/star/graphic/SvgTools.hpp>
39 #include <basegfx/DrawCommands.hxx>
40 
41 using namespace css;
42 
43 namespace vcl
44 {
45 namespace
46 {
lcl_getThemeDefinitionPath()47 OUString lcl_getThemeDefinitionPath()
48 {
49     OUString sPath("$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER "/theme_definitions/");
50     rtl::Bootstrap::expandMacros(sPath);
51     return sPath;
52 }
53 
lcl_directoryExists(OUString const & sDirectory)54 bool lcl_directoryExists(OUString const& sDirectory)
55 {
56     osl::DirectoryItem aDirectoryItem;
57     osl::FileBase::RC eRes = osl::DirectoryItem::get(sDirectory, aDirectoryItem);
58     return eRes == osl::FileBase::E_None;
59 }
60 
lcl_fileExists(OUString const & sFilename)61 bool lcl_fileExists(OUString const& sFilename)
62 {
63     osl::File aFile(sFilename);
64     osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
65     return osl::FileBase::E_None == eRC;
66 }
67 
getWidgetDefinition(OUString const & rDefinitionFile,OUString const & rDefinitionResourcesPath)68 std::shared_ptr<WidgetDefinition> getWidgetDefinition(OUString const& rDefinitionFile,
69                                                       OUString const& rDefinitionResourcesPath)
70 {
71     auto pWidgetDefinition = std::make_shared<WidgetDefinition>();
72     WidgetDefinitionReader aReader(rDefinitionFile, rDefinitionResourcesPath);
73     if (aReader.read(*pWidgetDefinition))
74         return pWidgetDefinition;
75     return std::shared_ptr<WidgetDefinition>();
76 }
77 
78 std::shared_ptr<WidgetDefinition> const&
getWidgetDefinitionForTheme(std::u16string_view rThemenName)79 getWidgetDefinitionForTheme(std::u16string_view rThemenName)
80 {
81     static std::shared_ptr<WidgetDefinition> spDefinition;
82     if (!spDefinition)
83     {
84         OUString sSharedDefinitionBasePath = lcl_getThemeDefinitionPath();
85         OUString sThemeFolder = sSharedDefinitionBasePath + rThemenName + "/";
86         OUString sThemeDefinitionFile = sThemeFolder + "definition.xml";
87         if (lcl_directoryExists(sThemeFolder) && lcl_fileExists(sThemeDefinitionFile))
88             spDefinition = getWidgetDefinition(sThemeDefinitionFile, sThemeFolder);
89     }
90     return spDefinition;
91 }
92 
getSettingValueInteger(OString const & rValue,int nDefault)93 int getSettingValueInteger(OString const& rValue, int nDefault)
94 {
95     if (rValue.isEmpty())
96         return nDefault;
97     if (!comphelper::string::isdigitAsciiString(rValue))
98         return nDefault;
99     return rValue.toInt32();
100 }
101 
getSettingValueBool(std::string_view rValue,bool bDefault)102 bool getSettingValueBool(std::string_view rValue, bool bDefault)
103 {
104     if (rValue.empty())
105         return bDefault;
106     if (rValue == "true" || rValue == "false")
107         return rValue == "true";
108     return bDefault;
109 }
110 
111 } // end anonymous namespace
112 
FileDefinitionWidgetDraw(SalGraphics & rGraphics)113 FileDefinitionWidgetDraw::FileDefinitionWidgetDraw(SalGraphics& rGraphics)
114     : m_rGraphics(rGraphics)
115     , m_bIsActive(false)
116 {
117     m_pWidgetDefinition = getWidgetDefinitionForTheme(u"online");
118 #ifdef IOS
119     if (!m_pWidgetDefinition)
120         m_pWidgetDefinition = getWidgetDefinitionForTheme(u"ios");
121 #endif
122 
123     if (!m_pWidgetDefinition)
124         return;
125 
126     auto& pSettings = m_pWidgetDefinition->mpSettings;
127 
128     ImplSVData* pSVData = ImplGetSVData();
129     pSVData->maNWFData.mbNoFocusRects = true;
130     pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true;
131     pSVData->maNWFData.mbNoActiveTabTextRaise
132         = getSettingValueBool(pSettings->msNoActiveTabTextRaise, true);
133     pSVData->maNWFData.mbCenteredTabs = getSettingValueBool(pSettings->msCenteredTabs, true);
134     pSVData->maNWFData.mbProgressNeedsErase = true;
135     pSVData->maNWFData.mnStatusBarLowerRightOffset = 10;
136     pSVData->maNWFData.mbCanDrawWidgetAnySize = true;
137 
138     int nDefaultListboxEntryMargin = pSVData->maNWFData.mnListBoxEntryMargin;
139     pSVData->maNWFData.mnListBoxEntryMargin
140         = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin);
141 
142     m_bIsActive = true;
143 }
144 
isNativeControlSupported(ControlType eType,ControlPart ePart)145 bool FileDefinitionWidgetDraw::isNativeControlSupported(ControlType eType, ControlPart ePart)
146 {
147     switch (eType)
148     {
149         case ControlType::Generic:
150         case ControlType::Pushbutton:
151         case ControlType::Radiobutton:
152         case ControlType::Checkbox:
153             return true;
154         case ControlType::Combobox:
155             if (ePart == ControlPart::HasBackgroundTexture)
156                 return false;
157             return true;
158         case ControlType::Editbox:
159         case ControlType::EditboxNoBorder:
160         case ControlType::MultilineEditbox:
161             return true;
162         case ControlType::Listbox:
163             if (ePart == ControlPart::HasBackgroundTexture)
164                 return false;
165             return true;
166         case ControlType::Spinbox:
167             if (ePart == ControlPart::AllButtons)
168                 return false;
169             return true;
170         case ControlType::SpinButtons:
171             return false;
172         case ControlType::TabItem:
173         case ControlType::TabPane:
174         case ControlType::TabHeader:
175         case ControlType::TabBody:
176             return true;
177         case ControlType::Scrollbar:
178             if (ePart == ControlPart::DrawBackgroundHorz
179                 || ePart == ControlPart::DrawBackgroundVert)
180                 return false;
181             return true;
182         case ControlType::Slider:
183         case ControlType::Fixedline:
184         case ControlType::Toolbar:
185             return true;
186         case ControlType::Menubar:
187         case ControlType::MenuPopup:
188             return true;
189         case ControlType::Progress:
190             return true;
191         case ControlType::IntroProgress:
192             return false;
193         case ControlType::Tooltip:
194             return true;
195         case ControlType::WindowBackground:
196         case ControlType::Frame:
197         case ControlType::ListNode:
198         case ControlType::ListNet:
199         case ControlType::ListHeader:
200             return true;
201     }
202 
203     return false;
204 }
205 
hitTestNativeControl(ControlType,ControlPart,const tools::Rectangle &,const Point &,bool &)206 bool FileDefinitionWidgetDraw::hitTestNativeControl(
207     ControlType /*eType*/, ControlPart /*ePart*/,
208     const tools::Rectangle& /*rBoundingControlRegion*/, const Point& /*aPos*/, bool& /*rIsInside*/)
209 {
210     return false;
211 }
212 
drawPolyPolygon(SalGraphics & rGraphics,const basegfx::B2DHomMatrix & rObjectToDevice,const basegfx::B2DPolyPolygon & i_rPolyPolygon,double i_fTransparency)213 void FileDefinitionWidgetDraw::drawPolyPolygon(SalGraphics& rGraphics,
214                                                const basegfx::B2DHomMatrix& rObjectToDevice,
215                                                const basegfx::B2DPolyPolygon& i_rPolyPolygon,
216                                                double i_fTransparency)
217 {
218     rGraphics.drawPolyPolygon(rObjectToDevice, i_rPolyPolygon, i_fTransparency);
219 }
220 
drawPolyLine(SalGraphics & rGraphics,const basegfx::B2DHomMatrix & rObjectToDevice,const basegfx::B2DPolygon & i_rPolygon,double i_fTransparency,double i_fLineWidth,const std::vector<double> * i_pStroke,basegfx::B2DLineJoin i_eLineJoin,css::drawing::LineCap i_eLineCap,double i_fMiterMinimumAngle,bool bPixelSnapHairline)221 void FileDefinitionWidgetDraw::drawPolyLine(
222     SalGraphics& rGraphics, const basegfx::B2DHomMatrix& rObjectToDevice,
223     const basegfx::B2DPolygon& i_rPolygon, double i_fTransparency, double i_fLineWidth,
224     const std::vector<double>* i_pStroke, basegfx::B2DLineJoin i_eLineJoin,
225     css::drawing::LineCap i_eLineCap, double i_fMiterMinimumAngle, bool bPixelSnapHairline)
226 {
227     rGraphics.drawPolyLine(rObjectToDevice, i_rPolygon, i_fTransparency, i_fLineWidth, i_pStroke,
228                            i_eLineJoin, i_eLineCap, i_fMiterMinimumAngle, bPixelSnapHairline);
229 }
230 
drawBitmap(SalGraphics & rGraphics,const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap)231 void FileDefinitionWidgetDraw::drawBitmap(SalGraphics& rGraphics, const SalTwoRect& rPosAry,
232                                           const SalBitmap& rSalBitmap)
233 {
234     rGraphics.drawBitmap(rPosAry, rSalBitmap);
235 }
236 
drawBitmap(SalGraphics & rGraphics,const SalTwoRect & rPosAry,const SalBitmap & rSalBitmap,const SalBitmap & rTransparentBitmap)237 void FileDefinitionWidgetDraw::drawBitmap(SalGraphics& rGraphics, const SalTwoRect& rPosAry,
238                                           const SalBitmap& rSalBitmap,
239                                           const SalBitmap& rTransparentBitmap)
240 {
241     rGraphics.drawBitmap(rPosAry, rSalBitmap, rTransparentBitmap);
242 }
243 
implDrawGradient(SalGraphics & rGraphics,const basegfx::B2DPolyPolygon & rPolyPolygon,const SalGradient & rGradient)244 void FileDefinitionWidgetDraw::implDrawGradient(SalGraphics& rGraphics,
245                                                 const basegfx::B2DPolyPolygon& rPolyPolygon,
246                                                 const SalGradient& rGradient)
247 {
248     rGraphics.implDrawGradient(rPolyPolygon, rGradient);
249 }
250 
251 namespace
252 {
drawFromDrawCommands(gfx::DrawRoot const & rDrawRoot,SalGraphics & rGraphics,tools::Long nX,tools::Long nY,tools::Long nWidth,tools::Long nHeight)253 void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics, tools::Long nX,
254                           tools::Long nY, tools::Long nWidth, tools::Long nHeight)
255 {
256     basegfx::B2DRectangle aSVGRect = rDrawRoot.maRectangle;
257 
258     basegfx::B2DRange aTargetSurface(nX, nY, nX + nWidth + 1, nY + nHeight + 1);
259 
260     for (std::shared_ptr<gfx::DrawBase> const& pDrawBase : rDrawRoot.maChildren)
261     {
262         switch (pDrawBase->getType())
263         {
264             case gfx::DrawCommandType::Rectangle:
265             {
266                 auto const& rRectangle = static_cast<gfx::DrawRectangle const&>(*pDrawBase);
267 
268                 basegfx::B2DRange aInputRectangle(rRectangle.maRectangle);
269 
270                 double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth();
271                 double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight();
272 
273                 basegfx::B2DRange aFinalRectangle(
274                     aInputRectangle.getMinX(), aInputRectangle.getMinY(),
275                     aInputRectangle.getMaxX() + fDeltaX, aInputRectangle.getMaxY() + fDeltaY);
276 
277                 aFinalRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix(
278                     aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
279 
280                 basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect(
281                     aFinalRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0,
282                     rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0);
283 
284                 if (rRectangle.mpFillColor)
285                 {
286                     rGraphics.SetLineColor();
287                     rGraphics.SetFillColor(Color(*rRectangle.mpFillColor));
288                     FileDefinitionWidgetDraw::drawPolyPolygon(rGraphics, basegfx::B2DHomMatrix(),
289                                                               basegfx::B2DPolyPolygon(aB2DPolygon),
290                                                               1.0 - rRectangle.mnOpacity);
291                 }
292                 else if (rRectangle.mpFillGradient)
293                 {
294                     rGraphics.SetLineColor();
295                     rGraphics.SetFillColor();
296                     if (rRectangle.mpFillGradient->meType == gfx::GradientType::Linear)
297                     {
298                         auto* pLinearGradient = static_cast<gfx::LinearGradientInfo*>(
299                             rRectangle.mpFillGradient.get());
300                         SalGradient aGradient;
301                         double x, y;
302 
303                         x = pLinearGradient->x1;
304                         y = pLinearGradient->y1;
305 
306                         if (x > aSVGRect.getCenterX())
307                             x = x + fDeltaX;
308                         if (y > aSVGRect.getCenterY())
309                             y = y + fDeltaY;
310 
311                         aGradient.maPoint1 = basegfx::B2DPoint(x, y);
312                         aGradient.maPoint1 *= basegfx::utils::createTranslateB2DHomMatrix(
313                             aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5);
314 
315                         x = pLinearGradient->x2;
316                         y = pLinearGradient->y2;
317 
318                         if (x > aSVGRect.getCenterX())
319                             x = x + fDeltaX;
320                         if (y > aSVGRect.getCenterY())
321                             y = y + fDeltaY;
322 
323                         aGradient.maPoint2 = basegfx::B2DPoint(x, y);
324                         aGradient.maPoint2 *= basegfx::utils::createTranslateB2DHomMatrix(
325                             aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5);
326 
327                         for (gfx::GradientStop const& rStop : pLinearGradient->maGradientStops)
328                         {
329                             Color aColor(rStop.maColor);
330                             aColor.SetAlpha(255
331                                             - (rStop.mfOpacity * (1.0f - rRectangle.mnOpacity)));
332                             aGradient.maStops.emplace_back(aColor, rStop.mfOffset);
333                         }
334                         FileDefinitionWidgetDraw::implDrawGradient(
335                             rGraphics, basegfx::B2DPolyPolygon(aB2DPolygon), aGradient);
336                     }
337                 }
338                 if (rRectangle.mpStrokeColor)
339                 {
340                     rGraphics.SetLineColor(Color(*rRectangle.mpStrokeColor));
341                     rGraphics.SetFillColor();
342                     FileDefinitionWidgetDraw::drawPolyLine(
343                         rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 1.0 - rRectangle.mnOpacity,
344                         rRectangle.mnStrokeWidth,
345                         nullptr, // MM01
346                         basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false);
347                 }
348             }
349             break;
350             case gfx::DrawCommandType::Path:
351             {
352                 auto const& rPath = static_cast<gfx::DrawPath const&>(*pDrawBase);
353 
354                 double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth();
355                 double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight();
356 
357                 basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon);
358                 for (auto& rPolygon : aPolyPolygon)
359                 {
360                     for (size_t i = 0; i < rPolygon.count(); ++i)
361                     {
362                         auto& rPoint = rPolygon.getB2DPoint(i);
363                         double x = rPoint.getX();
364                         double y = rPoint.getY();
365 
366                         if (x > aSVGRect.getCenterX())
367                             x = x + fDeltaX;
368                         if (y > aSVGRect.getCenterY())
369                             y = y + fDeltaY;
370                         rPolygon.setB2DPoint(i, basegfx::B2DPoint(x, y));
371                     }
372                 }
373                 aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(
374                     aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
375 
376                 if (rPath.mpFillColor)
377                 {
378                     rGraphics.SetLineColor();
379                     rGraphics.SetFillColor(Color(*rPath.mpFillColor));
380                     FileDefinitionWidgetDraw::drawPolyPolygon(rGraphics, basegfx::B2DHomMatrix(),
381                                                               aPolyPolygon, 1.0 - rPath.mnOpacity);
382                 }
383                 if (rPath.mpStrokeColor)
384                 {
385                     rGraphics.SetLineColor(Color(*rPath.mpStrokeColor));
386                     rGraphics.SetFillColor();
387                     for (auto const& rPolygon : aPolyPolygon)
388                     {
389                         FileDefinitionWidgetDraw::drawPolyLine(
390                             rGraphics, basegfx::B2DHomMatrix(), rPolygon, 1.0 - rPath.mnOpacity,
391                             rPath.mnStrokeWidth,
392                             nullptr, // MM01
393                             basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false);
394                     }
395                 }
396             }
397             break;
398 
399             default:
400                 break;
401         }
402     }
403 }
404 
munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const & rDrawActions,SalGraphics & rGraphics,tools::Long nX,tools::Long nY,tools::Long nWidth,tools::Long nHeight)405 void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>> const& rDrawActions,
406                        SalGraphics& rGraphics, tools::Long nX, tools::Long nY, tools::Long nWidth,
407                        tools::Long nHeight)
408 {
409     for (std::shared_ptr<WidgetDrawAction> const& pDrawAction : rDrawActions)
410     {
411         switch (pDrawAction->maType)
412         {
413             case WidgetDrawActionType::RECTANGLE:
414             {
415                 auto const& rWidgetDraw
416                     = static_cast<WidgetDrawActionRectangle const&>(*pDrawAction);
417 
418                 basegfx::B2DRectangle rRect(
419                     nX + (nWidth * rWidgetDraw.mfX1), nY + (nHeight * rWidgetDraw.mfY1),
420                     nX + (nWidth * rWidgetDraw.mfX2), nY + (nHeight * rWidgetDraw.mfY2));
421 
422                 basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect(
423                     rRect, rWidgetDraw.mnRx / rRect.getWidth() * 2.0,
424                     rWidgetDraw.mnRy / rRect.getHeight() * 2.0);
425 
426                 rGraphics.SetLineColor();
427                 rGraphics.SetFillColor(rWidgetDraw.maFillColor);
428                 FileDefinitionWidgetDraw::drawPolyPolygon(
429                     rGraphics, basegfx::B2DHomMatrix(), basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f);
430                 rGraphics.SetLineColor(rWidgetDraw.maStrokeColor);
431                 rGraphics.SetFillColor();
432                 FileDefinitionWidgetDraw::drawPolyLine(
433                     rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f,
434                     rWidgetDraw.mnStrokeWidth, nullptr, // MM01
435                     basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false);
436             }
437             break;
438             case WidgetDrawActionType::LINE:
439             {
440                 auto const& rWidgetDraw = static_cast<WidgetDrawActionLine const&>(*pDrawAction);
441                 Point aRectPoint(nX + 1, nY + 1);
442 
443                 Size aRectSize(nWidth - 1, nHeight - 1);
444 
445                 rGraphics.SetFillColor();
446                 rGraphics.SetLineColor(rWidgetDraw.maStrokeColor);
447 
448                 basegfx::B2DPolygon aB2DPolygon{
449                     { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX1),
450                       aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY1) },
451                     { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX2),
452                       aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY2) },
453                 };
454 
455                 FileDefinitionWidgetDraw::drawPolyLine(
456                     rGraphics, basegfx::B2DHomMatrix(), aB2DPolygon, 0.0f,
457                     rWidgetDraw.mnStrokeWidth, nullptr, // MM01
458                     basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, false);
459             }
460             break;
461             case WidgetDrawActionType::IMAGE:
462             {
463                 double nScaleFactor = 1.0;
464                 if (comphelper::LibreOfficeKit::isActive())
465                     nScaleFactor = comphelper::LibreOfficeKit::getDPIScale();
466 
467                 auto const& rWidgetDraw = static_cast<WidgetDrawActionImage const&>(*pDrawAction);
468                 auto& rCacheImages = ImplGetSVData()->maGDIData.maThemeImageCache;
469                 OUString rCacheKey = rWidgetDraw.msSource + "@" + OUString::number(nScaleFactor);
470                 auto aIterator = rCacheImages.find(rCacheKey);
471 
472                 BitmapEx aBitmap;
473                 if (aIterator == rCacheImages.end())
474                 {
475                     SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
476 
477                     vcl::bitmap::loadFromSvg(aFileStream, "", aBitmap, nScaleFactor);
478                     if (!aBitmap.IsEmpty())
479                     {
480                         rCacheImages.insert(std::make_pair(rCacheKey, aBitmap));
481                     }
482                 }
483                 else
484                 {
485                     aBitmap = aIterator->second;
486                 }
487 
488                 tools::Long nImageWidth = aBitmap.GetSizePixel().Width();
489                 tools::Long nImageHeight = aBitmap.GetSizePixel().Height();
490                 SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, nImageWidth / nScaleFactor,
491                                nImageHeight / nScaleFactor);
492                 if (!aBitmap.IsEmpty())
493                 {
494                     const std::shared_ptr<SalBitmap> pSalBitmap
495                         = aBitmap.GetBitmap().ImplGetSalBitmap();
496                     if (aBitmap.IsAlpha())
497                     {
498                         const std::shared_ptr<SalBitmap> pSalBitmapAlpha
499                             = aBitmap.GetAlpha().ImplGetSalBitmap();
500                         FileDefinitionWidgetDraw::drawBitmap(rGraphics, aTR, *pSalBitmap,
501                                                              *pSalBitmapAlpha);
502                     }
503                     else
504                     {
505                         FileDefinitionWidgetDraw::drawBitmap(rGraphics, aTR, *pSalBitmap);
506                     }
507                 }
508             }
509             break;
510             case WidgetDrawActionType::EXTERNAL:
511             {
512                 auto const& rWidgetDraw
513                     = static_cast<WidgetDrawActionExternal const&>(*pDrawAction);
514 
515                 auto& rCacheDrawCommands = ImplGetSVData()->maGDIData.maThemeDrawCommandsCache;
516 
517                 auto aIterator = rCacheDrawCommands.find(rWidgetDraw.msSource);
518 
519                 if (aIterator == rCacheDrawCommands.end())
520                 {
521                     SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
522 
523                     uno::Reference<uno::XComponentContext> xContext(
524                         comphelper::getProcessComponentContext());
525                     const uno::Reference<graphic::XSvgParser> xSvgParser
526                         = graphic::SvgTools::create(xContext);
527 
528                     std::size_t nSize = aFileStream.remainingSize();
529                     std::vector<sal_Int8> aBuffer(nSize + 1);
530                     aFileStream.ReadBytes(aBuffer.data(), nSize);
531                     aBuffer[nSize] = 0;
532 
533                     uno::Sequence<sal_Int8> aData(aBuffer.data(), nSize + 1);
534                     uno::Reference<io::XInputStream> aInputStream(
535                         new comphelper::SequenceInputStream(aData));
536 
537                     uno::Any aAny = xSvgParser->getDrawCommands(aInputStream, "");
538                     if (aAny.has<sal_uInt64>())
539                     {
540                         auto* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
541                         if (pDrawRoot)
542                         {
543                             rCacheDrawCommands.insert(
544                                 std::make_pair(rWidgetDraw.msSource, *pDrawRoot));
545                             drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, nWidth, nHeight);
546                         }
547                     }
548                 }
549                 else
550                 {
551                     drawFromDrawCommands(aIterator->second, rGraphics, nX, nY, nWidth, nHeight);
552                 }
553             }
554             break;
555         }
556     }
557 }
558 
559 } // end anonymous namespace
560 
resolveDefinition(ControlType eType,ControlPart ePart,ControlState eState,const ImplControlValue & rValue,tools::Long nX,tools::Long nY,tools::Long nWidth,tools::Long nHeight)561 bool FileDefinitionWidgetDraw::resolveDefinition(ControlType eType, ControlPart ePart,
562                                                  ControlState eState,
563                                                  const ImplControlValue& rValue, tools::Long nX,
564                                                  tools::Long nY, tools::Long nWidth,
565                                                  tools::Long nHeight)
566 {
567     bool bOK = false;
568     auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ePart);
569     if (pPart)
570     {
571         auto const& aStates = pPart->getStates(eType, ePart, eState, rValue);
572         if (!aStates.empty())
573         {
574             // use last defined state
575             auto const& pState = aStates.back();
576             {
577                 munchDrawCommands(pState->mpWidgetDrawActions, m_rGraphics, nX, nY, nWidth,
578                                   nHeight);
579                 bOK = true;
580             }
581         }
582     }
583     return bOK;
584 }
585 
drawNativeControl(ControlType eType,ControlPart ePart,const tools::Rectangle & rControlRegion,ControlState eState,const ImplControlValue & rValue,const OUString &,const Color &)586 bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart ePart,
587                                                  const tools::Rectangle& rControlRegion,
588                                                  ControlState eState,
589                                                  const ImplControlValue& rValue,
590                                                  const OUString& /*aCaptions*/,
591                                                  const Color& /*rBackgroundColor*/)
592 {
593     bool bOldAA = m_rGraphics.getAntiAlias();
594     m_rGraphics.setAntiAlias(true);
595 
596     tools::Long nWidth = rControlRegion.GetWidth() - 1;
597     tools::Long nHeight = rControlRegion.GetHeight() - 1;
598     tools::Long nX = rControlRegion.Left();
599     tools::Long nY = rControlRegion.Top();
600 
601     bool bOK = false;
602 
603     switch (eType)
604     {
605         case ControlType::Pushbutton:
606         {
607             /*bool bIsAction = false;
608             const PushButtonValue* pPushButtonValue = static_cast<const PushButtonValue*>(&rValue);
609             if (pPushButtonValue)
610                 bIsAction = pPushButtonValue->mbIsAction;*/
611 
612             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
613         }
614         break;
615         case ControlType::Radiobutton:
616         {
617             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
618         }
619         break;
620         case ControlType::Checkbox:
621         {
622             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
623         }
624         break;
625         case ControlType::Combobox:
626         {
627             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
628         }
629         break;
630         case ControlType::Editbox:
631         case ControlType::EditboxNoBorder:
632         case ControlType::MultilineEditbox:
633         {
634             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
635         }
636         break;
637         case ControlType::Listbox:
638         {
639             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
640         }
641         break;
642         case ControlType::Spinbox:
643         {
644             if (rValue.getType() == ControlType::SpinButtons)
645             {
646                 const SpinbuttonValue* pSpinVal = static_cast<const SpinbuttonValue*>(&rValue);
647 
648                 {
649                     ControlPart eUpButtonPart = pSpinVal->mnUpperPart;
650                     ControlState eUpButtonState = pSpinVal->mnUpperState;
651 
652                     tools::Long nUpperX = pSpinVal->maUpperRect.Left();
653                     tools::Long nUpperY = pSpinVal->maUpperRect.Top();
654                     tools::Long nUpperWidth = pSpinVal->maUpperRect.GetWidth() - 1;
655                     tools::Long nUpperHeight = pSpinVal->maUpperRect.GetHeight() - 1;
656 
657                     bOK = resolveDefinition(eType, eUpButtonPart, eUpButtonState,
658                                             ImplControlValue(), nUpperX, nUpperY, nUpperWidth,
659                                             nUpperHeight);
660                 }
661 
662                 if (bOK)
663                 {
664                     ControlPart eDownButtonPart = pSpinVal->mnLowerPart;
665                     ControlState eDownButtonState = pSpinVal->mnLowerState;
666 
667                     tools::Long nLowerX = pSpinVal->maLowerRect.Left();
668                     tools::Long nLowerY = pSpinVal->maLowerRect.Top();
669                     tools::Long nLowerWidth = pSpinVal->maLowerRect.GetWidth() - 1;
670                     tools::Long nLowerHeight = pSpinVal->maLowerRect.GetHeight() - 1;
671 
672                     bOK = resolveDefinition(eType, eDownButtonPart, eDownButtonState,
673                                             ImplControlValue(), nLowerX, nLowerY, nLowerWidth,
674                                             nLowerHeight);
675                 }
676             }
677             else
678             {
679                 bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
680             }
681         }
682         break;
683         case ControlType::SpinButtons:
684             break;
685         case ControlType::TabItem:
686         case ControlType::TabHeader:
687         case ControlType::TabPane:
688         case ControlType::TabBody:
689         {
690             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
691         }
692         break;
693         case ControlType::Scrollbar:
694         {
695             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
696         }
697         break;
698         case ControlType::Slider:
699         {
700             const SliderValue* pSliderValue = static_cast<const SliderValue*>(&rValue);
701             tools::Long nThumbX = pSliderValue->maThumbRect.Left();
702             tools::Long nThumbY = pSliderValue->maThumbRect.Top();
703             tools::Long nThumbWidth = pSliderValue->maThumbRect.GetWidth() - 1;
704             tools::Long nThumbHeight = pSliderValue->maThumbRect.GetHeight() - 1;
705 
706             if (ePart == ControlPart::TrackHorzArea)
707             {
708                 tools::Long nCenterX = nThumbX + nThumbWidth / 2;
709 
710                 bOK = resolveDefinition(eType, ControlPart::TrackHorzLeft, eState, rValue, nX, nY,
711                                         nCenterX - nX, nHeight);
712                 if (bOK)
713                     bOK = resolveDefinition(eType, ControlPart::TrackHorzRight, eState, rValue,
714                                             nCenterX, nY, nX + nWidth - nCenterX, nHeight);
715             }
716             else if (ePart == ControlPart::TrackVertArea)
717             {
718                 tools::Long nCenterY = nThumbY + nThumbHeight / 2;
719 
720                 bOK = resolveDefinition(eType, ControlPart::TrackVertUpper, eState, rValue, nX, nY,
721                                         nWidth, nCenterY - nY);
722                 if (bOK)
723                     bOK = resolveDefinition(eType, ControlPart::TrackVertLower, eState, rValue, nY,
724                                             nCenterY, nWidth, nY + nHeight - nCenterY);
725             }
726 
727             if (bOK)
728             {
729                 bOK = resolveDefinition(eType, ControlPart::Button,
730                                         eState | pSliderValue->mnThumbState, rValue, nThumbX,
731                                         nThumbY, nThumbWidth, nThumbHeight);
732             }
733         }
734         break;
735         case ControlType::Fixedline:
736         {
737             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
738         }
739         break;
740         case ControlType::Toolbar:
741         {
742             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
743         }
744         break;
745         case ControlType::Menubar:
746         case ControlType::MenuPopup:
747         {
748             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
749         }
750         break;
751         case ControlType::Progress:
752         {
753             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
754         }
755         break;
756         case ControlType::IntroProgress:
757             break;
758         case ControlType::Tooltip:
759         {
760             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
761         }
762         break;
763         case ControlType::WindowBackground:
764         case ControlType::Frame:
765         {
766             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
767         }
768         break;
769         case ControlType::ListNode:
770         case ControlType::ListNet:
771         case ControlType::ListHeader:
772         {
773             bOK = resolveDefinition(eType, ePart, eState, rValue, nX, nY, nWidth, nHeight);
774         }
775         break;
776         default:
777             break;
778     }
779 
780     m_rGraphics.setAntiAlias(bOldAA);
781 
782     return bOK;
783 }
784 
getNativeControlRegion(ControlType eType,ControlPart ePart,const tools::Rectangle & rBoundingControlRegion,ControlState,const ImplControlValue &,const OUString &,tools::Rectangle & rNativeBoundingRegion,tools::Rectangle & rNativeContentRegion)785 bool FileDefinitionWidgetDraw::getNativeControlRegion(
786     ControlType eType, ControlPart ePart, const tools::Rectangle& rBoundingControlRegion,
787     ControlState /*eState*/, const ImplControlValue& /*aValue*/, const OUString& /*aCaption*/,
788     tools::Rectangle& rNativeBoundingRegion, tools::Rectangle& rNativeContentRegion)
789 {
790     Point aLocation(rBoundingControlRegion.TopLeft());
791 
792     switch (eType)
793     {
794         case ControlType::Spinbox:
795         {
796             auto const& pButtonUpPart
797                 = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonUp);
798             if (!pButtonUpPart)
799                 return false;
800             Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight);
801 
802             auto const& pButtonDownPart
803                 = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown);
804             if (!pButtonDownPart)
805                 return false;
806             Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight);
807 
808             auto const& pEntirePart
809                 = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
810 
811             OString sOrientation = pEntirePart->msOrientation;
812 
813             if (sOrientation.isEmpty() || sOrientation == "stacked")
814             {
815                 return false;
816             }
817             else if (sOrientation == "decrease-edit-increase")
818             {
819                 if (ePart == ControlPart::ButtonUp)
820                 {
821                     Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
822                                      - aButtonSizeUp.Width(),
823                                  aLocation.Y());
824                     rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
825                     rNativeBoundingRegion = rNativeContentRegion;
826                     return true;
827                 }
828                 else if (ePart == ControlPart::ButtonDown)
829                 {
830                     rNativeContentRegion = tools::Rectangle(aLocation, aButtonSizeDown);
831                     rNativeBoundingRegion = rNativeContentRegion;
832                     return true;
833                 }
834                 else if (ePart == ControlPart::SubEdit)
835                 {
836                     Point aPoint(aLocation.X() + aButtonSizeDown.Width(), aLocation.Y());
837                     Size aSize(rBoundingControlRegion.GetWidth()
838                                    - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
839                                std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
840                     rNativeContentRegion = tools::Rectangle(aPoint, aSize);
841                     rNativeBoundingRegion = rNativeContentRegion;
842                     return true;
843                 }
844                 else if (ePart == ControlPart::Entire)
845                 {
846                     Size aSize(rBoundingControlRegion.GetWidth(),
847                                std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
848                     rNativeContentRegion = tools::Rectangle(aLocation, aSize);
849                     rNativeBoundingRegion = rNativeContentRegion;
850                     return true;
851                 }
852             }
853             else if (sOrientation == "edit-decrease-increase")
854             {
855                 if (ePart == ControlPart::ButtonUp)
856                 {
857                     Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
858                                      - aButtonSizeUp.Width(),
859                                  aLocation.Y());
860                     rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeUp);
861                     rNativeBoundingRegion = rNativeContentRegion;
862                     return true;
863                 }
864                 else if (ePart == ControlPart::ButtonDown)
865                 {
866                     Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
867                                      - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
868                                  aLocation.Y());
869                     rNativeContentRegion = tools::Rectangle(aPoint, aButtonSizeDown);
870                     rNativeBoundingRegion = rNativeContentRegion;
871                     return true;
872                 }
873                 else if (ePart == ControlPart::SubEdit)
874                 {
875                     Size aSize(rBoundingControlRegion.GetWidth()
876                                    - (aButtonSizeDown.Width() + aButtonSizeUp.Width()),
877                                std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
878                     rNativeContentRegion = tools::Rectangle(aLocation, aSize);
879                     rNativeBoundingRegion = rNativeContentRegion;
880                     return true;
881                 }
882                 else if (ePart == ControlPart::Entire)
883                 {
884                     Size aSize(rBoundingControlRegion.GetWidth(),
885                                std::max(aButtonSizeUp.Height(), aButtonSizeDown.Height()));
886                     rNativeContentRegion = tools::Rectangle(aLocation, aSize);
887                     rNativeBoundingRegion = rNativeContentRegion;
888                     return true;
889                 }
890             }
891         }
892         break;
893         case ControlType::Checkbox:
894         {
895             auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
896             if (!pPart)
897                 return false;
898 
899             Size aSize(pPart->mnWidth, pPart->mnHeight);
900             rNativeContentRegion = tools::Rectangle(Point(), aSize);
901             return true;
902         }
903         case ControlType::Radiobutton:
904         {
905             auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
906             if (!pPart)
907                 return false;
908 
909             Size aSize(pPart->mnWidth, pPart->mnHeight);
910             rNativeContentRegion = tools::Rectangle(Point(), aSize);
911             return true;
912         }
913         case ControlType::TabItem:
914         {
915             auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
916             if (!pPart)
917                 return false;
918 
919             tools::Long nWidth = std::max(rBoundingControlRegion.GetWidth() + pPart->mnMarginWidth,
920                                           tools::Long(pPart->mnWidth));
921             tools::Long nHeight
922                 = std::max(rBoundingControlRegion.GetHeight() + pPart->mnMarginHeight,
923                            tools::Long(pPart->mnHeight));
924 
925             rNativeBoundingRegion = tools::Rectangle(aLocation, Size(nWidth, nHeight));
926             rNativeContentRegion = rNativeBoundingRegion;
927             return true;
928         }
929         case ControlType::Editbox:
930         case ControlType::EditboxNoBorder:
931         case ControlType::MultilineEditbox:
932         {
933             sal_Int32 nHeight = rBoundingControlRegion.GetHeight();
934 
935             auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::Entire);
936             if (pPart)
937                 nHeight = std::max(nHeight, pPart->mnHeight);
938 
939             Size aSize(rBoundingControlRegion.GetWidth(), nHeight);
940             rNativeContentRegion = tools::Rectangle(aLocation, aSize);
941             rNativeBoundingRegion = rNativeContentRegion;
942             rNativeBoundingRegion.expand(2);
943             return true;
944         }
945         break;
946         case ControlType::Scrollbar:
947         {
948             if (ePart == ControlPart::ButtonUp || ePart == ControlPart::ButtonDown
949                 || ePart == ControlPart::ButtonLeft || ePart == ControlPart::ButtonRight)
950             {
951                 rNativeContentRegion = tools::Rectangle(aLocation, Size(0, 0));
952                 rNativeBoundingRegion = rNativeContentRegion;
953                 return true;
954             }
955             else
956             {
957                 rNativeBoundingRegion = rBoundingControlRegion;
958                 rNativeContentRegion = rNativeBoundingRegion;
959                 return true;
960             }
961         }
962         break;
963         case ControlType::Combobox:
964         case ControlType::Listbox:
965         {
966             auto const& pPart = m_pWidgetDefinition->getDefinition(eType, ControlPart::ButtonDown);
967             Size aComboButtonSize(pPart->mnWidth, pPart->mnHeight);
968 
969             if (ePart == ControlPart::ButtonDown)
970             {
971                 Point aPoint(aLocation.X() + rBoundingControlRegion.GetWidth()
972                                  - aComboButtonSize.Width() - 1,
973                              aLocation.Y());
974                 rNativeContentRegion = tools::Rectangle(aPoint, aComboButtonSize);
975                 rNativeBoundingRegion = rNativeContentRegion;
976                 return true;
977             }
978             else if (ePart == ControlPart::SubEdit)
979             {
980                 Size aSize(rBoundingControlRegion.GetWidth() - aComboButtonSize.Width(),
981                            aComboButtonSize.Height());
982                 rNativeContentRegion = tools::Rectangle(aLocation + Point(1, 1), aSize);
983                 rNativeBoundingRegion = rNativeContentRegion;
984                 return true;
985             }
986             else if (ePart == ControlPart::Entire)
987             {
988                 Size aSize(rBoundingControlRegion.GetWidth(), aComboButtonSize.Height());
989                 rNativeContentRegion = tools::Rectangle(aLocation, aSize);
990                 rNativeBoundingRegion = rNativeContentRegion;
991                 rNativeBoundingRegion.expand(2);
992                 return true;
993             }
994         }
995         break;
996         case ControlType::Slider:
997             if (ePart == ControlPart::ThumbHorz || ePart == ControlPart::ThumbVert)
998             {
999                 rNativeContentRegion = tools::Rectangle(aLocation, Size(28, 28));
1000                 rNativeBoundingRegion = rNativeContentRegion;
1001                 return true;
1002             }
1003             break;
1004         default:
1005             break;
1006     }
1007 
1008     return false;
1009 }
1010 
updateSettings(AllSettings & rSettings)1011 bool FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings)
1012 {
1013     StyleSettings aStyleSet = rSettings.GetStyleSettings();
1014 
1015     auto& pDefinitionStyle = m_pWidgetDefinition->mpStyle;
1016 
1017     aStyleSet.SetFaceColor(pDefinitionStyle->maFaceColor);
1018     aStyleSet.SetCheckedColor(pDefinitionStyle->maCheckedColor);
1019     aStyleSet.SetLightColor(pDefinitionStyle->maLightColor);
1020     aStyleSet.SetLightBorderColor(pDefinitionStyle->maLightBorderColor);
1021     aStyleSet.SetShadowColor(pDefinitionStyle->maShadowColor);
1022     aStyleSet.SetDarkShadowColor(pDefinitionStyle->maDarkShadowColor);
1023     aStyleSet.SetDefaultButtonTextColor(pDefinitionStyle->maDefaultButtonTextColor);
1024     aStyleSet.SetButtonTextColor(pDefinitionStyle->maButtonTextColor);
1025     aStyleSet.SetDefaultActionButtonTextColor(pDefinitionStyle->maDefaultActionButtonTextColor);
1026     aStyleSet.SetActionButtonTextColor(pDefinitionStyle->maActionButtonTextColor);
1027     aStyleSet.SetFlatButtonTextColor(pDefinitionStyle->maFlatButtonTextColor);
1028     aStyleSet.SetDefaultButtonRolloverTextColor(pDefinitionStyle->maDefaultButtonRolloverTextColor);
1029     aStyleSet.SetButtonRolloverTextColor(pDefinitionStyle->maButtonRolloverTextColor);
1030     aStyleSet.SetDefaultActionButtonRolloverTextColor(
1031         pDefinitionStyle->maDefaultActionButtonRolloverTextColor);
1032     aStyleSet.SetActionButtonRolloverTextColor(pDefinitionStyle->maActionButtonRolloverTextColor);
1033     aStyleSet.SetFlatButtonRolloverTextColor(pDefinitionStyle->maFlatButtonRolloverTextColor);
1034     aStyleSet.SetDefaultButtonPressedRolloverTextColor(
1035         pDefinitionStyle->maDefaultButtonPressedRolloverTextColor);
1036     aStyleSet.SetButtonPressedRolloverTextColor(pDefinitionStyle->maButtonPressedRolloverTextColor);
1037     aStyleSet.SetDefaultActionButtonPressedRolloverTextColor(
1038         pDefinitionStyle->maDefaultActionButtonPressedRolloverTextColor);
1039     aStyleSet.SetActionButtonPressedRolloverTextColor(
1040         pDefinitionStyle->maActionButtonPressedRolloverTextColor);
1041     aStyleSet.SetFlatButtonPressedRolloverTextColor(
1042         pDefinitionStyle->maFlatButtonPressedRolloverTextColor);
1043     aStyleSet.SetRadioCheckTextColor(pDefinitionStyle->maRadioCheckTextColor);
1044     aStyleSet.SetGroupTextColor(pDefinitionStyle->maGroupTextColor);
1045     aStyleSet.SetLabelTextColor(pDefinitionStyle->maLabelTextColor);
1046     aStyleSet.SetWindowColor(pDefinitionStyle->maWindowColor);
1047     aStyleSet.SetWindowTextColor(pDefinitionStyle->maWindowTextColor);
1048     aStyleSet.SetDialogColor(pDefinitionStyle->maDialogColor);
1049     aStyleSet.SetDialogTextColor(pDefinitionStyle->maDialogTextColor);
1050     aStyleSet.SetWorkspaceColor(pDefinitionStyle->maWorkspaceColor);
1051     aStyleSet.SetMonoColor(pDefinitionStyle->maMonoColor);
1052     aStyleSet.SetFieldColor(pDefinitionStyle->maFieldColor);
1053     aStyleSet.SetFieldTextColor(pDefinitionStyle->maFieldTextColor);
1054     aStyleSet.SetFieldRolloverTextColor(pDefinitionStyle->maFieldRolloverTextColor);
1055     aStyleSet.SetActiveColor(pDefinitionStyle->maActiveColor);
1056     aStyleSet.SetActiveTextColor(pDefinitionStyle->maActiveTextColor);
1057     aStyleSet.SetActiveBorderColor(pDefinitionStyle->maActiveBorderColor);
1058     aStyleSet.SetDeactiveColor(pDefinitionStyle->maDeactiveColor);
1059     aStyleSet.SetDeactiveTextColor(pDefinitionStyle->maDeactiveTextColor);
1060     aStyleSet.SetDeactiveBorderColor(pDefinitionStyle->maDeactiveBorderColor);
1061     aStyleSet.SetMenuColor(pDefinitionStyle->maMenuColor);
1062     aStyleSet.SetMenuBarColor(pDefinitionStyle->maMenuBarColor);
1063     aStyleSet.SetMenuBarRolloverColor(pDefinitionStyle->maMenuBarRolloverColor);
1064     aStyleSet.SetMenuBorderColor(pDefinitionStyle->maMenuBorderColor);
1065     aStyleSet.SetMenuTextColor(pDefinitionStyle->maMenuTextColor);
1066     aStyleSet.SetMenuBarTextColor(pDefinitionStyle->maMenuBarTextColor);
1067     aStyleSet.SetMenuBarRolloverTextColor(pDefinitionStyle->maMenuBarRolloverTextColor);
1068     aStyleSet.SetMenuBarHighlightTextColor(pDefinitionStyle->maMenuBarHighlightTextColor);
1069     aStyleSet.SetMenuHighlightColor(pDefinitionStyle->maMenuHighlightColor);
1070     aStyleSet.SetMenuHighlightTextColor(pDefinitionStyle->maMenuHighlightTextColor);
1071     aStyleSet.SetHighlightColor(pDefinitionStyle->maHighlightColor);
1072     aStyleSet.SetHighlightTextColor(pDefinitionStyle->maHighlightTextColor);
1073     aStyleSet.SetActiveTabColor(pDefinitionStyle->maActiveTabColor);
1074     aStyleSet.SetInactiveTabColor(pDefinitionStyle->maInactiveTabColor);
1075     aStyleSet.SetTabTextColor(pDefinitionStyle->maTabTextColor);
1076     aStyleSet.SetTabRolloverTextColor(pDefinitionStyle->maTabRolloverTextColor);
1077     aStyleSet.SetTabHighlightTextColor(pDefinitionStyle->maTabHighlightTextColor);
1078     aStyleSet.SetDisableColor(pDefinitionStyle->maDisableColor);
1079     aStyleSet.SetHelpColor(pDefinitionStyle->maHelpColor);
1080     aStyleSet.SetHelpTextColor(pDefinitionStyle->maHelpTextColor);
1081     aStyleSet.SetLinkColor(pDefinitionStyle->maLinkColor);
1082     aStyleSet.SetVisitedLinkColor(pDefinitionStyle->maVisitedLinkColor);
1083     aStyleSet.SetToolTextColor(pDefinitionStyle->maToolTextColor);
1084     aStyleSet.SetFontColor(pDefinitionStyle->maFontColor);
1085 
1086     auto& pSettings = m_pWidgetDefinition->mpSettings;
1087 
1088     int nFontSize = getSettingValueInteger(pSettings->msDefaultFontSize, 10);
1089     vcl::Font aFont(FAMILY_SWISS, Size(0, nFontSize));
1090     aFont.SetCharSet(osl_getThreadTextEncoding());
1091     aFont.SetWeight(WEIGHT_NORMAL);
1092     aFont.SetFamilyName("Liberation Sans");
1093     aStyleSet.SetAppFont(aFont);
1094     aStyleSet.SetHelpFont(aFont);
1095     aStyleSet.SetMenuFont(aFont);
1096     aStyleSet.SetToolFont(aFont);
1097     aStyleSet.SetGroupFont(aFont);
1098     aStyleSet.SetLabelFont(aFont);
1099     aStyleSet.SetRadioCheckFont(aFont);
1100     aStyleSet.SetPushButtonFont(aFont);
1101     aStyleSet.SetFieldFont(aFont);
1102     aStyleSet.SetIconFont(aFont);
1103     aStyleSet.SetTabFont(aFont);
1104 
1105     aFont.SetWeight(WEIGHT_BOLD);
1106     aStyleSet.SetFloatTitleFont(aFont);
1107     aStyleSet.SetTitleFont(aFont);
1108 
1109     int nTitleHeight = getSettingValueInteger(pSettings->msTitleHeight, aStyleSet.GetTitleHeight());
1110     aStyleSet.SetTitleHeight(nTitleHeight);
1111 
1112     int nFloatTitleHeight
1113         = getSettingValueInteger(pSettings->msFloatTitleHeight, aStyleSet.GetFloatTitleHeight());
1114     aStyleSet.SetFloatTitleHeight(nFloatTitleHeight);
1115 
1116     int nLogicWidth = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicWidth,
1117                                              15); // See vcl/source/app/settings.cxx
1118     int nLogicHeight = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicHeight, 7);
1119     aStyleSet.SetListBoxPreviewDefaultLogicSize(Size(nLogicWidth, nLogicHeight));
1120 
1121     rSettings.SetStyleSettings(aStyleSet);
1122 
1123     return true;
1124 }
1125 
1126 } // end vcl namespace
1127 
1128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1129