xref: /trunk/main/embedserv/source/inc/docholder.hxx (revision a20fd023)
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 _DOCHOLDER_HXX_
25 #define _DOCHOLDER_HXX_
26 
27 #include "common.h"
28 #include <com/sun/star/frame/XLayoutManager.hpp>
29 #include <com/sun/star/util/XCloseListener.hpp>
30 #include <com/sun/star/frame/XTerminateListener.hpp>
31 #include <com/sun/star/util/XModifyListener.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
34 #include <cppuhelper/implbase4.hxx>
35 
36 #include <rtl/ref.hxx>
37 
38 #include "embeddocaccess.hxx"
39 
40 class EmbedDocument_Impl;
41 class Interceptor;
42 class CIIAObj;
43 
44 namespace winwrap {
45 	class CHatchWin;
46 }
47 
48 
49 class DocumentHolder :
50 	public ::cppu::WeakImplHelper4<
51                         ::com::sun::star::util::XCloseListener,
52 					  	::com::sun::star::frame::XTerminateListener,
53                         ::com::sun::star::util::XModifyListener,
54                         ::com::sun::star::ui::XDockingAreaAcceptor>
55 {
56 private:
57 	::osl::Mutex				m_aMutex;
58 
59 	BOOL                        m_bAllowInPlace;
60 	LPOLEINPLACESITE            m_pIOleIPSite;
61 	LPOLEINPLACEFRAME           m_pIOleIPFrame;
62 	LPOLEINPLACEUIWINDOW        m_pIOleIPUIWindow;
63 	winwrap::CHatchWin*         m_pCHatchWin;
64 
65 	::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess;
66 
67 	::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xInterceptorLocker;
68 	Interceptor*                m_pInterceptor;
69 
70 	::com::sun::star::uno::Reference<
71 	::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
72 
73     RECT                          m_aBorder;
74 
75 	// contains top level system window data
76     bool                          m_bOnDeactivate;
77     HWND                          m_hWndxWinParent;
78     HWND                          m_hWndxWinCont;
79 	HMENU                         m_nMenuHandle;
80     HMENU                         m_nMenuShared;
81     HOLEMENU                      m_nOLEMenu;
82     com::sun::star::uno::Reference<
83         com::sun::star::awt::XWindow> m_xEditWindow;
84 
85     com::sun::star::uno::Reference<
86         com::sun::star::awt::XWindow> m_xContainerWindow;
87 
88 	::com::sun::star::uno::Reference<
89 	::com::sun::star::frame::XModel > m_xDocument;
90     sal_Int16                    m_nMacroExecMode;
91 
92     ::com::sun::star::uno::Reference<
93     ::com::sun::star::frame::XLayoutManager> m_xLayoutManager;
94 
95 
96 	::com::sun::star::uno::Reference<
97 	::com::sun::star::frame::XFrame > m_xFrame;
98 
99 	::rtl::OUString m_aContainerName,m_aDocumentNamePart,m_aFilterName;
100 
101 	CComPtr< IDispatch > m_pIDispatch;
102 
103 	sal_Bool m_bLink;
104 
105 
106 	::com::sun::star::uno::Reference<
107 	::com::sun::star::frame::XFrame > DocumentFrame();
108 
109 
110 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >
111 		CreateNewInterceptor();
112 
113 	void ClearInterceptorInternally();
114 
115     void LoadDocInFrame( sal_Bool bPluginMode );
116 public:
117 
118 
119 	// the instance to which we belong
120 	static HINSTANCE m_hInstance;
121 
GetEditWindowParentHandle() const122     HWND GetEditWindowParentHandle() const
123     {
124         return m_hWndxWinParent;
125     }
126 
SetContainerWindowHandle(HWND hWndxWinCont)127     void SetContainerWindowHandle(HWND hWndxWinCont)
128     {
129         m_hWndxWinCont = hWndxWinCont;
130     }
131 
132 	DocumentHolder(
133 		const ::com::sun::star::uno::Reference<
134 		::com::sun::star::lang::XMultiServiceFactory >& xFactory,
135 		const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess );
136 
137 	~DocumentHolder();
138 
139 	// Methods for inplace activation
140 
141 
142 	BOOL isActive() const;
143 	void DisableInplaceActivation(BOOL);
144 	HRESULT InPlaceActivate(LPOLECLIENTSITE,BOOL);
145 	void InPlaceDeactivate(void);
146 	HRESULT UIActivate();
147 	void UIDeactivate();
148 	BOOL InPlaceMenuCreate(void);
149 	BOOL InPlaceMenuDestroy(void);
150 
151 	void OpenIntoWindow(void);
152 	BOOL Undo(void);
153 
154 	// further methods
155 
156 	void SetDocument(
157 		const ::com::sun::star::uno::Reference<
158 		::com::sun::star::frame::XModel >& xDoc,
159 		sal_Bool bLink = sal_False
160 	);
161 
162 	sal_Bool ExecuteSuspendCloseFrame();
163 
164 	void DisconnectFrameDocument( sal_Bool bComplete = sal_False );
165 	void CloseDocument();
166 	void CloseFrame();
167 	void ClearInterceptor();
168 	void FreeOffice();
169 
170 	void resizeWin( const SIZEL& rNewSize );
171 
172 	void setTitle(const rtl::OUString& aDocumentName);
getTitle() const173 	rtl::OUString getTitle() const { return m_aDocumentNamePart; }
174 
175 	void setContainerName(const rtl::OUString& aContainerName);
getContainerName() const176 	rtl::OUString getContainerName() const { return m_aContainerName; }
177     void OnPosRectChanged(LPRECT lpRect) const;
178 	void show();
179 
HasFrame()180     sal_Bool HasFrame() { return m_xFrame.is(); }
IsLink()181     sal_Bool IsLink() { return m_bLink; }
182 
183 	/** hides the document window, even in case of an external container
184 	 *  side managed window.
185 	 */
186 
187 	void hide();
188 
189 	IDispatch* GetIDispatch();
190 
191     HRESULT GetDocumentBorder( RECT *pRect );
192 	// HRESULT SetVisArea( const RECTL *pRect );
193 	// HRESULT GetVisArea( RECTL *pRect );
194 	HRESULT SetExtent( const SIZEL *pSize );
195 	HRESULT GetExtent( SIZEL *pSize );
196 	// sets extension on the hatchwindow
197     HRESULT SetContRects(LPCRECT pRect);
198 	HRESULT SetObjectRects(LPCRECT aRect, LPCRECT aClip);
199 
GetTopMostWinHandle() const200 	HWND GetTopMostWinHandle() const
201 	{
202         return m_hWndxWinParent;
203  	}
204 
205 	::com::sun::star::uno::Reference<
206 	::com::sun::star::frame::XModel >
GetDocument() const207 	GetDocument() const
208 	{
209 		return m_xDocument;
210 	}
211 
212 	// XEventListener
213 	virtual void SAL_CALL
214 	disposing( const com::sun::star::lang::EventObject& aSource )
215 		throw( ::com::sun::star::uno::RuntimeException );
216 
217 	// XCloseListener
218 	virtual void SAL_CALL
219 	queryClosing(
220 		const com::sun::star::lang::EventObject& aSource,
221 		sal_Bool bGetsOwnership
222 	)
223 		throw(
224 			::com::sun::star::util::CloseVetoException
225 		);
226 
227 	virtual void SAL_CALL
228 	notifyClosing(
229 		const com::sun::star::lang::EventObject& aSource
230 	)
231 		throw( ::com::sun::star::uno::RuntimeException );
232 
233 	// XTerminateListener
234 	virtual void SAL_CALL
235 	queryTermination(
236 		const com::sun::star::lang::EventObject& aSource
237 	)
238 		throw(
239 			::com::sun::star::frame::TerminationVetoException
240 		);
241 
242 	virtual void SAL_CALL
243 	notifyTermination(
244 		const com::sun::star::lang::EventObject& aSource
245 	)
246 		throw( ::com::sun::star::uno::RuntimeException );
247 
248 
249 	// XModifyListener
250 	virtual void SAL_CALL
251 	modified(
252 		const ::com::sun::star::lang::EventObject& aEvent
253 	)
254 		throw (
255 			::com::sun::star::uno::RuntimeException
256 		);
257 
258     // XDockingAreaAcceptor
259 
260     virtual ::com::sun::star::uno::Reference<
261         ::com::sun::star::awt::XWindow> SAL_CALL
262     getContainerWindow(
263     )
264         throw (
265             ::com::sun::star::uno::RuntimeException
266         );
267 
268     virtual sal_Bool SAL_CALL
269     requestDockingAreaSpace(
270         const ::com::sun::star::awt::Rectangle& RequestedSpace
271     )
272         throw(
273             ::com::sun::star::uno::RuntimeException
274         );
275 
276     virtual void SAL_CALL
277     setDockingAreaSpace(
278         const ::com::sun::star::awt::Rectangle& BorderSpace
279     )
280         throw (
281             ::com::sun::star::uno::RuntimeException
282         );
283 };
284 
285 #endif
286 
287