oleinplaceobject.cpp 4.54 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 27 28 29 30 31 32
 *****************************************************************************/

#include "plugin.h"
#include "oleinplaceobject.h"

#include <docobj.h>

using namespace std;

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

35
    *pHwnd = NULL;
36 37 38 39 40
    if( _p_instance->isInPlaceActive() )
    {
        if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
            return S_OK;
    }
41
    return E_FAIL;
42 43 44 45 46 47 48 49 50 51 52 53
};

STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
{
    return E_NOTIMPL;
};

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

55 56 57
        _p_instance->onInPlaceDeactivate();

        LPOLEOBJECT p_oleObject;
58
        if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
59 60 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
        {
            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);

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

                if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
95
                {
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
                    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();
                        }
                    }
115 116
                    p_inPlaceSite->OnUIDeactivate(FALSE);
                    p_inPlaceSite->Release();
117
                }
118
                p_clientSite->Release();
119
            }
120
            p_oleObject->Release();
121
        }
122
        return S_OK;
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
    }
    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;
};