Line data Source code
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 : #ifndef INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DOCHOLDER_HXX
21 : #define INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DOCHOLDER_HXX
22 :
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>
39 :
40 : class OCommonEmbeddedObject;
41 : class Interceptor;
42 :
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 >
51 : {
52 : private:
53 :
54 : OCommonEmbeddedObject* m_pEmbedObj;
55 :
56 : Interceptor* m_pInterceptor;
57 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
58 :
59 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
60 :
61 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent;
62 :
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
66 :
67 : ::com::sun::star::awt::Rectangle m_aObjRect;
68 : ::com::sun::star::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 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xCachedDocAreaAcc;
83 :
84 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOutplaceFrameProps;
85 :
86 :
87 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetDocFrame();
88 : bool LoadDocToFrame( bool );
89 :
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 );
92 :
93 : void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle& aHatchRect );
94 :
95 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > RetrieveOwnMenu_Impl();
96 : 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 );
101 :
102 : public:
103 :
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 );
108 :
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 );
116 :
117 :
118 : DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
119 : OCommonEmbeddedObject* pEmbObj );
120 : virtual ~DocumentHolder();
121 :
122 0 : OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; }
123 :
124 : void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, bool bReadOnly );
125 : void ResizeHatchWindow();
126 : void LockOffice();
127 : void FreeOffice();
128 :
129 : void CloseDocument( bool bDeliverOwnership, bool bWaitForClose );
130 : void CloseFrame();
131 :
132 0 : OUString GetTitle() const
133 : {
134 0 : return m_aContainerName + OUString( " - " ) + m_aDocumentNamePart;
135 : }
136 :
137 : OUString GetContainerName() const { return m_aContainerName; }
138 :
139 0 : void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aProps )
140 0 : { m_aOutplaceFrameProps = aProps; }
141 :
142 : void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect );
143 :
144 : bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
145 : bool bVisible );
146 :
147 : 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 );
150 :
151 : bool ShowUI(
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 );
155 : bool HideUI(
156 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM );
157 :
158 : void Show();
159 :
160 : bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize );
161 : bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize );
162 :
163 : sal_Int32 GetMapUnit( sal_Int64 nAspect );
164 :
165 0 : void SetOutplaceDispatchInterceptor(
166 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >&
167 : xOutplaceInterceptor )
168 : {
169 0 : m_xOutplaceInterceptor = xOutplaceInterceptor;
170 0 : }
171 :
172 34805 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; }
173 :
174 : // XEventListener
175 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 :
177 : // XCloseListener
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, std::exception) SAL_OVERRIDE;
179 : virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 :
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, std::exception) SAL_OVERRIDE;
183 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 :
185 : // XModifyListener
186 : virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
187 :
188 : // XEventListener
189 : virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
190 :
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, std::exception) SAL_OVERRIDE;
193 :
194 : // XHatchWindowController
195 : virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 : virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 : virtual void SAL_CALL activated( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 : virtual void SAL_CALL deactivated( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 : };
200 :
201 : #endif
202 :
203 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|