1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cachedprimitivebase.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CPPCANVAS_CACHEDPRIMITIVEBASE_HXX
32 #define _CPPCANVAS_CACHEDPRIMITIVEBASE_HXX
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <com/sun/star/rendering/XCanvas.hpp>
37 #include <cppcanvas/canvas.hxx>
38 #include <boost/utility.hpp>
42 namespace basegfx
{ class B2DHomMatrix
; }
45 /* Definition of internal::CachedPrimitiveBase class */
51 /** Base class providing cached re-rendering, if XCanvas
52 returns XCachedPrimitive
54 Derive from this class and implement private render()
55 method to perform the actual primitive rendering. Return
56 cached primitive into given reference. Next time this
57 class' public render() method gets called, the cached
58 representation is taken.
60 class CachedPrimitiveBase
: public Action
,
61 private ::boost::noncopyable
67 Canvas on which this primitive is to appear
69 @param bOnlyRedrawWithSameTransform
70 When true, this class only reuses the cached
71 primitive, if the overall transformation stays the
72 same. Otherwise, repaints are always performed via the
75 CachedPrimitiveBase( const CanvasSharedPtr
& rCanvas
,
76 bool bOnlyRedrawWithSameTransform
);
77 virtual ~CachedPrimitiveBase() {}
79 virtual bool render( const ::basegfx::B2DHomMatrix
& rTransformation
) const;
85 virtual bool render( ::com::sun::star::uno::Reference
<
86 ::com::sun::star::rendering::XCachedPrimitive
>& rCachedPrimitive
,
87 const ::basegfx::B2DHomMatrix
& rTransformation
) const = 0;
89 CanvasSharedPtr mpCanvas
;
90 mutable ::com::sun::star::uno::Reference
<
91 ::com::sun::star::rendering::XCachedPrimitive
> mxCachedPrimitive
;
92 mutable ::basegfx::B2DHomMatrix maLastTransformation
;
93 const bool mbOnlyRedrawWithSameTransform
;
98 #endif /*_CPPCANVAS_CACHEDPRIMITIVEBASE_HXX */