diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2019-11-21 17:47:10 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2019-11-27 17:02:08 +0100 |
commit | 66ecf17744754d239a56113a1384f1ac36653f80 (patch) | |
tree | 6f503d0155c11c947cf1fc2cbff3d9bd30fe6fb2 /svx | |
parent | fe8dc93fa6afa3b0ac7211058ea963ab97b15615 (diff) |
jsdialogs: dumpAsJSON for SfxItems with FillGradient example
Change-Id: I1b9303af6f52ad071074200bb630c587c8f611c1
Reviewed-on: https://gerrit.libreoffice.org/83745
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx index fcb1b78e8bb7..37708b2cdf5c 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -61,6 +61,8 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <unotools/intlwrapper.hxx> #include <vcl/gradient.hxx> +#include <svx/svxids.hrc> +#include <string> #include <libxml/xmlwriter.h> @@ -1915,6 +1917,35 @@ bool XSecondaryFillColorItem::GetPresentation return true; } +std::string XGradient::GradientStyleToString(css::awt::GradientStyle eStyle) +{ + switch (eStyle) + { + case css::awt::GradientStyle::GradientStyle_LINEAR: + return "Linear"; + + case css::awt::GradientStyle::GradientStyle_AXIAL: + return "Axial"; + + case css::awt::GradientStyle::GradientStyle_RADIAL: + return "Radial"; + + case css::awt::GradientStyle::GradientStyle_ELLIPTICAL: + return "Elliptical"; + + case css::awt::GradientStyle::GradientStyle_SQUARE: + return "Square"; + + case css::awt::GradientStyle::GradientStyle_RECT: + return "Rect"; + + case css::awt::GradientStyle::GradientStyle_MAKE_FIXED_SIZE: + return "FixedSize"; + } + + return ""; +} + XGradient::XGradient() : eStyle( css::awt::GradientStyle_LINEAR ), aStartColor( COL_BLACK ), @@ -1961,6 +1992,23 @@ bool XGradient::operator==(const XGradient& rGradient) const nStepCount == rGradient.nStepCount ); } +boost::property_tree::ptree XGradient::dumpAsJSON() const +{ + boost::property_tree::ptree aTree; + + aTree.put("style", XGradient::GradientStyleToString(eStyle)); + aTree.put("startcolor", aStartColor.AsRGBHexString()); + aTree.put("endcolor", aEndColor.AsRGBHexString()); + aTree.put("angle", std::to_string(nAngle)); + aTree.put("border", std::to_string(nBorder)); + aTree.put("x", std::to_string(nOfsX)); + aTree.put("y", std::to_string(nOfsY)); + aTree.put("intensstart", std::to_string(nIntensStart)); + aTree.put("intensend", std::to_string(nIntensEnd)); + aTree.put("stepcount", std::to_string(nStepCount)); + + return aTree; +} SfxPoolItem* XFillGradientItem::CreateDefault() { return new XFillGradientItem; } @@ -2269,6 +2317,18 @@ XFillGradientItem* XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) con return nullptr; } +boost::property_tree::ptree XFillGradientItem::dumpAsJSON() const +{ + boost::property_tree::ptree aTree = SfxPoolItem::dumpAsJSON(); + + if (Which() == XATTR_FILLGRADIENT) + aTree.put("which", ".uno:FillGradient"); + + aTree.push_back(std::make_pair("data", GetGradientValue().dumpAsJSON())); + + return aTree; +} + SfxPoolItem* XFillFloatTransparenceItem::CreateDefault() { return new XFillFloatTransparenceItem; } |