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