summaryrefslogtreecommitdiff
path: root/svx/source/styles
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-09-07 16:36:24 +0200
committerMichael Stahl <mstahl@redhat.com>2015-09-07 16:49:58 +0200
commit93067f37cf22aa119db5878c4345fea500cbbb42 (patch)
treef8660673667e6addc9b08b2e76350cbac469ddee /svx/source/styles
parent110dc43d97d559b6369bca308f9dd39fd02e751e (diff)
tdf#91383: sw: prevent style preview from actually creating styles
The dialog/sidebar should not actually create styles that don't exist yet, because it messes up Undo and the (unused) styles are then unnecessarily exported to documents. Due to Writer's ... unusual SwDocStyleSheet class this is a bit tricky. Add a new function GetItemSetForPreview() and use it from the style preview code. The implementation does not use FillPhysical so will temporarily create and then delete any non-existing styles. Skip page and numbering styles for now since they don't have a useful preview. (regression from ca95307638207db5d662059aa61594151a13e927) Change-Id: Id6ee30ea467fc24c991547a4c23a9ce14fdd86c7
Diffstat (limited to 'svx/source/styles')
-rw-r--r--svx/source/styles/CommonStylePreviewRenderer.cxx36
1 files changed, 19 insertions, 17 deletions
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
index 2d9ac3f5dd10..19bce5f5ef63 100644
--- a/svx/source/styles/CommonStylePreviewRenderer.cxx
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -60,65 +60,67 @@ CommonStylePreviewRenderer::~CommonStylePreviewRenderer()
bool CommonStylePreviewRenderer::recalculate()
{
- const SfxItemSet& aItemSet = mpStyle->GetItemSet();
-
maFont = SvxFont();
+ std::unique_ptr<SfxItemSet> pItemSet(mpStyle->GetItemSetForPreview());
+
+ if (!pItemSet) return false;
+
const SfxPoolItem* pItem;
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT)) != nullptr)
{
maFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE)) != nullptr)
{
maFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR)) != nullptr)
{
maFont.SetOutline(static_cast< const SvxContourItem*>(pItem)->GetValue());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED)) != nullptr)
{
maFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF)) != nullptr)
{
maFont.SetRelief(static_cast<FontRelief>(static_cast<const SvxCharReliefItem*>(pItem)->GetValue()));
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE)) != nullptr)
{
maFont.SetUnderline(static_cast< const SvxUnderlineItem*>(pItem)->GetLineStyle());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE)) != nullptr)
{
maFont.SetOverline(static_cast<FontUnderline>(static_cast<const SvxOverlineItem*>(pItem)->GetValue()));
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT)) != nullptr)
{
maFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP)) != nullptr)
{
maFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK)) != nullptr)
{
maFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR)) != nullptr)
{
maFontColor = Color(static_cast<const SvxColorItem*>(pItem)->GetValue());
}
if (mpStyle->GetFamily() == SFX_STYLE_FAMILY_PARA)
{
- if ((pItem = aItemSet.GetItem(XATTR_FILLSTYLE)) != nullptr)
+ if ((pItem = pItemSet->GetItem(XATTR_FILLSTYLE)) != nullptr)
{
sal_uInt16 aFillStyle = static_cast<const XFillStyleItem*>(pItem)->GetValue();
if (aFillStyle == drawing::FillStyle_SOLID)
{
- if ((pItem = aItemSet.GetItem(XATTR_FILLCOLOR)) != nullptr)
+ if ((pItem = pItemSet->GetItem(XATTR_FILLCOLOR)) != nullptr)
{
maBackgroundColor = Color(static_cast<const XFillColorItem*>(pItem)->GetColorValue());
}
@@ -126,7 +128,7 @@ bool CommonStylePreviewRenderer::recalculate()
}
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_FONT)) != nullptr)
{
const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
maFont.SetName(pFontItem->GetFamilyName());
@@ -137,7 +139,7 @@ bool CommonStylePreviewRenderer::recalculate()
return false;
}
- if ((pItem = aItemSet.GetItem(SID_ATTR_CHAR_FONTHEIGHT)) != nullptr)
+ if ((pItem = pItemSet->GetItem(SID_ATTR_CHAR_FONTHEIGHT)) != nullptr)
{
const SvxFontHeightItem* pFontHeightItem = static_cast<const SvxFontHeightItem*>(pItem);
Size aFontSize(0, pFontHeightItem->GetHeight());