summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-06-16 08:07:04 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-06-24 11:38:38 +0200
commit3dcf7a3d221290b290aca4a7f4cb691322873fb6 (patch)
tree0c91980d890d1e76dbaf6c4001a25324f6c4a821 /include
parent8aa6c7e1f7ef444978bbbb930e99bfd7e2da0a63 (diff)
jsdialog: generate JSON for drawing area
Change-Id: Ic9402f0f7c891868790b657cd7e9860e46f3e8e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96852 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96985 Tested-by: Jenkins
Diffstat (limited to 'include')
-rw-r--r--include/vcl/layout.hxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 67e856fabdca..1081415fc4cf 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -22,7 +22,12 @@
#include <vcl/vclptr.hxx>
#include <vcl/IContext.hxx>
#include <vcl/commandevent.hxx>
+#include <tools/stream.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <comphelper/base64.hxx>
+#include <vcl/virdev.hxx>
#include <set>
+#include <boost/property_tree/json_parser.hpp>
class ScrollBar;
class ScrollBar;
@@ -802,6 +807,26 @@ public:
m_xTransferHelper = rHelper;
m_nDragAction = eDNDConstants;
}
+ boost::property_tree::ptree DumpAsPropertyTree() override
+ {
+ boost::property_tree::ptree aTree(Control::DumpAsPropertyTree());
+ aTree.put("type", "drawingarea");
+ ScopedVclPtrInstance<VirtualDevice> pDevice;
+ pDevice->SetOutputSize( GetSizePixel() );
+ tools::Rectangle aRect(Point(0,0), GetSizePixel());
+ Paint(*pDevice, aRect);
+ BitmapEx aImage = pDevice->GetBitmapEx( Point(0,0), GetSizePixel() );
+ 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);
+ aTree.put("image", aBuffer.makeStringAndClear());
+ }
+ return aTree;
+ }
};
//Get first window of a pTopLevel window as