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 _VCLCANVAS_WINDOWOUTDEVHOLDER_HXX
25 #define _VCLCANVAS_WINDOWOUTDEVHOLDER_HXX
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <vcl/window.hxx>
30 
31 #include "outdevprovider.hxx"
32 
33 #include <boost/utility.hpp>
34 
35 namespace vclcanvas
36 {
37     class WindowOutDevHolder : public OutDevProvider,
38                                private ::boost::noncopyable
39     {
40     public:
41         explicit WindowOutDevHolder( const ::com::sun::star::uno::Reference<
42                                            ::com::sun::star::awt::XWindow>& xWin );
43 
44     private:
getOutDev()45         virtual OutputDevice& 		getOutDev() { return mrOutputWindow; }
getOutDev() const46         virtual const OutputDevice& getOutDev() const { return mrOutputWindow; }
47 
48         // TODO(Q2): Lifetime issue. Though WindowGraphicDeviceBase
49         // now listenes to the window component, I still consider
50         // holding a naked reference unsafe here (especially as we
51         // pass it around via getOutDev). This _only_ works reliably,
52         // if disposing the SpriteCanvas correctly disposes all
53         // entities which hold this pointer.
54         // So: as soon as the protocol inside
55         // vcl/source/window/window.cxx is broken, that disposes the
56         // canvas during window deletion, we're riding a dead horse
57         // here
58         Window& mrOutputWindow;
59     };
60 }
61 
62 #endif /* _VCLCANVAS_WINDOWOUTDEVHOLDER_HXX */
63