23#include <com/sun/star/lang/IllegalArgumentException.hpp>
37 std::u16string_view sName, sal_Int32 nHeight,
tools::Rectangle const & aRect)
43 std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer
45 pStylePreviewRenderer->recalculate();
56 float fScalingFactor = pVirtualDev->GetDPIScaleFactor();
58 sal_Int32 nMargin = 6 * fScalingFactor;
60 sal_Int32 nPreviewWidth = 144 * fScalingFactor;
62 sal_Int32 nNameHeight = 16 * fScalingFactor;
63 sal_Int32 nTitleHeight = 32 * fScalingFactor;
64 sal_Int32 nHeadingHeight = 24 * fScalingFactor;
65 sal_Int32 nTextBodyHeight = 16 * fScalingFactor;
68 sal_Int32 nNameFontSize = 12 * fScalingFactor;
70 sal_Int32 nPreviewHeight = nNameHeight + nTitleHeight + nHeadingHeight + nTextBodyHeight +
nBottomMargin;
72 Size aSize(nPreviewWidth, nPreviewHeight);
74 pVirtualDev->SetOutputSizePixel(aSize);
76 pVirtualDev->SetLineColor(COL_LIGHTGRAY);
77 pVirtualDev->SetFillColor();
81 pVirtualDev->SetFillColor(COL_LIGHTGRAY);
83 pVirtualDev->DrawRect(aNameRect);
88 pVirtualDev->SetFont(aFont);
90 Size aTextSize(pVirtualDev->GetTextWidth(aName), pVirtualDev->GetTextHeight());
92 Point aPoint((aNameRect.GetWidth() / 2.0) - (aTextSize.Width() / 2.0),
93 y + (aNameRect.GetHeight() / 2.0) - (aTextSize.Height() / 2.0));
95 pVirtualDev->DrawText(aPoint, aName);
102 renderPreview(pStyleManager, *pVirtualDev, u
"Title", nTitleHeight, aRenderRect);
108 renderPreview(pStyleManager, *pVirtualDev, u
"Heading 1", nHeadingHeight, aRenderRect);
113 renderPreview(pStyleManager, *pVirtualDev, u
"Body Text", nTextBodyHeight, aRenderRect);
116 return pVirtualDev->GetBitmapEx(
Point(), aSize);
119BitmapEx CreatePreview(OUString
const & aUrl, OUString
const & aName)
123 SfxMedium aMedium(aUrl, StreamMode::STD_READWRITE);
127 return GenerateStylePreview(*xTemplDoc, aName);
136 if (pParent ==
nullptr)
137 throw css::lang::IllegalArgumentException(
"no parent Window given to StylePresetsPanel::Create",
nullptr, 0);
139 return std::make_unique<StylePresetsPanel>(pParent);
143 :
PanelLayout(pParent,
"StylePresetsPanel",
"modules/swriter/ui/sidebarstylepresets.ui")
145 , mxValueSetWin(new
weld::CustomWeld(*m_xBuilder,
"valueset", *mxValueSet))
162 if (aRegionName ==
"Styles")
164 for (sal_uInt16 j = 0; j < aTemplates.
GetCount(
i); ++j)
169 sal_uInt16
nId = j + 1;
185 sal_Int32 nItemId = mxValueSet->GetSelectedItemId();
186 TemplateEntry* pEntry =
static_cast<TemplateEntry*
>(mxValueSet->GetItemData(nItemId));
193 pDocSh->LoadStylesFromFile(pEntry->maURL, aOption,
false);
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
OUString GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const
sal_uInt16 GetRegionCount() const
sal_uInt16 GetCount(sal_uInt16 nRegion) const
OUString GetFullRegionName(sal_uInt16 nIdx) const
OUString GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const
virtual bool LoadFrom(SfxMedium &rMedium)
virtual sfx2::StyleManager * GetStyleManager()
static SfxObjectShell * CreateObjectByFactoryName(const OUString &rURL, SfxObjectCreateMode=SfxObjectCreateMode::STANDARD)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void SetNumRules(const bool bNew)
void SetTextFormats(const bool bNew)
virtual std::unique_ptr< StylePreviewRenderer > CreateStylePreviewRenderer(OutputDevice &rOutputDev, SfxStyleSheetBase *pStyle, tools::Long nMaxHeight)=0
SfxStyleSheetBase * Search(std::u16string_view rStyleName, SfxStyleFamily eFamily)
void SetFontSize(const Size &)
#define LINK(Instance, Class, Member)
tools::Long const nBottomMargin