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