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