1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propspec.cxx,v $
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 //+-------------------------------------------------------------------------
38 // Contents: C++ wrappers for FULLPROPSPEC
40 //--------------------------------------------------------------------------
42 #pragma warning(push, 1)
46 #pragma warning(disable: 4512)
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 = {
65 // { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 }
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
);
137 _psProperty
.lpwstr
= 0;
141 _psProperty
.propid
= src
._psProperty
.propid
;
144 inline void * operator new( size_t /*size*/, void * p
)
148 //+-------------------------------------------------------------------------
150 // Member: CFullPropSpec::operator=, public
152 // Synopsis: Assignment operator
154 // Arguments: [Property] -- Source property
156 //--------------------------------------------------------------------------
157 CFullPropSpec
& CFullPropSpec::operator=( CFullPropSpec
const & Property
)
160 this->CFullPropSpec::~CFullPropSpec();
163 #pragma warning( disable : 4291 ) // unmatched operator new
165 new (this) CFullPropSpec( Property
);
167 #pragma warning( default : 4291 )
171 CFullPropSpec::~CFullPropSpec()
173 if ( _psProperty
.ulKind
== PRSPEC_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
,
208 _psProperty
.lpwstr
= 0;
212 int CFullPropSpec::operator==( CFullPropSpec
const & prop
) const
214 if ( memcmp( &prop
._guidPropSet
,
216 sizeof( _guidPropSet
) ) != 0 ||
217 prop
._psProperty
.ulKind
!= _psProperty
.ulKind
)
221 switch( _psProperty
.ulKind
)
224 return( _wcsicmp( GetPropertyName(), prop
.GetPropertyName() ) == 0 );
227 return( GetPropertyPropid() == prop
.GetPropertyPropid() );
234 int CFullPropSpec::operator!=( CFullPropSpec
const & prop
) const