/src/libreoffice/embeddedobj/source/inc/docholder.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #pragma once |
21 | | |
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> |
39 | | |
40 | | class OCommonEmbeddedObject; |
41 | | |
42 | | namespace embeddedobj |
43 | | { |
44 | | class Interceptor; |
45 | | |
46 | | class DocumentHolder : |
47 | | public ::cppu::WeakImplHelper< |
48 | | css::util::XCloseListener, |
49 | | css::frame::XTerminateListener, |
50 | | css::util::XModifyListener, |
51 | | css::document::XEventListener, |
52 | | css::frame::XBorderResizeListener, |
53 | | css::embed::XHatchWindowController > |
54 | | { |
55 | | private: |
56 | | |
57 | | OCommonEmbeddedObject& m_rEmbedObj; |
58 | | |
59 | | rtl::Reference<Interceptor> m_xInterceptor; |
60 | | css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor; |
61 | | |
62 | | css::uno::Reference< css::uno::XComponentContext > m_xContext; |
63 | | |
64 | | css::uno::Reference< css::util::XCloseable > m_xComponent; |
65 | | |
66 | | css::uno::Reference< css::frame::XFrame > m_xFrame; |
67 | | css::uno::Reference< css::awt::XWindow > m_xOwnWindow; // set for inplace objects |
68 | | css::uno::Reference< css::awt::XWindow > m_xHatchWindow; // set for inplace objects |
69 | | |
70 | | css::awt::Rectangle m_aObjRect; |
71 | | css::frame::BorderWidths m_aBorderWidths; |
72 | | |
73 | | OUString m_aContainerName; |
74 | | OUString m_aDocumentNamePart; |
75 | | |
76 | | bool m_bReadOnly; |
77 | | |
78 | | bool m_bWaitForClose; |
79 | | bool m_bAllowClosing; |
80 | | bool m_bDesktopTerminated; |
81 | | |
82 | | sal_Int32 m_nNoBorderResizeReact; |
83 | | sal_Int32 m_nNoResizeReact; |
84 | | |
85 | | css::uno::Sequence< css::uno::Any > m_aOutplaceFrameProps; |
86 | | |
87 | | |
88 | | css::uno::Reference< css::frame::XFrame > const & GetDocFrame(); |
89 | | bool LoadDocToFrame( bool ); |
90 | | |
91 | | css::awt::Rectangle CalculateBorderedArea( const css::awt::Rectangle& aRect ); |
92 | | css::awt::Rectangle AddBorderToArea( const css::awt::Rectangle& aRect ); |
93 | | |
94 | | void ResizeWindows_Impl( const css::awt::Rectangle& aHatchRect ); |
95 | | |
96 | | css::uno::Reference< css::container::XIndexAccess > RetrieveOwnMenu_Impl(); |
97 | | bool MergeMenus_Impl( |
98 | | const css::uno::Reference< css::frame::XLayoutManager >& xOwnLM, |
99 | | const css::uno::Reference< css::frame::XLayoutManager >& xContLM, |
100 | | const css::uno::Reference< css::frame::XDispatchProvider >& xContDisp, |
101 | | const OUString& aContModuleName ); |
102 | | |
103 | | sal_Int32 getHatchBorderWidth(); |
104 | | |
105 | | public: |
106 | | /// @throws css::uno::Exception |
107 | | static void FindConnectPoints( |
108 | | const css::uno::Reference< css::container::XIndexAccess >& xMenu, |
109 | | sal_Int32 nConnectPoints[2] ); |
110 | | |
111 | | /// @throws css::uno::Exception |
112 | | static css::uno::Reference< css::container::XIndexAccess > MergeMenusForInplace( |
113 | | const css::uno::Reference< css::container::XIndexAccess >& xContMenu, |
114 | | const css::uno::Reference< css::frame::XDispatchProvider >& xContDisp, |
115 | | const OUString& aContModuleName, |
116 | | const css::uno::Reference< css::container::XIndexAccess >& xOwnMenu, |
117 | | const css::uno::Reference< css::frame::XDispatchProvider >& xOwnDisp ); |
118 | | |
119 | | |
120 | | DocumentHolder( css::uno::Reference< css::uno::XComponentContext > xContext, |
121 | | OCommonEmbeddedObject& rEmbObj ); |
122 | | virtual ~DocumentHolder() override; |
123 | | |
124 | 0 | OCommonEmbeddedObject& GetEmbedObject() { return m_rEmbedObj; } |
125 | | |
126 | | void SetComponent( const css::uno::Reference< css::util::XCloseable >& xDoc, bool bReadOnly ); |
127 | | void ResizeHatchWindow(); |
128 | | void FreeOffice(); |
129 | | |
130 | | void CloseDocument( bool bDeliverOwnership, bool bWaitForClose ); |
131 | | void CloseFrame(); |
132 | | |
133 | | OUString GetTitle() const |
134 | 0 | { |
135 | 0 | return m_aContainerName + ( m_aDocumentNamePart.isEmpty() ? OUString() : ( " - " + m_aDocumentNamePart ) ); |
136 | 0 | } |
137 | | |
138 | | OUString const & GetContainerName() const |
139 | 0 | { |
140 | 0 | return m_aContainerName; |
141 | 0 | } |
142 | | |
143 | | void SetOutplaceFrameProperties( const css::uno::Sequence< css::uno::Any >& aProps ) |
144 | 0 | { m_aOutplaceFrameProps = aProps; } |
145 | | |
146 | | void PlaceFrame( const css::awt::Rectangle& aNewRect ); |
147 | | |
148 | | static bool SetFrameLMVisibility( const css::uno::Reference< css::frame::XFrame >& xFrame, |
149 | | bool bVisible ); |
150 | | |
151 | | bool ShowInplace( const css::uno::Reference< css::awt::XWindowPeer >& xParent, |
152 | | const css::awt::Rectangle& aRectangleToShow, |
153 | | const css::uno::Reference< css::frame::XDispatchProvider >& xContainerDP ); |
154 | | |
155 | | bool ShowUI( |
156 | | const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM, |
157 | | const css::uno::Reference< css::frame::XDispatchProvider >& xContainerDP, |
158 | | const OUString& aContModuleName ); |
159 | | bool HideUI( |
160 | | const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM ); |
161 | | |
162 | | void Show(); |
163 | | |
164 | | bool SetExtent( sal_Int64 nAspect, const css::awt::Size& aSize ); |
165 | | bool GetExtent( sal_Int64 nAspect, css::awt::Size *pSize ); |
166 | | |
167 | | sal_Int32 GetMapUnit( sal_Int64 nAspect ); |
168 | | |
169 | | void SetOutplaceDispatchInterceptor( |
170 | | const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& |
171 | | xOutplaceInterceptor ) |
172 | 0 | { |
173 | 0 | m_xOutplaceInterceptor = xOutplaceInterceptor; |
174 | 0 | } |
175 | | |
176 | 0 | const css::uno::Reference< css::util::XCloseable >& GetComponent() const { return m_xComponent; } |
177 | | |
178 | | // XEventListener |
179 | | virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; |
180 | | |
181 | | // XCloseListener |
182 | | virtual void SAL_CALL queryClosing( const css::lang::EventObject& Source, sal_Bool GetsOwnership ) override; |
183 | | virtual void SAL_CALL notifyClosing( const css::lang::EventObject& Source ) override; |
184 | | |
185 | | // XTerminateListener |
186 | | virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override; |
187 | | virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override; |
188 | | |
189 | | // XModifyListener |
190 | | virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; |
191 | | |
192 | | // XEventListener |
193 | | virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override; |
194 | | |
195 | | // XBorderResizeListener |
196 | | virtual void SAL_CALL borderWidthsChanged( const css::uno::Reference< css::uno::XInterface >& aObject, const css::frame::BorderWidths& aNewSize ) override; |
197 | | |
198 | | // XHatchWindowController |
199 | | virtual void SAL_CALL requestPositioning( const css::awt::Rectangle& aRect ) override; |
200 | | virtual css::awt::Rectangle SAL_CALL calcAdjustedRectangle( const css::awt::Rectangle& aRect ) override; |
201 | | virtual void SAL_CALL activated( ) override; |
202 | | virtual void SAL_CALL deactivated( ) override; |
203 | | }; |
204 | | |
205 | | } // namespace embeddedobj |
206 | | |
207 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |