update dev300-m58
[ooovba.git] / shell / source / win32 / shlxthandler / ooofilt / propspec.cxx
blob019cb12d7e2b902520bed9d481175458705e65cd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propspec.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
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.
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).
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.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
34 //+-------------------------------------------------------------------------
36 // File: propspec.cxx
38 // Contents: C++ wrappers for FULLPROPSPEC
40 //--------------------------------------------------------------------------
41 #if defined _MSC_VER
42 #pragma warning(push, 1)
43 #endif
44 #include <windows.h>
45 #ifdef _MSC_VER
46 #pragma warning(disable: 4512)
47 #endif
48 #include <filter.h>
49 #if defined _MSC_VER
50 #pragma warning(pop)
51 #endif
53 #include "propspec.hxx"
55 //GUID CLSID_Storage = PSGUID_STORAGE;
58 //refer to ms-help://MS.VSCC/MS.MSDNVS.2052/com/stgasstg_7agk.htm
59 //FMTID_SummaryInformation
61 //GUID CLSID_SummaryInforation = {
62 // 0xF29F85E0,
63 // 0x4FF9,
64 // 0x1068,
65 // { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 }
66 //};
67 //+-------------------------------------------------------------------------
69 // Member: CFullPropSpec::CFullPropSpec, public
71 // Synopsis: Default constructor
73 // Effects: Defines property with null guid and propid 0
75 //--------------------------------------------------------------------------
77 CFullPropSpec::CFullPropSpec()
79 memset( &_guidPropSet, 0, sizeof( _guidPropSet ) );
80 _psProperty.ulKind = PRSPEC_PROPID;
81 _psProperty.propid = 0;
83 //+-------------------------------------------------------------------------
85 // Member: CFullPropSpec::CFullPropSpec, public
87 // Synopsis: Construct propid based propspec
89 // Arguments: [guidPropSet] -- Property set
90 // [pidProperty] -- Property
92 //--------------------------------------------------------------------------
93 CFullPropSpec::CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty ) :
94 _guidPropSet( guidPropSet )
96 _psProperty.ulKind = PRSPEC_PROPID;
97 _psProperty.propid = pidProperty;
99 //+-------------------------------------------------------------------------
101 // Member: CFullPropSpec::CFullPropSpec, public
103 // Synopsis: Construct name based propspec
105 // Arguments: [guidPropSet] -- Property set
106 // [wcsProperty] -- Property
108 //--------------------------------------------------------------------------
109 CFullPropSpec::CFullPropSpec( GUID const & guidPropSet,
110 WCHAR const * wcsProperty ) :
111 _guidPropSet( guidPropSet )
113 _psProperty.ulKind = PRSPEC_PROPID;
114 SetProperty( wcsProperty );
116 //+-------------------------------------------------------------------------
118 // Member: CFullPropSpec::CFullPropSpec, public
120 // Synopsis: Copy constructor
122 // Arguments: [src] -- Source property spec
124 //--------------------------------------------------------------------------
125 CFullPropSpec::CFullPropSpec( CFullPropSpec const & src ) :
126 _guidPropSet( src._guidPropSet )
128 _psProperty.ulKind = src._psProperty.ulKind;
129 if ( _psProperty.ulKind == PRSPEC_LPWSTR )
131 if ( src._psProperty.lpwstr )
133 _psProperty.ulKind = PRSPEC_PROPID;
134 SetProperty( src._psProperty.lpwstr );
136 else
137 _psProperty.lpwstr = 0;
139 else
141 _psProperty.propid = src._psProperty.propid;
144 inline void * operator new( size_t /*size*/, void * p )
146 return( p );
148 //+-------------------------------------------------------------------------
150 // Member: CFullPropSpec::operator=, public
152 // Synopsis: Assignment operator
154 // Arguments: [Property] -- Source property
156 //--------------------------------------------------------------------------
157 CFullPropSpec & CFullPropSpec::operator=( CFullPropSpec const & Property )
159 // Clean up.
160 this->CFullPropSpec::~CFullPropSpec();
162 #ifdef _MSC_VER
163 #pragma warning( disable : 4291 ) // unmatched operator new
164 #endif
165 new (this) CFullPropSpec( Property );
166 #ifdef _MSC_VER
167 #pragma warning( default : 4291 )
168 #endif
169 return *this;
171 CFullPropSpec::~CFullPropSpec()
173 if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
174 _psProperty.lpwstr )
176 CoTaskMemFree( _psProperty.lpwstr );
179 void CFullPropSpec::SetProperty( PROPID pidProperty )
181 if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
182 0 != _psProperty.lpwstr )
184 CoTaskMemFree( _psProperty.lpwstr );
186 _psProperty.ulKind = PRSPEC_PROPID;
187 _psProperty.propid = pidProperty;
189 BOOL CFullPropSpec::SetProperty( WCHAR const * wcsProperty )
191 if ( _psProperty.ulKind == PRSPEC_LPWSTR &&
192 0 != _psProperty.lpwstr )
194 CoTaskMemFree( _psProperty.lpwstr );
196 _psProperty.ulKind = PRSPEC_LPWSTR;
197 int len = (int) ( (wcslen( wcsProperty ) + 1) * sizeof( WCHAR ) );
198 _psProperty.lpwstr = (WCHAR *)CoTaskMemAlloc( len );
199 if ( 0 != _psProperty.lpwstr )
201 memcpy( _psProperty.lpwstr,
202 wcsProperty,
203 len );
204 return( TRUE );
206 else
208 _psProperty.lpwstr = 0;
209 return( FALSE );
212 int CFullPropSpec::operator==( CFullPropSpec const & prop ) const
214 if ( memcmp( &prop._guidPropSet,
215 &_guidPropSet,
216 sizeof( _guidPropSet ) ) != 0 ||
217 prop._psProperty.ulKind != _psProperty.ulKind )
219 return( 0 );
221 switch( _psProperty.ulKind )
223 case PRSPEC_LPWSTR:
224 return( _wcsicmp( GetPropertyName(), prop.GetPropertyName() ) == 0 );
225 break;
226 case PRSPEC_PROPID:
227 return( GetPropertyPropid() == prop.GetPropertyPropid() );
228 break;
229 default:
230 return( 0 );
231 break;
234 int CFullPropSpec::operator!=( CFullPropSpec const & prop ) const
236 if (*this == prop)
237 return( 0 );
238 else
239 return( 1 );