]> git.sesse.net Git - vlc/blob - activex/oleinplaceobject.cpp
Make Zorglub less unhappy
[vlc] / activex / oleinplaceobject.cpp
1 /*****************************************************************************
2  * oleinplaceobject.cpp: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  *
6  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 #include "plugin.h"
24 #include "oleinplaceobject.h"
25
26 #include <docobj.h>
27
28 using namespace std;
29
30 STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
31 {
32     if( NULL == pHwnd )
33         return E_INVALIDARG;
34
35     if( _p_instance->isInPlaceActive() )
36     {
37         if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
38             return S_OK;
39
40         return E_FAIL;
41     }
42     *pHwnd = NULL;
43
44     return E_UNEXPECTED;
45 };
46
47 STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
48 {
49     return E_NOTIMPL;
50 };
51
52 STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
53 {
54     if( _p_instance->isInPlaceActive() )
55     {
56         UIDeactivate();
57         _p_instance->onInPlaceDeactivate();
58
59         LPOLEOBJECT p_oleObject;
60         if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) 
61         {
62             LPOLECLIENTSITE p_clientSite;
63             if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
64             {
65                 LPOLEINPLACESITE p_inPlaceSite;
66
67                 if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
68                 {
69                     p_inPlaceSite->OnInPlaceDeactivate();
70                     p_inPlaceSite->Release();
71                 }
72                 p_clientSite->Release();
73             }
74             p_oleObject->Release();
75         }
76         return S_OK;
77     }
78     return E_UNEXPECTED;
79 };
80
81 STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
82 {
83     if( _p_instance->isInPlaceActive() )
84     {
85         if( _p_instance->hasFocus() )
86         {
87             _p_instance->setFocus(FALSE);
88
89             LPOLEOBJECT p_oleObject;
90             if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) 
91             {
92                 LPOLECLIENTSITE p_clientSite;
93                 if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
94                 {
95                     LPOLEINPLACESITE p_inPlaceSite;
96
97                     if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
98                     {
99                         p_inPlaceSite->OnUIDeactivate(FALSE);
100                         p_inPlaceSite->Release();
101                     }
102                     p_clientSite->Release();
103                 }
104                 p_oleObject->Release();
105             }
106             return S_OK;
107         }
108     }
109     return E_UNEXPECTED;
110 };
111
112 STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
113 {
114     if( _p_instance->isInPlaceActive() )
115     {
116         _p_instance->onPositionChange(lprcPosRect, lprcClipRect);
117         return S_OK;
118     }
119     return E_UNEXPECTED;
120 };
121
122 STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void)
123 {
124     return INPLACE_E_NOTUNDOABLE;
125 };
126