19#include <rtl/bootstrap.hxx>
20#include <config_folders.h>
21#include <osl/file.hxx>
38#include <com/sun/star/graphic/SvgTools.hpp>
48OUString lcl_getThemeDefinitionPath()
50 OUString sPath(
"$BRAND_BASE_DIR/" LIBO_SHARE_FOLDER
"/theme_definitions/");
51 rtl::Bootstrap::expandMacros(sPath);
55bool lcl_directoryExists(OUString
const& sDirectory)
57 osl::DirectoryItem aDirectoryItem;
58 osl::FileBase::RC eRes = osl::DirectoryItem::get(sDirectory, aDirectoryItem);
59 return eRes == osl::FileBase::E_None;
62bool lcl_fileExists(OUString
const& sFilename)
64 osl::File aFile(sFilename);
65 osl::FileBase::RC eRC = aFile.open(osl_File_OpenFlag_Read);
66 return osl::FileBase::E_None == eRC;
69std::shared_ptr<WidgetDefinition> getWidgetDefinition(OUString
const& rDefinitionFile,
70 OUString
const& rDefinitionResourcesPath)
72 auto pWidgetDefinition = std::make_shared<WidgetDefinition>();
73 WidgetDefinitionReader aReader(rDefinitionFile, rDefinitionResourcesPath);
74 if (aReader.read(*pWidgetDefinition))
75 return pWidgetDefinition;
76 return std::shared_ptr<WidgetDefinition>();
79std::shared_ptr<WidgetDefinition>
const&
80getWidgetDefinitionForTheme(std::u16string_view rThemenName)
82 static std::shared_ptr<WidgetDefinition> spDefinition;
85 OUString sSharedDefinitionBasePath = lcl_getThemeDefinitionPath();
86 OUString sThemeFolder = sSharedDefinitionBasePath + rThemenName +
"/";
87 OUString sThemeDefinitionFile = sThemeFolder +
"definition.xml";
88 if (lcl_directoryExists(sThemeFolder) && lcl_fileExists(sThemeDefinitionFile))
89 spDefinition = getWidgetDefinition(sThemeDefinitionFile, sThemeFolder);
94int getSettingValueInteger(std::string_view rValue,
int nDefault)
103bool getSettingValueBool(std::string_view rValue,
bool bDefault)
107 if (rValue ==
"true" || rValue ==
"false")
108 return rValue ==
"true";
115 : m_rGraphics(rGraphics)
133 = getSettingValueBool(pSettings->msNoActiveTabTextRaise,
true);
141 = getSettingValueInteger(pSettings->msListBoxEntryMargin, nDefaultListboxEntryMargin);
217 double i_fTransparency)
219 rGraphics.
drawPolyPolygon(rObjectToDevice, i_rPolyPolygon, i_fTransparency);
226 css::drawing::LineCap i_eLineCap,
double i_fMiterMinimumAngle,
bool bPixelSnapHairline)
228 rGraphics.
drawPolyLine(rObjectToDevice, i_rPolygon, i_fTransparency, i_fLineWidth, i_pStroke,
229 i_eLineJoin, i_eLineCap, i_fMiterMinimumAngle, bPixelSnapHairline);
242 rGraphics.
drawBitmap(rPosAry, rSalBitmap, rTransparentBitmap);
261 for (std::shared_ptr<gfx::DrawBase>
const& pDrawBase : rDrawRoot.
maChildren)
263 switch (pDrawBase->getType())
271 double fDeltaX = aTargetSurface.getWidth() - aSVGRect.
getWidth();
272 double fDeltaY = aTargetSurface.getHeight() - aSVGRect.
getHeight();
275 aInputRectangle.getMinX(), aInputRectangle.getMinY(),
276 aInputRectangle.getMaxX() + fDeltaX, aInputRectangle.getMaxY() + fDeltaY);
279 aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
282 aFinalRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0,
283 rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0);
285 if (rRectangle.mpFillColor)
291 1.0 - rRectangle.mnOpacity);
293 else if (rRectangle.mpFillGradient)
300 rRectangle.mpFillGradient.get());
304 x = pLinearGradient->x1;
305 y = pLinearGradient->y1;
314 aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5);
316 x = pLinearGradient->x2;
317 y = pLinearGradient->y2;
326 aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5);
332 - (rStop.
mfOpacity * (1.0f - rRectangle.mnOpacity)));
339 if (rRectangle.mpStrokeColor)
345 rRectangle.mnStrokeWidth,
353 auto const& rPath =
static_cast<gfx::DrawPath const&
>(*pDrawBase);
355 double fDeltaX = aTargetSurface.getWidth() - aSVGRect.
getWidth();
356 double fDeltaY = aTargetSurface.getHeight() - aSVGRect.
getHeight();
359 for (
auto& rPolygon : aPolyPolygon)
361 for (
size_t i = 0;
i < rPolygon.count(); ++
i)
363 auto& rPoint = rPolygon.getB2DPoint(i);
364 double x = rPoint.getX();
365 double y = rPoint.getY();
375 aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5));
377 if (rPath.mpFillColor)
382 aPolyPolygon, 1.0 - rPath.mnOpacity);
384 if (rPath.mpStrokeColor)
388 for (
auto const& rPolygon : std::as_const(aPolyPolygon))
406void munchDrawCommands(std::vector<std::shared_ptr<WidgetDrawAction>>
const& rDrawActions,
410 for (std::shared_ptr<WidgetDrawAction>
const& pDrawAction : rDrawActions)
412 switch (pDrawAction->maType)
416 auto const& rWidgetDraw
417 =
static_cast<WidgetDrawActionRectangle const&
>(*pDrawAction);
420 nX + (nWidth * rWidgetDraw.mfX1), nY + (nHeight * rWidgetDraw.mfY1),
421 nX + (nWidth * rWidgetDraw.mfX2), nY + (nHeight * rWidgetDraw.mfY2));
424 rRect, rWidgetDraw.mnRx / rRect.getWidth() * 2.0,
425 rWidgetDraw.mnRy / rRect.getHeight() * 2.0);
435 rWidgetDraw.mnStrokeWidth,
nullptr,
441 auto const& rWidgetDraw =
static_cast<WidgetDrawActionLine const&
>(*pDrawAction);
442 Point aRectPoint(nX + 1, nY + 1);
444 Size aRectSize(nWidth - 1, nHeight - 1);
450 { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX1),
451 aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY1) },
452 { aRectPoint.X() + (aRectSize.Width() * rWidgetDraw.mfX2),
453 aRectPoint.Y() + (aRectSize.Height() * rWidgetDraw.mfY2) },
458 rWidgetDraw.mnStrokeWidth,
nullptr,
464 double nScaleFactor = 1.0;
468 auto const& rWidgetDraw =
static_cast<WidgetDrawActionImage const&
>(*pDrawAction);
470 OUString rCacheKey = rWidgetDraw.msSource +
"@" + OUString::number(nScaleFactor);
471 auto aIterator = rCacheImages.find(rCacheKey);
474 if (aIterator == rCacheImages.end())
476 SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
481 rCacheImages.insert(std::make_pair(rCacheKey, aBitmap));
486 aBitmap = aIterator->second;
491 SalTwoRect aTR(0, 0, nImageWidth, nImageHeight, nX, nY, nImageWidth / nScaleFactor,
492 nImageHeight / nScaleFactor);
495 const std::shared_ptr<SalBitmap> pSalBitmap
499 const std::shared_ptr<SalBitmap> pSalBitmapAlpha
513 auto const& rWidgetDraw
514 =
static_cast<WidgetDrawActionExternal const&
>(*pDrawAction);
518 auto aIterator = rCacheDrawCommands.
find(rWidgetDraw.msSource);
520 if (aIterator == rCacheDrawCommands.end())
522 SvFileStream aFileStream(rWidgetDraw.msSource, StreamMode::READ);
524 uno::Reference<uno::XComponentContext> xContext(
526 const uno::Reference<graphic::XSvgParser> xSvgParser
527 = graphic::SvgTools::create(xContext);
529 std::size_t nSize = aFileStream.remainingSize();
530 std::vector<sal_Int8>
aBuffer(nSize + 1);
531 aFileStream.ReadBytes(
aBuffer.data(), nSize);
534 uno::Sequence<sal_Int8>
aData(
aBuffer.data(), nSize + 1);
535 uno::Reference<io::XInputStream> aInputStream(
538 uno::Any aAny = xSvgParser->getDrawCommands(aInputStream,
"");
539 if (aAny.has<sal_uInt64>())
541 auto* pDrawRoot =
reinterpret_cast<gfx::DrawRoot*
>(aAny.get<sal_uInt64>());
544 rCacheDrawCommands.insert(
545 std::make_pair(rWidgetDraw.msSource, *pDrawRoot));
546 drawFromDrawCommands(*pDrawRoot, rGraphics, nX, nY, nWidth, nHeight);
552 drawFromDrawCommands(aIterator->second, rGraphics, nX, nY, nWidth, nHeight);
572 auto const& aStates = pPart->getStates(
eType, ePart, eState, rValue);
573 if (!aStates.empty())
576 auto const& pState = aStates.back();
578 munchDrawCommands(pState->mpWidgetDrawActions,
m_rGraphics, nX, nY, nWidth,
712 nCenterX - nX, nHeight);
715 nCenterX, nY, nX + nWidth - nCenterX, nHeight);
722 nWidth, nCenterY - nY);
725 nCenterY, nWidth, nY + nHeight - nCenterY);
732 nThumbY, nThumbWidth, nThumbHeight);
797 auto const& pButtonUpPart
801 Size aButtonSizeUp(pButtonUpPart->mnWidth, pButtonUpPart->mnHeight);
803 auto const& pButtonDownPart
805 if (!pButtonDownPart)
807 Size aButtonSizeDown(pButtonDownPart->mnWidth, pButtonDownPart->mnHeight);
809 auto const& pEntirePart
812 OString sOrientation = pEntirePart->msOrientation;
814 if (sOrientation.isEmpty() || sOrientation ==
"stacked")
818 else if (sOrientation ==
"decrease-edit-increase")
823 - aButtonSizeUp.
Width(),
826 rNativeBoundingRegion = rNativeContentRegion;
832 rNativeBoundingRegion = rNativeContentRegion;
837 Point aPoint(aLocation.
X() + aButtonSizeDown.
Width(), aLocation.
Y());
839 - (aButtonSizeDown.
Width() + aButtonSizeUp.
Width()),
840 std::max(aButtonSizeUp.
Height(), aButtonSizeDown.
Height()));
842 rNativeBoundingRegion = rNativeContentRegion;
848 std::max(aButtonSizeUp.
Height(), aButtonSizeDown.
Height()));
850 rNativeBoundingRegion = rNativeContentRegion;
854 else if (sOrientation ==
"edit-decrease-increase")
859 - aButtonSizeUp.
Width(),
862 rNativeBoundingRegion = rNativeContentRegion;
868 - (aButtonSizeDown.
Width() + aButtonSizeUp.
Width()),
871 rNativeBoundingRegion = rNativeContentRegion;
877 - (aButtonSizeDown.
Width() + aButtonSizeUp.
Width()),
878 std::max(aButtonSizeUp.
Height(), aButtonSizeDown.
Height()));
880 rNativeBoundingRegion = rNativeContentRegion;
886 std::max(aButtonSizeUp.
Height(), aButtonSizeDown.
Height()));
888 rNativeBoundingRegion = rNativeContentRegion;
900 Size aSize(pPart->mnWidth, pPart->mnHeight);
910 Size aSize(pPart->mnWidth, pPart->mnHeight);
923 = std::max(rBoundingControlRegion.
GetHeight() + pPart->mnMarginHeight,
927 rNativeContentRegion = rNativeBoundingRegion;
934 sal_Int32 nHeight = rBoundingControlRegion.
GetHeight();
938 nHeight = std::max(nHeight, pPart->mnHeight);
942 rNativeBoundingRegion = rNativeContentRegion;
943 rNativeBoundingRegion.
expand(2);
953 rNativeBoundingRegion = rNativeContentRegion;
958 rNativeBoundingRegion = rBoundingControlRegion;
959 rNativeContentRegion = rNativeBoundingRegion;
968 Size aComboButtonSize(pPart->mnWidth, pPart->mnHeight);
973 - aComboButtonSize.
Width() - 1,
976 rNativeBoundingRegion = rNativeContentRegion;
982 aComboButtonSize.
Height());
984 rNativeBoundingRegion = rNativeContentRegion;
991 rNativeBoundingRegion = rNativeContentRegion;
992 rNativeBoundingRegion.
expand(2);
1001 rNativeBoundingRegion = rNativeContentRegion;
1032 pDefinitionStyle->maDefaultActionButtonRolloverTextColor);
1036 pDefinitionStyle->maDefaultButtonPressedRolloverTextColor);
1039 pDefinitionStyle->maDefaultActionButtonPressedRolloverTextColor);
1041 pDefinitionStyle->maActionButtonPressedRolloverTextColor);
1043 pDefinitionStyle->maFlatButtonPressedRolloverTextColor);
1088 int nFontSize = getSettingValueInteger(pSettings->msDefaultFontSize, 10);
1090 aFont.
SetCharSet(osl_getThreadTextEncoding());
1109 int nTitleHeight = getSettingValueInteger(pSettings->msTitleHeight, aStyleSet.
GetTitleHeight());
1112 int nFloatTitleHeight
1116 int nLogicWidth = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicWidth,
1118 int nLogicHeight = getSettingValueInteger(pSettings->msListBoxPreviewDefaultLogicHeight, 7);
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
const Size & GetSizePixel() const
const std::shared_ptr< SalBitmap > & ImplGetSalBitmap() const
ControlType getType() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const Point **pPtAry)=0
bool getAntiAlias() const
void setAntiAlias(bool bNew)
virtual void SetLineColor()=0
virtual void SetFillColor()=0
virtual void drawPolyLine(sal_uInt32 nPoints, const Point *pPtAry)=0
virtual void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap)=0
virtual bool implDrawGradient(basegfx::B2DPolyPolygon const &, SalGradient const &)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
tools::Rectangle maThumbRect
ControlState mnThumbState
void SetFieldTextColor(const Color &rColor)
void SetLabelFont(const vcl::Font &rFont)
void SetLightBorderColor(const Color &rColor)
void SetRadioCheckFont(const vcl::Font &rFont)
void SetLinkColor(const Color &rColor)
void SetFieldRolloverTextColor(const Color &rColor)
void SetActionButtonTextColor(const Color &rColor)
void SetGroupTextColor(const Color &rColor)
void SetFloatTitleFont(const vcl::Font &rFont)
void SetFlatButtonPressedRolloverTextColor(const Color &rColor)
void SetActiveTextColor(const Color &rColor)
sal_Int32 GetTitleHeight() const
void SetFaceColor(const Color &rColor)
void SetHelpFont(const vcl::Font &rFont)
void SetHelpTextColor(const Color &rColor)
void SetToolFont(const vcl::Font &rFont)
void SetShadowColor(const Color &rColor)
void SetListBoxPreviewDefaultLogicSize(Size const &rSize)
void SetActiveBorderColor(const Color &rColor)
void SetPushButtonFont(const vcl::Font &rFont)
void SetTabTextColor(const Color &rColor)
void SetTitleHeight(sal_Int32 nSize)
void SetDisableColor(const Color &rColor)
void SetActiveTabColor(const Color &rColor)
void SetHighlightTextColor(const Color &rColor)
void SetFloatTitleHeight(sal_Int32 nSize)
void SetActionButtonRolloverTextColor(const Color &rColor)
void SetTabRolloverTextColor(const Color &rColor)
void SetDefaultButtonPressedRolloverTextColor(const Color &rColor)
void SetMenuBarHighlightTextColor(const Color &rColor)
void SetDefaultActionButtonTextColor(const Color &rColor)
void SetActiveColor(const Color &rColor)
void SetHelpColor(const Color &rColor)
void SetInactiveTabColor(const Color &rColor)
void SetDialogColor(const Color &rColor)
void SetMenuTextColor(const Color &rColor)
void SetDefaultButtonRolloverTextColor(const Color &rColor)
void SetTabFont(const vcl::Font &rFont)
void SetFlatButtonRolloverTextColor(const Color &rColor)
void SetDefaultActionButtonRolloverTextColor(const Color &rColor)
void SetGroupFont(const vcl::Font &rFont)
void SetCheckedColor(const Color &rColor)
void SetMenuColor(const Color &rColor)
void SetHighlightColor(const Color &rColor)
void SetMonoColor(const Color &rColor)
void SetButtonPressedRolloverTextColor(const Color &rColor)
void SetAppFont(const vcl::Font &rFont)
void SetMenuBarColor(const Color &rColor)
void SetMenuBarRolloverTextColor(const Color &rColor)
void SetMenuHighlightTextColor(const Color &rColor)
void SetTitleFont(const vcl::Font &rFont)
sal_Int32 GetFloatTitleHeight() const
void SetRadioCheckTextColor(const Color &rColor)
void SetLabelTextColor(const Color &rColor)
void SetFieldFont(const vcl::Font &rFont)
void SetDefaultButtonTextColor(const Color &rColor)
void SetIconFont(const vcl::Font &rFont)
void SetButtonRolloverTextColor(const Color &rColor)
void SetButtonTextColor(const Color &rColor)
void SetWindowColor(const Color &rColor)
void SetWindowTextColor(const Color &rColor)
void SetTabHighlightTextColor(const Color &rColor)
void SetVisitedLinkColor(const Color &rColor)
void SetMenuBarTextColor(const Color &rColor)
void SetMenuBarRolloverColor(const Color &rColor)
void SetDeactiveTextColor(const Color &rColor)
void SetDarkShadowColor(const Color &rColor)
void SetFieldColor(const Color &rColor)
void SetMenuFont(const vcl::Font &rFont)
void SetDefaultActionButtonPressedRolloverTextColor(const Color &rColor)
void SetMenuBorderColor(const Color &rColor)
void SetToolTextColor(const Color &rColor)
void SetMenuHighlightColor(const Color &rColor)
void SetLightColor(const Color &rColor)
void SetWorkspaceColor(const Color &rColor)
void SetDeactiveBorderColor(const Color &rColor)
void SetDeactiveColor(const Color &rColor)
void SetActionButtonPressedRolloverTextColor(const Color &rColor)
void SetDialogTextColor(const Color &rColor)
void SetFlatButtonTextColor(const Color &rColor)
double getCenterX() const
double getCenterY() const
std::vector< std::shared_ptr< DrawBase > > maChildren
basegfx::B2DRange maRectangle
list_const_iterator_t find(const Key &key)
void SetWeight(FontWeight)
void SetCharSet(rtl_TextEncoding)
void SetFamilyName(const OUString &rFamilyName)
constexpr OUStringLiteral aData
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
bool isdigitAsciiString(std::string_view rString)
Reference< XComponentContext > getProcessComponentContext()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
void loadFromSvg(SvStream &rStream, const OUString &sPath, BitmapEx &rBitmapEx, double fScalingFactor)
o3tl::lru_map< OUString, BitmapEx > maThemeImageCache
o3tl::lru_map< OUString, gfx::DrawRoot > maThemeDrawCommandsCache
bool mbCanDrawWidgetAnySize
bool mbNoFocusRectsForFlatButtons
int mnStatusBarLowerRightOffset
bool mbProgressNeedsErase
bool mbNoActiveTabTextRaise
basegfx::B2DPoint maPoint1
basegfx::B2DPoint maPoint2
std::vector< SalGradientStop > maStops
ImplSVData * ImplGetSVData()
std::unique_ptr< char[]> aBuffer