1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _DOCHOLDER_HXX_
30 #define _DOCHOLDER_HXX_
32 #include <com/sun/star/util/XCloseListener.hpp>
33 #include <com/sun/star/frame/XTerminateListener.hpp>
34 #include <com/sun/star/util/XModifyListener.hpp>
35 #include <com/sun/star/util/XCloseable.hpp>
36 #include <com/sun/star/document/XEventListener.hpp>
37 #include <com/sun/star/frame/XFrame.hpp>
38 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
39 #include <com/sun/star/frame/XBorderResizeListener.hpp>
40 #include <com/sun/star/frame/BorderWidths.hpp>
41 #include <com/sun/star/awt/XWindowPeer.hpp>
42 #include <com/sun/star/awt/Size.hpp>
43 #include <com/sun/star/awt/Rectangle.hpp>
44 #include <com/sun/star/embed/XHatchWindowController.hpp>
45 #include <com/sun/star/frame/XLayoutManager.hpp>
46 #include <cppuhelper/implbase6.hxx>
48 class OCommonEmbeddedObject
;
51 class DocumentHolder
:
52 public ::cppu::WeakImplHelper6
<
53 ::com::sun::star::util::XCloseListener
,
54 ::com::sun::star::frame::XTerminateListener
,
55 ::com::sun::star::util::XModifyListener
,
56 ::com::sun::star::document::XEventListener
,
57 ::com::sun::star::frame::XBorderResizeListener
,
58 ::com::sun::star::embed::XHatchWindowController
>
62 OCommonEmbeddedObject
* m_pEmbedObj
;
64 Interceptor
* m_pInterceptor
;
65 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
> m_xOutplaceInterceptor
;
67 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xFactory
;
69 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> m_xComponent
;
71 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
72 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xOwnWindow
; // set for inplace objects
73 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xHatchWindow
; // set for inplace objects
75 ::com::sun::star::awt::Rectangle m_aObjRect
;
76 ::com::sun::star::frame::BorderWidths m_aBorderWidths
;
78 ::rtl::OUString m_aContainerName
;
79 ::rtl::OUString m_aDocumentNamePart
;
83 sal_Bool m_bWaitForClose
;
84 sal_Bool m_bAllowClosing
;
85 sal_Bool m_bDesktopTerminated
;
87 sal_Int32 m_nNoBorderResizeReact
;
88 sal_Int32 m_nNoResizeReact
;
90 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> m_xCachedDocAreaAcc
;
92 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aOutplaceFrameProps
;
95 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> GetDocFrame();
96 sal_Bool
LoadDocToFrame( sal_Bool
);
98 ::com::sun::star::awt::Rectangle
CalculateBorderedArea( const ::com::sun::star::awt::Rectangle
& aRect
);
99 ::com::sun::star::awt::Rectangle
AddBorderToArea( const ::com::sun::star::awt::Rectangle
& aRect
);
101 void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle
& aHatchRect
);
103 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> RetrieveOwnMenu_Impl();
104 sal_Bool
MergeMenues_Impl(
105 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xOwnLM
,
106 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContLM
,
107 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
108 const ::rtl::OUString
& aContModuleName
);
112 static void FindConnectPoints(
113 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xMenu
,
114 sal_Int32 nConnectPoints
[2] )
115 throw ( ::com::sun::star::uno::Exception
);
117 static ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> MergeMenuesForInplace(
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xContMenu
,
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
120 const ::rtl::OUString
& aContModuleName
,
121 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xOwnMenu
,
122 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xOwnDisp
)
123 throw ( ::com::sun::star::uno::Exception
);
126 DocumentHolder( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xFactory
,
127 OCommonEmbeddedObject
* pEmbObj
);
130 OCommonEmbeddedObject
* GetEmbedObject() { return m_pEmbedObj
; }
132 void SetComponent( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
>& xDoc
, sal_Bool bReadOnly
);
133 void ResizeHatchWindow();
137 void CloseDocument( sal_Bool bDeliverOwnership
, sal_Bool bWaitForClose
);
140 rtl::OUString
GetTitle() const
142 return m_aContainerName
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( " - " )) + m_aDocumentNamePart
;
145 rtl::OUString
GetContainerName() const { return m_aContainerName
; }
147 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aProps
)
148 { m_aOutplaceFrameProps
= aProps
; }
150 void PlaceFrame( const ::com::sun::star::awt::Rectangle
& aNewRect
);
152 sal_Bool
SetFrameLMVisibility( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
,
155 sal_Bool
ShowInplace( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& xParent
,
156 const ::com::sun::star::awt::Rectangle
& aRectangleToShow
,
157 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
);
160 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
,
161 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
,
162 const ::rtl::OUString
& aContModuleName
);
164 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
);
168 sal_Bool
SetExtent( sal_Int64 nAspect
, const ::com::sun::star::awt::Size
& aSize
);
169 sal_Bool
GetExtent( sal_Int64 nAspect
, ::com::sun::star::awt::Size
*pSize
);
171 sal_Int32
GetMapUnit( sal_Int64 nAspect
);
173 void SetOutplaceDispatchInterceptor(
174 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
>&
175 xOutplaceInterceptor
)
177 m_xOutplaceInterceptor
= xOutplaceInterceptor
;
180 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> GetComponent() { return m_xComponent
; }
183 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
186 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
);
187 virtual void SAL_CALL
notifyClosing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
189 // XTerminateListener
190 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
191 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::uno::RuntimeException
);
194 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw ( ::com::sun::star::uno::RuntimeException
);
197 virtual void SAL_CALL
notifyEvent( const ::com::sun::star::document::EventObject
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
199 // XBorderResizeListener
200 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
);
202 // XHatchWindowController
203 virtual void SAL_CALL
requestPositioning( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
204 virtual ::com::sun::star::awt::Rectangle SAL_CALL
calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
205 virtual void SAL_CALL
activated( ) throw (::com::sun::star::uno::RuntimeException
);
206 virtual void SAL_CALL
deactivated( ) throw (::com::sun::star::uno::RuntimeException
);
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */