Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / embeddedobj / source / inc / docholder.hxx
blobabe49ff9475eed3ac51b4a41b8824e34b9440083
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DOCHOLDER_HXX
21 #define INCLUDED_EMBEDDEDOBJ_SOURCE_INC_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/implbase.hxx>
39 #include <rtl/ref.hxx>
41 class OCommonEmbeddedObject;
42 class Interceptor;
44 class DocumentHolder :
45 public ::cppu::WeakImplHelper<
46 css::util::XCloseListener,
47 css::frame::XTerminateListener,
48 css::util::XModifyListener,
49 css::document::XEventListener,
50 css::frame::XBorderResizeListener,
51 css::embed::XHatchWindowController >
53 private:
55 OCommonEmbeddedObject* m_pEmbedObj;
57 rtl::Reference<Interceptor> m_xInterceptor;
58 css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
60 css::uno::Reference< css::uno::XComponentContext > m_xContext;
62 css::uno::Reference< css::util::XCloseable > m_xComponent;
64 css::uno::Reference< css::frame::XFrame > m_xFrame;
65 css::uno::Reference< css::awt::XWindow > m_xOwnWindow; // set for inplace objects
66 css::uno::Reference< css::awt::XWindow > m_xHatchWindow; // set for inplace objects
68 css::awt::Rectangle m_aObjRect;
69 css::frame::BorderWidths m_aBorderWidths;
71 OUString m_aContainerName;
72 OUString m_aDocumentNamePart;
74 bool m_bReadOnly;
76 bool m_bWaitForClose;
77 bool m_bAllowClosing;
78 bool m_bDesktopTerminated;
80 sal_Int32 m_nNoBorderResizeReact;
81 sal_Int32 m_nNoResizeReact;
83 css::uno::Sequence< css::uno::Any > m_aOutplaceFrameProps;
86 css::uno::Reference< css::frame::XFrame > const & GetDocFrame();
87 bool LoadDocToFrame( bool );
89 css::awt::Rectangle CalculateBorderedArea( const css::awt::Rectangle& aRect );
90 css::awt::Rectangle AddBorderToArea( const css::awt::Rectangle& aRect );
92 void ResizeWindows_Impl( const css::awt::Rectangle& aHatchRect );
94 css::uno::Reference< css::container::XIndexAccess > RetrieveOwnMenu_Impl();
95 bool MergeMenus_Impl(
96 const css::uno::Reference< css::frame::XLayoutManager >& xOwnLM,
97 const css::uno::Reference< css::frame::XLayoutManager >& xContLM,
98 const css::uno::Reference< css::frame::XDispatchProvider >& xContDisp,
99 const OUString& aContModuleName );
101 public:
102 /// @throws css::uno::Exception
103 static void FindConnectPoints(
104 const css::uno::Reference< css::container::XIndexAccess >& xMenu,
105 sal_Int32 nConnectPoints[2] );
107 /// @throws css::uno::Exception
108 static css::uno::Reference< css::container::XIndexAccess > MergeMenusForInplace(
109 const css::uno::Reference< css::container::XIndexAccess >& xContMenu,
110 const css::uno::Reference< css::frame::XDispatchProvider >& xContDisp,
111 const OUString& aContModuleName,
112 const css::uno::Reference< css::container::XIndexAccess >& xOwnMenu,
113 const css::uno::Reference< css::frame::XDispatchProvider >& xOwnDisp );
116 DocumentHolder( const css::uno::Reference< css::uno::XComponentContext >& xContext,
117 OCommonEmbeddedObject* pEmbObj );
118 virtual ~DocumentHolder() override;
120 OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; }
122 void SetComponent( const css::uno::Reference< css::util::XCloseable >& xDoc, bool bReadOnly );
123 void ResizeHatchWindow();
124 void FreeOffice();
126 void CloseDocument( bool bDeliverOwnership, bool bWaitForClose );
127 void CloseFrame();
129 OUString GetTitle() const
131 return m_aContainerName + ( m_aDocumentNamePart.isEmpty() ? OUString() : ( " - " + m_aDocumentNamePart ) );
134 OUString const & GetContainerName() const
136 return m_aContainerName;
139 void SetOutplaceFrameProperties( const css::uno::Sequence< css::uno::Any >& aProps )
140 { m_aOutplaceFrameProps = aProps; }
142 void PlaceFrame( const css::awt::Rectangle& aNewRect );
144 static bool SetFrameLMVisibility( const css::uno::Reference< css::frame::XFrame >& xFrame,
145 bool bVisible );
147 bool ShowInplace( const css::uno::Reference< css::awt::XWindowPeer >& xParent,
148 const css::awt::Rectangle& aRectangleToShow,
149 const css::uno::Reference< css::frame::XDispatchProvider >& xContainerDP );
151 bool ShowUI(
152 const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM,
153 const css::uno::Reference< css::frame::XDispatchProvider >& xContainerDP,
154 const OUString& aContModuleName );
155 bool HideUI(
156 const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM );
158 void Show();
160 bool SetExtent( sal_Int64 nAspect, const css::awt::Size& aSize );
161 bool GetExtent( sal_Int64 nAspect, css::awt::Size *pSize );
163 sal_Int32 GetMapUnit( sal_Int64 nAspect );
165 void SetOutplaceDispatchInterceptor(
166 const css::uno::Reference< css::frame::XDispatchProviderInterceptor >&
167 xOutplaceInterceptor )
169 m_xOutplaceInterceptor = xOutplaceInterceptor;
172 const css::uno::Reference< css::util::XCloseable >& GetComponent() const { return m_xComponent; }
174 // XEventListener
175 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
177 // XCloseListener
178 virtual void SAL_CALL queryClosing( const css::lang::EventObject& Source, sal_Bool GetsOwnership ) override;
179 virtual void SAL_CALL notifyClosing( const css::lang::EventObject& Source ) override;
181 // XTerminateListener
182 virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override;
183 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override;
185 // XModifyListener
186 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
188 // XEventListener
189 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override;
191 // XBorderResizeListener
192 virtual void SAL_CALL borderWidthsChanged( const css::uno::Reference< css::uno::XInterface >& aObject, const css::frame::BorderWidths& aNewSize ) override;
194 // XHatchWindowController
195 virtual void SAL_CALL requestPositioning( const css::awt::Rectangle& aRect ) override;
196 virtual css::awt::Rectangle SAL_CALL calcAdjustedRectangle( const css::awt::Rectangle& aRect ) override;
197 virtual void SAL_CALL activated( ) override;
198 virtual void SAL_CALL deactivated( ) override;
201 #endif
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */