1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docholder.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DOCHOLDER_HXX_
32 #define _DOCHOLDER_HXX_
34 #include <com/sun/star/util/XCloseListener.hpp>
35 #include <com/sun/star/frame/XTerminateListener.hpp>
36 #include <com/sun/star/util/XModifyListener.hpp>
37 #include <com/sun/star/util/XCloseable.hpp>
38 #include <com/sun/star/document/XEventListener.hpp>
39 #include <com/sun/star/frame/XFrame.hpp>
40 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
41 #include <com/sun/star/frame/XBorderResizeListener.hpp>
42 #ifndef _COM_SUN_STAR_FRAME_XBORDERWIDTHS_HPP_
43 #include <com/sun/star/frame/BorderWidths.hpp>
45 #include <com/sun/star/awt/XWindowPeer.hpp>
46 #include <com/sun/star/awt/Size.hpp>
47 #include <com/sun/star/awt/Rectangle.hpp>
48 #include <com/sun/star/embed/XHatchWindowController.hpp>
49 #include <com/sun/star/frame/XLayoutManager.hpp>
50 #include <cppuhelper/implbase6.hxx>
52 class OCommonEmbeddedObject
;
55 class DocumentHolder
:
56 public ::cppu::WeakImplHelper6
<
57 ::com::sun::star::util::XCloseListener
,
58 ::com::sun::star::frame::XTerminateListener
,
59 ::com::sun::star::util::XModifyListener
,
60 ::com::sun::star::document::XEventListener
,
61 ::com::sun::star::frame::XBorderResizeListener
,
62 ::com::sun::star::embed::XHatchWindowController
>
66 OCommonEmbeddedObject
* m_pEmbedObj
;
68 Interceptor
* m_pInterceptor
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
> m_xOutplaceInterceptor
;
71 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xFactory
;
73 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> m_xComponent
;
75 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
76 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xOwnWindow
; // set for inplace objects
77 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xHatchWindow
; // set for inplace objects
79 ::com::sun::star::awt::Rectangle m_aObjRect
;
80 ::com::sun::star::frame::BorderWidths m_aBorderWidths
;
82 ::rtl::OUString m_aContainerName
;
83 ::rtl::OUString m_aDocumentNamePart
;
87 sal_Bool m_bWaitForClose
;
88 sal_Bool m_bAllowClosing
;
89 sal_Bool m_bDesktopTerminated
;
91 sal_Int32 m_nNoBorderResizeReact
;
92 sal_Int32 m_nNoResizeReact
;
94 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> m_xCachedDocAreaAcc
;
96 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aOutplaceFrameProps
;
99 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> GetDocFrame();
100 sal_Bool
LoadDocToFrame( sal_Bool
);
102 ::com::sun::star::awt::Rectangle
CalculateBorderedArea( const ::com::sun::star::awt::Rectangle
& aRect
);
103 ::com::sun::star::awt::Rectangle
AddBorderToArea( const ::com::sun::star::awt::Rectangle
& aRect
);
105 void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle
& aHatchRect
);
107 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> RetrieveOwnMenu_Impl();
108 sal_Bool
MergeMenues_Impl(
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xOwnLM
,
110 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContLM
,
111 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
112 const ::rtl::OUString
& aContModuleName
);
116 static void FindConnectPoints(
117 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xMenu
,
118 sal_Int32 nConnectPoints
[2] )
119 throw ( ::com::sun::star::uno::Exception
);
121 static ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> MergeMenuesForInplace(
122 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xContMenu
,
123 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
124 const ::rtl::OUString
& aContModuleName
,
125 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xOwnMenu
,
126 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xOwnDisp
)
127 throw ( ::com::sun::star::uno::Exception
);
130 DocumentHolder( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xFactory
,
131 OCommonEmbeddedObject
* pEmbObj
);
134 OCommonEmbeddedObject
* GetEmbedObject() { return m_pEmbedObj
; }
136 void SetComponent( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
>& xDoc
, sal_Bool bReadOnly
);
137 void ResizeHatchWindow();
141 void CloseDocument( sal_Bool bDeliverOwnership
, sal_Bool bWaitForClose
);
144 rtl::OUString
GetTitle() const
146 return m_aContainerName
+ ::rtl::OUString::createFromAscii( " - " ) + m_aDocumentNamePart
;
149 rtl::OUString
GetContainerName() const { return m_aContainerName
; }
151 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aProps
)
152 { m_aOutplaceFrameProps
= aProps
; }
154 void PlaceFrame( const ::com::sun::star::awt::Rectangle
& aNewRect
);
156 sal_Bool
SetFrameLMVisibility( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
,
159 sal_Bool
ShowInplace( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& xParent
,
160 const ::com::sun::star::awt::Rectangle
& aRectangleToShow
,
161 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
);
164 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
,
165 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
,
166 const ::rtl::OUString
& aContModuleName
);
168 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
);
172 // sal_Bool SetVisArea( sal_Int64 nAspect, const ::com::sun::star::awt::Rectangle& aRect );
173 // sal_Bool GetVisArea( sal_Int64 nAspect, ::com::sun::star::awt::Rectangle *pRect );
174 sal_Bool
SetExtent( sal_Int64 nAspect
, const ::com::sun::star::awt::Size
& aSize
);
175 sal_Bool
GetExtent( sal_Int64 nAspect
, ::com::sun::star::awt::Size
*pSize
);
177 sal_Int32
GetMapUnit( sal_Int64 nAspect
);
179 void SetOutplaceDispatchInterceptor(
180 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
>&
181 xOutplaceInterceptor
)
183 m_xOutplaceInterceptor
= xOutplaceInterceptor
;
186 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> GetComponent() { return m_xComponent
; }
189 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
192 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
);
193 virtual void SAL_CALL
notifyClosing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
195 // XTerminateListener
196 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
197 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::uno::RuntimeException
);
200 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw ( ::com::sun::star::uno::RuntimeException
);
203 virtual void SAL_CALL
notifyEvent( const ::com::sun::star::document::EventObject
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
205 // XBorderResizeListener
206 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
);
208 // XHatchWindowController
209 virtual void SAL_CALL
requestPositioning( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
210 virtual ::com::sun::star::awt::Rectangle SAL_CALL
calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
211 virtual void SAL_CALL
activated( ) throw (::com::sun::star::uno::RuntimeException
);
212 virtual void SAL_CALL
deactivated( ) throw (::com::sun::star::uno::RuntimeException
);