xref: /trunk/main/shell/inc/internal/propertyhdl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2008 by Sun Microsystems, Inc.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * $RCSfile: PropertyHdl.hxx,v $
10  * $Revision: 1.5 $
11  *
12  * This file is part of OpenOffice.org.
13  *
14  * OpenOffice.org is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU Lesser General Public License version 3
16  * only, as published by the Free Software Foundation.
17  *
18  * OpenOffice.org is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License version 3 for more details
22  * (a copy is included in the LICENSE file that accompanied this code).
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * version 3 along with OpenOffice.org.  If not, see
26  * <http://www.openoffice.org/license.html>
27  * for a copy of the LGPLv3 License.
28  *
29  ************************************************************************/
30 
31 #ifndef PROPERTYHDL_HXX_INCLUDED
32 #define PROPERTYHDL_HXX_INCLUDED
33 
34 #if defined _MSC_VER
35 #pragma warning(push, 1)
36 #pragma warning(disable:4917)
37 #endif
38 #include <shlobj.h>
39 #if defined _MSC_VER
40 #pragma warning(pop)
41 #endif
42 
43 // {AE424E85-F6DF-4910-A6A9-438797986431}
44 const CLSID CLSID_PROPERTY_HANDLER =
45 { 0xae424e85, 0xf6df, 0x4910, { 0xa6, 0xa9, 0x43, 0x87, 0x97, 0x98, 0x64, 0x31 } };
46 
47 class CMetaInfoReader;
48 
49 class CPropertyHdl : public IPropertyStore,
50                      public IPropertyStoreCapabilities,
51                      public IInitializeWithStream
52 {
53 public:
54 	         CPropertyHdl(long RefCnt = 1);
55 	virtual ~CPropertyHdl();
56 
57 	//-----------------------------
58 	// IUnknown methods
59 	//-----------------------------
60 	virtual HRESULT STDMETHODCALLTYPE QueryInterface(
61             REFIID riid,
62             void __RPC_FAR *__RPC_FAR *ppvObject );
63     virtual ULONG STDMETHODCALLTYPE AddRef( void );
64     virtual ULONG STDMETHODCALLTYPE Release( void );
65 
66 	//-----------------------------
67 	// IPropertyStore
68 	//-----------------------------
69     virtual HRESULT STDMETHODCALLTYPE GetCount( DWORD *pcProps );
70     virtual HRESULT STDMETHODCALLTYPE GetAt( DWORD iProp, PROPERTYKEY *pkey );
71     virtual HRESULT STDMETHODCALLTYPE GetValue( REFPROPERTYKEY key, PROPVARIANT *pPropVar );
72     virtual HRESULT STDMETHODCALLTYPE SetValue( REFPROPERTYKEY key, REFPROPVARIANT propVar );
73     virtual HRESULT STDMETHODCALLTYPE Commit();
74 
75 	//-----------------------------
76 	// IPropertyStoreCapabilities
77 	//-----------------------------
78     virtual HRESULT STDMETHODCALLTYPE IsPropertyWritable( REFPROPERTYKEY key );
79 
80 	//-----------------------------
81 	// IInitializeWithStream
82 	//-----------------------------
83     virtual HRESULT STDMETHODCALLTYPE Initialize(IStream *pStream, DWORD grfMode);
84 
85 private:
86     void        LoadProperties( CMetaInfoReader *pMetaInfoReader );
87     HRESULT     GetItemData( CMetaInfoReader *pMetaInfoReader, UINT nIndex, PROPVARIANT *pVarData );
88 
89 private:
90     long m_RefCnt;
91     IPropertyStoreCache* m_pCache;
92 };
93 
94 class CClassFactory : public IClassFactory
95 {
96 public:
97     CClassFactory( const CLSID& clsid );
98     virtual ~CClassFactory();
99 
100     //-----------------------------
101     // IUnknown methods
102     //-----------------------------
103     virtual HRESULT STDMETHODCALLTYPE QueryInterface(
104             REFIID riid,
105             void __RPC_FAR *__RPC_FAR *ppvObject);
106     virtual ULONG STDMETHODCALLTYPE AddRef( void );
107     virtual ULONG STDMETHODCALLTYPE Release( void );
108 
109 	//-----------------------------
110 	// IClassFactory methods
111 	//-----------------------------
112 	virtual HRESULT STDMETHODCALLTYPE CreateInstance(
113 	        IUnknown __RPC_FAR *pUnkOuter,
114             REFIID riid,
115             void __RPC_FAR *__RPC_FAR *ppvObject);
116 
117     virtual HRESULT STDMETHODCALLTYPE LockServer( BOOL fLock );
118     static bool IsLocked();
119 
120 private:
121     long  m_RefCnt;
122     CLSID m_Clsid;
123     static long  s_ServerLocks;
124 };
125 
126 #endif
127