Branch libreoffice-5-0-4
[LibreOffice.git] / include / canvas / base / cachedprimitivebase.hxx
blob4afc2ce14bc4bd4441b900c9e18ee846a4ec5d8a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_BASE_CACHEDPRIMITIVEBASE_HXX
21 #define INCLUDED_CANVAS_BASE_CACHEDPRIMITIVEBASE_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/rendering/XCanvas.hpp>
26 #include <com/sun/star/rendering/XCachedPrimitive.hpp>
27 #include <com/sun/star/rendering/ViewState.hpp>
28 #include <cppuhelper/compbase2.hxx>
29 #include <comphelper/broadcasthelper.hxx>
31 #include <canvas/canvastoolsdllapi.h>
33 /* Definition of CachedPrimitiveBase class */
35 namespace canvas
37 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive,
38 ::com::sun::star::lang::XServiceInfo > CachedPrimitiveBase_Base;
40 /** Base class, providing common functionality for implementers of
41 the XCachedPrimitive interface.
43 class CANVASTOOLS_DLLPUBLIC CachedPrimitiveBase:
44 public comphelper::OBaseMutex, public CachedPrimitiveBase_Base
46 public:
48 /** Create an XCachedPrimitive for given target canvas
50 @param rUsedViewState
51 The viewstate the original object was rendered with
53 @param rTarget
54 The target canvas the repaint should happen on.
56 @param bFailForChangedViewTransform
57 When true, derived classes will never receive doRedraw()
58 calls with dissimilar view transformations and
59 bSameViewTransform set to false. This is useful for cached
60 objects where re-transforming the generated output is not
61 desirable, e.g. for hinted font output.
63 CachedPrimitiveBase( const ::com::sun::star::rendering::ViewState& rUsedViewState,
64 const ::com::sun::star::uno::Reference<
65 ::com::sun::star::rendering::XCanvas >& rTarget,
66 bool bFailForChangedViewTransform );
68 /// Dispose all internal references
69 virtual void SAL_CALL disposing() SAL_OVERRIDE;
71 // XCachedPrimitive
72 virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 // XServiceInfo
75 virtual OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 protected:
80 virtual ~CachedPrimitiveBase(); // we're a ref-counted UNO class. _We_ destroy ourselves.
82 private:
83 CachedPrimitiveBase( const CachedPrimitiveBase& ) SAL_DELETED_FUNCTION;
84 CachedPrimitiveBase& operator=( const CachedPrimitiveBase& ) SAL_DELETED_FUNCTION;
86 /** Actually perform the requested redraw.
88 Clients must override this method, instead of the public
89 redraw() one.
91 @param rNewState
92 The viewstate to redraw with
94 @param rOldState
95 The viewstate this cache object was created with.
97 @param rTargetCanvas
98 Target canvas to render to.
100 @param bSameViewTransform
101 When true, rNewState and rOldState have the same transformation.
103 virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState,
104 const ::com::sun::star::rendering::ViewState& rOldState,
105 const ::com::sun::star::uno::Reference<
106 ::com::sun::star::rendering::XCanvas >& rTargetCanvas,
107 bool bSameViewTransform ) = 0;
109 ::com::sun::star::rendering::ViewState maUsedViewState;
110 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget;
111 const bool mbFailForChangedViewTransform;
115 #endif // INCLUDED_CANVAS_BASE_CACHEDPRIMITIVEBASE_HXX
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */