diff options
-rw-r--r-- | include/svx/svxids.hrc | 1 | ||||
-rw-r--r-- | include/svx/xgrad.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 11 | ||||
-rw-r--r-- | svx/sdi/svx.sdi | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 58 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawdlg.cxx | 11 |
7 files changed, 94 insertions, 1 deletions
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 2842dcf5a77f..f7e0e2253566 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 268b0e06253b..5e1f33ace5a0 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 f7f5b1e9ab86..cac505e7e1f0 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> @@ -583,6 +584,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/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index ed413935bb25..0bd2964a6ad8 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 a43a8be1cad7..f1ef70efcc09 100644 --- a/svx/source/xoutdev/xattr.cxx +++ b/svx/source/xoutdev/xattr.cxx @@ -95,6 +95,8 @@ using namespace ::com::sun::star; +typedef std::map<OUString, OUString> StringMap; + static long ScaleMetricValue( long nVal, long nMul, long nDiv ) { BigInt aVal( nVal ); @@ -1974,6 +1976,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 8ef098bc9287..5f9d04af8079 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -41,6 +41,7 @@ #include <svx/xlnwtit.hxx> #include <svx/xflclit.hxx> #include <svx/xfillit0.hxx> +#include <svx/xflgrit.hxx> #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -257,6 +258,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); + } + } } } |