oleinplaceobject.cpp 4.55 KB
Newer Older
1 2 3
/*****************************************************************************
 * oleinplaceobject.cpp: ActiveX control for VLC
 *****************************************************************************
4
 * Copyright (C) 2005 the VideoLAN team
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 22
 *****************************************************************************/

23 24 25 26
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

27 28 29 30 31 32 33 34
#include "plugin.h"
#include "oleinplaceobject.h"

#include <docobj.h>

STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
{
    if( NULL == pHwnd )
35
        return E_POINTER;
36

37
    *pHwnd = NULL;
38 39 40 41 42
    if( _p_instance->isInPlaceActive() )
    {
        if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
            return S_OK;
    }
43
    return E_FAIL;
44 45
};

46
STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL)
47 48 49 50 51 52 53 54 55
{
    return E_NOTIMPL;
};

STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
{
    if( _p_instance->isInPlaceActive() )
    {
        UIDeactivate();
56

57 58 59
        _p_instance->onInPlaceDeactivate();

        LPOLEOBJECT p_oleObject;
60
        if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
        {
            LPOLECLIENTSITE p_clientSite;
            if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
            {
                LPOLEINPLACESITE p_inPlaceSite;

                if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
                {
                    p_inPlaceSite->OnInPlaceDeactivate();
                    p_inPlaceSite->Release();
                }
                p_clientSite->Release();
            }
            p_oleObject->Release();
        }
        return S_OK;
    }
    return E_UNEXPECTED;
};

STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
{
    if( _p_instance->isInPlaceActive() )
    {
        if( _p_instance->hasFocus() )
            _p_instance->setFocus(FALSE);

88
        LPOLEOBJECT p_oleObject;
89
        if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
90 91 92
        {
            LPOLECLIENTSITE p_clientSite;
            if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
93
            {
94 95 96
                LPOLEINPLACESITE p_inPlaceSite;

                if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
97
                {
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
                    LPOLEINPLACEFRAME p_inPlaceFrame;
                    LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
                    OLEINPLACEFRAMEINFO oleFrameInfo;
                    RECT posRect, clipRect;

                    oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
                    if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
                    {
                        if( p_inPlaceFrame )
                        {
                            p_inPlaceFrame->SetActiveObject(NULL, NULL);
                            p_inPlaceFrame->Release();
                        }
                        if( p_inPlaceUIWindow )
                        {
                            p_inPlaceUIWindow->SetActiveObject(NULL, NULL);
                            p_inPlaceUIWindow->Release();
                        }
                    }
117 118
                    p_inPlaceSite->OnUIDeactivate(FALSE);
                    p_inPlaceSite->Release();
119
                }
120
                p_clientSite->Release();
121
            }
122
            p_oleObject->Release();
123
        }
124
        return S_OK;
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    }
    return E_UNEXPECTED;
};

STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
    if( _p_instance->isInPlaceActive() )
    {
        _p_instance->onPositionChange(lprcPosRect, lprcClipRect);
        return S_OK;
    }
    return E_UNEXPECTED;
};

STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void)
{
    return INPLACE_E_NOTUNDOABLE;
};