diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/cppcanvas | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/cppcanvas')
-rw-r--r-- | include/cppcanvas/basegfxfactory.hxx | 89 | ||||
-rw-r--r-- | include/cppcanvas/bitmap.hxx | 74 | ||||
-rw-r--r-- | include/cppcanvas/bitmapcanvas.hxx | 60 | ||||
-rw-r--r-- | include/cppcanvas/canvas.hxx | 106 | ||||
-rw-r--r-- | include/cppcanvas/canvasgraphic.hxx | 157 | ||||
-rw-r--r-- | include/cppcanvas/color.hxx | 89 | ||||
-rw-r--r-- | include/cppcanvas/cppcanvasdllapi.h | 30 | ||||
-rw-r--r-- | include/cppcanvas/customsprite.hxx | 47 | ||||
-rw-r--r-- | include/cppcanvas/font.hxx | 55 | ||||
-rw-r--r-- | include/cppcanvas/polypolygon.hxx | 87 | ||||
-rw-r--r-- | include/cppcanvas/renderer.hxx | 144 | ||||
-rw-r--r-- | include/cppcanvas/sprite.hxx | 110 | ||||
-rw-r--r-- | include/cppcanvas/spritecanvas.hxx | 76 | ||||
-rw-r--r-- | include/cppcanvas/text.hxx | 45 | ||||
-rw-r--r-- | include/cppcanvas/vclfactory.hxx | 102 |
15 files changed, 1271 insertions, 0 deletions
diff --git a/include/cppcanvas/basegfxfactory.hxx b/include/cppcanvas/basegfxfactory.hxx new file mode 100644 index 000000000000..83acb38c448f --- /dev/null +++ b/include/cppcanvas/basegfxfactory.hxx @@ -0,0 +1,89 @@ +/* -*- 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 _CPPCANVAS_BASEGFXFACTORY_HXX +#define _CPPCANVAS_BASEGFXFACTORY_HXX + +#include <cppcanvas/canvas.hxx> +#include <cppcanvas/bitmapcanvas.hxx> +#include <cppcanvas/spritecanvas.hxx> +#include <cppcanvas/polypolygon.hxx> +#include <cppcanvas/bitmap.hxx> +#include <cppcanvas/renderer.hxx> +#include <cppcanvas/text.hxx> +#include <cppcanvas/sprite.hxx> +#include <basegfx/vector/b2isize.hxx> + +#include <cppcanvas/cppcanvasdllapi.h> + +namespace basegfx +{ + class B2DPolygon; + class B2DPolyPolygon; +} + + +/* 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: + static BaseGfxFactory& getInstance(); + + /** Create a polygon from a ::basegfx::B2DPolygon + + The created polygon initially has the same size in user + coordinate space as the source polygon + */ + PolyPolygonSharedPtr createPolyPolygon( const CanvasSharedPtr&, const ::basegfx::B2DPolygon& rPoly ) const; + + /** Create an uninitialized bitmap with the given size + */ + BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::basegfx::B2ISize& rSize ) const; + + /** Create an uninitialized alpha bitmap with the given size + */ + BitmapSharedPtr createAlphaBitmap( const CanvasSharedPtr&, const ::basegfx::B2ISize& rSize ) const; + + private: + friend struct InitInstance2; + + // singleton + BaseGfxFactory(); + + // default: disabled copy/assignment + BaseGfxFactory(const BaseGfxFactory&); + BaseGfxFactory& operator=( const BaseGfxFactory& ); + }; + +} + +#endif /* _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 000000000000..5e542e7220aa --- /dev/null +++ b/include/cppcanvas/bitmap.hxx @@ -0,0 +1,74 @@ +/* -*- 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 _CPPCANVAS_BITMAP_HXX +#define _CPPCANVAS_BITMAP_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/canvasgraphic.hxx> +#include <cppcanvas/bitmapcanvas.hxx> + +namespace com { namespace sun { namespace star { namespace 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]). + + @return whether the rendering finished successfully. + */ + virtual bool drawAlphaModulated( double nAlphaModulation ) const = 0; + + virtual BitmapCanvasSharedPtr getBitmapCanvas() const = 0; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XBitmap > getUNOBitmap() const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Bitmap > BitmapSharedPtr; +} + +#endif /* _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 000000000000..620182a14e45 --- /dev/null +++ b/include/cppcanvas/bitmapcanvas.hxx @@ -0,0 +1,60 @@ +/* -*- 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 _CPPCANVAS_BITMAPCANVAS_HXX +#define _CPPCANVAS_BITMAPCANVAS_HXX + +#include <sal/types.h> +#include <osl/diagnose.h> + +#include <boost/shared_ptr.hpp> +#include <basegfx/vector/b2isize.hxx> +#include <cppcanvas/canvas.hxx> + + +/* Definition of BitmapCanvas */ + +namespace cppcanvas +{ + class BitmapCanvas; + + // forward declaration, since cloneBitmapCanvas() also references BitmapCanvas + typedef ::boost::shared_ptr< BitmapCanvas > BitmapCanvasSharedPtr; + + /** BitmapCanvas interface + */ + class BitmapCanvas : public virtual Canvas + { + public: + virtual ::basegfx::B2ISize getSize() const = 0; + + // shared_ptr does not allow for covariant return types + BitmapCanvasSharedPtr cloneBitmapCanvas() const + { + BitmapCanvasSharedPtr p( ::boost::dynamic_pointer_cast< BitmapCanvas >(this->clone()) ); + OSL_ENSURE(p.get(), "BitmapCanvas::cloneBitmapCanvas(): dynamic cast failed"); + return p; + } + }; + +} + +#endif /* _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 000000000000..0a77e7129a43 --- /dev/null +++ b/include/cppcanvas/canvas.hxx @@ -0,0 +1,106 @@ +/* -*- 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 _CPPCANVAS_CANVAS_HXX +#define _CPPCANVAS_CANVAS_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/font.hxx> +#include <cppcanvas/color.hxx> + + +namespace basegfx +{ + class B2DHomMatrix; + class B2DPolyPolygon; +} + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XCanvas; + struct ViewState; +} } } } + + +/* Definition of BitmapCanvas */ + +namespace cppcanvas +{ + class PolyPolygon; + class Canvas; + + // forward declaration, since PolyPolygon also references Canvas + typedef ::boost::shared_ptr< PolyPolygon > PolyPolygonSharedPtr; + + // forward declaration, since cloneCanvas() also references Canvas + typedef ::boost::shared_ptr< Canvas > CanvasSharedPtr; + + /** Canvas interface + */ + class Canvas + { + public: + enum + { + /** 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. + */ + ANTIALIASING_EXTRA_SIZE=2 + }; + + 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 FontSharedPtr createFont( const OUString& rFontName, const double& rCellSize ) const = 0; + + virtual ColorSharedPtr createColor() 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 ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvas > getUNOCanvas() const = 0; + virtual ::com::sun::star::rendering::ViewState getViewState() const = 0; + }; + +} + +#endif /* _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 000000000000..e496df6aeb33 --- /dev/null +++ b/include/cppcanvas/canvasgraphic.hxx @@ -0,0 +1,157 @@ +/* -*- 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 _CPPCANVAS_CANVASGRAPHIC_HXX +#define _CPPCANVAS_CANVASGRAPHIC_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/color.hxx> +#include <cppcanvas/canvas.hxx> + +namespace basegfx +{ + class B2DHomMatrix; + class B2DPolyPolygon; +} + + +/* Definition of CanvasGraphic interface */ + +namespace cppcanvas +{ + // forward declaration, since PolyPolygon also derives from CanvasGraphic + typedef ::boost::shared_ptr< class PolyPolygon > PolyPolygonSharedPtr; + + + /** This interface defines basic properties of + objects that can be painted on a Canvas + */ + class CanvasGraphic + { + public: + + /** These enums determine how the primitive color is combined + with the background. When performing this calculations, it + is assumed that all color values are premultiplied with + the corresponding alpha values (if no alpha is specified, + 1.0 is assumed). Then, the following general compositing + operation is performed: + + C = Ca * Fa + Cb * Fb + + where C is the result color, Ca and Cb are the input + colors, premultiplied with alpha, and Fa and Fb are + described for the different composite modes (wherein Aa + and Ab denote source and destination alpha, respectively). + */ + enum CompositeOp + { + /// Clear destination. Fa = Fb = 0. + CLEAR, + + /// Copy source as-is to destination. Fa = 1, Fb = 0. + SOURCE, + + /// Leave destination as-is. Fa = 0, Fb = 1. + DESTINATION, + + /// Copy source over destination. Fa = 1, Fb = 1-Aa. + OVER, + + /// Copy source under destination. Fa = 1-Ab, Fb = 1. + UNDER, + + /// Copy source to destination, but limited to where the destination is. Fa = Ab, Fb = 0. + INSIDE, + + /// Leave destination as is, but only where source was. Fa = 0, Fb = Aa. + INSIDE_REVERSE, + + /// Copy source to destination, but limited to where destination is not. Fa = 1-Ab, Fb = 0. + OUTSIDE, + + /// Leave destination as is, but only where source has not been. Fa = 0, Fb = 1-Aa. + OUTSIDE_REVERSE, + + /// Copy source over destination, but only where destination is. Keep destination. Fa = Ab, Fb = 1-Aa. + ATOP, + + /// Copy destination over source, but only where source is. Keep source. Fa = 1-Ab, Fb = Aa. + ATOP_REVERSE, + + /// Take only parts where either source or destination, but not both are. Fa = 1-Ab, Fb = 1-Aa. + XOR, + + /** simply add contributions of both source and destination. The + resulting color values are limited to the permissible color + range, and clipped to the maximal value, if exceeded. Fa = 1, Fb = 1. + */ + ADD, + + /// Fa = min(1,(1-Ab)/Aa), Fb = 1 + SATURATE + }; + + virtual ~CanvasGraphic() {} + + /** Set object transformation matrix + */ + virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix ) = 0; + /** Get object transformation matrix + */ + virtual ::basegfx::B2DHomMatrix getTransformation() const = 0; + + /** Set object clipping polygon + */ + virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly ) = 0; + /** Clear object clipping polygon + */ + virtual void setClip() = 0; + /** Get object clipping polygon + + @return NULL, if no clip is set; otherwise, the current clip poly-polygon is returned + */ + virtual ::basegfx::B2DPolyPolygon const* getClip() const = 0; + + /** Set object composite mode + */ + virtual void setCompositeOp( CompositeOp aOp ) = 0; + /** Get object composite mode + */ + virtual CompositeOp getCompositeOp() const = 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; + + }; + + typedef ::boost::shared_ptr< ::cppcanvas::CanvasGraphic > CanvasGraphicSharedPtr; +} + +#endif /* _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 000000000000..6d7dc957286a --- /dev/null +++ b/include/cppcanvas/color.hxx @@ -0,0 +1,89 @@ +/* -*- 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 _CPPCANVAS_COLOR_HXX +#define _CPPCANVAS_COLOR_HXX + +#include <com/sun/star/uno/Sequence.hxx> + +#include <boost/shared_ptr.hpp> + + +/* Definition of Color class */ + +namespace cppcanvas +{ + class Color + { + public: + /** 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; + + virtual ~Color() {} + + virtual IntSRGBA getIntSRGBA( ::com::sun::star::uno::Sequence< double >& rDeviceColor ) const = 0; + virtual ::com::sun::star::uno::Sequence< double > getDeviceColor( IntSRGBA aSRGBA ) const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Color > ColorSharedPtr; + + inline sal_uInt8 getRed( Color::IntSRGBA nCol ) + { + return static_cast<sal_uInt8>( (nCol&0xFF000000U) >> 24U ); + } + + inline sal_uInt8 getGreen( Color::IntSRGBA nCol ) + { + return static_cast<sal_uInt8>( (nCol&0x00FF0000U) >> 16U ); + } + + inline sal_uInt8 getBlue( Color::IntSRGBA nCol ) + { + return static_cast<sal_uInt8>( (nCol&0x0000FF00U) >> 8U ); + } + + inline sal_uInt8 getAlpha( Color::IntSRGBA nCol ) + { + return static_cast<sal_uInt8>( nCol&0x000000FFU ); + } + + inline Color::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 unMakeColor( sal_uInt8 nAlpha, sal_uInt8 nRed, sal_uInt8 nGreen, sal_uInt8 nBlue) + { + return (nAlpha << 24U)|(nRed << 16U)|(nGreen << 8U)|(nBlue); + } + + 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 /* _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 000000000000..be641aad8b2b --- /dev/null +++ b/include/cppcanvas/cppcanvasdllapi.h @@ -0,0 +1,30 @@ +/* -*- 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_CPPCANVASDLLAPI_H +#define INCLUDED_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 000000000000..70004e7e5900 --- /dev/null +++ b/include/cppcanvas/customsprite.hxx @@ -0,0 +1,47 @@ +/* -*- 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 _CPPCANVAS_CUSTOMSPRITE_HXX +#define _CPPCANVAS_CUSTOMSPRITE_HXX + +#include <sal/types.h> + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/sprite.hxx> +#include <cppcanvas/canvas.hxx> + + +/* Definition of CustomSprite class */ + +namespace cppcanvas +{ + + class CustomSprite : public virtual Sprite + { + public: + + virtual CanvasSharedPtr getContentCanvas() const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::CustomSprite > CustomSpriteSharedPtr; +} + +#endif /* _CPPCANVAS_CUSTOMSPRITE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppcanvas/font.hxx b/include/cppcanvas/font.hxx new file mode 100644 index 000000000000..967903eaa8e7 --- /dev/null +++ b/include/cppcanvas/font.hxx @@ -0,0 +1,55 @@ +/* -*- 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 _CPPCANVAS_FONT_HXX +#define _CPPCANVAS_FONT_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <boost/shared_ptr.hpp> + + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XCanvasFont; +} } } } + +/* Definition of Font class */ + +namespace cppcanvas +{ + + class Font + { + public: + virtual ~Font() {} + + virtual OUString getName() const = 0; + virtual double getCellSize() const = 0; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvasFont > getUNOFont() const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Font > FontSharedPtr; +} + +#endif /* _CPPCANVAS_FONT_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 000000000000..ccfbb95d3def --- /dev/null +++ b/include/cppcanvas/polypolygon.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 _CPPCANVAS_POLYPOLYGON_HXX +#define _CPPCANVAS_POLYPOLYGON_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/canvasgraphic.hxx> + +namespace basegfx +{ + class B2DPolygon; + class B2DPolyPolygon; +} + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XPolyPolygon2D; +} } } } + + +/* Definition of PolyPolygon interface */ + +namespace cppcanvas +{ + + /** This interface defines a 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: + virtual void addPolygon( const ::basegfx::B2DPolygon& rPoly ) = 0; + virtual void addPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly ) = 0; + + /** Set polygon fill color + */ + virtual void setRGBAFillColor( Color::IntSRGBA ) = 0; + /** Set polygon line color + */ + virtual void setRGBALineColor( Color::IntSRGBA ) = 0; + /** Get polygon fill color + */ + virtual Color::IntSRGBA getRGBAFillColor() const = 0; + /** Get polygon line color + */ + virtual Color::IntSRGBA getRGBALineColor() const = 0; + + virtual void setStrokeWidth( const double& rStrokeWidth ) = 0; + virtual double getStrokeWidth() const = 0; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D > getUNOPolyPolygon() const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::PolyPolygon > PolyPolygonSharedPtr; +} + +#endif /* _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 000000000000..e260e9400248 --- /dev/null +++ b/include/cppcanvas/renderer.hxx @@ -0,0 +1,144 @@ +/* -*- 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 _CPPCANVAS_RENDERER_HXX +#define _CPPCANVAS_RENDERER_HXX + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#include <boost/shared_ptr.hpp> +#include <boost/optional.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <cppcanvas/canvasgraphic.hxx> +#include <cppcanvas/color.hxx> + +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 + ::boost::optional< Color::IntSRGBA > maFillColor; + + /// Optionally forces the line color attribute for all actions + ::boost::optional< Color::IntSRGBA > maLineColor; + + /// Optionally forces the text color attribute for all actions + ::boost::optional< Color::IntSRGBA > maTextColor; + + /// Optionally forces the given fontname for all text actions + ::boost::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. + */ + ::boost::optional< ::basegfx::B2DHomMatrix > maTextTransformation; + + /// Optionally forces the given font weight for all text actions + ::boost::optional< sal_Int8 > maFontWeight; + + /// Optionally forces the given font letter form (italics etc.) for all text actions + ::boost::optional< sal_Int8 > maFontLetterForm; + + /// Optionally forces the given font proportion (condensed, monospaced etc.) for all text actions + ::boost::optional< sal_Int8 > maFontProportion; + + /// Optionally forces underlining for all text actions + ::boost::optional< bool > maFontUnderline; + }; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Renderer > RendererSharedPtr; +} + +#endif /* _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 000000000000..0e87ff9b9dd1 --- /dev/null +++ b/include/cppcanvas/sprite.hxx @@ -0,0 +1,110 @@ +/* -*- 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 _CPPCANVAS_SPRITE_HXX +#define _CPPCANVAS_SPRITE_HXX + +#include <com/sun/star/uno/Reference.hxx> + +#include <boost/shared_ptr.hpp> + +namespace basegfx +{ + class B2DHomMatrix; + class B2DPolyPolygon; + class B2DPoint; +} + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XSprite; +} } } } + + +/* 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; + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XSprite > getUNOSprite() const = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Sprite > SpriteSharedPtr; +} + +#endif /* _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 000000000000..6a606b331edf --- /dev/null +++ b/include/cppcanvas/spritecanvas.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 _CPPCANVAS_SPRITECANVAS_HXX +#define _CPPCANVAS_SPRITECANVAS_HXX + +#include <sal/types.h> +#include <osl/diagnose.h> +#include <basegfx/vector/b2dsize.hxx> + +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> + + +#include <cppcanvas/bitmapcanvas.hxx> +#include <cppcanvas/sprite.hxx> +#include <cppcanvas/customsprite.hxx> + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XSpriteCanvas; +} } } } + + +/* Definition of SpriteCanvas */ + +namespace cppcanvas +{ + class SpriteCanvas; + + // forward declaration, since cloneSpriteCanvas() also references SpriteCanvas + typedef ::boost::shared_ptr< ::cppcanvas::SpriteCanvas > SpriteCanvasSharedPtr; + + /** SpriteCanvas interface + */ + class SpriteCanvas : public virtual BitmapCanvas, private boost::noncopyable + { + public: + virtual bool updateScreen( bool bUpdateAll ) const = 0; + + virtual CustomSpriteSharedPtr createCustomSprite( const ::basegfx::B2DSize& ) const = 0; + virtual SpriteSharedPtr createClonedSprite( const SpriteSharedPtr& ) const = 0; + + // shared_ptr does not allow for covariant return types + SpriteCanvasSharedPtr cloneSpriteCanvas() const + { + SpriteCanvasSharedPtr p( ::boost::dynamic_pointer_cast< SpriteCanvas >(this->clone()) ); + OSL_ENSURE(p.get(), "SpriteCanvas::cloneSpriteCanvas(): dynamic cast failed"); + return p; + } + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XSpriteCanvas > getUNOSpriteCanvas() const = 0; + }; + +} + +#endif /* _CPPCANVAS_SPRITECANVAS_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppcanvas/text.hxx b/include/cppcanvas/text.hxx new file mode 100644 index 000000000000..4ca53532c282 --- /dev/null +++ b/include/cppcanvas/text.hxx @@ -0,0 +1,45 @@ +/* -*- 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 _CPPCANVAS_TEXT_HXX +#define _CPPCANVAS_TEXT_HXX + +#include <boost/shared_ptr.hpp> +#include <cppcanvas/canvasgraphic.hxx> + + + + +/* Definition of Text interface */ + +namespace cppcanvas +{ + class Text : public virtual CanvasGraphic + { + public: + virtual void setFont( const FontSharedPtr& ) = 0; + virtual FontSharedPtr getFont() = 0; + }; + + typedef ::boost::shared_ptr< ::cppcanvas::Text > TextSharedPtr; +} + +#endif /* _CPPCANVAS_TEXT_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 000000000000..b5d2f9612be9 --- /dev/null +++ b/include/cppcanvas/vclfactory.hxx @@ -0,0 +1,102 @@ +/* -*- 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 _CPPCANVAS_VCLFACTORY_HXX +#define _CPPCANVAS_VCLFACTORY_HXX + +#include <cppcanvas/canvas.hxx> +#include <cppcanvas/bitmapcanvas.hxx> +#include <cppcanvas/spritecanvas.hxx> +#include <cppcanvas/polypolygon.hxx> +#include <cppcanvas/bitmap.hxx> +#include <cppcanvas/renderer.hxx> +#include <cppcanvas/text.hxx> +#include <cppcanvas/sprite.hxx> + +#include <cppcanvas/cppcanvasdllapi.h> + +class Window; +class Bitmap; +class BitmapEx; +class Polygon; +class PolyPolygon; +class Size; +class Graphic; +class GDIMetaFile; +class Animation; + +namespace com { namespace sun { namespace star { namespace rendering +{ + 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 VCLFactory& getInstance(); + + BitmapCanvasSharedPtr createCanvas( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XBitmapCanvas >& xCanvas ); + + SpriteCanvasSharedPtr createSpriteCanvas( const ::Window& rVCLWindow ) const; + SpriteCanvasSharedPtr createSpriteCanvas( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XSpriteCanvas >& xCanvas ) const; + + /** Create a bitmap from a VCL Bitmap + */ + BitmapSharedPtr createBitmap( const CanvasSharedPtr&, const ::BitmapEx& rBmpEx ) const; + + /** Create a renderer object from a Metafile + + The created renderer initially draws the metafile + one-by-one units large, in user coordinate space + */ + RendererSharedPtr createRenderer( const CanvasSharedPtr& rCanvas, + const ::GDIMetaFile& rMtf, + const Renderer::Parameters& rParms ) const; + + private: + friend struct InitInstance; + + // singleton + VCLFactory(); + + // default: disabled copy/assignment + VCLFactory(const VCLFactory&); + VCLFactory& operator=( const VCLFactory& ); + }; + +} + +#endif /* _CPPCANVAS_VCLFACTORY_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |