1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include <windows.h> 29 #include "smartpointer.hxx" 30 31 namespace inprocserv { 32 33 class OleWrapperAdviseSink : public IAdviseSink 34 { 35 protected: 36 ULONG m_nRefCount; 37 38 ComSmart< IAdviseSink > m_pListener; 39 DWORD m_nListenerID; 40 41 FORMATETC* m_pFormatEtc; 42 DWORD m_nAspect; 43 44 DWORD m_nRegID; 45 DWORD m_bObjectAdvise; 46 DWORD m_nDataRegFlag; 47 DWORD m_nViewRegFlag; 48 49 BOOL m_bHandleClosed; 50 BOOL m_bClosed; 51 52 public: 53 // an AdviseSink for own needs, should be created always 54 OleWrapperAdviseSink(); 55 56 // an AdviseSink for IOleObject interface 57 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener ); 58 59 // an AdviseSink for IDataObject interface 60 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, FORMATETC* pFormatEtc, DWORD nDataRegFlag ); 61 62 // an AdviseSink for IViewObject interface 63 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, DWORD nAspect, DWORD nViewRegFlag ); 64 65 virtual ~OleWrapperAdviseSink(); 66 67 void SetRegID( DWORD nRegID ) { m_nRegID = nRegID; } 68 DWORD GetRegID() { return m_nRegID; } 69 70 BOOL IsOleAdvise() { return m_bObjectAdvise; } 71 DWORD GetDataAdviseFlag() { return m_nDataRegFlag; } 72 DWORD GetViewAdviseFlag() { return m_nViewRegFlag; } 73 74 FORMATETC* GetFormatEtc() { return m_pFormatEtc; } 75 DWORD GetAspect() { return m_nAspect; } 76 ComSmart< IAdviseSink >& GetOrigAdvise() { return m_pListener; } 77 void DisconnectOrigAdvise() { m_pListener = NULL; } 78 79 void SetClosed() { m_bClosed = TRUE; } 80 void UnsetClosed() { m_bClosed = FALSE; } 81 BOOL IsClosed() { return m_bClosed; } 82 83 STDMETHODIMP QueryInterface(REFIID, void**); 84 STDMETHODIMP_(ULONG) AddRef(void); 85 STDMETHODIMP_(ULONG) Release(void); 86 87 STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM); 88 STDMETHODIMP_(void) OnViewChange(DWORD, LONG); 89 STDMETHODIMP_(void) OnRename(LPMONIKER); 90 STDMETHODIMP_(void) OnSave(void); 91 STDMETHODIMP_(void) OnClose(void); 92 }; 93 94 }; // namespace advisesink 95 96