21#include <com/sun/star/drawing/FillStyle.hpp>
32#include <editeng/editeng.hxx>
41#include <editeng/editids.hrc>
51 : StylePreviewRenderer(rShell, rOutputDev, pStyle, nMaxHeight)
57 , maStyleName(mpStyle->
GetName())
76 rFont.SetFamily(rFontItem.GetFamily());
77 rFont.SetFamilyName(rFontItem.GetFamilyName());
78 rFont.SetPitch(rFontItem.GetPitch());
79 rFont.SetCharSet(rFontItem.GetCharSet());
80 rFont.SetStyleName(rFontItem.GetStyleName());
93 Size aFontSize(0, rFontHeightItem.GetHeight());
95 rFont.SetFontSize(aFontSize);
111 if (!pItemSet)
return false;
119 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT)) !=
nullptr)
120 aFont.SetWeight(
static_cast<const SvxWeightItem*
>(pItem)->GetWeight());
121 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CJK_WEIGHT)) !=
nullptr)
122 aCJKFont.SetWeight(
static_cast<const SvxWeightItem*
>(pItem)->GetWeight());
123 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CTL_WEIGHT)) !=
nullptr)
124 aCTLFont.SetWeight(
static_cast<const SvxWeightItem*
>(pItem)->GetWeight());
126 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE)) !=
nullptr)
127 aFont.SetItalic(
static_cast<const SvxPostureItem*
>(pItem)->GetPosture());
128 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CJK_POSTURE)) !=
nullptr)
129 aCJKFont.SetItalic(
static_cast<const SvxPostureItem*
>(pItem)->GetPosture());
130 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CTL_POSTURE)) !=
nullptr)
131 aCTLFont.SetItalic(
static_cast<const SvxPostureItem*
>(pItem)->GetPosture());
133 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR)) !=
nullptr)
136 aFont.SetOutline(aVal);
137 aCJKFont.SetOutline(aVal);
138 aCTLFont.SetOutline(aVal);
140 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED)) !=
nullptr)
143 aFont.SetShadow(aVal);
144 aCJKFont.SetShadow(aVal);
145 aCTLFont.SetShadow(aVal);
147 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF)) !=
nullptr)
150 aFont.SetRelief(aVal);
151 aCJKFont.SetRelief(aVal);
152 aCTLFont.SetRelief(aVal);
154 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE)) !=
nullptr)
157 aFont.SetUnderline(aVal);
158 aCJKFont.SetUnderline(aVal);
159 aCTLFont.SetUnderline(aVal);
161 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE)) !=
nullptr)
164 aFont.SetOverline(aVal);
165 aCJKFont.SetOverline(aVal);
166 aCTLFont.SetOverline(aVal);
168 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT)) !=
nullptr)
171 aFont.SetStrikeout(aVal);
172 aCJKFont.SetStrikeout(aVal);
173 aCTLFont.SetStrikeout(aVal);
175 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP)) !=
nullptr)
182 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK)) !=
nullptr)
185 aFont.SetEmphasisMark(aVal);
186 aCJKFont.SetEmphasisMark(aVal);
187 aCTLFont.SetEmphasisMark(aVal);
189 if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR)) !=
nullptr)
193 if ((pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR)) !=
nullptr)
203 if (aFillStyle == drawing::FillStyle_SOLID)
213 if (
SetFont(*pItemSet, SID_ATTR_CHAR_FONT, aFont) &&
214 SetFontSize(*pItemSet, SID_ATTR_CHAR_FONTHEIGHT, aFont))
217 if (
SetFont(*pItemSet, SID_ATTR_CHAR_CJK_FONT, aCJKFont) &&
218 SetFontSize(*pItemSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, aCJKFont))
221 if (
SetFont(*pItemSet, SID_ATTR_CHAR_CTL_FONT, aCTLFont) &&
222 SetFontSize(*pItemSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, aCTLFont))
238 sal_Int32 nStart = 0;
249 nEnd = rText.getLength();
250 aScript = SvtScriptType::LATIN;
255 auto oFont = (aScript == SvtScriptType::ASIAN) ?
257 ((aScript == SvtScriptType::COMPLEX) ?
267 nWidth = oFont->GetTextSize(
mrOutputDev, rText, nStart, nEnd - nStart).Width();
284 if (nEnd < rText.getLength() && nIdx < nCnt)
306 aFontSize =
m_oFont->GetFontSize();
321 aChange.textWidth *= fRatio;
354 sal_Int32 nStart = 0;
364 nEnd = rText.getLength();
365 aScript = SvtScriptType::LATIN;
370 auto oFont = (aScript == SvtScriptType::ASIAN)
372 : ((aScript == SvtScriptType::COMPLEX)
381 oFont->QuickDrawText(&
mrOutputDev, aFontDrawPosition, rText, nStart, nEnd - nStart, {});
389 if (nEnd < rText.getLength() && nIdx < nCnt)
417 auto aScript = aEditEngine.GetScriptType({ 0, 0, 0, 0 });
420 auto aNextScript = aEditEngine.GetScriptType({ 0,
i, 0,
i });
421 if (aNextScript != aScript)
425 aScript = aNextScript;
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetTextColor(const Color &rColor)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
FontMetric GetFontMetric() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
SfxItemPool * GetPool() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
MapUnit GetMapUnit() const
SfxStyleFamily GetFamily() const
virtual std::optional< SfxItemSet > GetItemSetForPreview()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetCaseMap(const SvxCaseMap eNew)
SfxStyleSheetBase * mpStyle
OutputDevice & mrOutputDev
const SfxObjectShell & mrShell
std::optional< SvxFont > m_oCTLFont
CommonStylePreviewRenderer(const SfxObjectShell &rShell, OutputDevice &rOutputDev, SfxStyleSheetBase *pStyle, tools::Long nMaxHeight)
virtual ~CommonStylePreviewRenderer() override
virtual bool render(const tools::Rectangle &aRectangle, RenderAlign eRenderAlign=RenderAlign::CENTER) override
std::optional< SvxFont > m_oFont
virtual bool recalculate() override
std::optional< SvxFont > m_oCJKFont
std::vector< ScriptInfo > maScriptChanges
bool SetFontSize(const SfxItemSet &rSet, sal_uInt16 nSlot, SvxFont &rFont)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
virtual OUString GetName() const override
sal_Int16 GetCaseMap(sal_Int32 nToken)
static bool GetWhich(const SfxItemSet &rSet, sal_uInt16 nSlot, sal_uInt16 &rWhich)
static bool SetFont(const SfxItemSet &rSet, sal_uInt16 nSlot, SvxFont &rFont)
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)