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
25 #include <sal/config.h>
29 #if !defined WIN32_LEAN_AND_MEAN
30 # define WIN32_LEAN_AND_MEAN
35 #include "propspec.hxx"
37 //refer to ms-help://MS.VSCC/MS.MSDNVS.2052/com/stgasstg_7agk.htm
38 //FMTID_SummaryInformation
39 //GUID CLSID_SummaryInformation = {
43 // { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 }
45 //+-------------------------------------------------------------------------
46 // Member: CFullPropSpec::CFullPropSpec, public
47 // Synopsis: Default constructor
48 // Effects: Defines property with null guid and propid 0
51 CFullPropSpec::CFullPropSpec()
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
= nullptr;
102 _psProperty
.propid
= src
._psProperty
.propid
;
106 //+-------------------------------------------------------------------------
107 // Member: CFullPropSpec::operator=, public
108 // Synopsis: Assignment operator
109 // Arguments: [Property] -- Source property
111 CFullPropSpec
& CFullPropSpec::operator=( CFullPropSpec
const & Property
)
113 if (this != &Property
)
116 this->CFullPropSpec::~CFullPropSpec();
118 ::new (this) CFullPropSpec( Property
);
123 CFullPropSpec::~CFullPropSpec()
125 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
128 CoTaskMemFree( _psProperty
.lpwstr
);
132 void CFullPropSpec::SetProperty( PROPID pidProperty
)
134 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
135 nullptr != _psProperty
.lpwstr
)
137 CoTaskMemFree( _psProperty
.lpwstr
);
139 _psProperty
.ulKind
= PRSPEC_PROPID
;
140 _psProperty
.propid
= pidProperty
;
142 BOOL
CFullPropSpec::SetProperty( WCHAR
const * wcsProperty
)
144 if ( _psProperty
.ulKind
== PRSPEC_LPWSTR
&&
145 nullptr != _psProperty
.lpwstr
)
147 CoTaskMemFree( _psProperty
.lpwstr
);
149 _psProperty
.ulKind
= PRSPEC_LPWSTR
;
150 int len
= static_cast<int>( (wcslen( wcsProperty
) + 1) * sizeof( WCHAR
) );
151 _psProperty
.lpwstr
= static_cast<WCHAR
*>(CoTaskMemAlloc( len
));
152 if ( nullptr != _psProperty
.lpwstr
)
154 memcpy( _psProperty
.lpwstr
,
161 _psProperty
.lpwstr
= nullptr;
165 bool CFullPropSpec::operator==( CFullPropSpec
const & prop
) const
167 if ( memcmp( &prop
._guidPropSet
,
169 sizeof( _guidPropSet
) ) != 0 ||
170 prop
._psProperty
.ulKind
!= _psProperty
.ulKind
)
174 switch( _psProperty
.ulKind
)
177 return( _wcsicmp( GetPropertyName(), prop
.GetPropertyName() ) == 0 );
179 return( GetPropertyPropid() == prop
.GetPropertyPropid() );
184 bool CFullPropSpec::operator!=( CFullPropSpec
const & prop
) const
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */