[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/inc vcl/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 12 09:33:31 UTC 2021
vcl/inc/iconview.hxx | 2 +
vcl/source/treelist/iconview.cxx | 63 +++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
New commits:
commit bd882120ce84510f7a5272ecdbf59a5947ea2d45
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Jan 8 10:54:14 2021 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jan 12 10:32:57 2021 +0100
jsdialog: dump IconView
Change-Id: I82df1f5e5f966e764b768044526b3401d55fc394
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108984
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/vcl/inc/iconview.hxx b/vcl/inc/iconview.hxx
index 750f7ec6ebf0..087d0fb900b9 100644
--- a/vcl/inc/iconview.hxx
+++ b/vcl/inc/iconview.hxx
@@ -32,6 +32,8 @@ public:
virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nEntryPos ) override;
void PaintEntry( SvTreeListEntry&, long nX, long nY, vcl::RenderContext& rRenderContext);
+
+ virtual boost::property_tree::ptree DumpAsPropertyTree() override;
};
#endif
diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx
index 45740a38cde5..cda30201fa2f 100644
--- a/vcl/source/treelist/iconview.cxx
+++ b/vcl/source/treelist/iconview.cxx
@@ -21,6 +21,11 @@
#include <vcl/viewdataentry.hxx>
#include <iconview.hxx>
#include "iconviewimpl.hxx"
+#include <boost/property_tree/ptree.hpp>
+#include <vcl/svlbitm.hxx>
+#include <tools/stream.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <comphelper/base64.hxx>
IconView::IconView( vcl::Window* pParent, WinBits nBits )
: SvTreeListBox( pParent, nBits )
@@ -221,4 +226,62 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, long nX, long nY,
}
}
+static OUString extractPngString(const SvLBoxContextBmp* pBmpItem)
+{
+ BitmapEx aImage = pBmpItem->GetBitmap1().GetBitmapEx();
+ SvMemoryStream aOStm(65535, 65535);
+ if(GraphicConverter::Export(aOStm, aImage, ConvertDataFormat::PNG) == ERRCODE_NONE)
+ {
+ css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell());
+ OUStringBuffer aBuffer("data:image/png;base64,");
+ ::comphelper::Base64::encode(aBuffer, aSeq);
+ return aBuffer.makeStringAndClear();
+ }
+
+ return "";
+}
+
+static boost::property_tree::ptree lcl_DumpEntryAndSiblings(SvTreeListEntry* pEntry,
+ SvTreeListBox* pTabListBox)
+{
+ boost::property_tree::ptree aEntries;
+
+ while (pEntry)
+ {
+ boost::property_tree::ptree aEntry;
+
+ // simple listbox value
+ const SvLBoxItem* pIt = pEntry->GetFirstItem(SvLBoxItemType::String);
+ if (pIt)
+ aEntry.put("text", static_cast<const SvLBoxString*>(pIt)->GetText());
+
+ pIt = pEntry->GetFirstItem(SvLBoxItemType::ContextBmp);
+ if (pIt)
+ {
+ const SvLBoxContextBmp* pBmpItem = static_cast<const SvLBoxContextBmp*>(pIt);
+ if (pBmpItem)
+ aEntry.put("image", extractPngString(pBmpItem));
+ }
+
+ if (pTabListBox->IsSelected(pEntry))
+ aEntry.put("selected", "true");
+
+ aEntry.put("row", OString::number(pTabListBox->GetModel()->GetAbsPos(pEntry)).getStr());
+
+ aEntries.push_back(std::make_pair("", aEntry));
+
+ pEntry = pEntry->NextSibling();
+ }
+
+ return aEntries;
+}
+
+boost::property_tree::ptree IconView::DumpAsPropertyTree()
+{
+ boost::property_tree::ptree aTree = SvTreeListBox::DumpAsPropertyTree();
+ aTree.put("type", "iconview");
+ aTree.push_back(std::make_pair("entries", lcl_DumpEntryAndSiblings(First(), this)));
+ return aTree;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list