]> git.sesse.net Git - vlc/blob - activex/oleinplaceobject.cpp
Removes trailing spaces. Removes tabs.
[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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 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_POINTER;
34
35     *pHwnd = NULL;
36     if( _p_instance->isInPlaceActive() )
37     {
38         if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
39             return S_OK;
40     }
41     return E_FAIL;
42 };
43
44 STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
45 {
46     return E_NOTIMPL;
47 };
48
49 STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
50 {
51     if( _p_instance->isInPlaceActive() )
52     {
53         UIDeactivate();
54
55         _p_instance->onInPlaceDeactivate();
56
57         LPOLEOBJECT p_oleObject;
58         if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
59         {
60             LPOLECLIENTSITE p_clientSite;
61             if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
62             {
63                 LPOLEINPLACESITE p_inPlaceSite;
64
65                 if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
66                 {
67                     p_inPlaceSite->OnInPlaceDeactivate();
68                     p_inPlaceSite->Release();
69                 }
70                 p_clientSite->Release();
71             }
72             p_oleObject->Release();
73         }
74         return S_OK;
75     }
76     return E_UNEXPECTED;
77 };
78
79 STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
80 {
81     if( _p_instance->isInPlaceActive() )
82     {
83         if( _p_instance->hasFocus() )
84             _p_instance->setFocus(FALSE);
85
86         LPOLEOBJECT p_oleObject;
87         if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
88         {
89             LPOLECLIENTSITE p_clientSite;
90             if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
91             {
92                 LPOLEINPLACESITE p_inPlaceSite;
93
94                 if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
95                 {
96                     LPOLEINPLACEFRAME p_inPlaceFrame;
97                     LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
98                     OLEINPLACEFRAMEINFO oleFrameInfo;
99                     RECT posRect, clipRect;
100
101                     oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
102                     if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
103                     {
104                         if( p_inPlaceFrame )
105                         {
106                             p_inPlaceFrame->SetActiveObject(NULL, NULL);
107                             p_inPlaceFrame->Release();
108                         }
109                         if( p_inPlaceUIWindow )
110                         {
111                             p_inPlaceUIWindow->SetActiveObject(NULL, NULL);
112                             p_inPlaceUIWindow->Release();
113                         }
114                     }
115                     p_inPlaceSite->OnUIDeactivate(FALSE);
116                     p_inPlaceSite->Release();
117                 }
118                 p_clientSite->Release();
119             }
120             p_oleObject->Release();
121         }
122         return S_OK;
123     }
124     return E_UNEXPECTED;
125 };
126
127 STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
128 {
129     if( _p_instance->isInPlaceActive() )
130     {
131         _p_instance->onPositionChange(lprcPosRect, lprcClipRect);
132         return S_OK;
133     }
134     return E_UNEXPECTED;
135 };
136
137 STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void)
138 {
139     return INPLACE_E_NOTUNDOABLE;
140 };
141