Skip to content

Commit

Permalink
tdf#129961 svx: add doc model xml dump for shadow-related pool items
Browse files Browse the repository at this point in the history
It seems that sdr::table::SdrTableObj is already capable of storing
shadow properties, but this is not easy to inspect, extend the xml
dumper to improve the situation.

Change-Id: Ideef43dfd6b844e0227632ec2cb6ab5d16171d8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106902
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
  • Loading branch information
vmiklos committed Nov 30, 2020
1 parent aa56e3b commit a750535
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 4 deletions.
2 changes: 2 additions & 0 deletions include/svx/sdmetitm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public:
MapUnit eCoreMetric,
MapUnit ePresMetric,
OUString& rText, const IntlWrapper&) const override;

virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};


Expand Down
2 changes: 2 additions & 0 deletions include/svx/sdooitm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public:
virtual OUString GetValueTextByVal(bool bVal) const override;

virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper&) const override;

virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};


Expand Down
2 changes: 2 additions & 0 deletions include/svx/sdprcitm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public:
virtual SdrPercentItem* Clone(SfxItemPool* pPool=nullptr) const override;

virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper&) const override;

virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};


Expand Down
1 change: 1 addition & 0 deletions include/svx/xcolit.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public:

const Color& GetColorValue() const;
void SetColorValue(const Color& rNew) { aColor = rNew; Detach(); }
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
};

#endif
Expand Down
54 changes: 54 additions & 0 deletions svx/source/svdraw/svdattr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,18 @@ bool SdrOnOffItem::GetPresentation(SfxItemPresentation ePres,
return true;
}

void SdrOnOffItem::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("SdrOnOffItem"));
if (Which() == SDRATTR_SHADOW)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOW"));
}

SfxBoolItem::dumpAsXml(pWriter);

xmlTextWriterEndElement(pWriter);
}

SdrYesNoItem* SdrYesNoItem::Clone(SfxItemPool* /*pPool*/) const
{
Expand Down Expand Up @@ -770,6 +782,20 @@ bool SdrPercentItem::GetPresentation(
return true;
}

void SdrPercentItem::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("SdrPercentItem"));
if (Which() == SDRATTR_SHADOWTRANSPARENCE)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"),
BAD_CAST("SDRATTR_SHADOWTRANSPARENCE"));
}

SfxUInt16Item::dumpAsXml(pWriter);

xmlTextWriterEndElement(pWriter);
}

SdrAngleItem* SdrAngleItem::Clone(SfxItemPool* /*pPool*/) const
{
return new SdrAngleItem(Which(),GetValue());
Expand Down Expand Up @@ -869,6 +895,34 @@ bool SdrMetricItem::GetPresentation(SfxItemPresentation ePres,
return true;
}

void SdrMetricItem::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("SdrMetricItem"));
if (Which() == SDRATTR_SHADOWXDIST)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWXDIST"));
}
else if (Which() == SDRATTR_SHADOWYDIST)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWYDIST"));
}
else if (Which() == SDRATTR_SHADOWSIZEX)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWSIZEX"));
}
else if (Which() == SDRATTR_SHADOWSIZEY)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWSIZEY"));
}
else if (Which() == SDRATTR_SHADOWBLUR)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWBLUR"));
}

SfxInt32Item::dumpAsXml(pWriter);

xmlTextWriterEndElement(pWriter);
}

// items of the legend object

Expand Down
16 changes: 16 additions & 0 deletions svx/source/xoutdev/xattr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include <svx/xftshcit.hxx>
#include <svx/xftshxy.hxx>
#include <svx/xftadit.hxx>
#include <svx/svddef.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <unotools/intlwrapper.hxx>
#include <unotools/syslocale.hxx>
Expand Down Expand Up @@ -329,6 +330,21 @@ bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
return true;
}

void XColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("XColorItem"));
if (Which() == SDRATTR_SHADOWCOLOR)
{
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST("SDRATTR_SHADOWCOLOR"));
}
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aColor"),
BAD_CAST(aColor.AsRGBHexString().toUtf8().getStr()));

NameOrIndex::dumpAsXml(pWriter);

xmlTextWriterEndElement(pWriter);
}

// --- line attributes ---


Expand Down
12 changes: 8 additions & 4 deletions sw/qa/extras/layout/layout.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -801,21 +801,25 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf137025)
CPPUNIT_ASSERT(pXmlDoc);

// Check the layout xml
// SDRATTR_TEXT_LEFTDIST
assertXPath(pXmlDoc,
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
"/DefaultProperties/SfxItemSet/SfxInt32Item[3]",
"/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1071']",
"value", "567");
// SDRATTR_TEXT_RIGHTDIST
assertXPath(pXmlDoc,
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
"/DefaultProperties/SfxItemSet/SfxInt32Item[4]",
"/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1072']",
"value", "1134");
// SDRATTR_TEXT_UPPERDIST
assertXPath(pXmlDoc,
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
"/DefaultProperties/SfxItemSet/SfxInt32Item[5]",
"/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1073']",
"value", "1701");
// SDRATTR_TEXT_LOWERDIST
assertXPath(pXmlDoc,
"/root/page/body/txt/anchored/SwAnchoredDrawObject/SdrObject"
"/DefaultProperties/SfxItemSet/SfxInt32Item[6]",
"/DefaultProperties/SfxItemSet/SdrMetricItem/SfxInt32Item[@whichId='1074']",
"value", "2268");

// Check the textbox-shape import too
Expand Down

0 comments on commit a750535

Please sign in to comment.