xref: /trunk/main/shell/inc/internal/propertyhdl.hxx (revision 67e470da)
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 #ifndef PROPERTYHDL_HXX_INCLUDED
25 #define PROPERTYHDL_HXX_INCLUDED
26 
27 #if defined _MSC_VER
28 #pragma warning(push, 1)
29 #pragma warning(disable:4917)
30 #endif
31 #include <shlobj.h>
32 #if defined _MSC_VER
33 #pragma warning(pop)
34 #endif
35 
36 // {AE424E85-F6DF-4910-A6A9-438797986431}
37 const CLSID CLSID_PROPERTY_HANDLER =
38 { 0xae424e85, 0xf6df, 0x4910, { 0xa6, 0xa9, 0x43, 0x87, 0x97, 0x98, 0x64, 0x31 } };
39 
40 class CMetaInfoReader;
41 
42 class CPropertyHdl : public IPropertyStore,
43                      public IPropertyStoreCapabilities,
44                      public IInitializeWithStream
45 {
46 public:
47 	         CPropertyHdl(long RefCnt = 1);
48 	virtual ~CPropertyHdl();
49 
50 	//-----------------------------
51 	// IUnknown methods
52 	//-----------------------------
53 	virtual HRESULT STDMETHODCALLTYPE QueryInterface(
54             REFIID riid,
55             void __RPC_FAR *__RPC_FAR *ppvObject );
56     virtual ULONG STDMETHODCALLTYPE AddRef( void );
57     virtual ULONG STDMETHODCALLTYPE Release( void );
58 
59 	//-----------------------------
60 	// IPropertyStore
61 	//-----------------------------
62     virtual HRESULT STDMETHODCALLTYPE GetCount( DWORD *pcProps );
63     virtual HRESULT STDMETHODCALLTYPE GetAt( DWORD iProp, PROPERTYKEY *pkey );
64     virtual HRESULT STDMETHODCALLTYPE GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar );
65     virtual HRESULT STDMETHODCALLTYPE SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar );
66     virtual HRESULT STDMETHODCALLTYPE Commit();
67 
68 	//-----------------------------
69 	// IPropertyStoreCapabilities
70 	//-----------------------------
71     virtual HRESULT STDMETHODCALLTYPE IsPropertyWritable( REFPROPERTYKEY key );
72 
73 	//-----------------------------
74 	// IInitializeWithStream
75 	//-----------------------------
76     virtual HRESULT STDMETHODCALLTYPE Initialize(IStream *pStream, DWORD grfMode);
77 
78 private:
79     void        LoadProperties( CMetaInfoReader *pMetaInfoReader );
80     HRESULT     GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData );
81 
82 private:
83     long m_RefCnt;
84     IPropertyStoreCache* m_pCache;
85 };
86 
87 class CClassFactory : public IClassFactory
88 {
89 public:
90     CClassFactory( const CLSID& clsid );
91     virtual ~CClassFactory();
92 
93     //-----------------------------
94     // IUnknown methods
95     //-----------------------------
96     virtual HRESULT STDMETHODCALLTYPE QueryInterface(
97             REFIID riid,
98             void __RPC_FAR *__RPC_FAR *ppvObject);
99     virtual ULONG STDMETHODCALLTYPE AddRef( void );
100     virtual ULONG STDMETHODCALLTYPE Release( void );
101 
102 	//-----------------------------
103 	// IClassFactory methods
104 	//-----------------------------
105 	virtual HRESULT STDMETHODCALLTYPE CreateInstance(
106 	        IUnknown __RPC_FAR *pUnkOuter,
107             REFIID riid,
108             void __RPC_FAR *__RPC_FAR *ppvObject);
109 
110     virtual HRESULT STDMETHODCALLTYPE LockServer( BOOL fLock );
111     static bool IsLocked();
112 
113 private:
114     long  m_RefCnt;
115     CLSID m_Clsid;
116     static long  s_ServerLocks;
117 };
118 
119 #endif
120