1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docholder.cxx,v $
10 * $Revision: 1.31.10.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #if defined(_MSC_VER) && (_MSC_VER > 1310)
31 #pragma warning(disable : 4917 4555)
36 #include "docholder.hxx"
37 #include "embeddoc.hxx"
38 #include "intercept.hxx"
39 #include "syswinwrapper.hxx"
40 #include "iipaobj.hxx"
44 #include <com/sun/star/lang/SystemDependent.hpp>
45 #include <com/sun/star/awt/XSystemChildFactory.hpp>
46 #ifndef _COM_SUN_STAR_AWT_XSYSTEMDEPENDENTWINDOWPERR_HPP_
47 #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
49 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
50 #include <com/sun/star/ui/XUIElement.hpp>
51 #include <com/sun/star/awt/WindowAttribute.hpp>
52 #include <com/sun/star/awt/XWindow.hpp>
53 #include <com/sun/star/frame/XComponentLoader.hpp>
54 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
55 #include <com/sun/star/util/XCloseBroadcaster.hpp>
56 #include <com/sun/star/util/XCloseAble.hpp>
57 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACESS_HPP_
58 #include <com/sun/star/container/XNameAccess.hpp>
60 #include <com/sun/star/beans/XPropertySet.hpp>
61 #include <com/sun/star/frame/XModel.hpp>
62 #include <com/sun/star/frame/XDesktop.hpp>
63 #include <com/sun/star/frame/XFramesSupplier.hpp>
64 #include <com/sun/star/frame/FrameSearchFlag.hpp>
65 #include <com/sun/star/frame/XStatusListener.hpp>
66 #include <com/sun/star/util/XModifyBroadcaster.hpp>
67 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
68 #include <com/sun/star/awt/XTopWindow.hpp>
69 #include <com/sun/star/awt/PosSize.hpp>
70 #include <com/sun/star/awt/XView.hpp>
71 #include <com/sun/star/bridge/XBridgeSupplier2.hpp>
72 #include <com/sun/star/bridge/ModelDependent.hpp>
73 #include <com/sun/star/embed/EmbedMapUnits.hpp>
74 #include <com/sun/star/embed/XVisualObject.hpp>
75 #include <com/sun/star/document/MacroExecMode.hpp>
76 #include <com/sun/star/task/XInteractionHandler.hpp>
77 #include <osl/diagnose.h>
78 #include <rtl/process.h>
80 using namespace ::com::sun::star
;
82 extern ::rtl::OUString
getFilterNameFromGUID_Impl( GUID
* );
84 // add mutex locking ???
86 DocumentHolder::DocumentHolder(
87 const uno::Reference
<lang::XMultiServiceFactory
>& xFactory
,
88 const ::rtl::Reference
< EmbeddedDocumentInstanceAccess_Impl
>& xOleAccess
)
90 m_bAllowInPlace(true),
95 m_xOleAccess( xOleAccess
),
97 m_xFactory( xFactory
),
98 m_bOnDeactivate(false),
99 m_hWndxWinParent(NULL
),
100 m_hWndxWinCont(NULL
),
104 m_nMacroExecMode( document::MacroExecMode::USE_CONFIG
),
107 static const ::rtl::OUString
aServiceName (
108 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
109 uno::Reference
< frame::XDesktop
> xDesktop(
110 m_xFactory
->createInstance( aServiceName
),
113 xDesktop
->addTerminateListener( (frame::XTerminateListener
*)this );
117 DocumentHolder::~DocumentHolder()
121 ClearInterceptorInternally();
125 void DocumentHolder::LoadDocInFrame( sal_Bool bPluginMode
)
127 uno::Reference
<frame::XComponentLoader
> xComponentLoader(
128 m_xFrame
,uno::UNO_QUERY
);
129 if( xComponentLoader
.is() && m_xDocument
.is() )
131 uno::Reference
< task::XInteractionHandler
> xHandler(
132 m_xFactory
->createInstance(
133 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) ),
138 uno::Sequence
<beans::PropertyValue
> aSeq( nLen
);
140 aAny
<<= uno::Reference
<uno::XInterface
>(
141 m_xDocument
, uno::UNO_QUERY
);
142 aSeq
[0] = beans::PropertyValue(
144 RTL_CONSTASCII_USTRINGPARAM("Model")),
147 beans::PropertyState_DIRECT_VALUE
);
150 aSeq
[1] = beans::PropertyValue(
152 RTL_CONSTASCII_USTRINGPARAM("ReadOnly")),
155 beans::PropertyState_DIRECT_VALUE
);
157 aAny
<<= (sal_Bool
) sal_True
;
158 aSeq
[2] = beans::PropertyValue(
160 RTL_CONSTASCII_USTRINGPARAM("NoAutoSave")),
163 beans::PropertyState_DIRECT_VALUE
);
167 aSeq
.realloc( ++nLen
);
168 aAny
<<= (sal_Int16
) 3;
169 aSeq
[nLen
-1] = beans::PropertyValue(
171 RTL_CONSTASCII_USTRINGPARAM("PluginMode")),
174 beans::PropertyState_DIRECT_VALUE
);
179 aSeq
.realloc( nLen
+=2 );
181 aSeq
[nLen
-2] = beans::PropertyValue(
183 RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")),
186 beans::PropertyState_DIRECT_VALUE
);
188 aAny
<<= m_nMacroExecMode
;
189 aSeq
[nLen
-1] = beans::PropertyValue(
191 RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode")),
194 beans::PropertyState_DIRECT_VALUE
);
197 xComponentLoader
->loadComponentFromURL(
199 RTL_CONSTASCII_USTRINGPARAM("private:object")),
200 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")),
204 uno::Sequence
< beans::PropertyValue
> aResArgs
= m_xDocument
->getArgs();
205 for ( int nInd
= 0; nInd
< aResArgs
.getLength(); nInd
++ )
206 if ( aResArgs
[nInd
].Name
.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MacroExecutionMode" ) ) ) )
208 aResArgs
[nInd
].Value
>>= m_nMacroExecMode
;
214 void DocumentHolder::OnPosRectChanged(LPRECT lpRect
) const
216 lpRect
->left
+= m_aBorder
.left
;
217 lpRect
->right
-= m_aBorder
.right
;
218 lpRect
->top
+= m_aBorder
.top
;
219 lpRect
->bottom
-= m_aBorder
.bottom
;
221 m_pIOleIPSite
->OnPosRectChange(lpRect
);
226 void DocumentHolder::DisableInplaceActivation(BOOL b
)
228 m_bAllowInPlace
= ! b
;
231 BOOL
DocumentHolder::isActive() const
233 return m_pIOleIPSite
!= 0;
236 HRESULT
DocumentHolder::InPlaceActivate(
237 LPOLECLIENTSITE pActiveSite
,
240 m_bOnDeactivate
= false;
249 OLEINPLACEFRAMEINFO frameInfo
;
251 if (NULL
==pActiveSite
)
252 return ResultFromScode(E_INVALIDARG
);
254 if (NULL
!=m_pIOleIPSite
)
262 if ( !m_xDocument
.is() )
265 //1. Initialization, obtaining interfaces, OnInPlaceActivate.
266 hr
=pActiveSite
->QueryInterface(
268 (void**) &m_pIOleIPSite
);
273 hr
=m_pIOleIPSite
->CanInPlaceActivate();
277 m_pIOleIPSite
->Release(), m_pIOleIPSite
=NULL
;
278 return ResultFromScode(E_FAIL
);
281 m_pIOleIPSite
->OnInPlaceActivate();
283 //2. Get the site window
284 //3. and determine container frame and
285 // document window for tools and menus, as well
286 // as frameInfo for accelerators
287 m_pIOleIPSite
->GetWindow(&hWndSite
);
289 frameInfo
.cb
=sizeof(OLEINPLACEFRAMEINFO
);
290 m_pIOleIPSite
->GetWindowContext(
291 &m_pIOleIPFrame
,&m_pIOleIPUIWindow
,&rcPos
,&rcClip
,&frameInfo
);
293 // initialize the office as, with hwnd as parentwindow
295 uno::Sequence
<sal_Int8
> aProcessIdent(16);
296 rtl_getGlobalProcessId((sal_uInt8
*)aProcessIdent
.getArray());
300 if(!m_xEditWindow
.is())
301 { // determine XWindow and window handle of parent
302 HWND
hWndxWinParent(0);
303 uno::Reference
<awt::XWindow
> xWin
;
305 static const ::rtl::OUString
aToolkitServiceName(
306 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.awt.Toolkit" ) );
307 uno::Reference
<awt::XSystemChildFactory
> xToolkit(
308 m_xFactory
->createInstance(aToolkitServiceName
),uno::UNO_QUERY
);
311 // create system window wrapper for hwnd
313 m_pCHatchWin
= new winwrap::CHatchWin(
316 if(m_pCHatchWin
->Init(hWndSite
,/*ID_HATCHWINDOW*/2000, NULL
)) {
317 m_pCHatchWin
->RectsSet(&rcPos
,&rcClip
); //set visible area
318 hWndxWinParent
= m_pCHatchWin
->Window();
319 ShowWindow(hWndxWinParent
,SW_SHOW
); //Make visible.
322 // no success initializing hatch window
323 delete m_pCHatchWin
, m_pCHatchWin
= 0;
324 hWndxWinParent
= hWndSite
;
327 aAny
<<= sal_Int32(hWndxWinParent
);
328 xWin
= uno::Reference
<awt::XWindow
>(
329 xToolkit
->createSystemChild(
332 lang::SystemDependent::SYSTEM_WIN32
),
338 m_pCHatchWin
? HATCHWIN_BORDERWIDTHDEFAULT
: 0,
339 m_pCHatchWin
? HATCHWIN_BORDERWIDTHDEFAULT
: 0,
340 rcPos
.right
-rcPos
.left
,
341 rcPos
.bottom
- rcPos
.top
,
342 awt::PosSize::POSSIZE
);
343 xWin
->setVisible(sal_True
);
345 m_xEditWindow
= xWin
;
346 m_hWndxWinParent
= hWndxWinParent
;
352 if(m_hWndxWinParent
) {
353 SetParent(m_hWndxWinParent
,hWndSite
);
354 ShowWindow(m_hWndxWinParent
,SW_SHOW
); //Make visible.
357 if ( !m_xFrame
.is() )
358 // initially set size to "empty", this guarantees that the final resize
359 // is always executed (will be done by "SetObjectRects" after getting internal border)
360 m_xEditWindow
->setPosSize(
365 awt::PosSize::POSSIZE
);
366 m_xEditWindow
->setVisible(sal_True
);
369 if(m_xContainerWindow
.is()) {
373 m_pIOleIPFrame
->GetWindow(&hWndCont
);
374 SetParent(m_hWndxWinCont
,hWndCont
);
375 ShowWindow(m_hWndxWinCont
,SW_SHOW
);
378 m_xContainerWindow
->setVisible(true);
382 m_xFrame
->activate();
384 // create frame and initialize it with with the created window
385 static const ::rtl::OUString
aFrameServiceName(
386 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Frame" ) );
387 m_xFrame
= uno::Reference
<frame::XFrame
>(
388 m_xFactory
->createInstance(aFrameServiceName
),
394 m_xFrame
->initialize(m_xEditWindow
);
396 uno::Reference
<frame::XDispatchProviderInterception
>
397 xDPI(m_xFrame
,uno::UNO_QUERY
);
399 xDPI
->registerDispatchProviderInterceptor( CreateNewInterceptor() );
401 uno::Reference
<beans::XPropertySet
> xPS(m_xFrame
,uno::UNO_QUERY
);
404 aAny
= xPS
->getPropertyValue(
405 rtl::OUString::createFromAscii("LayoutManager"));
406 aAny
>>= m_xLayoutManager
;
409 if(m_xLayoutManager
.is())
410 m_xLayoutManager
->setDockingAreaAcceptor(this);
412 // load the model into the frame
413 LoadDocInFrame( sal_True
);
415 static const ::rtl::OUString
aDesktopServiceName (
416 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
417 uno::Reference
< frame::XFramesSupplier
> xDesktop(
418 m_xFactory
->createInstance( aDesktopServiceName
),
421 xDesktop
->getFrames()->append(m_xFrame
);
423 // determine the menuhandle to get menutitems.
424 if(m_xLayoutManager
.is()) {
425 uno::Reference
< ::com::sun::star::ui::XUIElement
> xUIEl(
426 m_xLayoutManager
->getElement(
427 rtl::OUString::createFromAscii(
428 "private:resource/menubar/menubar")));
429 OSL_ENSURE(xUIEl
.is(),"no menubar");
430 uno::Reference
<awt::XSystemDependentMenuPeer
> xSDMP(
431 xUIEl
->getRealInterface(),
433 aAny
= xSDMP
->getMenuHandle(
434 aProcessIdent
,lang::SystemDependent::SYSTEM_WIN32
);
437 m_nMenuHandle
= HMENU(tmp
);
438 m_xLayoutManager
->hideElement(
440 RTL_CONSTASCII_USTRINGPARAM(
441 "private:resource/menubar/menubar" )));
445 // TODO/cd: Workaround for status indicator bug. It always makes the
446 // document window visible, when someone tries to use the status
447 // indicator. As we save our document when we get the deactivation
448 // from OLE this conflict to hide floating windows.
449 if(m_xLayoutManager
.is())
450 m_xLayoutManager
->setVisible(true);
452 // get document border and resize rects according to border
453 GetDocumentBorder( &m_aBorder
);
454 SetObjectRects( &rcPos
, &rcClip
);
456 if ( m_xOleAccess
.is() )
458 LockedEmbedDocument_Impl aDocLock
= m_xOleAccess
->GetEmbedDocument();
459 if ( aDocLock
.GetEmbedDocument() )
460 aDocLock
.GetEmbedDocument()->ShowObject();
463 // setTitle(m_aDocumentNamePart);
467 m_pIOleIPSite
->DiscardUndoState();
469 catch( uno::Exception
& )
478 void DocumentHolder::InPlaceDeactivate(void)
480 m_bOnDeactivate
= true;
483 if(m_xFrame
.is()) m_xFrame
->deactivate();
485 if(m_xEditWindow
.is()) {
486 m_xEditWindow
->setVisible(false);
487 ShowWindow(m_hWndxWinParent
,SW_HIDE
);
488 SetParent(m_hWndxWinParent
,0);
491 if(m_xContainerWindow
.is()) {
492 m_xContainerWindow
->setVisible(false);
493 ShowWindow(m_hWndxWinCont
,SW_HIDE
);
494 SetParent(m_hWndxWinCont
,0);
497 // TODO/cd: Workaround for status indicator bug. It always makes the
498 // document window visible, when someone tries to use the status
499 // indicator. As we save our document when we get the deactivation
500 // from OLE this conflict to hide floating windows.
501 if (m_xLayoutManager
.is())
502 m_xLayoutManager
->setVisible(false);
504 if (NULL
!=m_pIOleIPSite
)
506 // The following workaround should let the object be stored in case of inplace editing
507 // CComPtr< IOleClientSite > pClientSite;
509 // m_pIOleIPSite->QueryInterface(
510 // IID_IOleClientSite, (void**)&pClientSite );
511 // if ( pClientSite )
512 // pClientSite->SaveObject();
514 m_pIOleIPSite
->OnInPlaceDeactivate();
517 if(m_pIOleIPFrame
) m_pIOleIPFrame
->Release(); m_pIOleIPFrame
= 0;
518 if(m_pIOleIPUIWindow
) m_pIOleIPUIWindow
->Release(); m_pIOleIPUIWindow
= 0;
519 if(m_pIOleIPSite
) m_pIOleIPSite
->Release(); m_pIOleIPSite
= 0;
521 if ( m_xOleAccess
.is() )
523 LockedEmbedDocument_Impl aDocLock
= m_xOleAccess
->GetEmbedDocument();
524 if ( aDocLock
.GetEmbedDocument() )
526 aDocLock
.GetEmbedDocument()->SaveObject();
534 HRESULT
DocumentHolder::UIActivate()
536 // 1. Call IOleInPlaceSite::UIActivate
537 if (NULL
!=m_pIOleIPSite
)
538 m_pIOleIPSite
->OnUIActivate();
540 //2. Critical for accelerators to work initially.
541 SetFocus(m_pCHatchWin
->Window());
542 // if(m_xEditWindow.is()) m_xEditWindow->setFocus();
544 //3. Set the active object
546 OLECHAR starOffice
[] = {'S','t','a','r','O','f','f','i','c','e',0};
547 CComPtr
< IOleInPlaceActiveObject
> pObj
= new CIIAObj( this );
549 if (NULL
!=m_pIOleIPFrame
)
550 m_pIOleIPFrame
->SetActiveObject(
553 if (NULL
!=m_pIOleIPUIWindow
)
554 m_pIOleIPUIWindow
->SetActiveObject(
557 //4. Create the shared menu.
563 void DocumentHolder::UIDeactivate()
565 //1. Remove the shared menu.
566 InPlaceMenuDestroy();
568 if (NULL
!=m_pIOleIPFrame
)
569 m_pIOleIPFrame
->SetActiveObject(NULL
, NULL
);
571 if (NULL
!=m_pIOleIPUIWindow
)
572 m_pIOleIPUIWindow
->SetActiveObject(NULL
, NULL
);
574 //3. Call IOleInPlaceSite::OnUIDeactivate
575 if (NULL
!=m_pIOleIPSite
)
576 m_pIOleIPSite
->OnUIDeactivate(FALSE
);
581 void CopyToOLEMenu(HMENU hOrig
,WORD origPos
,HMENU hDest
,WORD destPos
)
584 UINT uTemp
= MF_BYPOSITION
| MF_POPUP
;
587 subMenu
= GetSubMenu(hOrig
,origPos
);
588 GetMenuString(hOrig
,origPos
,buffer
,256,MF_BYPOSITION
);
589 InsertMenu(hDest
,destPos
,uTemp
,
590 (UINT
)subMenu
,LPCTSTR(buffer
));
593 memset(&mi
,0,sizeof(mi
));
594 mi
.cbSize
= sizeof(mi
);
595 mi
.fMask
= MIIM_DATA
;
596 if(GetMenuItemInfoW(hOrig
,origPos
,TRUE
,&mi
))
597 SetMenuItemInfoW(hDest
,(WORD
)destPos
,TRUE
,&mi
);
600 BOOL
DocumentHolder::InPlaceMenuCreate(void)
604 OLEMENUGROUPWIDTHS mgw
;
609 //We already have popup menu handles in m_pFR->m_phMenu[]
611 //Create the new shared menu and let container do its thing
613 m_pIOleIPFrame
->InsertMenus(hMenu
,&mgw
);
615 int count
= GetMenuItemCount(m_nMenuHandle
);
618 // start with 1, because we don't include "File"
619 WORD pos
= (WORD
)mgw
.width
[0];
620 CopyToOLEMenu(m_nMenuHandle
,1,hMenu
,pos
);
623 // insert object menu here
624 pos
= ((WORD
)(mgw
.width
[0] + mgw
.width
[1] + mgw
.width
[2]));
625 for(WORD i
= 2; i
< help
-1; ++i
,++pos
)
626 CopyToOLEMenu(m_nMenuHandle
,i
,hMenu
,pos
);
627 mgw
.width
[3] = help
- 3;
630 pos
= (WORD
)(mgw
.width
[0] + mgw
.width
[1] + mgw
.width
[2] +
631 mgw
.width
[3] + mgw
.width
[4]);
632 CopyToOLEMenu(m_nMenuHandle
,WORD(help
),hMenu
,pos
);
635 m_nMenuShared
= hMenu
;
636 m_nOLEMenu
= OleCreateMenuDescriptor(m_nMenuShared
,&mgw
);
638 uno::Reference
<awt::XSystemDependentWindowPeer
> xSysDepWin(m_xContainerWindow
,uno::UNO_QUERY
);
639 if(xSysDepWin
.is()) {
640 uno::Sequence
<sal_Int8
> aProcessIdent(16);
641 rtl_getGlobalProcessId((sal_uInt8
*)aProcessIdent
.getArray());
642 uno::Any aAny
= xSysDepWin
->getWindowHandle(aProcessIdent
,lang::SystemDependent::SYSTEM_WIN32
);
645 HWND aHwnd
= (HWND
) tmp
;
646 m_pIOleIPFrame
->SetMenu(
647 m_nMenuShared
,m_nOLEMenu
,aHwnd
);
650 m_pIOleIPFrame
->SetMenu(
651 m_nMenuShared
,m_nOLEMenu
,::GetWindow(m_hWndxWinParent
,GW_CHILD
));
655 BOOL
DocumentHolder::InPlaceMenuDestroy(void)
657 if( NULL
== m_nMenuShared
)
660 m_pIOleIPFrame
->SetMenu(NULL
,NULL
,NULL
);
662 OleDestroyMenuDescriptor(m_nOLEMenu
),m_nOLEMenu
= NULL
;
666 void DocumentHolder::OpenIntoWindow(void)
671 BOOL
DocumentHolder::Undo(void)
678 void DocumentHolder::FreeOffice()
680 const ::rtl::OUString
aServiceName(
681 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
682 uno::Reference
< frame::XDesktop
> xDesktop(
683 m_xFactory
->createInstance( aServiceName
), uno::UNO_QUERY
);
686 xDesktop
->removeTerminateListener(
687 (frame::XTerminateListener
*)this );
691 void DocumentHolder::DisconnectFrameDocument( sal_Bool bComplete
)
695 uno::Reference
< util::XModifyBroadcaster
> xModifiable( m_xDocument
, uno::UNO_QUERY_THROW
);
696 xModifiable
->removeModifyListener( (util::XModifyListener
*)this );
698 catch( uno::Exception
& )
703 uno::Reference
< util::XCloseBroadcaster
> xBroadcaster(
704 m_xDocument
, uno::UNO_QUERY_THROW
);
705 xBroadcaster
->removeCloseListener( (util::XCloseListener
*)this );
707 catch( uno::Exception
& )
712 uno::Reference
< util::XCloseBroadcaster
> xBroadcaster(
713 m_xFrame
, uno::UNO_QUERY_THROW
);
714 xBroadcaster
->removeCloseListener( (util::XCloseListener
*)this );
716 catch( uno::Exception
& )
721 m_xFrame
= uno::Reference
< frame::XFrame
>();
723 m_xDocument
= uno::Reference
< frame::XModel
>();
727 void DocumentHolder::CloseDocument()
729 DisconnectFrameDocument();
731 uno::Reference
< util::XCloseable
> xCloseable(
732 m_xDocument
, uno::UNO_QUERY
);
734 if ( xCloseable
.is() )
738 xCloseable
->close( sal_True
);
740 catch( uno::Exception
& )
745 m_xDocument
= uno::Reference
< frame::XModel
>();
749 void DocumentHolder::CloseFrame()
753 uno::Reference
< util::XCloseBroadcaster
> xBroadcaster(
754 m_xFrame
, uno::UNO_QUERY_THROW
);
755 xBroadcaster
->removeCloseListener( (util::XCloseListener
*)this );
757 catch( uno::Exception
& )
760 uno::Reference
<util::XCloseable
> xCloseable(
761 m_xFrame
,uno::UNO_QUERY
);
764 xCloseable
->close(sal_True
);
766 catch( const uno::Exception
& ) {
769 uno::Reference
<lang::XComponent
> xComp(m_xFrame
,uno::UNO_QUERY
);
774 m_xFrame
= uno::Reference
< frame::XFrame
>();
777 void DocumentHolder::SetDocument( const uno::Reference
< frame::XModel
>& xDoc
, sal_Bool bLink
)
779 if ( m_xDocument
.is() )
785 uno::Reference
< util::XCloseBroadcaster
> xBroadcaster(
786 m_xDocument
, uno::UNO_QUERY
);
788 if ( xBroadcaster
.is() )
789 xBroadcaster
->addCloseListener( (util::XCloseListener
*)this );
791 if ( m_xDocument
.is() && !m_bLink
)
793 // set the document mode to embedded
794 uno::Sequence
< beans::PropertyValue
> aSeq(1);
795 aSeq
[0].Name
= ::rtl::OUString::createFromAscii( "SetEmbedded" );
796 aSeq
[0].Value
<<= sal_True
;
797 m_xDocument
->attachResource(::rtl::OUString(),aSeq
);
801 sal_Bool
DocumentHolder::ExecuteSuspendCloseFrame()
803 if ( m_xFrame
.is() && m_xFactory
.is() )
807 uno::Reference
< frame::XController
> xController
= m_xFrame
->getController();
808 if ( xController
.is() )
810 if ( !xController
->suspend( sal_True
) )
816 uno::Reference
<util::XCloseable
> xCloseable( m_xFrame
, uno::UNO_QUERY
);
817 if ( xCloseable
.is() )
818 xCloseable
->close(sal_True
);
821 uno::Reference
<lang::XComponent
> xComp( m_xFrame
, uno::UNO_QUERY_THROW
);
826 catch( const util::CloseVetoException
& )
828 // should be called if the frame could not be closed
829 xController
->suspend( sal_False
);
833 catch( uno::Exception
& )
837 m_xFrame
= uno::Reference
< frame::XFrame
>();
843 uno::Reference
< frame::XFrame
> DocumentHolder::DocumentFrame()
847 rtl::OUString
aDesktopSrvNm(
848 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"));
850 uno::Reference
<frame::XDesktop
> xDesktop(
851 m_xFactory
->createInstance(aDesktopSrvNm
),
854 uno::Reference
<frame::XFrame
> xFrame(
855 xDesktop
,uno::UNO_QUERY
);
857 // the frame will be registered on desktop here, later when the document
858 // is loaded into the frame in ::show() method the terminate listener will be removed
859 // this is so only for outplace activation
861 m_xFrame
= xFrame
->findFrame(
862 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_blank")),0);
864 uno::Reference
< util::XCloseBroadcaster
> xBroadcaster(
865 m_xFrame
, uno::UNO_QUERY
);
867 if ( xBroadcaster
.is() )
869 xBroadcaster
->addCloseListener( (util::XCloseListener
*)this );
870 FreeOffice(); // the frame is part of the desktop
877 uno::Reference
<frame::XDispatchProviderInterception
>
878 xDPI(m_xFrame
,uno::UNO_QUERY
);
880 xDPI
->registerDispatchProviderInterceptor( CreateNewInterceptor() );
887 uno::Reference
< frame::XDispatchProviderInterceptor
> DocumentHolder::CreateNewInterceptor()
889 ::osl::MutexGuard
aGuard( m_aMutex
);
891 ClearInterceptorInternally();
893 uno::Reference
< frame::XDispatchProviderInterceptor
> xInterceptor( m_pInterceptor
= new Interceptor( m_xOleAccess
, this, m_bLink
) );
894 m_xInterceptorLocker
= xInterceptor
;
898 void DocumentHolder::ClearInterceptorInternally()
900 ::osl::MutexGuard
aGuard( m_aMutex
);
901 uno::Reference
< frame::XDispatchProviderInterceptor
> xInterceptor( m_xInterceptorLocker
);
902 if ( xInterceptor
.is() && m_pInterceptor
)
903 m_pInterceptor
->DisconnectDocHolder();
905 m_xInterceptorLocker
= uno::Reference
< frame::XDispatchProviderInterceptor
>();
909 void DocumentHolder::ClearInterceptor()
911 ::osl::MutexGuard
aGuard( m_aMutex
);
912 m_xInterceptorLocker
= uno::Reference
< frame::XDispatchProviderInterceptor
>();
917 void DocumentHolder::show()
923 m_xFrame
->activate();
924 uno::Reference
<awt::XTopWindow
> xTopWindow(
925 m_xFrame
->getContainerWindow(),uno::UNO_QUERY
);
927 xTopWindow
->toFront();
929 else if( DocumentFrame().is() )
931 LoadDocInFrame( sal_False
);
933 // get rid of second closer if it is there
934 uno::Reference
< beans::XPropertySet
> xProps( m_xFrame
, uno::UNO_QUERY
);
937 uno::Reference
< frame::XLayoutManager
> xLayoutManager
;
938 xProps
->getPropertyValue( rtl::OUString::createFromAscii( "LayoutManager" ) ) >>= xLayoutManager
;
939 uno::Reference
< beans::XPropertySet
> xLMProps( xLayoutManager
, uno::UNO_QUERY
);
942 xLMProps
->setPropertyValue( ::rtl::OUString::createFromAscii( "MenuBarCloser" ),
943 uno::makeAny( uno::Reference
< frame::XStatusListener
>() ) );
951 uno::Reference
< util::XModifyBroadcaster
> xModifiable( m_xDocument
, uno::UNO_QUERY_THROW
);
952 xModifiable
->addModifyListener( (util::XModifyListener
*)this );
954 catch( uno::Exception
& )
959 setTitle(m_aDocumentNamePart
);
962 catch( uno::Exception
& )
964 OSL_ENSURE( sal_False
, "Can not show the frame!\n" );
969 void DocumentHolder::resizeWin( const SIZEL
& rNewSize
)
971 LockedEmbedDocument_Impl aDocLock
;
973 if ( m_xOleAccess
.is() )
974 aDocLock
= m_xOleAccess
->GetEmbedDocument();
976 if ( m_xFrame
.is() && aDocLock
.GetEmbedDocument() )
978 uno::Reference
< awt::XWindow
> xWindow(
979 m_xFrame
->getContainerWindow(), uno::UNO_QUERY
);
980 uno::Reference
< awt::XView
> xView( xWindow
, uno::UNO_QUERY
);
982 if ( xWindow
.is() && xView
.is() )
985 xView
->setZoom( fScale
, fScale
);
988 GetExtent( &aOldSize
);
990 if ( aOldSize
.cx
!= rNewSize
.cx
|| aOldSize
.cy
!= rNewSize
.cy
)
992 HDC hdc
= GetDC( NULL
);
993 SetMapMode( hdc
, MM_HIMETRIC
);
996 aOldOffset
.x
= aOldSize
.cx
;
997 aOldOffset
.y
= aOldSize
.cy
;
998 BOOL bIsOk
= LPtoDP( hdc
, &aOldOffset
, 1 );
1001 aNewOffset
.x
= rNewSize
.cx
;
1002 aNewOffset
.y
= rNewSize
.cy
;
1003 bIsOk
= LPtoDP( hdc
, &aNewOffset
, 1 );
1005 ReleaseDC( NULL
, hdc
);
1007 awt::Rectangle aWinRect
= xWindow
->getPosSize();
1009 sal_Int32 aWidthDelta
= aWinRect
.Width
- aOldOffset
.x
;
1010 sal_Int32 aHeightDelta
= aWinRect
.Height
- aOldOffset
.y
;
1012 if ( aWidthDelta
> 0 && aHeightDelta
> 0 )
1013 xWindow
->setPosSize(0,
1015 aNewOffset
.x
+ aWidthDelta
,
1016 aNewOffset
.y
+ aHeightDelta
,
1017 awt::PosSize::SIZE
);
1023 void DocumentHolder::setTitle(const rtl::OUString
& aDocumentName
)
1027 if(m_aFilterName
.getLength() == 0)
1029 rtl::OUString aFilterName
;
1030 uno::Sequence
<beans::PropertyValue
> aSeq
;
1031 if(m_xDocument
.is())
1034 m_xDocument
->getArgs();
1035 for(sal_Int32 j
= 0; j
< aSeq
.getLength(); ++j
)
1039 RTL_CONSTASCII_USTRINGPARAM("FilterName")))
1041 aSeq
[j
].Value
>>= aFilterName
;
1047 if(aFilterName
.getLength())
1049 uno::Reference
<container::XNameAccess
> xNameAccess(
1050 m_xFactory
->createInstance(
1051 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
1052 "com.sun.star.document.FilterFactory"))),
1055 if(xNameAccess
.is() &&
1056 (xNameAccess
->getByName(aFilterName
) >>= aSeq
))
1058 for(sal_Int32 j
= 0; j
< aSeq
.getLength(); ++j
)
1061 RTL_CONSTASCII_USTRINGPARAM("UIName")))
1063 aSeq
[j
].Value
>>= m_aFilterName
;
1068 catch(const uno::Exception
& ) {
1069 // nothing better to do here
1070 m_aFilterName
= aFilterName
;
1075 uno::Reference
<beans::XPropertySet
> xPropSet(
1076 m_xFrame
,uno::UNO_QUERY
);
1079 static const sal_Unicode u
[] = { ' ','(',0 };
1080 static const sal_Unicode c
[] = { ')',0 };
1081 rtl::OUString
aTotalName(m_aFilterName
);
1082 aTotalName
+= rtl::OUString(u
);
1083 aTotalName
+= aDocumentName
;
1084 aTotalName
+= rtl::OUString(c
);
1085 aAny
<<= aTotalName
;
1087 xPropSet
->setPropertyValue(
1088 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")),
1091 catch( const uno::Exception
& ) {
1096 m_aDocumentNamePart
= aDocumentName
;
1100 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1102 Interceptor
* pTmpInter
= NULL
;
1103 uno::Reference
< frame::XDispatchProviderInterceptor
> xLock( m_xInterceptorLocker
);
1104 if ( xLock
.is() && m_pInterceptor
)
1105 pTmpInter
= m_pInterceptor
;
1110 pTmpInter
->generateFeatureStateEvent();
1115 void DocumentHolder::setContainerName(const rtl::OUString
& aContainerName
)
1117 m_aContainerName
= aContainerName
;
1121 void DocumentHolder::hide()
1123 if(m_xFrame
.is()) m_xFrame
->deactivate();
1126 // after hiding the window it is always allowed to InPlaceActivate it
1127 m_bAllowInPlace
= true;
1130 IDispatch
* DocumentHolder::GetIDispatch()
1132 if ( !m_pIDispatch
&& m_xDocument
.is() )
1134 const ::rtl::OUString
aServiceName (
1135 RTL_CONSTASCII_USTRINGPARAM (
1136 "com.sun.star.bridge.OleBridgeSupplier2" ) );
1137 uno::Reference
< bridge::XBridgeSupplier2
> xSupplier(
1138 m_xFactory
->createInstance( aServiceName
), uno::UNO_QUERY
);
1140 if ( xSupplier
.is() )
1142 uno::Sequence
< sal_Int8
> aProcId( 16 );
1143 rtl_getGlobalProcessId( (sal_uInt8
*)aProcId
.getArray() );
1146 uno::Any anyResult
= xSupplier
->createBridge(
1147 uno::makeAny( m_xDocument
),
1149 bridge::ModelDependent::UNO
,
1150 bridge::ModelDependent::OLE
);
1152 if ( anyResult
.getValueTypeClass() ==
1153 getCppuType((sal_uInt32
*) 0).getTypeClass() )
1155 VARIANT
* pVariant
= *(VARIANT
**)anyResult
.getValue();
1156 if ( pVariant
->vt
== VT_DISPATCH
)
1157 m_pIDispatch
= pVariant
->pdispVal
;
1159 VariantClear( pVariant
);
1160 CoTaskMemFree( pVariant
);
1163 catch ( uno::Exception
& )
1168 return m_pIDispatch
;
1172 HRESULT
DocumentHolder::SetVisArea( const RECTL
*pRect
)
1174 if ( pRect
&& m_xDocument
.is() )
1176 uno::Sequence
< beans::PropertyValue
> aArgs
= m_xDocument
->getArgs();
1177 for ( sal_Int32 nInd
= 0; nInd
< aArgs
.getLength(); nInd
++ )
1178 if ( aArgs
[nInd
].Name
.equalsAscii( "WinExtent" ) )
1180 // should allways be there
1181 uno::Sequence
< sal_Int32
> aRect(4);
1183 aRect
[0] = pRect
->left
;
1184 aRect
[1] = pRect
->top
;
1185 aRect
[2] = pRect
->right
;
1186 aRect
[3] = pRect
->bottom
;
1188 aArgs
[nInd
].Value
<<= aRect
;
1190 m_xDocument
->attachResource( m_xDocument
->getURL(), aArgs
);
1194 OSL_ENSURE( sal_False
, "WinExtent seems not to be implemented!\n" );
1200 HRESULT
DocumentHolder::GetVisArea( RECTL
*pRect
)
1202 if ( pRect
&& m_xDocument
.is() )
1204 uno::Sequence
< beans::PropertyValue
> aArgs
= m_xDocument
->getArgs();
1205 for ( sal_Int32 nInd
= 0; nInd
< aArgs
.getLength(); nInd
++ )
1206 if ( aArgs
[nInd
].Name
.equalsAscii( "WinExtent" ) )
1208 uno::Sequence
< sal_Int32
> aRect
;
1209 if ( ( aArgs
[nInd
].Value
>>= aRect
) && aRect
.getLength() == 4 )
1211 pRect
->left
= aRect
[0];
1212 pRect
->top
= aRect
[1];
1213 pRect
->right
= aRect
[2];
1214 pRect
->bottom
= aRect
[3];
1227 HRESULT
DocumentHolder::GetDocumentBorder( RECT
*pRect
)
1229 if ( pRect
&& m_xDocument
.is() )
1231 uno::Sequence
< beans::PropertyValue
> aArgs
= m_xDocument
->getArgs();
1232 for ( sal_Int32 nInd
= 0; nInd
< aArgs
.getLength(); nInd
++ )
1233 if ( aArgs
[nInd
].Name
.equalsAscii( "DocumentBorder" ) )
1235 uno::Sequence
< sal_Int32
> aRect
;
1236 if ( ( aArgs
[nInd
].Value
>>= aRect
) && aRect
.getLength() == 4 )
1238 pRect
->left
= aRect
[0];
1239 pRect
->top
= aRect
[1];
1240 pRect
->right
= aRect
[2];
1241 pRect
->bottom
= aRect
[3];
1253 HRESULT
DocumentHolder::SetExtent( const SIZEL
*pSize
)
1257 uno::Reference
< embed::XVisualObject
> xVisObj( m_xDocument
, uno::UNO_QUERY
);
1262 awt::Size
aNewSize( pSize
->cx
, pSize
->cy
);
1264 sal_Int32 aMapMode
= xVisObj
->getMapUnit( DVASPECT_CONTENT
);
1266 // TODO/LATER: in future UNO API should be used for the conversion, currently there is no
1267 if ( aMapMode
== embed::EmbedMapUnits::TWIP
)
1269 // convertion from ONE_100TH_MM
1270 aNewSize
.Width
= aNewSize
.Width
* 144 / 254;
1271 aNewSize
.Height
= aNewSize
.Height
* 144 / 254;
1275 xVisObj
->setVisualAreaSize( DVASPECT_CONTENT
, aNewSize
);
1279 catch( uno::Exception
& )
1287 HRESULT
DocumentHolder::GetExtent( SIZEL
*pSize
)
1291 uno::Reference
< embed::XVisualObject
> xVisObj( m_xDocument
, uno::UNO_QUERY
);
1296 awt::Size aDocSize
= xVisObj
->getVisualAreaSize( DVASPECT_CONTENT
);
1298 sal_Int32 aMapMode
= xVisObj
->getMapUnit( DVASPECT_CONTENT
);
1300 // TODO/LATER: in future UNO API should be used for the conversion, currently there is no
1301 if ( aMapMode
== embed::EmbedMapUnits::TWIP
)
1303 // convertion to ONE_100TH_MM
1304 aDocSize
.Width
= aDocSize
.Width
* 254 / 144;
1305 aDocSize
.Height
= aDocSize
.Height
* 254 / 144;
1308 pSize
->cx
= aDocSize
.Width
;
1309 pSize
->cy
= aDocSize
.Height
;
1313 catch( uno::Exception
& )
1322 HRESULT
DocumentHolder::SetContRects(LPCRECT aRect
)
1324 if(m_xContainerWindow
.is()) {
1326 memset(&wi
,0,sizeof(wi
));
1327 if(m_pIOleIPFrame
) {
1328 m_pIOleIPFrame
->GetBorder((LPRECT
)&wi
);
1329 m_xContainerWindow
->setPosSize(
1333 awt::PosSize::POSSIZE
);
1336 m_xContainerWindow
->setPosSize(
1338 aRect
->right
- aRect
->left
,
1339 aRect
->bottom
- aRect
->top
,
1340 awt::PosSize::POSSIZE
);
1349 HRESULT
DocumentHolder::SetObjectRects(LPCRECT aRect
, LPCRECT aClip
)
1351 ((LPRECT
)aRect
)->left
-= m_aBorder
.left
;
1352 ((LPRECT
)aRect
)->right
+= m_aBorder
.right
;
1353 ((LPRECT
)aRect
)->top
-= m_aBorder
.top
;
1354 ((LPRECT
)aRect
)->bottom
+= m_aBorder
.bottom
;
1355 ((LPRECT
)aClip
)->left
-= m_aBorder
.left
;
1356 ((LPRECT
)aClip
)->right
+= m_aBorder
.right
;
1357 ((LPRECT
)aClip
)->top
-= m_aBorder
.top
;
1358 ((LPRECT
)aClip
)->bottom
+= m_aBorder
.bottom
;
1361 m_pCHatchWin
->RectsSet((LPRECT
)aRect
, (LPRECT
)aClip
);
1362 if(m_xEditWindow
.is()) {
1363 m_xEditWindow
->setVisible(false);
1364 m_xEditWindow
->setPosSize(
1365 m_pCHatchWin
? HATCHWIN_BORDERWIDTHDEFAULT
: 0,
1366 m_pCHatchWin
? HATCHWIN_BORDERWIDTHDEFAULT
: 0,
1367 aRect
->right
- aRect
->left
,
1368 aRect
->bottom
- aRect
->top
,
1369 awt::PosSize::POSSIZE
);
1370 m_xEditWindow
->setVisible(true);
1376 ::com::sun::star::uno::Reference
<
1377 ::com::sun::star::awt::XWindow
> SAL_CALL
1378 DocumentHolder::getContainerWindow(
1381 ::com::sun::star::uno::RuntimeException
1384 if(m_xContainerWindow
.is())
1385 return m_xContainerWindow
;
1387 uno::Reference
<awt::XWindow
> xWin(0);
1389 static const ::rtl::OUString
aToolkitServiceName(
1390 RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.awt.Toolkit" ) );
1391 uno::Reference
<awt::XSystemChildFactory
> xToolkit(
1392 m_xFactory
->createInstance(aToolkitServiceName
),uno::UNO_QUERY
);
1394 if(xToolkit
.is() && m_pIOleIPFrame
) {
1396 m_pIOleIPFrame
->GetWindow(&hWnd
);
1398 uno::Sequence
<sal_Int8
> aProcessIdent(16);
1399 rtl_getGlobalProcessId((sal_uInt8
*)aProcessIdent
.getArray());
1402 aAny
<<= sal_Int32(hWnd
);
1403 xWin
= uno::Reference
<awt::XWindow
>(
1404 xToolkit
->createSystemChild(
1407 lang::SystemDependent::SYSTEM_WIN32
),
1411 memset(&wi
,0,sizeof(wi
));
1412 if(xWin
.is() && m_pIOleIPFrame
->GetBorder((LPRECT
)&wi
) == NOERROR
) {
1413 xWin
->setVisible(true);
1418 awt::PosSize::POSSIZE
);
1420 uno::Reference
<awt::XSystemDependentWindowPeer
> xSysWin(
1421 xWin
,uno::UNO_QUERY
);
1423 aAny
= xSysWin
->getWindowHandle(
1424 aProcessIdent
,lang::SystemDependent::SYSTEM_WIN32
);
1427 SetContainerWindowHandle((HWND
) tmp
);
1432 m_xContainerWindow
= xWin
;
1439 DocumentHolder::requestDockingAreaSpace(
1440 const ::com::sun::star::awt::Rectangle
& RequestedSpace
1443 ::com::sun::star::uno::RuntimeException
1450 SetRect((LPRECT
)&bw
,
1451 RequestedSpace
.X
,RequestedSpace
.Y
,
1452 RequestedSpace
.Width
,RequestedSpace
.Height
);
1453 if( m_pIOleIPFrame
)
1454 return m_pIOleIPFrame
->RequestBorderSpace(&bw
) == NOERROR
;
1456 return sal_Bool(false);
1461 DocumentHolder::setDockingAreaSpace(
1462 const ::com::sun::star::awt::Rectangle
& BorderSpace
1465 ::com::sun::star::uno::RuntimeException
1472 SetRect((LPRECT
)&bw
,
1473 BorderSpace
.X
,BorderSpace
.Y
,
1474 BorderSpace
.Width
,BorderSpace
.Height
);
1475 if( m_pIOleIPFrame
) {
1477 GetClientRect(m_hWndxWinCont
,&aRect
);
1478 HRGN hrgn1
= CreateRectRgn(
1480 aRect
.right
,BorderSpace
.Y
);
1481 HRGN hrgn2
= CreateRectRgn(aRect
.right
-BorderSpace
.Width
,0,aRect
.right
,aRect
.bottom
);
1482 CombineRgn(hrgn1
,hrgn1
,hrgn2
,RGN_OR
);
1483 DeleteObject(hrgn2
);
1484 hrgn2
= CreateRectRgn(0,aRect
.bottom
-BorderSpace
.Height
,aRect
.right
,aRect
.bottom
);
1485 CombineRgn(hrgn1
,hrgn1
,hrgn2
,RGN_OR
);
1486 DeleteObject(hrgn2
);
1487 hrgn2
= CreateRectRgn(0,0,BorderSpace
.X
,aRect
.bottom
);
1488 CombineRgn(hrgn1
,hrgn1
,hrgn2
,RGN_OR
);
1489 DeleteObject(hrgn2
);
1491 SetWindowRgn(m_hWndxWinCont
,hrgn1
,true);
1492 // not:: DeleteObject(hrgn1);
1493 m_pIOleIPFrame
->SetBorderSpace(&bw
);
1499 DocumentHolder::disposing(
1500 const com::sun::star::lang::EventObject
& aSource
1502 throw( uno::RuntimeException
)
1504 if ( m_xDocument
.is() && m_xDocument
== aSource
.Source
)
1506 m_pIDispatch
= NULL
;
1507 m_xDocument
= uno::Reference
< frame::XModel
>();
1510 if( m_xFrame
.is() && m_xFrame
== aSource
.Source
)
1511 m_xFrame
= uno::Reference
< frame::XFrame
>();
1516 DocumentHolder::queryClosing(
1517 const lang::EventObject
& aSource
,
1518 sal_Bool
/*bGetsOwnership*/
1521 util::CloseVetoException
1525 && ( m_xDocument
.is() && m_xDocument
== aSource
.Source
|| m_xFrame
.is() && m_xFrame
== aSource
.Source
) )
1526 throw util::CloseVetoException();
1531 DocumentHolder::notifyClosing(
1532 const lang::EventObject
& aSource
)
1533 throw( uno::RuntimeException
)
1537 uno::Reference
< util::XCloseBroadcaster
> xEventBroadcaster(
1538 aSource
.Source
, uno::UNO_QUERY_THROW
);
1539 xEventBroadcaster
->removeCloseListener( (util::XCloseListener
*)this );
1541 catch( uno::Exception
& )
1544 if ( m_xDocument
.is() && m_xDocument
== aSource
.Source
)
1546 // can happen only in case of links
1547 m_pIDispatch
= NULL
;
1548 m_xDocument
= uno::Reference
< frame::XModel
>();
1549 m_xFrame
= uno::Reference
< frame::XFrame
>();
1551 LockedEmbedDocument_Impl aDocLock
= m_xOleAccess
->GetEmbedDocument();
1552 if ( aDocLock
.GetEmbedDocument() )
1553 aDocLock
.GetEmbedDocument()->OLENotifyClosing();
1555 else if( m_xFrame
.is() && m_xFrame
== aSource
.Source
)
1556 m_xFrame
= uno::Reference
< frame::XFrame
>();
1560 DocumentHolder::queryTermination(
1561 const lang::EventObject
& /*aSource*/
1564 frame::TerminationVetoException
1567 if ( m_xDocument
.is() )
1568 throw frame::TerminationVetoException();
1572 DocumentHolder::notifyTermination(
1573 const lang::EventObject
& aSource
1575 throw( uno::RuntimeException
)
1577 OSL_ENSURE( !m_xDocument
.is(), "Just a disaster..." );
1578 uno::Reference
< frame::XDesktop
> xDesktop(
1579 aSource
.Source
, uno::UNO_QUERY
);
1581 if ( xDesktop
.is() )
1582 xDesktop
->removeTerminateListener( (frame::XTerminateListener
*)this );
1587 void SAL_CALL
DocumentHolder::modified( const lang::EventObject
& /*aEvent*/ )
1588 throw (uno::RuntimeException
)
1590 if ( m_xOleAccess
.is() )
1592 LockedEmbedDocument_Impl aDocLock
= m_xOleAccess
->GetEmbedDocument();
1593 if ( aDocLock
.GetEmbedDocument() )
1594 aDocLock
.GetEmbedDocument()->notify();
1600 // if(m_pOLEInterface->GetGUID() == OID_WriterTextServer) {
1602 // CopyToOLEMenu(m_nMenuHandle,1,hMenu,(WORD)mgw.width[0]);
1603 // CopyToOLEMenu(m_nMenuHandle,2,hMenu,1+(WORD)mgw.width[0]);
1604 // CopyToOLEMenu(m_nMenuHandle,3,hMenu,2+(WORD)mgw.width[0]);
1605 // CopyToOLEMenu(m_nMenuHandle,4,hMenu,3+(WORD)mgw.width[0]);
1611 // hMenu,4+(WORD)mgw.width[0]+(WORD)mgw.width[2]);
1617 // hMenu,5+(WORD)mgw.width[0]+(WORD)mgw.width[2]+(WORD)mgw.width[4]);
1620 // else if(m_pOLEInterface->GetGUID() == OID_CalcServer) {
1622 // CopyToOLEMenu(m_nMenuHandle,1,hMenu,(WORD)mgw.width[0]);
1623 // CopyToOLEMenu(m_nMenuHandle,2,hMenu,1+(WORD)mgw.width[0]);
1624 // CopyToOLEMenu(m_nMenuHandle,3,hMenu,2+(WORD)mgw.width[0]);
1625 // CopyToOLEMenu(m_nMenuHandle,4,hMenu,3+(WORD)mgw.width[0]);
1631 // hMenu,4+(WORD)mgw.width[0]+(WORD)mgw.width[2]);
1634 // hMenu,5+(WORD)mgw.width[0]+(WORD)mgw.width[2]);
1640 // hMenu,6+(WORD)mgw.width[0]+(WORD)mgw.width[2]+(WORD)mgw.width[4]);
1644 // Fix strange warnings about some
1645 // ATL::CAxHostWindow::QueryInterface|AddRef|Releae functions.
1646 // warning C4505: 'xxx' : unreferenced local function has been removed
1647 #if defined(_MSC_VER)
1648 #pragma warning(disable: 4505)