[Libreoffice-commits] core.git: include/svx sc/source sd/source svx/sdi svx/source sw/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 10 10:08:33 UTC 2019
include/svx/svxids.hrc | 1
include/svx/xgrad.hxx | 1
sc/source/ui/drawfunc/drawsh.cxx | 11 ++++++
sd/source/ui/view/drviews2.cxx | 11 ++++++
svx/sdi/svx.sdi | 2 -
svx/source/xoutdev/xattr.cxx | 58 ++++++++++++++++++++++++++++++++++++
sw/source/uibase/shells/drawdlg.cxx | 11 ++++++
7 files changed, 94 insertions(+), 1 deletion(-)
New commits:
commit 1c04f677b53d6e0731f6401bc4c3a0dfd9e6ed01
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Dec 9 14:47:09 2019 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Dec 10 11:07:51 2019 +0100
jsdialog: apply FillGradient with JSON arg
Change-Id: I0ca53a53ff53e66d2f25ad4eb13305edbc3aaa12
Reviewed-on: https://gerrit.libreoffice.org/84798
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 8d4b16389b5d..f12a326d0d2a 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -327,6 +327,7 @@ class SvxSetItem;
#define SID_FRAME_LINESTYLE TypedWhichId<SvxLineItem>( SID_SVX_START + 201 )
#define SID_FRAME_LINECOLOR TypedWhichId<SvxColorItem>( SID_SVX_START + 202 )
#define SID_ATTR_LINE_WIDTH_ARG ( SID_SVX_START + 203 )
+#define SID_FILL_GRADIENT_JSON ( SID_SVX_START + 204 )
#define SID_SEARCHDLG_SEARCHSTRINGS ( SID_SVX_START + 215 )
#define SID_SEARCHDLG_REPLACESTRINGS ( SID_SVX_START + 216 )
#define SID_ATTR_TABLE ( SID_SVX_START + 217 )
diff --git a/include/svx/xgrad.hxx b/include/svx/xgrad.hxx
index 3c9b2b4572a4..8fae7d896c75 100644
--- a/include/svx/xgrad.hxx
+++ b/include/svx/xgrad.hxx
@@ -75,6 +75,7 @@ public:
sal_uInt16 GetSteps() const { return nStepCount; }
boost::property_tree::ptree dumpAsJSON() const;
+ static XGradient fromJSON(const OUString& rJSON);
};
#endif
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 718e6cce54d5..069642c55268 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -57,6 +57,7 @@
#include <svx/chrtitem.hxx>
#include <svx/xlnclit.hxx>
#include <svx/xflclit.hxx>
+#include <svx/xflgrit.hxx>
SFX_IMPL_INTERFACE(ScDrawShell, SfxShell)
@@ -104,6 +105,16 @@ namespace
}
}
}
+ if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem))
+ {
+ const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem);
+ if (pJSON)
+ {
+ XGradient aGradient = XGradient::fromJSON(pJSON->GetValue());
+ XFillGradientItem aItem(aGradient);
+ pArgs->Put(aItem);
+ }
+ }
}
}
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 12a2b8919be6..3097f9496542 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -89,6 +89,7 @@
#include <svx/xlnwtit.hxx>
#include <svx/chrtitem.hxx>
#include <svx/xlnclit.hxx>
+#include <svx/xflgrit.hxx>
#include <tools/diagnose_ex.h>
@@ -578,6 +579,16 @@ public:
}
}
}
+ if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem))
+ {
+ const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem);
+ if (pJSON)
+ {
+ XGradient aGradient = XGradient::fromJSON(pJSON->GetValue());
+ XFillGradientItem aItem(aGradient);
+ pArgs->Put(aItem);
+ }
+ }
}
}
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 795d4df6f944..9d1d9cbc8747 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -2649,7 +2649,7 @@ XFillColorItem FillPageColor SID_ATTR_PAGE_COLOR
]
XFillGradientItem FillGradient SID_ATTR_FILL_GRADIENT
-
+(SfxStringItem FillGradientJSON SID_FILL_GRADIENT_JSON)
[
AutoUpdate = TRUE,
FastCall = FALSE,
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 2c50c3e6f263..c94fcdea4d93 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -96,6 +96,8 @@
using namespace ::com::sun::star;
+typedef std::map<OUString, OUString> StringMap;
+
static long ScaleMetricValue( long nVal, long nMul, long nDiv )
{
BigInt aVal( nVal );
@@ -1975,6 +1977,62 @@ std::string XGradient::GradientStyleToString(css::awt::GradientStyle eStyle)
return "";
}
+namespace
+{
+ css::awt::GradientStyle lcl_getStyleFromString(const OUString& rStyle)
+ {
+ if (rStyle == "LINEAR")
+ return css::awt::GradientStyle_LINEAR;
+ else if (rStyle == "AXIAL")
+ return css::awt::GradientStyle_AXIAL;
+ else if (rStyle == "RADIAL")
+ return css::awt::GradientStyle_RADIAL;
+ else if (rStyle == "ELLIPTICAL")
+ return css::awt::GradientStyle_ELLIPTICAL;
+ else if (rStyle == "SQUARE")
+ return css::awt::GradientStyle_SQUARE;
+ else if (rStyle == "RECT")
+ return css::awt::GradientStyle_RECT;
+
+ return css::awt::GradientStyle_LINEAR;
+ }
+
+ StringMap lcl_jsonToStringMap(const OUString& rJSON)
+ {
+ StringMap aArgs;
+ if (rJSON.getLength() && rJSON[0] != '\0')
+ {
+ std::stringstream aStream(OUStringToOString(rJSON, RTL_TEXTENCODING_ASCII_US).getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+
+ for (const auto& rPair : aTree)
+ {
+ aArgs[OUString::fromUtf8(rPair.first.c_str())] = OUString::fromUtf8(rPair.second.get_value<std::string>(".").c_str());
+ }
+ }
+ return aArgs;
+ }
+
+ XGradient lcl_buildGradientFromStringMap(StringMap& rMap)
+ {
+ XGradient aGradient;
+
+ aGradient.SetStartColor(rMap["startcolor"].toInt32(16));
+ aGradient.SetEndColor(rMap["endcolor"].toInt32(16));
+ aGradient.SetGradientStyle(lcl_getStyleFromString(rMap["style"]));
+ aGradient.SetAngle(rMap["angle"].toInt32());
+
+ return aGradient;
+ }
+}
+
+XGradient XGradient::fromJSON(const OUString& rJSON)
+{
+ StringMap aMap(lcl_jsonToStringMap(rJSON));
+ return lcl_buildGradientFromStringMap(aMap);
+}
+
XGradient::XGradient() :
eStyle( css::awt::GradientStyle_LINEAR ),
aStartColor( COL_BLACK ),
diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx
index d9c82359dc83..457e0e341cd7 100644
--- a/sw/source/uibase/shells/drawdlg.cxx
+++ b/sw/source/uibase/shells/drawdlg.cxx
@@ -40,6 +40,7 @@
#include <svx/chrtitem.hxx>
#include <svx/xlnwtit.hxx>
#include <svx/xfillit0.hxx>
+#include <svx/xflgrit.hxx>
#include <comphelper/lok.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -256,6 +257,16 @@ namespace
XLineWidthItem aItem(nValue);
pArgs->Put(aItem);
}
+ if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem))
+ {
+ const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem);
+ if (pJSON)
+ {
+ XGradient aGradient = XGradient::fromJSON(pJSON->GetValue());
+ XFillGradientItem aItem(aGradient);
+ pArgs->Put(aItem);
+ }
+ }
}
}
More information about the Libreoffice-commits
mailing list