Kaydet (Commit) 9acd707d authored tarafından Caolán McNamara's avatar Caolán McNamara

fix crashing on exit in static SvxBrushItem dtor

site of second ctor

Change-Id: Ic319bd36f207a0f1939482a7b4c729b519bb5ce1
üst df4bd415
......@@ -98,6 +98,8 @@ public:
//UUUUinline
SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true,
const SfxPoolItem **ppItem = 0 ) const;
SfxItemState GetBackgroundState(SvxBrushItem &rItem,
bool bSrchInParent = true) const;
virtual bool SetFmtAttr( const SfxPoolItem& rAttr );
virtual bool SetFmtAttr( const SfxItemSet& rSet );
virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
......
......@@ -409,13 +409,12 @@ const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, bool bInParents ) const
return aSet.Get( nWhich, bInParents );
}
SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
{
if(RES_BACKGROUND == nWhich && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
{
//UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFmt::GetBackgroundStat (simple fallback is in place and used)");
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
// check if the new fill attributes are used
......@@ -424,6 +423,7 @@ SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const S
// if yes, fill the local SvxBrushItem using the new fill attributes
// as good as possible to have an instance for the pointer to point
// to and return as state that it is set
static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bSrchInParent);
......@@ -444,6 +444,33 @@ SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const S
return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
}
SfxItemState SwFmt::GetBackgroundState(SvxBrushItem &rItem, bool bSrchInParent) const
{
if (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
{
//UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
// check if the new fill attributes are used
if(aFill.get() && aFill->isUsed())
{
// if yes, fill the local SvxBrushItem using the new fill attributes
// as good as possible to have an instance for the pointer to point
// to and return as state that it is set
rItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bSrchInParent);
return SFX_ITEM_SET;
}
// if not return SFX_ITEM_DEFAULT to signal that the item is not set
return SFX_ITEM_DEFAULT;
}
const SfxPoolItem* pItem = 0;
SfxItemState eRet = aSet.GetItemState(RES_BACKGROUND, bSrchInParent, &pItem);
if (pItem)
rItem = *(const SvxBrushItem*)pItem;
return eRet;
}
bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
{
......
......@@ -821,7 +821,7 @@ void DocxExport::WriteSettings()
}
// Display Background Shape
if (boost::optional<const SvxBrushItem*> oBrush = getBackground())
if (boost::optional<SvxBrushItem> oBrush = getBackground())
{
// Turn on the 'displayBackgroundShape'
pFS->singleElementNS( XML_w, XML_displayBackgroundShape, FSEND );
......@@ -1280,19 +1280,18 @@ bool DocxExport::isMirroredMargin()
return bMirroredMargins;
}
boost::optional<const SvxBrushItem*> DocxExport::getBackground()
boost::optional<SvxBrushItem> DocxExport::getBackground()
{
boost::optional<const SvxBrushItem*> oRet;
boost::optional<SvxBrushItem> oRet;
const SwFrmFmt &rFmt = pDoc->GetPageDesc(0).GetMaster();
const SfxPoolItem* pItem = 0;
SfxItemState eState = rFmt.GetItemState(RES_BACKGROUND, true, &pItem);
SvxBrushItem aBrush(RES_BACKGROUND);
SfxItemState eState = rFmt.GetBackgroundState(aBrush);
if (SFX_ITEM_SET == eState && pItem)
if (SFX_ITEM_SET == eState)
{
// The 'color' is set for the first page style - take it and use it as the background color of the entire DOCX
const SvxBrushItem* pBrush = (const SvxBrushItem*)pItem;
if (pBrush->GetColor().GetColor() != COL_AUTO)
oRet.reset(pBrush);
if (aBrush.GetColor().GetColor() != COL_AUTO)
oRet.reset(aBrush);
}
return oRet;
}
......@@ -1303,9 +1302,9 @@ void DocxExport::WriteMainText()
m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces( m_pDocumentFS ));
// Write background page color
if (boost::optional<const SvxBrushItem*> oBrush = getBackground())
if (boost::optional<SvxBrushItem> oBrush = getBackground())
{
Color backgroundColor = (*oBrush)->GetColor();
Color backgroundColor = oBrush->GetColor();
OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor);
m_pDocumentFS->singleElementNS( XML_w, XML_background, FSNS( XML_w, XML_color ), aBackgroundColorStr, FSEND );
......
......@@ -252,7 +252,7 @@ private:
void WriteEmbeddings();
/// Get background color of the document, if there is one.
boost::optional<const SvxBrushItem*> getBackground();
boost::optional<SvxBrushItem> getBackground();
/// return true if Page Layout is set as Mirrored
bool isMirroredMargin();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment