1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 //+-------------------------------------------------------------------------
24 //
25 //  File:       propspec.hxx
26 //
27 //  Contents:   C++ wrapper(s) for FULLPROPSPEC
28 //
29 //-------------------------------------------------------------------------
30 #pragma once
31 #if defined _MSC_VER
32 #pragma warning(push, 1)
33 #endif
34 #include <windows.h>
35 #include <ole2.h>
36 #include <ntquery.h>
37 #if defined _MSC_VER
38 #pragma warning(pop)
39 #endif
40 //+-------------------------------------------------------------------------
41 //
42 //  Declare:    CLSID_SummaryInforation, GUID
43 //              CLSID_Storage, GUID
44 //
45 //  Contents:   Definitions of OpenOffice.org Document properties
46 //
47 //--------------------------------------------------------------------------
48 
49 //extern GUID CLSID_Storage;
50 //
51 //extern GUID CLSID_SummaryInformation;
52 //const PID_TITLE     = PIDSI_TITLE; // 2;
53 //const PID_SUBJECT   = PIDSI_SUBJECT; // 3;
54 //const PID_AUTHOR    = PIDSI_AUTHOR; // 4;
55 //const PID_KEYWORDS  = PIDSI_KEYWORDS; // 5;
56 //const PID_COMMENTS  = PIDSI_COMMENTS; //6;
57 //const PID_REVNUMBER = PIDSI_REVNUMBER; //9;
58 //const PID_WORDCOUNT = PIDSI_WORDCOUNT; //f;
59 //+-------------------------------------------------------------------------
60 //
61 //  Class:      CFullPropertySpec
62 //
63 //  Purpose:    Describes full (PropertySet\Property) name of a property.
64 //
65 //--------------------------------------------------------------------------
66 
67 class CFullPropSpec
68 {
69 public:
70     CFullPropSpec();
71     CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty );
72     CFullPropSpec( GUID const & guidPropSet, WCHAR const * wcsProperty );
73     // Validity check
74     inline BOOL IsValid() const;
75 
76     // Copy constructors/assignment/clone
77     CFullPropSpec( CFullPropSpec const & Property );
78     CFullPropSpec & operator=( CFullPropSpec const & Property );
79     ~CFullPropSpec();
80     // Memory allocation
81     void * operator new( size_t size );
82     inline void * operator new( size_t size, void * p );
83     void   operator delete( void * p );
84     inline FULLPROPSPEC * CastToStruct();
85     inline FULLPROPSPEC const * CastToStruct() const;
86     // Comparators
87     int operator==( CFullPropSpec const & prop ) const;
88     int operator!=( CFullPropSpec const & prop ) const;
89     // Member variable access
90     inline void SetPropSet( GUID const & guidPropSet );
91     inline GUID const & GetPropSet() const;
92 
93     void SetProperty( PROPID pidProperty );
94     BOOL SetProperty( WCHAR const * wcsProperty );
95     inline WCHAR const * GetPropertyName() const;
96     inline PROPID GetPropertyPropid() const;
97     inline PROPSPEC GetPropSpec() const;
98     inline BOOL IsPropertyName() const;
99     inline BOOL IsPropertyPropid() const;
100 private:
101     GUID     _guidPropSet;
102     PROPSPEC _psProperty;
103 };
104 // Inline methods for CFullPropSpec
operator new(size_t size)105 inline void * CFullPropSpec::operator new( size_t size )
106 {
107     void * p = CoTaskMemAlloc( size );
108     return( p );
109 }
operator new(size_t,void * p)110 inline void * CFullPropSpec::operator new( size_t /*size*/, void * p )
111 {
112     return( p );
113 }
operator delete(void * p)114 inline void CFullPropSpec::operator delete( void * p )
115 {
116     if ( p )
117         CoTaskMemFree( p );
118 }
IsValid() const119 inline BOOL CFullPropSpec::IsValid() const
120 {
121     return ( _psProperty.ulKind == PRSPEC_PROPID ||
122              0 != _psProperty.lpwstr );
123 }
SetPropSet(GUID const & guidPropSet)124 inline void CFullPropSpec::SetPropSet( GUID const & guidPropSet )
125 {
126     _guidPropSet = guidPropSet;
127 }
GetPropSet() const128 inline GUID const & CFullPropSpec::GetPropSet() const
129 {
130     return( _guidPropSet );
131 }
GetPropSpec() const132 inline PROPSPEC CFullPropSpec::GetPropSpec() const
133 {
134     return( _psProperty );
135 }
GetPropertyName() const136 inline WCHAR const * CFullPropSpec::GetPropertyName() const
137 {
138     return( _psProperty.lpwstr );
139 }
GetPropertyPropid() const140 inline PROPID CFullPropSpec::GetPropertyPropid() const
141 {
142     return( _psProperty.propid );
143 }
IsPropertyName() const144 inline BOOL CFullPropSpec::IsPropertyName() const
145 {
146     return( _psProperty.ulKind == PRSPEC_LPWSTR );
147 }
IsPropertyPropid() const148 inline BOOL CFullPropSpec::IsPropertyPropid() const
149 {
150     return( _psProperty.ulKind == PRSPEC_PROPID );
151 }
152 
153 
154 
155 
156