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 20:31:07 +0100 |
commit | dcb31718a238f115f703f1088ba5220e620dec1c (patch) | |
tree | 1044a2713ca5cc3a2621f1a6f8c4f1637e17fa6f /sc/source/ui/drawfunc | |
parent | e55a1dc163165cb79fc9113101d16ee8d3db7298 (diff) |
jsdialogs: dumpAsJSON for SfxItems with FillGradient example
Change-Id: I1b9303af6f52ad071074200bb630c587c8f611c1
Reviewed-on: https://gerrit.libreoffice.org/83875
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sc/source/ui/drawfunc')
-rw-r--r-- | sc/source/ui/drawfunc/drawsh2.cxx | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 118412c24822..e2ef0c75a173 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -48,6 +48,7 @@ #include <svx/svdoole2.hxx> #include <svx/svdocapt.hxx> #include <svx/xfillit0.hxx> +#include <svx/xflgrit.hxx> #include <comphelper/lok.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> @@ -57,54 +58,29 @@ using namespace com::sun::star::drawing; using namespace com::sun::star; namespace { - OUString lcl_fillStyleEnumToString(FillStyle eStyle) - { - switch (eStyle) - { - case FillStyle_NONE: - return "NONE"; - - case FillStyle_SOLID: - return "SOLID"; - - case FillStyle_GRADIENT: - return "GRADIENT"; - - case FillStyle_HATCH: - return "HATCH"; - - case FillStyle_BITMAP: - return "BITMAP"; - - default: - return ""; - } - } - void lcl_sendAttrUpdatesForLOK(SfxViewShell* pShell, const SfxItemSet& rSet) { if (!pShell) return; - OUString sPayload; - const SfxPoolItem* pItem = rSet.GetItem(SID_ATTR_FILL_STYLE); + boost::property_tree::ptree aTree; + boost::property_tree::ptree anArray; - if (pItem) + for(int i = 0; i < rSet.Count(); i++) { - const XFillStyleItem* pFillStyleItem = static_cast<const XFillStyleItem*>(pItem); - FillStyle eStyle; - css::uno::Any aAny; - - pFillStyleItem->QueryValue(aAny); - aAny >>= eStyle; - sPayload = ".uno:FillStyle=" + lcl_fillStyleEnumToString(eStyle); + sal_uInt16 nWhich = rSet.GetWhichByPos(i); + if (rSet.HasItem(nWhich) && SfxItemState::SET >= rSet.GetItemState(nWhich)) + { + boost::property_tree::ptree aItem = rSet.Get(nWhich).dumpAsJSON(); + if (!aItem.empty()) + anArray.push_back(std::make_pair("", aItem)); + } } + aTree.add_child("items", anArray); - if (!sPayload.isEmpty()) - { - pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, - OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr()); - } + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str()); } } |