summaryrefslogtreecommitdiff
path: root/canvas/source/vcl/outdevholder.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-05-04 11:32:11 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-05-06 11:22:47 +0200
commit402acbcfadbc8fd9f45330b46a4bfaad3e02eb39 (patch)
treebb12f967f882208c1b13febbca435f8b68999c57 /canvas/source/vcl/outdevholder.hxx
parent834822413d687572691753c33d837ffdb5064f2b (diff)
make it possible to write canvas unittests
One of the problems is that canvas apparently works only with windows, but tests obviously need an offscreen surface. This patch moves Window::GetCanvas() to OutputDevice, and makes vclcanvas capable of working with OutputDevice classes that are not windows. Other canvas implementations still don't work, but presumably at least cairocanvas could be fixed too. This commit adds a "simple" test that just draws a line and tries to verify it's been drawn properly. Adding another test should be a matter of basing it on this existing one, and then copy&pasting the complicated UNO way of drawing using canvas from somewhere, such as canvas/workben/canvasdemo.cxx. Change-Id: I42db12b09433763cd31c3dd497c10157424b8598 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115117 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'canvas/source/vcl/outdevholder.hxx')
-rw-r--r--canvas/source/vcl/outdevholder.hxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/canvas/source/vcl/outdevholder.hxx b/canvas/source/vcl/outdevholder.hxx
new file mode 100644
index 000000000000..78f3badf8bb6
--- /dev/null
+++ b/canvas/source/vcl/outdevholder.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <vcl/outdev.hxx>
+
+#include "outdevprovider.hxx"
+
+namespace vclcanvas
+{
+class OutDevHolder : public OutDevProvider
+{
+public:
+ OutDevHolder(const OutDevHolder&) = delete;
+ const OutDevHolder& operator=(const OutDevHolder&) = delete;
+
+ explicit OutDevHolder(OutputDevice& rOutDev)
+ : mrOutDev(rOutDev)
+ {
+ }
+
+private:
+ virtual OutputDevice& getOutDev() override { return mrOutDev; }
+ virtual const OutputDevice& getOutDev() const override { return mrOutDev; }
+
+ // TODO(Q2): Lifetime issue. This _only_ works reliably,
+ // if disposing the Canvas correctly disposes all
+ // entities which hold this pointer.
+ OutputDevice& mrOutDev;
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */