1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _DOCHOLDER_HXX_ 29 #define _DOCHOLDER_HXX_ 30 31 #include <com/sun/star/util/XCloseListener.hpp> 32 #include <com/sun/star/frame/XTerminateListener.hpp> 33 #include <com/sun/star/util/XModifyListener.hpp> 34 #include <com/sun/star/util/XCloseable.hpp> 35 #include <com/sun/star/document/XEventListener.hpp> 36 #include <com/sun/star/frame/XFrame.hpp> 37 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> 38 #include <com/sun/star/frame/XBorderResizeListener.hpp> 39 #ifndef _COM_SUN_STAR_FRAME_XBORDERWIDTHS_HPP_ 40 #include <com/sun/star/frame/BorderWidths.hpp> 41 #endif 42 #include <com/sun/star/awt/XWindowPeer.hpp> 43 #include <com/sun/star/awt/Size.hpp> 44 #include <com/sun/star/awt/Rectangle.hpp> 45 #include <com/sun/star/embed/XHatchWindowController.hpp> 46 #include <com/sun/star/frame/XLayoutManager.hpp> 47 #include <cppuhelper/implbase6.hxx> 48 49 class OCommonEmbeddedObject; 50 class Interceptor; 51 52 class DocumentHolder : 53 public ::cppu::WeakImplHelper6< 54 ::com::sun::star::util::XCloseListener, 55 ::com::sun::star::frame::XTerminateListener, 56 ::com::sun::star::util::XModifyListener, 57 ::com::sun::star::document::XEventListener, 58 ::com::sun::star::frame::XBorderResizeListener, 59 ::com::sun::star::embed::XHatchWindowController > 60 { 61 private: 62 63 OCommonEmbeddedObject* m_pEmbedObj; 64 65 Interceptor* m_pInterceptor; 66 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor; 67 68 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; 69 70 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xComponent; 71 72 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; 73 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xOwnWindow; // set for inplace objects 74 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xHatchWindow; // set for inplace objects 75 76 ::com::sun::star::awt::Rectangle m_aObjRect; 77 ::com::sun::star::frame::BorderWidths m_aBorderWidths; 78 79 ::rtl::OUString m_aContainerName; 80 ::rtl::OUString m_aDocumentNamePart; 81 82 sal_Bool m_bReadOnly; 83 84 sal_Bool m_bWaitForClose; 85 sal_Bool m_bAllowClosing; 86 sal_Bool m_bDesktopTerminated; 87 88 sal_Int32 m_nNoBorderResizeReact; 89 sal_Int32 m_nNoResizeReact; 90 91 ::com::sun::star::uno::Reference< ::com::sun::star::ui::XDockingAreaAcceptor > m_xCachedDocAreaAcc; 92 93 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aOutplaceFrameProps; 94 95 96 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetDocFrame(); 97 sal_Bool LoadDocToFrame( sal_Bool ); 98 99 ::com::sun::star::awt::Rectangle CalculateBorderedArea( const ::com::sun::star::awt::Rectangle& aRect ); 100 ::com::sun::star::awt::Rectangle AddBorderToArea( const ::com::sun::star::awt::Rectangle& aRect ); 101 102 void ResizeWindows_Impl( const ::com::sun::star::awt::Rectangle& aHatchRect ); 103 104 ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > RetrieveOwnMenu_Impl(); 105 sal_Bool MergeMenues_Impl( 106 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xOwnLM, 107 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContLM, 108 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp, 109 const ::rtl::OUString& aContModuleName ); 110 111 public: 112 113 static void FindConnectPoints( 114 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xMenu, 115 sal_Int32 nConnectPoints[2] ) 116 throw ( ::com::sun::star::uno::Exception ); 117 118 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > MergeMenuesForInplace( 119 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xContMenu, 120 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp, 121 const ::rtl::OUString& aContModuleName, 122 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xOwnMenu, 123 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xOwnDisp ) 124 throw ( ::com::sun::star::uno::Exception ); 125 126 127 DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 128 OCommonEmbeddedObject* pEmbObj ); 129 ~DocumentHolder(); 130 131 OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; } 132 133 void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, sal_Bool bReadOnly ); 134 void ResizeHatchWindow(); 135 void LockOffice(); 136 void FreeOffice(); 137 138 void CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose ); 139 void CloseFrame(); 140 141 rtl::OUString GetTitle() const 142 { 143 return m_aContainerName + ::rtl::OUString::createFromAscii( " - " ) + m_aDocumentNamePart; 144 } 145 146 rtl::OUString GetContainerName() const { return m_aContainerName; } 147 148 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aProps ) 149 { m_aOutplaceFrameProps = aProps; } 150 151 void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect ); 152 153 sal_Bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, 154 sal_Bool bVisible ); 155 156 sal_Bool ShowInplace( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, 157 const ::com::sun::star::awt::Rectangle& aRectangleToShow, 158 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP ); 159 160 sal_Bool ShowUI( 161 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM, 162 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP, 163 const ::rtl::OUString& aContModuleName ); 164 sal_Bool HideUI( 165 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM ); 166 167 void Show(); 168 169 // sal_Bool SetVisArea( sal_Int64 nAspect, const ::com::sun::star::awt::Rectangle& aRect ); 170 // sal_Bool GetVisArea( sal_Int64 nAspect, ::com::sun::star::awt::Rectangle *pRect ); 171 sal_Bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize ); 172 sal_Bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize ); 173 174 sal_Int32 GetMapUnit( sal_Int64 nAspect ); 175 176 void SetOutplaceDispatchInterceptor( 177 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& 178 xOutplaceInterceptor ) 179 { 180 m_xOutplaceInterceptor = xOutplaceInterceptor; 181 } 182 183 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; } 184 185 // XEventListener 186 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 187 188 // XCloseListener 189 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); 190 virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 191 192 // XTerminateListener 193 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); 194 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); 195 196 // XModifyListener 197 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException ); 198 199 // XEventListener 200 virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 201 202 // XBorderResizeListener 203 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); 204 205 // XHatchWindowController 206 virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException); 207 virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ) throw (::com::sun::star::uno::RuntimeException); 208 virtual void SAL_CALL activated( ) throw (::com::sun::star::uno::RuntimeException); 209 virtual void SAL_CALL deactivated( ) throw (::com::sun::star::uno::RuntimeException); 210 }; 211 212 #endif 213 214