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 #include <canvas/canvastoolsdllapi.h> 36 37 /* Definition of CachedPrimitiveBase class */ 38 39 namespace canvas 40 { 41 typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive, 42 ::com::sun::star::lang::XServiceInfo > CachedPrimitiveBase_Base; 43 44 /** Base class, providing common functionality for implementers of 45 the XCachedPrimitive interface. 46 */ 47 class CANVASTOOLS_DLLPUBLIC CachedPrimitiveBase : public CachedPrimitiveBase_Base, 48 public ::comphelper::OBaseMutex 49 { 50 public: 51 52 /** Create an XCachedPrimitive for given target canvas 53 54 @param rUsedViewState 55 The viewstate the original object was rendered with 56 57 @param rTarget 58 The target canvas the repaint should happen on. 59 60 @param bFailForChangedViewTransform 61 When true, derived classes will never receive doRedraw() 62 calls with dissimilar view transformations and 63 bSameViewTransform set to false. This is useful for cached 64 objects where re-transforming the generated output is not 65 desirable, e.g. for hinted font output. 66 */ 67 CachedPrimitiveBase( const ::com::sun::star::rendering::ViewState& rUsedViewState, 68 const ::com::sun::star::uno::Reference< 69 ::com::sun::star::rendering::XCanvas >& rTarget, 70 bool bFailForChangedViewTransform ); 71 72 /// Dispose all internal references 73 virtual void SAL_CALL disposing(); 74 75 // XCachedPrimitive 76 virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 77 78 // XServiceInfo 79 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 80 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 81 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 82 83 protected: 84 ~CachedPrimitiveBase(); // we're a ref-counted UNO class. _We_ destroy ourselves. 85 86 private: 87 CachedPrimitiveBase( const CachedPrimitiveBase& ); 88 CachedPrimitiveBase& operator=( const CachedPrimitiveBase& ); 89 90 /** Actually perform the requested redraw. 91 92 Clients must override this method, instead of the public 93 redraw() one. 94 95 @param rNewState 96 The viewstate to redraw with 97 98 @param rOldState 99 The viewstate this cache object was created with. 100 101 @param rTargetCanvas 102 Target canvas to render to. 103 104 @param bSameViewTransform 105 When true, rNewState and rOldState have the same transformation. 106 */ 107 virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState, 108 const ::com::sun::star::rendering::ViewState& rOldState, 109 const ::com::sun::star::uno::Reference< 110 ::com::sun::star::rendering::XCanvas >& rTargetCanvas, 111 bool bSameViewTransform ) = 0; 112 113 ::com::sun::star::rendering::ViewState maUsedViewState; 114 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget; 115 const bool mbFailForChangedViewTransform; 116 }; 117 } 118 119 #endif /* INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX */ 120