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 // 26 // File: propspec.hxx 27 // 28 // Contents: C++ wrapper(s) for FULLPROPSPEC 29 // 30 //------------------------------------------------------------------------- 31 #pragma once 32 #if defined _MSC_VER 33 #pragma warning(push, 1) 34 #endif 35 #include <windows.h> 36 #include <ole2.h> 37 #include <ntquery.h> 38 #if defined _MSC_VER 39 #pragma warning(pop) 40 #endif 41 //+------------------------------------------------------------------------- 42 // 43 // Declare: CLSID_SummaryInforation, GUID 44 // CLSID_Storage, GUID 45 // 46 // Contents: Definitions of OpenOffice Document properties 47 // 48 //-------------------------------------------------------------------------- 49 50 //extern GUID CLSID_Storage; 51 // 52 //extern GUID CLSID_SummaryInformation; 53 //const PID_TITLE = PIDSI_TITLE; // 2; 54 //const PID_SUBJECT = PIDSI_SUBJECT; // 3; 55 //const PID_AUTHOR = PIDSI_AUTHOR; // 4; 56 //const PID_KEYWORDS = PIDSI_KEYWORDS; // 5; 57 //const PID_COMMENTS = PIDSI_COMMENTS; //6; 58 //const PID_REVNUMBER = PIDSI_REVNUMBER; //9; 59 //const PID_WORDCOUNT = PIDSI_WORDCOUNT; //f; 60 //+------------------------------------------------------------------------- 61 // 62 // Class: CFullPropertySpec 63 // 64 // Purpose: Describes full (PropertySet\Property) name of a property. 65 // 66 //-------------------------------------------------------------------------- 67 68 class CFullPropSpec 69 { 70 public: 71 CFullPropSpec(); 72 CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty ); 73 CFullPropSpec( GUID const & guidPropSet, WCHAR const * wcsProperty ); 74 // Validity check 75 inline BOOL IsValid() const; 76 77 // Copy constructors/assignment/clone 78 CFullPropSpec( CFullPropSpec const & Property ); 79 CFullPropSpec & operator=( CFullPropSpec const & Property ); 80 ~CFullPropSpec(); 81 // Memory allocation 82 void * operator new( size_t size ); 83 inline void * operator new( size_t size, void * p ); 84 void operator delete( void * p ); 85 inline FULLPROPSPEC * CastToStruct(); 86 inline FULLPROPSPEC const * CastToStruct() const; 87 // Comparators 88 int operator==( CFullPropSpec const & prop ) const; 89 int operator!=( CFullPropSpec const & prop ) const; 90 // Member variable access 91 inline void SetPropSet( GUID const & guidPropSet ); 92 inline GUID const & GetPropSet() const; 93 94 void SetProperty( PROPID pidProperty ); 95 BOOL SetProperty( WCHAR const * wcsProperty ); 96 inline WCHAR const * GetPropertyName() const; 97 inline PROPID GetPropertyPropid() const; 98 inline PROPSPEC GetPropSpec() const; 99 inline BOOL IsPropertyName() const; 100 inline BOOL IsPropertyPropid() const; 101 private: 102 GUID _guidPropSet; 103 PROPSPEC _psProperty; 104 }; 105 // Inline methods for CFullPropSpec 106 inline void * CFullPropSpec::operator new( size_t size ) 107 { 108 void * p = CoTaskMemAlloc( size ); 109 return( p ); 110 } 111 inline void * CFullPropSpec::operator new( size_t /*size*/, void * p ) 112 { 113 return( p ); 114 } 115 inline void CFullPropSpec::operator delete( void * p ) 116 { 117 if ( p ) 118 CoTaskMemFree( p ); 119 } 120 inline BOOL CFullPropSpec::IsValid() const 121 { 122 return ( _psProperty.ulKind == PRSPEC_PROPID || 123 0 != _psProperty.lpwstr ); 124 } 125 inline void CFullPropSpec::SetPropSet( GUID const & guidPropSet ) 126 { 127 _guidPropSet = guidPropSet; 128 } 129 inline GUID const & CFullPropSpec::GetPropSet() const 130 { 131 return( _guidPropSet ); 132 } 133 inline PROPSPEC CFullPropSpec::GetPropSpec() const 134 { 135 return( _psProperty ); 136 } 137 inline WCHAR const * CFullPropSpec::GetPropertyName() const 138 { 139 return( _psProperty.lpwstr ); 140 } 141 inline PROPID CFullPropSpec::GetPropertyPropid() const 142 { 143 return( _psProperty.propid ); 144 } 145 inline BOOL CFullPropSpec::IsPropertyName() const 146 { 147 return( _psProperty.ulKind == PRSPEC_LPWSTR ); 148 } 149 inline BOOL CFullPropSpec::IsPropertyPropid() const 150 { 151 return( _psProperty.ulKind == PRSPEC_PROPID ); 152 } 153