1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX 25 #define INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX 26 27 #include <com/sun/star/uno/Reference.hxx> 28 #include <com/sun/star/lang/XServiceInfo.hpp> 29 #include <com/sun/star/rendering/XCanvas.hpp> 30 #include <com/sun/star/rendering/XCachedPrimitive.hpp> 31 #include <com/sun/star/rendering/ViewState.hpp> 32 #include <cppuhelper/compbase2.hxx> 33 #include <comphelper/broadcasthelper.hxx> 34 35 36 /* Definition of CachedPrimitiveBase class */ 37 38 namespace canvas 39 { 40 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive, 41 ::com::sun::star::lang::XServiceInfo > CachedPrimitiveBase_Base; 42 43 /** Base class, providing common functionality for implementers of 44 the XCachedPrimitive interface. 45 */ 46 class CachedPrimitiveBase : public CachedPrimitiveBase_Base, 47 public ::comphelper::OBaseMutex 48 { 49 public: 50 51 /** Create an XCachedPrimitive for given target canvas 52 53 @param rUsedViewState 54 The viewstate the original object was rendered with 55 56 @param rTarget 57 The target canvas the repaint should happen on. 58 59 @param bFailForChangedViewTransform 60 When true, derived classes will never receive doRedraw() 61 calls with dissimilar view transformations and 62 bSameViewTransform set to false. This is useful for cached 63 objects where re-transforming the generated output is not 64 desirable, e.g. for hinted font output. 65 */ 66 CachedPrimitiveBase( const ::com::sun::star::rendering::ViewState& rUsedViewState, 67 const ::com::sun::star::uno::Reference< 68 ::com::sun::star::rendering::XCanvas >& rTarget, 69 bool bFailForChangedViewTransform ); 70 71 /// Dispose all internal references 72 virtual void SAL_CALL disposing(); 73 74 // XCachedPrimitive 75 virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 76 77 // XServiceInfo 78 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 79 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 80 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 81 82 protected: 83 ~CachedPrimitiveBase(); // we're a ref-counted UNO class. _We_ destroy ourselves. 84 85 private: 86 CachedPrimitiveBase( const CachedPrimitiveBase& ); 87 CachedPrimitiveBase& operator=( const CachedPrimitiveBase& ); 88 89 /** Actually perform the requested redraw. 90 91 Clients must override this method, instead of the public 92 redraw() one. 93 94 @param rNewState 95 The viewstate to redraw with 96 97 @param rOldState 98 The viewstate this cache object was created with. 99 100 @param rTargetCanvas 101 Target canvas to render to. 102 103 @param bSameViewTransform 104 When true, rNewState and rOldState have the same transformation. 105 */ 106 virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState, 107 const ::com::sun::star::rendering::ViewState& rOldState, 108 const ::com::sun::star::uno::Reference< 109 ::com::sun::star::rendering::XCanvas >& rTargetCanvas, 110 bool bSameViewTransform ) = 0; 111 112 ::com::sun::star::rendering::ViewState maUsedViewState; 113 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget; 114 const bool mbFailForChangedViewTransform; 115 }; 116 } 117 118 #endif /* INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX */ 119