1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 //+-------------------------------------------------------------------------
23 // Contents: C++ wrappers for FULLPROPSPEC
26 #pragma warning(push, 1)
34 #include "propspec.hxx"
36 //refer to ms-help://MS.VSCC/MS.MSDNVS.2052/com/stgasstg_7agk.htm
37 //FMTID_SummaryInformation
38 //GUID CLSID_SummaryInforation = {
42 // { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 }
44 //+-------------------------------------------------------------------------
45 // Member: CFullPropSpec::CFullPropSpec, public
46 // Synopsis: Default constructor
47 // Effects: Defines property with null guid and propid 0
50 CFullPropSpec::CFullPropSpec()
52 memset( &_guidPropSet
, 0, sizeof( _guidPropSet
) );
53 _psProperty
.ulKind
= PRSPEC_PROPID
;
54 _psProperty
.propid
= 0;
56 //+-------------------------------------------------------------------------
57 // Member: CFullPropSpec::CFullPropSpec, public
58 // Synopsis: Construct propid based propspec
59 // Arguments: [guidPropSet] -- Property set
60 // [pidProperty] -- Property
62 CFullPropSpec::CFullPropSpec( GUID
const & guidPropSet
, PROPID pidProperty
) :
63 _guidPropSet( guidPropSet
)
65 _psProperty
.ulKind
= PRSPEC_PROPID
;
66 _psProperty
.propid
= pidProperty
;
68 //+-------------------------------------------------------------------------
69 // Member: CFullPropSpec::CFullPropSpec, public
70 // Synopsis: Construct name based propspec
71 // Arguments: [guidPropSet] -- Property set
72 // [wcsProperty] -- Property
74 CFullPropSpec::CFullPropSpec( GUID
const & guidPropSet
,
75 WCHAR
const * wcsProperty
) :
76 _guidPropSet( guidPropSet
)
78 _psProperty
.ulKind
= PRSPEC_PROPID
;
79 SetProperty( wcsProperty
);
81 //+-------------------------------------------------------------------------
82 // Member: CFullPropSpec::CFullPropSpec, public
83 // Synopsis: Copy constructor
84 // Arguments: [src] -- Source property spec
86 CFullPropSpec::CFullPropSpec( CFullPropSpec
const & src
) :
87 _guidPropSet( src
._guidPropSet
)
89 _psProperty
.ulKind
= src
._psProperty
.ulKind
;
90 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
)
92 if ( src
._psProperty
.lpwstr
)
94 _psProperty
.ulKind
= PRSPEC_PROPID
;
95 SetProperty( src
._psProperty
.lpwstr
);
98 _psProperty
.lpwstr
= 0;
102 _psProperty
.propid
= src
._psProperty
.propid
;
105 inline void * operator new( size_t /*size*/, void * p
)
109 //+-------------------------------------------------------------------------
110 // Member: CFullPropSpec::operator=, public
111 // Synopsis: Assignment operator
112 // Arguments: [Property] -- Source property
114 CFullPropSpec
& CFullPropSpec::operator=( CFullPropSpec
const & Property
)
117 this->CFullPropSpec::~CFullPropSpec();
120 #pragma warning( disable : 4291 ) // unmatched operator new
122 new (this) CFullPropSpec( Property
);
124 #pragma warning( default : 4291 )
128 CFullPropSpec::~CFullPropSpec()
130 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
133 CoTaskMemFree( _psProperty
.lpwstr
);
136 void CFullPropSpec::SetProperty( PROPID pidProperty
)
138 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
139 0 != _psProperty
.lpwstr
)
141 CoTaskMemFree( _psProperty
.lpwstr
);
143 _psProperty
.ulKind
= PRSPEC_PROPID
;
144 _psProperty
.propid
= pidProperty
;
146 BOOL
CFullPropSpec::SetProperty( WCHAR
const * wcsProperty
)
148 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
149 0 != _psProperty
.lpwstr
)
151 CoTaskMemFree( _psProperty
.lpwstr
);
153 _psProperty
.ulKind
= PRSPEC_LPWSTR
;
154 int len
= (int) ( (wcslen( wcsProperty
) + 1) * sizeof( WCHAR
) );
155 _psProperty
.lpwstr
= (WCHAR
*)CoTaskMemAlloc( len
);
156 if ( 0 != _psProperty
.lpwstr
)
158 memcpy( _psProperty
.lpwstr
,
165 _psProperty
.lpwstr
= 0;
169 int CFullPropSpec::operator==( CFullPropSpec
const & prop
) const
171 if ( memcmp( &prop
._guidPropSet
,
173 sizeof( _guidPropSet
) ) != 0 ||
174 prop
._psProperty
.ulKind
!= _psProperty
.ulKind
)
178 switch( _psProperty
.ulKind
)
181 return( _wcsicmp( GetPropertyName(), prop
.GetPropertyName() ) == 0 );
184 return( GetPropertyPropid() == prop
.GetPropertyPropid() );
191 int CFullPropSpec::operator!=( CFullPropSpec
const & prop
) const
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */