1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _DOCHOLDER_HXX_
21 #define _DOCHOLDER_HXX_
23 #include <com/sun/star/util/XCloseListener.hpp>
24 #include <com/sun/star/frame/XTerminateListener.hpp>
25 #include <com/sun/star/util/XModifyListener.hpp>
26 #include <com/sun/star/util/XCloseable.hpp>
27 #include <com/sun/star/document/XEventListener.hpp>
28 #include <com/sun/star/frame/XFrame.hpp>
29 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
30 #include <com/sun/star/frame/XBorderResizeListener.hpp>
31 #include <com/sun/star/frame/BorderWidths.hpp>
32 #include <com/sun/star/awt/XWindowPeer.hpp>
33 #include <com/sun/star/awt/Size.hpp>
34 #include <com/sun/star/awt/Rectangle.hpp>
35 #include <com/sun/star/embed/XHatchWindowController.hpp>
36 #include <com/sun/star/frame/XLayoutManager.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <cppuhelper/implbase6.hxx>
40 class OCommonEmbeddedObject
;
43 class DocumentHolder
:
44 public ::cppu::WeakImplHelper6
<
45 ::com::sun::star::util::XCloseListener
,
46 ::com::sun::star::frame::XTerminateListener
,
47 ::com::sun::star::util::XModifyListener
,
48 ::com::sun::star::document::XEventListener
,
49 ::com::sun::star::frame::XBorderResizeListener
,
50 ::com::sun::star::embed::XHatchWindowController
>
54 OCommonEmbeddedObject
* m_pEmbedObj
;
56 Interceptor
* m_pInterceptor
;
57 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
> m_xOutplaceInterceptor
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
61 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> m_xComponent
;
63 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xOwnWindow
; // set for inplace objects
65 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xHatchWindow
; // set for inplace objects
67 ::com::sun::star::awt::Rectangle m_aObjRect
;
68 ::com::sun::star::frame::BorderWidths m_aBorderWidths
;
70 OUString m_aContainerName
;
71 OUString m_aDocumentNamePart
;
75 sal_Bool m_bWaitForClose
;
76 sal_Bool m_bAllowClosing
;
77 sal_Bool m_bDesktopTerminated
;
79 sal_Int32 m_nNoBorderResizeReact
;
80 sal_Int32 m_nNoResizeReact
;
82 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> m_xCachedDocAreaAcc
;
84 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> m_aOutplaceFrameProps
;
87 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> GetDocFrame();
88 sal_Bool
LoadDocToFrame( sal_Bool
);
90 ::com::sun::star::awt::Rectangle
CalculateBorderedArea( const ::com::sun::star::awt::Rectangle
& aRect
);
91 ::com::sun::star::awt::Rectangle
AddBorderToArea( const ::com::sun::star::awt::Rectangle
& aRect
);
93 void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle
& aHatchRect
);
95 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> RetrieveOwnMenu_Impl();
96 sal_Bool
MergeMenus_Impl(
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xOwnLM
,
98 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContLM
,
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
100 const OUString
& aContModuleName
);
104 static void FindConnectPoints(
105 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xMenu
,
106 sal_Int32 nConnectPoints
[2] )
107 throw ( ::com::sun::star::uno::Exception
);
109 static ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
> MergeMenusForInplace(
110 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xContMenu
,
111 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContDisp
,
112 const OUString
& aContModuleName
,
113 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xOwnMenu
,
114 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xOwnDisp
)
115 throw ( ::com::sun::star::uno::Exception
);
118 DocumentHolder( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& xContext
,
119 OCommonEmbeddedObject
* pEmbObj
);
122 OCommonEmbeddedObject
* GetEmbedObject() { return m_pEmbedObj
; }
124 void SetComponent( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
>& xDoc
, sal_Bool bReadOnly
);
125 void ResizeHatchWindow();
129 void CloseDocument( sal_Bool bDeliverOwnership
, sal_Bool bWaitForClose
);
132 OUString
GetTitle() const
134 return m_aContainerName
+ OUString( " - " ) + m_aDocumentNamePart
;
137 OUString
GetContainerName() const { return m_aContainerName
; }
139 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> aProps
)
140 { m_aOutplaceFrameProps
= aProps
; }
142 void PlaceFrame( const ::com::sun::star::awt::Rectangle
& aNewRect
);
144 sal_Bool
SetFrameLMVisibility( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
,
147 sal_Bool
ShowInplace( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& xParent
,
148 const ::com::sun::star::awt::Rectangle
& aRectangleToShow
,
149 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
);
152 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
,
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xContainerDP
,
154 const OUString
& aContModuleName
);
156 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManager
>& xContainerLM
);
160 sal_Bool
SetExtent( sal_Int64 nAspect
, const ::com::sun::star::awt::Size
& aSize
);
161 sal_Bool
GetExtent( sal_Int64 nAspect
, ::com::sun::star::awt::Size
*pSize
);
163 sal_Int32
GetMapUnit( sal_Int64 nAspect
);
165 void SetOutplaceDispatchInterceptor(
166 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterceptor
>&
167 xOutplaceInterceptor
)
169 m_xOutplaceInterceptor
= xOutplaceInterceptor
;
172 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> GetComponent() { return m_xComponent
; }
175 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
178 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
);
179 virtual void SAL_CALL
notifyClosing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
181 // XTerminateListener
182 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
183 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::uno::RuntimeException
);
186 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw ( ::com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
notifyEvent( const ::com::sun::star::document::EventObject
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
191 // XBorderResizeListener
192 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
);
194 // XHatchWindowController
195 virtual void SAL_CALL
requestPositioning( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
196 virtual ::com::sun::star::awt::Rectangle SAL_CALL
calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle
& aRect
) throw (::com::sun::star::uno::RuntimeException
);
197 virtual void SAL_CALL
activated( ) throw (::com::sun::star::uno::RuntimeException
);
198 virtual void SAL_CALL
deactivated( ) throw (::com::sun::star::uno::RuntimeException
);
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */