1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX 29 #define INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX 30 31 #include <com/sun/star/uno/Reference.hxx> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <com/sun/star/rendering/XCanvas.hpp> 34 #include <com/sun/star/rendering/XCachedPrimitive.hpp> 35 #include <com/sun/star/rendering/ViewState.hpp> 36 #include <cppuhelper/compbase2.hxx> 37 #include <comphelper/broadcasthelper.hxx> 38 39 40 /* Definition of CachedPrimitiveBase class */ 41 42 namespace canvas 43 { 44 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive, 45 ::com::sun::star::lang::XServiceInfo > CachedPrimitiveBase_Base; 46 47 /** Base class, providing common functionality for implementers of 48 the XCachedPrimitive interface. 49 */ 50 class CachedPrimitiveBase : public CachedPrimitiveBase_Base, 51 public ::comphelper::OBaseMutex 52 { 53 public: 54 55 /** Create an XCachedPrimitive for given target canvas 56 57 @param rUsedViewState 58 The viewstate the original object was rendered with 59 60 @param rTarget 61 The target canvas the repaint should happen on. 62 63 @param bFailForChangedViewTransform 64 When true, derived classes will never receive doRedraw() 65 calls with dissimilar view transformations and 66 bSameViewTransform set to false. This is useful for cached 67 objects where re-transforming the generated output is not 68 desirable, e.g. for hinted font output. 69 */ 70 CachedPrimitiveBase( const ::com::sun::star::rendering::ViewState& rUsedViewState, 71 const ::com::sun::star::uno::Reference< 72 ::com::sun::star::rendering::XCanvas >& rTarget, 73 bool bFailForChangedViewTransform ); 74 75 /// Dispose all internal references 76 virtual void SAL_CALL disposing(); 77 78 // XCachedPrimitive 79 virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 80 81 // XServiceInfo 82 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 83 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 84 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 85 86 protected: 87 ~CachedPrimitiveBase(); // we're a ref-counted UNO class. _We_ destroy ourselves. 88 89 private: 90 CachedPrimitiveBase( const CachedPrimitiveBase& ); 91 CachedPrimitiveBase& operator=( const CachedPrimitiveBase& ); 92 93 /** Actually perform the requested redraw. 94 95 Clients must override this method, instead of the public 96 redraw() one. 97 98 @param rNewState 99 The viewstate to redraw with 100 101 @param rOldState 102 The viewstate this cache object was created with. 103 104 @param rTargetCanvas 105 Target canvas to render to. 106 107 @param bSameViewTransform 108 When true, rNewState and rOldState have the same transformation. 109 */ 110 virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState, 111 const ::com::sun::star::rendering::ViewState& rOldState, 112 const ::com::sun::star::uno::Reference< 113 ::com::sun::star::rendering::XCanvas >& rTargetCanvas, 114 bool bSameViewTransform ) = 0; 115 116 ::com::sun::star::rendering::ViewState maUsedViewState; 117 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget; 118 const bool mbFailForChangedViewTransform; 119 }; 120 } 121 122 #endif /* INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX */ 123