1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DOCHOLDER_HXX_ 25 #define _DOCHOLDER_HXX_ 26 27 #include <com/sun/star/util/XCloseListener.hpp> 28 #include <com/sun/star/frame/XTerminateListener.hpp> 29 #include <com/sun/star/util/XModifyListener.hpp> 30 #include <com/sun/star/util/XCloseable.hpp> 31 #include <com/sun/star/document/XEventListener.hpp> 32 #include <com/sun/star/frame/XFrame.hpp> 33 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> 34 #include <com/sun/star/frame/XBorderResizeListener.hpp> 35 #ifndef _COM_SUN_STAR_FRAME_XBORDERWIDTHS_HPP_ 36 #include <com/sun/star/frame/BorderWidths.hpp> 37 #endif 38 #include <com/sun/star/awt/XWindowPeer.hpp> 39 #include <com/sun/star/awt/Size.hpp> 40 #include <com/sun/star/awt/Rectangle.hpp> 41 #include <com/sun/star/embed/XHatchWindowController.hpp> 42 #include <com/sun/star/frame/XLayoutManager.hpp> 43 #include <cppuhelper/implbase6.hxx> 44 45 class OCommonEmbeddedObject; 46 class Interceptor; 47 48 class DocumentHolder : 49 public ::cppu::WeakImplHelper6< 50 ::com::sun::star::util::XCloseListener, 51 ::com::sun::star::frame::XTerminateListener, 52 ::com::sun::star::util::XModifyListener, 53 ::com::sun::star::document::XEventListener, 54 ::com::sun::star::frame::XBorderResizeListener, 55 ::com::sun::star::embed::XHatchWindowController > 56 { 57 private: 58 59 OCommonEmbeddedObject* m_pEmbedObj; 60 61 Interceptor* m_pInterceptor; 62 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor; 63 64 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 65 66 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent; 67 68 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; 69 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xOwnWindow; // set for inplace objects 70 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xHatchWindow; // set for inplace objects 71 72 ::com::sun::star::awt::Rectangle m_aObjRect; 73 ::com::sun::star::frame::BorderWidths m_aBorderWidths; 74 75 ::rtl::OUString m_aContainerName; 76 ::rtl::OUString m_aDocumentNamePart; 77 78 sal_Bool m_bReadOnly; 79 80 sal_Bool m_bWaitForClose; 81 sal_Bool m_bAllowClosing; 82 sal_Bool m_bDesktopTerminated; 83 84 sal_Int32 m_nNoBorderResizeReact; 85 sal_Int32 m_nNoResizeReact; 86 87 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xCachedDocAreaAcc; 88 89 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOutplaceFrameProps; 90 91 92 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetDocFrame(); 93 sal_Bool LoadDocToFrame( sal_Bool ); 94 95 ::com::sun::star::awt::Rectangle CalculateBorderedArea( const ::com::sun::star::awt::Rectangle& aRect ); 96 ::com::sun::star::awt::Rectangle AddBorderToArea( const ::com::sun::star::awt::Rectangle& aRect ); 97 98 void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle& aHatchRect ); 99 100 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > RetrieveOwnMenu_Impl(); 101 sal_Bool MergeMenues_Impl( 102 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xOwnLM, 103 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContLM, 104 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp, 105 const ::rtl::OUString& aContModuleName ); 106 107 public: 108 109 static void FindConnectPoints( 110 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMenu, 111 sal_Int32 nConnectPoints[2] ) 112 throw ( ::com::sun::star::uno::Exception ); 113 114 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > MergeMenuesForInplace( 115 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xContMenu, 116 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp, 117 const ::rtl::OUString& aContModuleName, 118 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xOwnMenu, 119 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xOwnDisp ) 120 throw ( ::com::sun::star::uno::Exception ); 121 122 123 DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 124 OCommonEmbeddedObject* pEmbObj ); 125 ~DocumentHolder(); 126 GetEmbedObject()127 OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; } 128 129 void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, sal_Bool bReadOnly ); 130 void ResizeHatchWindow(); 131 void LockOffice(); 132 void FreeOffice(); 133 134 void CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose ); 135 void CloseFrame(); 136 GetTitle() const137 rtl::OUString GetTitle() const 138 { 139 return m_aContainerName + ::rtl::OUString::createFromAscii( " - " ) + m_aDocumentNamePart; 140 } 141 GetContainerName() const142 rtl::OUString GetContainerName() const { return m_aContainerName; } 143 SetOutplaceFrameProperties(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> aProps)144 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aProps ) 145 { m_aOutplaceFrameProps = aProps; } 146 147 void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect ); 148 149 sal_Bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, 150 sal_Bool bVisible ); 151 152 sal_Bool ShowInplace( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, 153 const ::com::sun::star::awt::Rectangle& aRectangleToShow, 154 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP ); 155 156 sal_Bool ShowUI( 157 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM, 158 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP, 159 const ::rtl::OUString& aContModuleName ); 160 sal_Bool HideUI( 161 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM ); 162 163 void Show(); 164 165 // sal_Bool SetVisArea( sal_Int64 nAspect, const ::com::sun::star::awt::Rectangle& aRect ); 166 // sal_Bool GetVisArea( sal_Int64 nAspect, ::com::sun::star::awt::Rectangle *pRect ); 167 sal_Bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize ); 168 sal_Bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize ); 169 170 sal_Int32 GetMapUnit( sal_Int64 nAspect ); 171 SetOutplaceDispatchInterceptor(const::com::sun::star::uno::Reference<::com::sun::star::frame::XDispatchProviderInterceptor> & xOutplaceInterceptor)172 void SetOutplaceDispatchInterceptor( 173 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& 174 xOutplaceInterceptor ) 175 { 176 m_xOutplaceInterceptor = xOutplaceInterceptor; 177 } 178 GetComponent()179 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; } 180 181 // XEventListener 182 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 183 184 // XCloseListener 185 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); 186 virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 187 188 // XTerminateListener 189 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); 190 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); 191 192 // XModifyListener 193 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException ); 194 195 // XEventListener 196 virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 197 198 // XBorderResizeListener 199 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); 200 201 // XHatchWindowController 202 virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException); 203 virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException); 204 virtual void SAL_CALL activated( ) throw (::com::sun::star::uno::RuntimeException); 205 virtual void SAL_CALL deactivated( ) throw (::com::sun::star::uno::RuntimeException); 206 }; 207 208 #endif 209 210