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 113 static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > MergeMenuesForInplace( 114 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xContMenu, 115 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContDisp, 116 const ::rtl::OUString& aContModuleName, 117 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xOwnMenu, 118 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xOwnDisp ); 119 120 121 DocumentHolder( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory, 122 OCommonEmbeddedObject* pEmbObj ); 123 ~DocumentHolder(); 124 GetEmbedObject()125 OCommonEmbeddedObject* GetEmbedObject() { return m_pEmbedObj; } 126 127 void SetComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable >& xDoc, sal_Bool bReadOnly ); 128 void ResizeHatchWindow(); 129 void LockOffice(); 130 void FreeOffice(); 131 132 void CloseDocument( sal_Bool bDeliverOwnership, sal_Bool bWaitForClose ); 133 void CloseFrame(); 134 GetTitle() const135 rtl::OUString GetTitle() const 136 { 137 return m_aContainerName + ::rtl::OUString::createFromAscii( " - " ) + m_aDocumentNamePart; 138 } 139 GetContainerName() const140 rtl::OUString GetContainerName() const { return m_aContainerName; } 141 SetOutplaceFrameProperties(const::com::sun::star::uno::Sequence<::com::sun::star::uno::Any> aProps)142 void SetOutplaceFrameProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aProps ) 143 { m_aOutplaceFrameProps = aProps; } 144 145 void PlaceFrame( const ::com::sun::star::awt::Rectangle& aNewRect ); 146 147 sal_Bool SetFrameLMVisibility( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, 148 sal_Bool bVisible ); 149 150 sal_Bool ShowInplace( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xParent, 151 const ::com::sun::star::awt::Rectangle& aRectangleToShow, 152 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP ); 153 154 sal_Bool ShowUI( 155 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM, 156 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xContainerDP, 157 const ::rtl::OUString& aContModuleName ); 158 sal_Bool HideUI( 159 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& xContainerLM ); 160 161 void Show(); 162 163 // sal_Bool SetVisArea( sal_Int64 nAspect, const ::com::sun::star::awt::Rectangle& aRect ); 164 // sal_Bool GetVisArea( sal_Int64 nAspect, ::com::sun::star::awt::Rectangle *pRect ); 165 sal_Bool SetExtent( sal_Int64 nAspect, const ::com::sun::star::awt::Size& aSize ); 166 sal_Bool GetExtent( sal_Int64 nAspect, ::com::sun::star::awt::Size *pSize ); 167 168 sal_Int32 GetMapUnit( sal_Int64 nAspect ); 169 SetOutplaceDispatchInterceptor(const::com::sun::star::uno::Reference<::com::sun::star::frame::XDispatchProviderInterceptor> & xOutplaceInterceptor)170 void SetOutplaceDispatchInterceptor( 171 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& 172 xOutplaceInterceptor ) 173 { 174 m_xOutplaceInterceptor = xOutplaceInterceptor; 175 } 176 GetComponent()177 ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > GetComponent() { return m_xComponent; } 178 179 // XEventListener 180 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ); 181 182 // XCloseListener 183 virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& Source, sal_Bool GetsOwnership ); 184 virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& Source ); 185 186 // XTerminateListener 187 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ); 188 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ); 189 190 // XModifyListener 191 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ); 192 193 // XEventListener 194 virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ); 195 196 // XBorderResizeListener 197 virtual void SAL_CALL borderWidthsChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& aObject, const ::com::sun::star::frame::BorderWidths& aNewSize ); 198 199 // XHatchWindowController 200 virtual void SAL_CALL requestPositioning( const ::com::sun::star::awt::Rectangle& aRect ); 201 virtual ::com::sun::star::awt::Rectangle SAL_CALL calcAdjustedRectangle( const ::com::sun::star::awt::Rectangle& aRect ); 202 virtual void SAL_CALL activated( ); 203 virtual void SAL_CALL deactivated( ); 204 }; 205 206 #endif 207