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 .
22 #include <com/sun/star/util/XCloseListener.hpp>
23 #include <com/sun/star/frame/XTerminateListener.hpp>
24 #include <com/sun/star/util/XModifyListener.hpp>
25 #include <com/sun/star/util/XCloseable.hpp>
26 #include <com/sun/star/document/XEventListener.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
29 #include <com/sun/star/frame/XBorderResizeListener.hpp>
30 #include <com/sun/star/frame/BorderWidths.hpp>
31 #include <com/sun/star/awt/XWindowPeer.hpp>
32 #include <com/sun/star/awt/Size.hpp>
33 #include <com/sun/star/awt/Rectangle.hpp>
34 #include <com/sun/star/embed/XHatchWindowController.hpp>
35 #include <com/sun/star/frame/XLayoutManager.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <rtl/ref.hxx>
40 class OCommonEmbeddedObject
;
43 class DocumentHolder
:
44 public ::cppu::WeakImplHelper
<
45 css::util::XCloseListener
,
46 css::frame::XTerminateListener
,
47 css::util::XModifyListener
,
48 css::document::XEventListener
,
49 css::frame::XBorderResizeListener
,
50 css::embed::XHatchWindowController
>
54 OCommonEmbeddedObject
* m_pEmbedObj
;
56 rtl::Reference
<Interceptor
> m_xInterceptor
;
57 css::uno::Reference
< css::frame::XDispatchProviderInterceptor
> m_xOutplaceInterceptor
;
59 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
61 css::uno::Reference
< css::util::XCloseable
> m_xComponent
;
63 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
64 css::uno::Reference
< css::awt::XWindow
> m_xOwnWindow
; // set for inplace objects
65 css::uno::Reference
< css::awt::XWindow
> m_xHatchWindow
; // set for inplace objects
67 css::awt::Rectangle m_aObjRect
;
68 css::frame::BorderWidths m_aBorderWidths
;
70 OUString m_aContainerName
;
71 OUString m_aDocumentNamePart
;
77 bool m_bDesktopTerminated
;
79 sal_Int32 m_nNoBorderResizeReact
;
80 sal_Int32 m_nNoResizeReact
;
82 css::uno::Sequence
< css::uno::Any
> m_aOutplaceFrameProps
;
85 css::uno::Reference
< css::frame::XFrame
> const & GetDocFrame();
86 bool LoadDocToFrame( bool );
88 css::awt::Rectangle
CalculateBorderedArea( const css::awt::Rectangle
& aRect
);
89 css::awt::Rectangle
AddBorderToArea( const css::awt::Rectangle
& aRect
);
91 void ResizeWindows_Impl( const css::awt::Rectangle
& aHatchRect
);
93 css::uno::Reference
< css::container::XIndexAccess
> RetrieveOwnMenu_Impl();
95 const css::uno::Reference
< css::frame::XLayoutManager
>& xOwnLM
,
96 const css::uno::Reference
< css::frame::XLayoutManager
>& xContLM
,
97 const css::uno::Reference
< css::frame::XDispatchProvider
>& xContDisp
,
98 const OUString
& aContModuleName
);
101 /// @throws css::uno::Exception
102 static void FindConnectPoints(
103 const css::uno::Reference
< css::container::XIndexAccess
>& xMenu
,
104 sal_Int32 nConnectPoints
[2] );
106 /// @throws css::uno::Exception
107 static css::uno::Reference
< css::container::XIndexAccess
> MergeMenusForInplace(
108 const css::uno::Reference
< css::container::XIndexAccess
>& xContMenu
,
109 const css::uno::Reference
< css::frame::XDispatchProvider
>& xContDisp
,
110 const OUString
& aContModuleName
,
111 const css::uno::Reference
< css::container::XIndexAccess
>& xOwnMenu
,
112 const css::uno::Reference
< css::frame::XDispatchProvider
>& xOwnDisp
);
115 DocumentHolder( css::uno::Reference
< css::uno::XComponentContext
> xContext
,
116 OCommonEmbeddedObject
* pEmbObj
);
117 virtual ~DocumentHolder() override
;
119 OCommonEmbeddedObject
* GetEmbedObject() { return m_pEmbedObj
; }
121 void SetComponent( const css::uno::Reference
< css::util::XCloseable
>& xDoc
, bool bReadOnly
);
122 void ResizeHatchWindow();
125 void CloseDocument( bool bDeliverOwnership
, bool bWaitForClose
);
128 OUString
GetTitle() const
130 return m_aContainerName
+ ( m_aDocumentNamePart
.isEmpty() ? OUString() : ( " - " + m_aDocumentNamePart
) );
133 OUString
const & GetContainerName() const
135 return m_aContainerName
;
138 void SetOutplaceFrameProperties( const css::uno::Sequence
< css::uno::Any
>& aProps
)
139 { m_aOutplaceFrameProps
= aProps
; }
141 void PlaceFrame( const css::awt::Rectangle
& aNewRect
);
143 static bool SetFrameLMVisibility( const css::uno::Reference
< css::frame::XFrame
>& xFrame
,
146 bool ShowInplace( const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
,
147 const css::awt::Rectangle
& aRectangleToShow
,
148 const css::uno::Reference
< css::frame::XDispatchProvider
>& xContainerDP
);
151 const css::uno::Reference
< css::frame::XLayoutManager
>& xContainerLM
,
152 const css::uno::Reference
< css::frame::XDispatchProvider
>& xContainerDP
,
153 const OUString
& aContModuleName
);
155 const css::uno::Reference
< css::frame::XLayoutManager
>& xContainerLM
);
159 bool SetExtent( sal_Int64 nAspect
, const css::awt::Size
& aSize
);
160 bool GetExtent( sal_Int64 nAspect
, css::awt::Size
*pSize
);
162 sal_Int32
GetMapUnit( sal_Int64 nAspect
);
164 void SetOutplaceDispatchInterceptor(
165 const css::uno::Reference
< css::frame::XDispatchProviderInterceptor
>&
166 xOutplaceInterceptor
)
168 m_xOutplaceInterceptor
= xOutplaceInterceptor
;
171 const css::uno::Reference
< css::util::XCloseable
>& GetComponent() const { return m_xComponent
; }
174 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
177 virtual void SAL_CALL
queryClosing( const css::lang::EventObject
& Source
, sal_Bool GetsOwnership
) override
;
178 virtual void SAL_CALL
notifyClosing( const css::lang::EventObject
& Source
) override
;
180 // XTerminateListener
181 virtual void SAL_CALL
queryTermination( const css::lang::EventObject
& Event
) override
;
182 virtual void SAL_CALL
notifyTermination( const css::lang::EventObject
& Event
) override
;
185 virtual void SAL_CALL
modified( const css::lang::EventObject
& aEvent
) override
;
188 virtual void SAL_CALL
notifyEvent( const css::document::EventObject
& Event
) override
;
190 // XBorderResizeListener
191 virtual void SAL_CALL
borderWidthsChanged( const css::uno::Reference
< css::uno::XInterface
>& aObject
, const css::frame::BorderWidths
& aNewSize
) override
;
193 // XHatchWindowController
194 virtual void SAL_CALL
requestPositioning( const css::awt::Rectangle
& aRect
) override
;
195 virtual css::awt::Rectangle SAL_CALL
calcAdjustedRectangle( const css::awt::Rectangle
& aRect
) override
;
196 virtual void SAL_CALL
activated( ) override
;
197 virtual void SAL_CALL
deactivated( ) override
;
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */