1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DOCHOLDER_HXX_
29*cdf0e10cSrcweir #define _DOCHOLDER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/util/XCloseListener.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/util/XModifyListener.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/frame/XBorderResizeListener.hpp>
39*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XBORDERWIDTHS_HPP_
40*cdf0e10cSrcweir #include <com/sun/star/frame/BorderWidths.hpp>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/embed/XHatchWindowController.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
47*cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir class OCommonEmbeddedObject;
50*cdf0e10cSrcweir class Interceptor;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class DocumentHolder :
53*cdf0e10cSrcweir 	public ::cppu::WeakImplHelper6<
54*cdf0e10cSrcweir                         ::com::sun::star::util::XCloseListener,
55*cdf0e10cSrcweir 					  	::com::sun::star::frame::XTerminateListener,
56*cdf0e10cSrcweir                         ::com::sun::star::util::XModifyListener,
57*cdf0e10cSrcweir                         ::com::sun::star::document::XEventListener,
58*cdf0e10cSrcweir                         ::com::sun::star::frame::XBorderResizeListener,
59*cdf0e10cSrcweir 						::com::sun::star::embed::XHatchWindowController >
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir private:
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	OCommonEmbeddedObject* m_pEmbedObj;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 	Interceptor*        m_pInterceptor;
66*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
73*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xOwnWindow; // set for inplace objects
74*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xHatchWindow; // set for inplace objects
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	::com::sun::star::awt::Rectangle m_aObjRect;
77*cdf0e10cSrcweir 	::com::sun::star::frame::BorderWidths m_aBorderWidths;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	::rtl::OUString m_aContainerName;
80*cdf0e10cSrcweir 	::rtl::OUString m_aDocumentNamePart;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	sal_Bool m_bReadOnly;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 	sal_Bool m_bWaitForClose;
85*cdf0e10cSrcweir 	sal_Bool m_bAllowClosing;
86*cdf0e10cSrcweir     sal_Bool m_bDesktopTerminated;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	sal_Int32 m_nNoBorderResizeReact;
89*cdf0e10cSrcweir 	sal_Int32 m_nNoResizeReact;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xCachedDocAreaAcc;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOutplaceFrameProps;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetDocFrame();
97*cdf0e10cSrcweir     sal_Bool LoadDocToFrame( sal_Bool );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	::com::sun::star::awt::Rectangle CalculateBorderedArea( const ::com::sun::star::awt::Rectangle& aRect );
100*cdf0e10cSrcweir 	::com::sun::star::awt::Rectangle AddBorderToArea( const ::com::sun::star::awt::Rectangle& aRect );
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle& aHatchRect );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > RetrieveOwnMenu_Impl();
105*cdf0e10cSrcweir 	sal_Bool MergeMenues_Impl(
106*cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xOwnLM,
107*cdf0e10cSrcweir 	   			const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContLM,
108*cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp,
109*cdf0e10cSrcweir 				const ::rtl::OUString& aContModuleName );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir public:
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	static void FindConnectPoints(
114*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMenu,
115*cdf0e10cSrcweir 		sal_Int32 nConnectPoints[2] )
116*cdf0e10cSrcweir 			throw ( ::com::sun::star::uno::Exception );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > MergeMenuesForInplace(
119*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xContMenu,
120*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp,
121*cdf0e10cSrcweir 		const ::rtl::OUString& aContModuleName,
122*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xOwnMenu,
123*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xOwnDisp )
124*cdf0e10cSrcweir 			throw ( ::com::sun::star::uno::Exception );
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
128*cdf0e10cSrcweir 					OCommonEmbeddedObject* pEmbObj );
129*cdf0e10cSrcweir 	~DocumentHolder();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, sal_Bool bReadOnly );
134*cdf0e10cSrcweir     void ResizeHatchWindow();
135*cdf0e10cSrcweir 	void LockOffice();
136*cdf0e10cSrcweir 	void FreeOffice();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 	void CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose );
139*cdf0e10cSrcweir 	void CloseFrame();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	rtl::OUString GetTitle() const
142*cdf0e10cSrcweir 	{
143*cdf0e10cSrcweir 		return m_aContainerName + ::rtl::OUString::createFromAscii( " - " ) + m_aDocumentNamePart;
144*cdf0e10cSrcweir 	}
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	rtl::OUString GetContainerName() const { return m_aContainerName; }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aProps )
149*cdf0e10cSrcweir 		{ m_aOutplaceFrameProps = aProps; }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 	sal_Bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
154*cdf0e10cSrcweir 									sal_Bool bVisible );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     sal_Bool ShowInplace( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
157*cdf0e10cSrcweir 					  const ::com::sun::star::awt::Rectangle& aRectangleToShow,
158*cdf0e10cSrcweir 					  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 	sal_Bool ShowUI(
161*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM,
162*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP,
163*cdf0e10cSrcweir 		const ::rtl::OUString& aContModuleName );
164*cdf0e10cSrcweir 	sal_Bool HideUI(
165*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	void Show();
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	// sal_Bool SetVisArea( sal_Int64 nAspect, const ::com::sun::star::awt::Rectangle& aRect );
170*cdf0e10cSrcweir 	// sal_Bool GetVisArea( sal_Int64 nAspect, ::com::sun::star::awt::Rectangle *pRect );
171*cdf0e10cSrcweir 	sal_Bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize );
172*cdf0e10cSrcweir 	sal_Bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize );
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     sal_Int32 GetMapUnit( sal_Int64 nAspect );
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	void SetOutplaceDispatchInterceptor(
177*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >&
178*cdf0e10cSrcweir 																							xOutplaceInterceptor )
179*cdf0e10cSrcweir 	{
180*cdf0e10cSrcweir 		m_xOutplaceInterceptor = xOutplaceInterceptor;
181*cdf0e10cSrcweir 	}
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir // XEventListener
186*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir // XCloseListener
189*cdf0e10cSrcweir     virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, sal_Bool GetsOwnership ) throw (::com::sun::star::util::CloseVetoException, ::com::sun::star::uno::RuntimeException);
190*cdf0e10cSrcweir     virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir // XTerminateListener
193*cdf0e10cSrcweir     virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
194*cdf0e10cSrcweir     virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir // XModifyListener
197*cdf0e10cSrcweir 	virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir // XEventListener
200*cdf0e10cSrcweir     virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw ( ::com::sun::star::uno::RuntimeException );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir // XBorderResizeListener
203*cdf0e10cSrcweir     virtual void SAL_CALL borderWidthsChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObject, const ::com::sun::star::frame::BorderWidths& aNewSize ) throw (::com::sun::star::uno::RuntimeException);
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir // XHatchWindowController
206*cdf0e10cSrcweir     virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException);
207*cdf0e10cSrcweir     virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException);
208*cdf0e10cSrcweir     virtual void SAL_CALL activated(  ) throw (::com::sun::star::uno::RuntimeException);
209*cdf0e10cSrcweir     virtual void SAL_CALL deactivated(  ) throw (::com::sun::star::uno::RuntimeException);
210*cdf0e10cSrcweir };
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir #endif
213*cdf0e10cSrcweir 
214