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 SD_FRAMEWORK_CHILD_WINDOW_PANE_HXX
29 #define SD_FRAMEWORK_CHILD_WINDOW_PANE_HXX
30 
31 #include "framework/Pane.hxx"
32 #include "PaneShells.hxx"
33 
34 #ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_
35 #include <com/sun/star/lang/XEventListener.hpp>
36 #endif
37 #ifndef _COM_SUN_STAR_DRAWING_FRAMEWORK_XRESOURCEID_HPP_
38 #include <com/sun/star/drawing/framework/XResourceId.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
41 #include <com/sun/star/awt/XWindow.hpp>
42 #endif
43 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
44 #include <cppuhelper/implbase1.hxx>
45 #endif
46 #ifndef _COMPHELPER_UNO3_HXX_
47 #include <comphelper/uno3.hxx>
48 #endif
49 #include <tools/link.hxx>
50 #include <memory>
51 
52 namespace {
53 
54 typedef ::cppu::ImplInheritanceHelper1 <
55     ::sd::framework::Pane,
56     ::com::sun::star::lang::XEventListener
57     > ChildWindowPaneInterfaceBase;
58 
59 } // end of anonymous namespace.
60 
61 
62 class SfxViewFrame;
63 
64 namespace sd { class ViewShellBase; }
65 
66 namespace sd { namespace framework {
67 
68 /** The ChildWindowPane listens to the child window and disposes itself when
69     the child window becomes inaccessible.  This happens for instance when a
70     document is made read-only and the task pane is turned off.
71 */
72 class ChildWindowPane
73     : public ChildWindowPaneInterfaceBase
74 {
75 public:
76 	ChildWindowPane (
77         const ::com::sun::star::uno::Reference<
78             ::com::sun::star::drawing::framework::XResourceId>& rxPaneId,
79         sal_uInt16 nChildWindowId,
80         ViewShellBase& rViewShellBase,
81         ::std::auto_ptr<SfxShell> pShell);
82     virtual ~ChildWindowPane (void) throw();
83 
84     /** Hide the pane.  To make the pane visible again, call GetWindow().
85     */
86     void Hide (void);
87 
88     virtual void SAL_CALL disposing (void);
89 
90     /** This returns the content window when the child window is already
91         visible.  Otherwise <NULL/> is returned.  In that case a later call
92         may return the requested window (making a child window visible is an
93         asynchronous process.)
94         Note that GetWindow() may return different Window pointers when
95         Hide() is called in between.
96     */
97     virtual ::Window* GetWindow (void);
98 
99     /** The local getWindow() first calls GetWindow() to provide a valid
100         window pointer before forwarding the call to the base class.
101     */
102     virtual ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow>
103         SAL_CALL getWindow (void)
104         throw (::com::sun::star::uno::RuntimeException);
105 
106     DECLARE_XINTERFACE()
107 	DECLARE_XTYPEPROVIDER()
108 
109 
110     // XEventListener
111 
112     virtual void SAL_CALL disposing(
113         const com::sun::star::lang::EventObject& rEvent)
114         throw (com::sun::star::uno::RuntimeException);
115 
116 private:
117     ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId> mxPaneId;
118     sal_uInt16 mnChildWindowId;
119     ViewShellBase& mrViewShellBase;
120     ::std::auto_ptr<SfxShell> mpShell;
121 
122     /** This flag is set when the pane shell has been activated at least
123         once.  It is used to optimize the start-up performance (by not
124         showing the window too early) and by not delaying its creation at
125         later times.
126     */
127     bool mbHasBeenActivated;
128 };
129 
130 } } // end of namespace sd::framework
131 
132 #endif
133