1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include <windows.h> 25 #include "smartpointer.hxx" 26 27 namespace inprocserv { 28 29 class OleWrapperAdviseSink : public IAdviseSink 30 { 31 protected: 32 ULONG m_nRefCount; 33 34 ComSmart< IAdviseSink > m_pListener; 35 DWORD m_nListenerID; 36 37 FORMATETC* m_pFormatEtc; 38 DWORD m_nAspect; 39 40 DWORD m_nRegID; 41 DWORD m_bObjectAdvise; 42 DWORD m_nDataRegFlag; 43 DWORD m_nViewRegFlag; 44 45 BOOL m_bHandleClosed; 46 BOOL m_bClosed; 47 48 public: 49 // an AdviseSink for own needs, should be created always 50 OleWrapperAdviseSink(); 51 52 // an AdviseSink for IOleObject interface 53 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener ); 54 55 // an AdviseSink for IDataObject interface 56 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, FORMATETC* pFormatEtc, DWORD nDataRegFlag ); 57 58 // an AdviseSink for IViewObject interface 59 OleWrapperAdviseSink( const ComSmart< IAdviseSink >& pListener, DWORD nAspect, DWORD nViewRegFlag ); 60 61 virtual ~OleWrapperAdviseSink(); 62 SetRegID(DWORD nRegID)63 void SetRegID( DWORD nRegID ) { m_nRegID = nRegID; } GetRegID()64 DWORD GetRegID() { return m_nRegID; } 65 IsOleAdvise()66 BOOL IsOleAdvise() { return m_bObjectAdvise; } GetDataAdviseFlag()67 DWORD GetDataAdviseFlag() { return m_nDataRegFlag; } GetViewAdviseFlag()68 DWORD GetViewAdviseFlag() { return m_nViewRegFlag; } 69 GetFormatEtc()70 FORMATETC* GetFormatEtc() { return m_pFormatEtc; } GetAspect()71 DWORD GetAspect() { return m_nAspect; } GetOrigAdvise()72 ComSmart< IAdviseSink >& GetOrigAdvise() { return m_pListener; } DisconnectOrigAdvise()73 void DisconnectOrigAdvise() { m_pListener = NULL; } 74 SetClosed()75 void SetClosed() { m_bClosed = TRUE; } UnsetClosed()76 void UnsetClosed() { m_bClosed = FALSE; } IsClosed()77 BOOL IsClosed() { return m_bClosed; } 78 79 STDMETHODIMP QueryInterface(REFIID, void**); 80 STDMETHODIMP_(ULONG) AddRef(void); 81 STDMETHODIMP_(ULONG) Release(void); 82 83 STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM); 84 STDMETHODIMP_(void) OnViewChange(DWORD, LONG); 85 STDMETHODIMP_(void) OnRename(LPMONIKER); 86 STDMETHODIMP_(void) OnSave(void); 87 STDMETHODIMP_(void) OnClose(void); 88 }; 89 90 }; // namespace advisesink 91 92