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 _DOCHOLDER_HXX_
21 : #define _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 <cppuhelper/implbase6.hxx>
38 :
39 : class OCommonEmbeddedObject;
40 : class Interceptor;
41 :
42 : class DocumentHolder :
43 : public ::cppu::WeakImplHelper6<
44 : ::com::sun::star::util::XCloseListener,
45 : ::com::sun::star::frame::XTerminateListener,
46 : ::com::sun::star::util::XModifyListener,
47 : ::com::sun::star::document::XEventListener,
48 : ::com::sun::star::frame::XBorderResizeListener,
49 : ::com::sun::star::embed::XHatchWindowController >
50 : {
51 : private:
52 :
53 : OCommonEmbeddedObject* m_pEmbedObj;
54 :
55 : Interceptor* m_pInterceptor;
56 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
57 :
58 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
59 :
60 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent;
61 :
62 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
63 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xOwnWindow; // set for inplace objects
64 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xHatchWindow; // set for inplace objects
65 :
66 : ::com::sun::star::awt::Rectangle m_aObjRect;
67 : ::com::sun::star::frame::BorderWidths m_aBorderWidths;
68 :
69 : ::rtl::OUString m_aContainerName;
70 : ::rtl::OUString m_aDocumentNamePart;
71 :
72 : sal_Bool m_bReadOnly;
73 :
74 : sal_Bool m_bWaitForClose;
75 : sal_Bool m_bAllowClosing;
76 : sal_Bool m_bDesktopTerminated;
77 :
78 : sal_Int32 m_nNoBorderResizeReact;
79 : sal_Int32 m_nNoResizeReact;
80 :
81 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xCachedDocAreaAcc;
82 :
83 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOutplaceFrameProps;
84 :
85 :
86 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetDocFrame();
87 : sal_Bool LoadDocToFrame( sal_Bool );
88 :
89 : ::com::sun::star::awt::Rectangle CalculateBorderedArea( const ::com::sun::star::awt::Rectangle& aRect );
90 : ::com::sun::star::awt::Rectangle AddBorderToArea( const ::com::sun::star::awt::Rectangle& aRect );
91 :
92 : void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle& aHatchRect );
93 :
94 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > RetrieveOwnMenu_Impl();
95 : sal_Bool MergeMenues_Impl(
96 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xOwnLM,
97 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContLM,
98 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp,
99 : const ::rtl::OUString& aContModuleName );
100 :
101 : public:
102 :
103 : static void FindConnectPoints(
104 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMenu,
105 : sal_Int32 nConnectPoints[2] )
106 : throw ( ::com::sun::star::uno::Exception );
107 :
108 : static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > MergeMenuesForInplace(
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xContMenu,
110 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp,
111 : const ::rtl::OUString& aContModuleName,
112 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xOwnMenu,
113 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xOwnDisp )
114 : throw ( ::com::sun::star::uno::Exception );
115 :
116 :
117 : DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
118 : OCommonEmbeddedObject* pEmbObj );
119 : ~DocumentHolder();
120 :
121 0 : OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; }
122 :
123 : void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, sal_Bool bReadOnly );
124 : void ResizeHatchWindow();
125 : void LockOffice();
126 : void FreeOffice();
127 :
128 : void CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose );
129 : void CloseFrame();
130 :
131 0 : rtl::OUString GetTitle() const
132 : {
133 0 : return m_aContainerName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( " - " )) + m_aDocumentNamePart;
134 : }
135 :
136 : rtl::OUString GetContainerName() const { return m_aContainerName; }
137 :
138 0 : void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aProps )
139 0 : { m_aOutplaceFrameProps = aProps; }
140 :
141 : void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect );
142 :
143 : sal_Bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
144 : sal_Bool bVisible );
145 :
146 : sal_Bool ShowInplace( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent,
147 : const ::com::sun::star::awt::Rectangle& aRectangleToShow,
148 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP );
149 :
150 : sal_Bool ShowUI(
151 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM,
152 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP,
153 : const ::rtl::OUString& aContModuleName );
154 : sal_Bool HideUI(
155 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM );
156 :
157 : void Show();
158 :
159 : sal_Bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize );
160 : sal_Bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize );
161 :
162 : sal_Int32 GetMapUnit( sal_Int64 nAspect );
163 :
164 0 : void SetOutplaceDispatchInterceptor(
165 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >&
166 : xOutplaceInterceptor )
167 : {
168 0 : m_xOutplaceInterceptor = xOutplaceInterceptor;
169 0 : }
170 :
171 5931 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; }
172 :
173 : // XEventListener
174 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
175 :
176 : // XCloseListener
177 : 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);
178 : virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
179 :
180 : // XTerminateListener
181 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
182 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
183 :
184 : // XModifyListener
185 : virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException );
186 :
187 : // XEventListener
188 : virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw ( ::com::sun::star::uno::RuntimeException );
189 :
190 : // XBorderResizeListener
191 : 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);
192 :
193 : // XHatchWindowController
194 : virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException);
195 : virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException);
196 : virtual void SAL_CALL activated( ) throw (::com::sun::star::uno::RuntimeException);
197 : virtual void SAL_CALL deactivated( ) throw (::com::sun::star::uno::RuntimeException);
198 : };
199 :
200 : #endif
201 :
202 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|