LibreOffice Module embeddedobj (master) 1
docholder.hxx
Go to the documentation of this file.
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>
38#include <rtl/ref.hxx>
39
41class Interceptor;
42
43class 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 >
51{
52private:
53
54 OCommonEmbeddedObject* m_pEmbedObj;
55
56 rtl::Reference<Interceptor> m_xInterceptor;
57 css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
58
59 css::uno::Reference< css::uno::XComponentContext > m_xContext;
60
61 css::uno::Reference< css::util::XCloseable > m_xComponent;
62
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
66
67 css::awt::Rectangle m_aObjRect;
68 css::frame::BorderWidths m_aBorderWidths;
69
70 OUString m_aContainerName;
71 OUString m_aDocumentNamePart;
72
73 bool m_bReadOnly;
74
75 bool m_bWaitForClose;
76 bool m_bAllowClosing;
77 bool m_bDesktopTerminated;
78
79 sal_Int32 m_nNoBorderResizeReact;
80 sal_Int32 m_nNoResizeReact;
81
82 css::uno::Sequence< css::uno::Any > m_aOutplaceFrameProps;
83
84
85 css::uno::Reference< css::frame::XFrame > const & GetDocFrame();
86 bool LoadDocToFrame( bool );
87
88 css::awt::Rectangle CalculateBorderedArea( const css::awt::Rectangle& aRect );
89 css::awt::Rectangle AddBorderToArea( const css::awt::Rectangle& aRect );
90
91 void ResizeWindows_Impl( const css::awt::Rectangle& aHatchRect );
92
93 css::uno::Reference< css::container::XIndexAccess > RetrieveOwnMenu_Impl();
94 bool MergeMenus_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 );
99
100public:
102 static void FindConnectPoints(
103 const css::uno::Reference< css::container::XIndexAccess >& xMenu,
104 sal_Int32 nConnectPoints[2] );
105
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 );
113
114
115 DocumentHolder( css::uno::Reference< css::uno::XComponentContext > xContext,
116 OCommonEmbeddedObject* pEmbObj );
117 virtual ~DocumentHolder() override;
118
119 OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; }
120
121 void SetComponent( const css::uno::Reference< css::util::XCloseable >& xDoc, bool bReadOnly );
122 void ResizeHatchWindow();
123 void FreeOffice();
124
125 void CloseDocument( bool bDeliverOwnership, bool bWaitForClose );
126 void CloseFrame();
127
128 OUString GetTitle() const
129 {
130 return m_aContainerName + ( m_aDocumentNamePart.isEmpty() ? OUString() : ( " - " + m_aDocumentNamePart ) );
131 }
132
133 OUString const & GetContainerName() const
134 {
135 return m_aContainerName;
136 }
137
138 void SetOutplaceFrameProperties( const css::uno::Sequence< css::uno::Any >& aProps )
139 { m_aOutplaceFrameProps = aProps; }
140
141 void PlaceFrame( const css::awt::Rectangle& aNewRect );
142
143 static bool SetFrameLMVisibility( const css::uno::Reference< css::frame::XFrame >& xFrame,
144 bool bVisible );
145
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 );
149
150 bool ShowUI(
151 const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM,
152 const css::uno::Reference< css::frame::XDispatchProvider >& xContainerDP,
153 const OUString& aContModuleName );
154 bool HideUI(
155 const css::uno::Reference< css::frame::XLayoutManager >& xContainerLM );
156
157 void Show();
158
159 bool SetExtent( sal_Int64 nAspect, const css::awt::Size& aSize );
160 bool GetExtent( sal_Int64 nAspect, css::awt::Size *pSize );
161
162 sal_Int32 GetMapUnit( sal_Int64 nAspect );
163
164 void SetOutplaceDispatchInterceptor(
165 const css::uno::Reference< css::frame::XDispatchProviderInterceptor >&
166 xOutplaceInterceptor )
167 {
168 m_xOutplaceInterceptor = xOutplaceInterceptor;
169 }
170
171 const css::uno::Reference< css::util::XCloseable >& GetComponent() const { return m_xComponent; }
172
173// XEventListener
174 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
175
176// XCloseListener
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;
179
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;
183
184// XModifyListener
185 virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override;
186
187// XEventListener
188 virtual void SAL_CALL notifyEvent( const css::document::EventObject& Event ) override;
189
190// XBorderResizeListener
191 virtual void SAL_CALL borderWidthsChanged( const css::uno::Reference< css::uno::XInterface >& aObject, const css::frame::BorderWidths& aNewSize ) override;
192
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;
198};
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL disposing(const css::lang::EventObject &aSource) override
Definition: docholder.cxx:1091
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &aSource) override
virtual void SAL_CALL queryTermination(const css::lang::EventObject &aSource) override
~DocumentHolder() override
Definition: docholder.cxx:181
virtual void SAL_CALL queryClosing(const css::lang::EventObject &aSource, sal_Bool bGetsOwnership) override
HRESULT GetExtent(SIZEL *pSize)
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
OUString m_aContainerName
Definition: docholder.hxx:70
virtual void SAL_CALL notifyClosing(const css::lang::EventObject &aSource) override
void CloseFrame()
Definition: docholder.cxx:206
void FreeOffice()
Definition: docholder.cxx:234
HRESULT SetExtent(const SIZEL *pSize)
void CloseDocument()
OUString m_aDocumentNamePart
Definition: docholder.hxx:71
css::uno::Reference< css::frame::XFrame2 > m_xFrame
DocumentHolder(const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory, const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > &xOleAccess)
Represents an OLE object that has native data and we loaded that data into a document model successfu...
unsigned char sal_Bool