summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-06-04 19:19:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-05 08:23:36 +0200
commite0e944a42059271d082f8bd5121f30a4536fb8f3 (patch)
treedbf7006c7aa94eb47df0bef742e87dabbb6854a5 /svx/source/styles
parentc1898a4d1b38e0077416a104e2b47573ce207ffa (diff)
no need to allocate this separately
Change-Id: I30df477cd708d021fc5b6fcfa9925e1c99be6650 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135429 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/CommonStylePreviewRenderer.cxx50
1 files changed, 25 insertions, 25 deletions
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
index 7ad9c8697dd1..df0e3539e769 100644
--- a/svx/source/styles/CommonStylePreviewRenderer.cxx
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -58,55 +58,55 @@ CommonStylePreviewRenderer::~CommonStylePreviewRenderer()
bool CommonStylePreviewRenderer::recalculate()
{
- m_pFont.reset();
+ m_oFont.reset();
std::optional<SfxItemSet> pItemSet(mpStyle->GetItemSetForPreview());
if (!pItemSet) return false;
- std::unique_ptr<SvxFont> pFont(new SvxFont);
+ SvxFont aFont;
const SfxPoolItem* pItem;
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
{
- pFont->SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
+ aFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
{
- pFont->SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
+ aFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
{
- pFont->SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
+ aFont.SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
{
- pFont->SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
+ aFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
{
- pFont->SetRelief(static_cast<const SvxCharReliefItem*>(pItem)->GetValue());
+ aFont.SetRelief(static_cast<const SvxCharReliefItem*>(pItem)->GetValue());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
{
- pFont->SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
+ aFont.SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
{
- pFont->SetOverline(static_cast<const SvxOverlineItem*>(pItem)->GetValue());
+ aFont.SetOverline(static_cast<const SvxOverlineItem*>(pItem)->GetValue());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
{
- pFont->SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
+ aFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
{
- pFont->SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
+ aFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
{
- pFont->SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
+ aFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
}
if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
{
@@ -137,8 +137,8 @@ bool CommonStylePreviewRenderer::recalculate()
const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
if (IsStarSymbol(pFontItem->GetFamilyName()))
return false;
- pFont->SetFamilyName(pFontItem->GetFamilyName());
- pFont->SetStyleName(pFontItem->GetStyleName());
+ aFont.SetFamilyName(pFontItem->GetFamilyName());
+ aFont.SetStyleName(pFontItem->GetStyleName());
}
else
{
@@ -150,11 +150,11 @@ bool CommonStylePreviewRenderer::recalculate()
const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
Size aFontSize(0, pFontHeightItem->GetHeight());
maPixelSize = mrOutputDev.LogicToPixel(aFontSize, MapMode(mrShell.GetMapUnit()));
- pFont->SetFontSize(maPixelSize);
+ aFont.SetFontSize(maPixelSize);
vcl::Font aOldFont(mrOutputDev.GetFont());
- mrOutputDev.SetFont(*pFont);
+ mrOutputDev.SetFont(aFont);
tools::Rectangle aTextRect;
mrOutputDev.GetTextBoundRect(aTextRect, mpStyle->GetName());
if (aTextRect.Bottom() > mnMaxHeight)
@@ -162,7 +162,7 @@ bool CommonStylePreviewRenderer::recalculate()
double ratio = double(mnMaxHeight) / aTextRect.Bottom();
maPixelSize.setWidth( maPixelSize.Width() * ratio );
maPixelSize.setHeight( maPixelSize.Height() * ratio );
- pFont->SetFontSize(maPixelSize);
+ aFont.SetFontSize(maPixelSize);
}
mrOutputDev.SetFont(aOldFont);
}
@@ -171,15 +171,15 @@ bool CommonStylePreviewRenderer::recalculate()
return false;
}
- m_pFont = std::move(pFont);
+ m_oFont = aFont;
maPixelSize = getRenderSize();
return true;
}
Size CommonStylePreviewRenderer::getRenderSize() const
{
- assert(m_pFont);
- Size aPixelSize = m_pFont->GetTextSize(mrOutputDev, maStyleName);
+ assert(m_oFont);
+ Size aPixelSize = m_oFont->GetTextSize(mrOutputDev, maStyleName);
if (aPixelSize.Height() > mnMaxHeight)
aPixelSize.setHeight( mnMaxHeight );
@@ -200,8 +200,8 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
mrOutputDev.DrawRect(aRectangle);
}
- if (m_pFont)
- mrOutputDev.SetFont(*m_pFont);
+ if (m_oFont)
+ mrOutputDev.SetFont(*m_oFont);
if (maFontColor != COL_AUTO)
mrOutputDev.SetTextColor(maFontColor);
@@ -209,7 +209,7 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
if (maHighlightColor != COL_AUTO)
mrOutputDev.SetTextFillColor(maHighlightColor);
- Size aPixelSize(m_pFont ? maPixelSize : mrOutputDev.GetFont().GetFontSize());
+ Size aPixelSize(m_oFont ? maPixelSize : mrOutputDev.GetFont().GetFontSize());
Point aFontDrawPosition = aRectangle.TopLeft();
if (eRenderAlign == RenderAlign::CENTER)
@@ -218,8 +218,8 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
aFontDrawPosition.AdjustY((aRectangle.GetHeight() - aPixelSize.Height()) / 2 );
}
- if (m_pFont)
- m_pFont->QuickDrawText( &mrOutputDev, aFontDrawPosition, rText, 0, rText.getLength(), {} );
+ if (m_oFont)
+ m_oFont->QuickDrawText( &mrOutputDev, aFontDrawPosition, rText, 0, rText.getLength(), {} );
else
mrOutputDev.DrawText(aFontDrawPosition, rText);