summaryrefslogtreecommitdiffstats
path: root/include/cppcanvas
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/cppcanvas
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/cppcanvas')
-rw-r--r--include/cppcanvas/basegfxfactory.hxx76
-rw-r--r--include/cppcanvas/bitmap.hxx70
-rw-r--r--include/cppcanvas/bitmapcanvas.hxx49
-rw-r--r--include/cppcanvas/canvas.hxx103
-rw-r--r--include/cppcanvas/canvasgraphic.hxx80
-rw-r--r--include/cppcanvas/color.hxx70
-rw-r--r--include/cppcanvas/cppcanvasdllapi.h31
-rw-r--r--include/cppcanvas/customsprite.hxx44
-rw-r--r--include/cppcanvas/polypolygon.hxx76
-rw-r--r--include/cppcanvas/renderer.hxx140
-rw-r--r--include/cppcanvas/sprite.hxx96
-rw-r--r--include/cppcanvas/spritecanvas.hxx63
-rw-r--r--include/cppcanvas/vclfactory.hxx87
13 files changed, 985 insertions, 0 deletions
diff --git a/include/cppcanvas/basegfxfactory.hxx b/include/cppcanvas/basegfxfactory.hxx
new file mode 100644
index 000000000..611523066
--- /dev/null
+++ b/include/cppcanvas/basegfxfactory.hxx
@@ -0,0 +1,76 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_BASEGFXFACTORY_HXX
+#define INCLUDED_CPPCANVAS_BASEGFXFACTORY_HXX
+
+#include <cppcanvas/canvas.hxx>
+#include <cppcanvas/polypolygon.hxx>
+#include <cppcanvas/bitmap.hxx>
+#include <basegfx/vector/b2isize.hxx>
+
+#include <cppcanvas/cppcanvasdllapi.h>
+
+namespace basegfx
+{
+ class B2DPolygon;
+}
+
+
+/* Definition of BaseGfxFactory class */
+
+namespace cppcanvas
+{
+ /** The BaseGfxFactory creates Canvas objects for various basegfx
+ primitives, such as polygons and bitmaps (not yet
+ implemented).
+
+ Please note that the objects created for a specific Canvas can
+ only be drawn on exactly that canvas. You have to regenerate
+ them for different canvases.
+ */
+ class CPPCANVAS_DLLPUBLIC BaseGfxFactory
+ {
+ public:
+ /** Create a polygon from a ::basegfx::B2DPolygon
+
+ The created polygon initially has the same size in user
+ coordinate space as the source polygon
+ */
+ static PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::basegfx::B2DPolygon& rPoly );
+
+ /** Create an uninitialized bitmap with the given size
+ */
+ static BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::basegfx::B2ISize& rSize );
+
+ /** Create an uninitialized alpha bitmap with the given size
+ */
+ static BitmapSharedPtr createAlphaBitmap( const CanvasSharedPtr&, const ::basegfx::B2ISize& rSize );
+
+ private:
+ BaseGfxFactory() = delete;
+ BaseGfxFactory(const BaseGfxFactory&) = delete;
+ BaseGfxFactory& operator=( const BaseGfxFactory& ) = delete;
+ };
+
+}
+
+#endif // INCLUDED_CPPCANVAS_BASEGFXFACTORY_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/bitmap.hxx b/include/cppcanvas/bitmap.hxx
new file mode 100644
index 000000000..1b163b82d
--- /dev/null
+++ b/include/cppcanvas/bitmap.hxx
@@ -0,0 +1,70 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_BITMAP_HXX
+#define INCLUDED_CPPCANVAS_BITMAP_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppcanvas/canvasgraphic.hxx>
+#include <cppcanvas/bitmapcanvas.hxx>
+#include <memory>
+
+namespace com::sun::star::rendering
+{
+ class XBitmap;
+}
+
+
+/* Definition of Bitmap interface */
+
+namespace cppcanvas
+{
+
+ /** This interface defines a Bitmap canvas object
+
+ Consider this object part of the view, and not of the model
+ data, as this bitmap can only be painted on its parent canvas
+ */
+ class Bitmap : public virtual CanvasGraphic
+ {
+ public:
+ /** Render to parent canvas, with global alpha.
+
+ This method renders the content to the parent canvas,
+ i.e. the canvas this object was constructed for.
+
+ @param nAlphaModulation
+ Global alpha value, with which each pixel alpha value gets
+ multiplied. For a normal, opaque bitmap, this will make
+ the bitmap appear transparent with the given alpha value
+ (value must be in the range [0,1]).
+ */
+ virtual void drawAlphaModulated( double nAlphaModulation ) const = 0;
+
+ virtual BitmapCanvasSharedPtr getBitmapCanvas() const = 0;
+
+ virtual css::uno::Reference< css::rendering::XBitmap > getUNOBitmap() const = 0;
+ };
+
+ typedef std::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr;
+}
+
+#endif // INCLUDED_CPPCANVAS_BITMAP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/bitmapcanvas.hxx b/include/cppcanvas/bitmapcanvas.hxx
new file mode 100644
index 000000000..9c3e7f843
--- /dev/null
+++ b/include/cppcanvas/bitmapcanvas.hxx
@@ -0,0 +1,49 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_BITMAPCANVAS_HXX
+#define INCLUDED_CPPCANVAS_BITMAPCANVAS_HXX
+
+#include <basegfx/vector/b2isize.hxx>
+#include <cppcanvas/canvas.hxx>
+#include <memory>
+
+
+/* Definition of BitmapCanvas */
+
+namespace cppcanvas
+{
+ class BitmapCanvas;
+
+ // forward declaration, since cloneBitmapCanvas() also references BitmapCanvas
+ typedef std::shared_ptr< BitmapCanvas > BitmapCanvasSharedPtr;
+
+ /** BitmapCanvas interface
+ */
+ class BitmapCanvas : public virtual Canvas
+ {
+ public:
+ virtual ::basegfx::B2ISize getSize() const = 0;
+ };
+
+}
+
+#endif // INCLUDED_CPPCANVAS_BITMAPCANVAS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/canvas.hxx b/include/cppcanvas/canvas.hxx
new file mode 100644
index 000000000..97562ede2
--- /dev/null
+++ b/include/cppcanvas/canvas.hxx
@@ -0,0 +1,103 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_CANVAS_HXX
+#define INCLUDED_CPPCANVAS_CANVAS_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <memory>
+
+namespace basegfx
+{
+ class B2DHomMatrix;
+ class B2DPolyPolygon;
+}
+
+namespace com::sun::star::rendering
+{
+ class XCanvas;
+ struct ViewState;
+}
+
+
+/* Definition of BitmapCanvas */
+
+namespace cppcanvas
+{
+ class PolyPolygon;
+ class Canvas;
+
+ // forward declaration, since tools::PolyPolygon also references Canvas
+ typedef std::shared_ptr< PolyPolygon > PolyPolygonSharedPtr;
+
+ // forward declaration, since cloneCanvas() also references Canvas
+ typedef std::shared_ptr< Canvas > CanvasSharedPtr;
+
+ /** Canvas interface
+ */
+ class Canvas
+ {
+ public:
+ /** Extra pixel used when canvas anti-aliases.
+
+ Enlarge the bounding box of drawing primitives by this
+ amount in both dimensions, and on both sides of the
+ bounds, to account for extra pixel touched outside the
+ actual primitive bounding box, when the canvas
+ performs anti-aliasing.
+ */
+ static constexpr auto ANTIALIASING_EXTRA_SIZE=2;
+
+ Canvas() = default;
+ Canvas(Canvas const &) = default;
+ Canvas(Canvas &&) = default;
+ Canvas & operator =(Canvas const &) = default;
+#if !(defined __GNUC__ && !defined __clang__ && __GNUC__ == 8) // bogus -Werror=virtual-move-assign
+ Canvas & operator =(Canvas &&) = default;
+#endif
+
+ virtual ~Canvas() {}
+
+ virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix ) = 0;
+ virtual ::basegfx::B2DHomMatrix getTransformation() const = 0;
+
+ virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly ) = 0;
+ virtual void setClip() = 0;
+
+ /** Get current clip
+
+ @return NULL, if no clip is set, otherwise the current clip poly-polygon
+ */
+ virtual ::basegfx::B2DPolyPolygon const* getClip() const = 0;
+
+ virtual CanvasSharedPtr clone() const = 0;
+ virtual void clear() const = 0;
+
+ // this should be considered private. if RTTI gets enabled
+ // someday, remove that to a separate interface
+ virtual css::uno::Reference<
+ css::rendering::XCanvas > getUNOCanvas() const = 0;
+ virtual css::rendering::ViewState getViewState() const = 0;
+ };
+
+}
+
+#endif // INCLUDED_CPPCANVAS_CANVAS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/canvasgraphic.hxx b/include/cppcanvas/canvasgraphic.hxx
new file mode 100644
index 000000000..ebee831f0
--- /dev/null
+++ b/include/cppcanvas/canvasgraphic.hxx
@@ -0,0 +1,80 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
+#define INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
+
+#include <sal/types.h>
+#include <memory>
+
+namespace basegfx
+{
+ class B2DHomMatrix;
+ class B2DPolyPolygon;
+}
+
+
+/* Definition of CanvasGraphic interface */
+
+namespace cppcanvas
+{
+ // forward declaration, since tools::PolyPolygon also derives from CanvasGraphic
+ typedef std::shared_ptr< class PolyPolygon > PolyPolygonSharedPtr;
+
+
+ /** This interface defines basic properties of
+ objects that can be painted on a Canvas
+ */
+ class CanvasGraphic
+ {
+ public:
+
+ virtual ~CanvasGraphic() {}
+
+ /** Set object transformation matrix
+ */
+ virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix ) = 0;
+
+ /** Set object clipping polygon
+ */
+ virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly ) = 0;
+ /** Clear object clipping polygon
+ */
+ virtual void setClip() = 0;
+
+ /** Set object composite mode
+ * @see css::rendering::CompositeOperation
+ */
+ virtual void setCompositeOp( sal_Int8 aOp ) = 0;
+
+ /** Render to parent canvas
+
+ This method renders the content to the parent canvas,
+ i.e. the canvas this object was constructed for.
+
+ @return whether the rendering finished successfully.
+ */
+ virtual bool draw() const = 0;
+
+ };
+}
+
+#endif // INCLUDED_CPPCANVAS_CANVASGRAPHIC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/color.hxx b/include/cppcanvas/color.hxx
new file mode 100644
index 000000000..500e5953e
--- /dev/null
+++ b/include/cppcanvas/color.hxx
@@ -0,0 +1,70 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_COLOR_HXX
+#define INCLUDED_CPPCANVAS_COLOR_HXX
+
+#include <sal/types.h>
+
+/* Definition of Color class */
+
+namespace cppcanvas
+{
+ /** Color in the sRGB color space, plus alpha channel
+
+ The four bytes of the sal_uInt32 are allocated as follows
+ to the color channels and alpha: 0xRRGGBBAA.
+ */
+ typedef sal_uInt32 IntSRGBA;
+
+ inline sal_uInt8 getRed( IntSRGBA nCol )
+ {
+ return static_cast<sal_uInt8>( (nCol&0xFF000000U) >> 24U );
+ }
+
+ inline sal_uInt8 getGreen( IntSRGBA nCol )
+ {
+ return static_cast<sal_uInt8>( (nCol&0x00FF0000U) >> 16U );
+ }
+
+ inline sal_uInt8 getBlue( IntSRGBA nCol )
+ {
+ return static_cast<sal_uInt8>( (nCol&0x0000FF00U) >> 8U );
+ }
+
+ inline sal_uInt8 getAlpha( IntSRGBA nCol )
+ {
+ return static_cast<sal_uInt8>( nCol&0x000000FFU );
+ }
+
+ inline IntSRGBA makeColor( sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue, sal_uInt8 nAlpha )
+ {
+ return (nRed << 24U)|(nGreen << 16U)|(nBlue << 8U)|nAlpha;
+ }
+
+ inline sal_Int32 makeColorARGB( sal_uInt8 nAlpha, sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue)
+ {
+ return (nAlpha << 24U)|(nRed << 16U)|(nGreen << 8U)|nBlue;
+ }
+
+}
+
+#endif // INCLUDED_CPPCANVAS_COLOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/cppcanvasdllapi.h b/include/cppcanvas/cppcanvasdllapi.h
new file mode 100644
index 000000000..90b0ba893
--- /dev/null
+++ b/include/cppcanvas/cppcanvasdllapi.h
@@ -0,0 +1,31 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_CPPCANVASDLLAPI_H
+#define INCLUDED_CPPCANVAS_CPPCANVASDLLAPI_H
+
+#if defined CPPCANVAS_DLLIMPLEMENTATION
+
+#define CPPCANVAS_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define CPPCANVAS_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define CPPCANVAS_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif
diff --git a/include/cppcanvas/customsprite.hxx b/include/cppcanvas/customsprite.hxx
new file mode 100644
index 000000000..abbd0c00b
--- /dev/null
+++ b/include/cppcanvas/customsprite.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_CUSTOMSPRITE_HXX
+#define INCLUDED_CPPCANVAS_CUSTOMSPRITE_HXX
+
+#include <cppcanvas/sprite.hxx>
+#include <cppcanvas/canvas.hxx>
+#include <memory>
+
+/* Definition of CustomSprite class */
+
+namespace cppcanvas
+{
+
+ class CustomSprite : public virtual Sprite
+ {
+ public:
+
+ virtual CanvasSharedPtr getContentCanvas() const = 0;
+ };
+
+ typedef std::shared_ptr< ::cppcanvas::CustomSprite > CustomSpriteSharedPtr;
+}
+
+#endif // INCLUDED_CPPCANVAS_CUSTOMSPRITE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/polypolygon.hxx b/include/cppcanvas/polypolygon.hxx
new file mode 100644
index 000000000..917ef4daf
--- /dev/null
+++ b/include/cppcanvas/polypolygon.hxx
@@ -0,0 +1,76 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_POLYPOLYGON_HXX
+#define INCLUDED_CPPCANVAS_POLYPOLYGON_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppcanvas/canvasgraphic.hxx>
+#include <cppcanvas/color.hxx>
+#include <memory>
+
+namespace com::sun::star::rendering
+{
+ class XPolyPolygon2D;
+}
+
+
+/* Definition of tools::PolyPolygon interface */
+
+namespace cppcanvas
+{
+
+ /** This interface defines a tools::PolyPolygon canvas object
+
+ Consider this object part of the view, and not of the model
+ data. Although the given polygon is typically copied and held
+ internally (to facilitate migration to incompatible canvases),
+ ::basegfx::B2DPolygon et al. are ref-counted copy-on-write
+ classes, i.e. memory shouldn't be wasted. On the other hand,
+ the API polygon created internally _does_ necessarily
+ duplicate the data held, but can be easily flushed away via
+ flush().
+ */
+ class PolyPolygon : public virtual CanvasGraphic
+ {
+ public:
+
+ /** Set polygon fill color
+ */
+ virtual void setRGBAFillColor( IntSRGBA ) = 0;
+ /** Set polygon line color
+ */
+ virtual void setRGBALineColor( IntSRGBA ) = 0;
+ /** Get polygon line color
+ */
+ virtual IntSRGBA getRGBALineColor() const = 0;
+
+ virtual void setStrokeWidth( const double& rStrokeWidth ) = 0;
+ virtual double getStrokeWidth() const = 0;
+
+ virtual css::uno::Reference<
+ css::rendering::XPolyPolygon2D > getUNOPolyPolygon() const = 0;
+ };
+
+ typedef std::shared_ptr< ::cppcanvas::PolyPolygon > PolyPolygonSharedPtr;
+}
+
+#endif // INCLUDED_CPPCANVAS_POLYPOLYGON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/renderer.hxx b/include/cppcanvas/renderer.hxx
new file mode 100644
index 000000000..d71be2f09
--- /dev/null
+++ b/include/cppcanvas/renderer.hxx
@@ -0,0 +1,140 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_RENDERER_HXX
+#define INCLUDED_CPPCANVAS_RENDERER_HXX
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <optional>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <cppcanvas/canvasgraphic.hxx>
+#include <cppcanvas/color.hxx>
+#include <memory>
+
+namespace basegfx
+{
+ class B2DRange;
+}
+
+/* Definition of Renderer interface */
+
+namespace cppcanvas
+{
+
+ class Renderer : public virtual CanvasGraphic
+ {
+ public:
+ /** Render subset of metafile to given canvas
+
+ This method renders the given subset of the content to the
+ associated canvas.
+
+ @param nStartIndex
+ The index of the first action to be rendered (the indices
+ correspond roughly to the action indices of the
+ originating GDIMetaFile. Note, although, that certain
+ actions, e.g. text, accounts for more than one index: a
+ text produces as many addressable indices as it has
+ characters).
+
+ @param nEndIndex
+ The index of the first action _not_ painted anymore,
+ i.e. the action after the last action rendered (the
+ indices correspond roughly to the action indices of the
+ originating GDIMetaFile. Note, although, that certain
+ actions, e.g. text, accounts for more than one index: a
+ text produces as many addressable indices as it has
+ characters).
+
+ @return whether the rendering finished successfully.
+ */
+ virtual bool drawSubset( sal_Int32 nStartIndex,
+ sal_Int32 nEndIndex ) const = 0;
+
+ /** Query bounding box of metafile subset
+
+ This method queries the actual bounding box of the given
+ subset, when rendered on the associated canvas.
+
+ @param nStartIndex
+ The index of the first action to be rendered (the indices
+ correspond roughly to the action indices of the
+ originating GDIMetaFile. Note, although, that certain
+ actions, e.g. text, accounts for more than one index: a
+ text produces as many addressable indices as it has
+ characters).
+
+ @param nEndIndex
+ The index of the first action _not_ painted anymore,
+ i.e. the action after the last action rendered (the
+ indices correspond roughly to the action indices of the
+ originating GDIMetaFile. Note, although, that certain
+ actions, e.g. text, accounts for more than one index: a
+ text produces as many addressable indices as it has
+ characters).
+
+ @return the bounding box of the specified subset
+ */
+ virtual ::basegfx::B2DRange getSubsetArea( sal_Int32 nStartIndex,
+ sal_Int32 nEndIndex ) const = 0;
+
+ /** Parameters for the Renderer
+ */
+ struct Parameters
+ {
+ /// Optionally forces the fill color attribute for all actions
+ ::std::optional< IntSRGBA > maFillColor;
+
+ /// Optionally forces the line color attribute for all actions
+ ::std::optional< IntSRGBA > maLineColor;
+
+ /// Optionally forces the text color attribute for all actions
+ ::std::optional< IntSRGBA > maTextColor;
+
+ /// Optionally forces the given fontname for all text actions
+ ::std::optional< OUString > maFontName;
+
+ /** Optionally transforms all text output actions with the
+ given matrix (in addition to the overall canvas
+ transformation).
+
+ Note that the matrix given here is applied to the unit
+ rect coordinate system, i.e. the metafile is assumed
+ to be contained in the unit rect.
+ */
+ ::std::optional< ::basegfx::B2DHomMatrix > maTextTransformation;
+
+ /// Optionally forces the given font weight for all text actions
+ ::std::optional< sal_Int8 > maFontWeight;
+
+ /// Optionally forces the given font letter form (italics etc.) for all text actions
+ ::std::optional< sal_Int8 > maFontLetterForm;
+
+ /// Optionally forces underlining for all text actions
+ ::std::optional< bool > maFontUnderline;
+ };
+ };
+
+ typedef std::shared_ptr< ::cppcanvas::Renderer > RendererSharedPtr;
+}
+
+#endif // INCLUDED_CPPCANVAS_RENDERER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/sprite.hxx b/include/cppcanvas/sprite.hxx
new file mode 100644
index 000000000..3321eb6a0
--- /dev/null
+++ b/include/cppcanvas/sprite.hxx
@@ -0,0 +1,96 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_SPRITE_HXX
+#define INCLUDED_CPPCANVAS_SPRITE_HXX
+
+namespace basegfx
+{
+ class B2DHomMatrix;
+ class B2DPolyPolygon;
+ class B2DPoint;
+}
+
+
+/* Definition of Sprite class */
+
+namespace cppcanvas
+{
+
+ class Sprite
+ {
+ public:
+ virtual ~Sprite() {}
+
+ virtual void setAlpha( const double& rAlpha ) = 0;
+
+ /** Set the sprite position on screen
+
+ This method differs from the XSprite::move() insofar, as
+ no viewstate/renderstate transformations are applied to
+ the specified position. The given position is interpreted
+ in device coordinates (i.e. screen pixel)
+ */
+ virtual void movePixel( const ::basegfx::B2DPoint& rNewPos ) = 0;
+
+ /** Set the sprite position on screen
+
+ This method sets the sprite position in the view
+ coordinate system of the parent canvas
+ */
+ virtual void move( const ::basegfx::B2DPoint& rNewPos ) = 0;
+
+ virtual void transform( const ::basegfx::B2DHomMatrix& rMatrix ) = 0;
+
+ /** Set output clipping
+
+ This method differs from the XSprite::clip() insofar, as
+ no viewstate/renderstate transformations are applied to
+ the specified clip polygon. The given polygon is
+ interpreted in device coordinates (i.e. screen pixel)
+ */
+ virtual void setClipPixel( const ::basegfx::B2DPolyPolygon& rClipPoly ) = 0;
+
+ /** Set output clipping
+
+ This method applies the clip poly-polygon interpreted in
+ the view coordinate system of the parent canvas.
+ */
+ virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly ) = 0;
+
+ virtual void setClip() = 0;
+
+ virtual void show() = 0;
+ virtual void hide() = 0;
+
+ /** Change the sprite priority
+
+ @param fPriority
+ New sprite priority. The higher the priority, the further
+ towards the viewer the sprite appears. That is, sprites
+ with higher priority appear before ones with lower
+ priority.
+ */
+ virtual void setPriority( double fPriority ) = 0;
+ };
+}
+
+#endif // INCLUDED_CPPCANVAS_SPRITE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/spritecanvas.hxx b/include/cppcanvas/spritecanvas.hxx
new file mode 100644
index 000000000..c4d100dbe
--- /dev/null
+++ b/include/cppcanvas/spritecanvas.hxx
@@ -0,0 +1,63 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_SPRITECANVAS_HXX
+#define INCLUDED_CPPCANVAS_SPRITECANVAS_HXX
+
+#include <basegfx/vector/b2dsize.hxx>
+#include <cppcanvas/canvas.hxx>
+#include <cppcanvas/customsprite.hxx>
+#include <memory>
+
+namespace com::sun::star::rendering
+{
+ class XSpriteCanvas;
+}
+
+
+/* Definition of SpriteCanvas */
+
+namespace cppcanvas
+{
+ class SpriteCanvas;
+
+ // forward declaration, since cloneSpriteCanvas() also references SpriteCanvas
+ typedef std::shared_ptr< ::cppcanvas::SpriteCanvas > SpriteCanvasSharedPtr;
+
+ /** SpriteCanvas interface
+ */
+ class SpriteCanvas : public virtual Canvas
+ {
+ SpriteCanvas(const SpriteCanvas&) = delete;
+ SpriteCanvas& operator=( const SpriteCanvas& ) = delete;
+ public:
+ SpriteCanvas() {}
+ virtual bool updateScreen( bool bUpdateAll ) const = 0;
+
+ virtual CustomSpriteSharedPtr createCustomSprite( const ::basegfx::B2DSize& ) const = 0;
+
+ virtual css::uno::Reference<
+ css::rendering::XSpriteCanvas > getUNOSpriteCanvas() const = 0;
+ };
+
+}
+
+#endif // INCLUDED_CPPCANVAS_SPRITECANVAS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppcanvas/vclfactory.hxx b/include/cppcanvas/vclfactory.hxx
new file mode 100644
index 000000000..73867626d
--- /dev/null
+++ b/include/cppcanvas/vclfactory.hxx
@@ -0,0 +1,87 @@
+/* -*- 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 .
+ */
+
+#ifndef INCLUDED_CPPCANVAS_VCLFACTORY_HXX
+#define INCLUDED_CPPCANVAS_VCLFACTORY_HXX
+
+#include <cppcanvas/canvas.hxx>
+#include <cppcanvas/bitmapcanvas.hxx>
+#include <cppcanvas/spritecanvas.hxx>
+#include <cppcanvas/bitmap.hxx>
+#include <cppcanvas/renderer.hxx>
+
+#include <cppcanvas/cppcanvasdllapi.h>
+
+namespace vcl { class Window; }
+class BitmapEx;
+
+class GDIMetaFile;
+
+namespace com::sun::star::rendering
+{
+ class XCanvas;
+ class XBitmapCanvas;
+ class XSpriteCanvas;
+}
+
+/* Definition of VCLFactory class */
+
+namespace cppcanvas
+{
+ /** The VCLFactory creates Canvas objects for various VCL
+ OutputDevice primitives, such as windows, polygons, bitmaps
+ and metafiles.
+
+ Please note that the objects created for a specific Canvas can
+ only be drawn on exactly that canvas. You have to regenerate
+ them for different canvases.
+ */
+ class CPPCANVAS_DLLPUBLIC VCLFactory
+ {
+ public:
+ static CanvasSharedPtr createCanvas( const css::uno::Reference< css::rendering::XCanvas >& xCanvas );
+ static BitmapCanvasSharedPtr createBitmapCanvas( const css::uno::Reference< css::rendering::XBitmapCanvas >& xCanvas );
+
+ static SpriteCanvasSharedPtr createSpriteCanvas( const vcl::Window& rVCLWindow );
+ static SpriteCanvasSharedPtr createSpriteCanvas( const css::uno::Reference< css::rendering::XSpriteCanvas >& xCanvas );
+
+ /** Create a bitmap from a VCL Bitmap
+ */
+ static BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::BitmapEx& rBmpEx );
+
+ /** Create a renderer object from a Metafile
+
+ The created renderer initially draws the metafile
+ one-by-one units large, in user coordinate space
+ */
+ static RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas,
+ const ::GDIMetaFile& rMtf,
+ const Renderer::Parameters& rParms );
+
+ private:
+ VCLFactory() = delete;
+ VCLFactory(const VCLFactory&) = delete;
+ VCLFactory& operator=( const VCLFactory& ) = delete;
+ };
+
+}
+
+#endif // INCLUDED_CPPCANVAS_VCLFACTORY_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */