1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_shell.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //+------------------------------------------------------------------------- 32*cdf0e10cSrcweir // 33*cdf0e10cSrcweir // File: propspec.cxx 34*cdf0e10cSrcweir // 35*cdf0e10cSrcweir // Contents: C++ wrappers for FULLPROPSPEC 36*cdf0e10cSrcweir // 37*cdf0e10cSrcweir //-------------------------------------------------------------------------- 38*cdf0e10cSrcweir #if defined _MSC_VER 39*cdf0e10cSrcweir #pragma warning(push, 1) 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #include <windows.h> 42*cdf0e10cSrcweir #ifdef _MSC_VER 43*cdf0e10cSrcweir #pragma warning(disable: 4512) 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #include <filter.h> 46*cdf0e10cSrcweir #if defined _MSC_VER 47*cdf0e10cSrcweir #pragma warning(pop) 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include "propspec.hxx" 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //GUID CLSID_Storage = PSGUID_STORAGE; 53*cdf0e10cSrcweir // 54*cdf0e10cSrcweir // 55*cdf0e10cSrcweir //refer to ms-help://MS.VSCC/MS.MSDNVS.2052/com/stgasstg_7agk.htm 56*cdf0e10cSrcweir //FMTID_SummaryInformation 57*cdf0e10cSrcweir // 58*cdf0e10cSrcweir //GUID CLSID_SummaryInforation = { 59*cdf0e10cSrcweir // 0xF29F85E0, 60*cdf0e10cSrcweir // 0x4FF9, 61*cdf0e10cSrcweir // 0x1068, 62*cdf0e10cSrcweir // { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } 63*cdf0e10cSrcweir //}; 64*cdf0e10cSrcweir //+------------------------------------------------------------------------- 65*cdf0e10cSrcweir // 66*cdf0e10cSrcweir // Member: CFullPropSpec::CFullPropSpec, public 67*cdf0e10cSrcweir // 68*cdf0e10cSrcweir // Synopsis: Default constructor 69*cdf0e10cSrcweir // 70*cdf0e10cSrcweir // Effects: Defines property with null guid and propid 0 71*cdf0e10cSrcweir // 72*cdf0e10cSrcweir //-------------------------------------------------------------------------- 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir CFullPropSpec::CFullPropSpec() 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir memset( &_guidPropSet, 0, sizeof( _guidPropSet ) ); 77*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_PROPID; 78*cdf0e10cSrcweir _psProperty.propid = 0; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir //+------------------------------------------------------------------------- 81*cdf0e10cSrcweir // 82*cdf0e10cSrcweir // Member: CFullPropSpec::CFullPropSpec, public 83*cdf0e10cSrcweir // 84*cdf0e10cSrcweir // Synopsis: Construct propid based propspec 85*cdf0e10cSrcweir // 86*cdf0e10cSrcweir // Arguments: [guidPropSet] -- Property set 87*cdf0e10cSrcweir // [pidProperty] -- Property 88*cdf0e10cSrcweir // 89*cdf0e10cSrcweir //-------------------------------------------------------------------------- 90*cdf0e10cSrcweir CFullPropSpec::CFullPropSpec( GUID const & guidPropSet, PROPID pidProperty ) : 91*cdf0e10cSrcweir _guidPropSet( guidPropSet ) 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_PROPID; 94*cdf0e10cSrcweir _psProperty.propid = pidProperty; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir //+------------------------------------------------------------------------- 97*cdf0e10cSrcweir // 98*cdf0e10cSrcweir // Member: CFullPropSpec::CFullPropSpec, public 99*cdf0e10cSrcweir // 100*cdf0e10cSrcweir // Synopsis: Construct name based propspec 101*cdf0e10cSrcweir // 102*cdf0e10cSrcweir // Arguments: [guidPropSet] -- Property set 103*cdf0e10cSrcweir // [wcsProperty] -- Property 104*cdf0e10cSrcweir // 105*cdf0e10cSrcweir //-------------------------------------------------------------------------- 106*cdf0e10cSrcweir CFullPropSpec::CFullPropSpec( GUID const & guidPropSet, 107*cdf0e10cSrcweir WCHAR const * wcsProperty ) : 108*cdf0e10cSrcweir _guidPropSet( guidPropSet ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_PROPID; 111*cdf0e10cSrcweir SetProperty( wcsProperty ); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir //+------------------------------------------------------------------------- 114*cdf0e10cSrcweir // 115*cdf0e10cSrcweir // Member: CFullPropSpec::CFullPropSpec, public 116*cdf0e10cSrcweir // 117*cdf0e10cSrcweir // Synopsis: Copy constructor 118*cdf0e10cSrcweir // 119*cdf0e10cSrcweir // Arguments: [src] -- Source property spec 120*cdf0e10cSrcweir // 121*cdf0e10cSrcweir //-------------------------------------------------------------------------- 122*cdf0e10cSrcweir CFullPropSpec::CFullPropSpec( CFullPropSpec const & src ) : 123*cdf0e10cSrcweir _guidPropSet( src._guidPropSet ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir _psProperty.ulKind = src._psProperty.ulKind; 126*cdf0e10cSrcweir if ( _psProperty.ulKind == PRSPEC_LPWSTR ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir if ( src._psProperty.lpwstr ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_PROPID; 131*cdf0e10cSrcweir SetProperty( src._psProperty.lpwstr ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir else 134*cdf0e10cSrcweir _psProperty.lpwstr = 0; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir else 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir _psProperty.propid = src._psProperty.propid; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir inline void * operator new( size_t /*size*/, void * p ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir return( p ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir //+------------------------------------------------------------------------- 146*cdf0e10cSrcweir // 147*cdf0e10cSrcweir // Member: CFullPropSpec::operator=, public 148*cdf0e10cSrcweir // 149*cdf0e10cSrcweir // Synopsis: Assignment operator 150*cdf0e10cSrcweir // 151*cdf0e10cSrcweir // Arguments: [Property] -- Source property 152*cdf0e10cSrcweir // 153*cdf0e10cSrcweir //-------------------------------------------------------------------------- 154*cdf0e10cSrcweir CFullPropSpec & CFullPropSpec::operator=( CFullPropSpec const & Property ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir // Clean up. 157*cdf0e10cSrcweir this->CFullPropSpec::~CFullPropSpec(); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir #ifdef _MSC_VER 160*cdf0e10cSrcweir #pragma warning( disable : 4291 ) // unmatched operator new 161*cdf0e10cSrcweir #endif 162*cdf0e10cSrcweir new (this) CFullPropSpec( Property ); 163*cdf0e10cSrcweir #ifdef _MSC_VER 164*cdf0e10cSrcweir #pragma warning( default : 4291 ) 165*cdf0e10cSrcweir #endif 166*cdf0e10cSrcweir return *this; 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir CFullPropSpec::~CFullPropSpec() 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir if ( _psProperty.ulKind == PRSPEC_LPWSTR && 171*cdf0e10cSrcweir _psProperty.lpwstr ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir CoTaskMemFree( _psProperty.lpwstr ); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir void CFullPropSpec::SetProperty( PROPID pidProperty ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if ( _psProperty.ulKind == PRSPEC_LPWSTR && 179*cdf0e10cSrcweir 0 != _psProperty.lpwstr ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir CoTaskMemFree( _psProperty.lpwstr ); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_PROPID; 184*cdf0e10cSrcweir _psProperty.propid = pidProperty; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir BOOL CFullPropSpec::SetProperty( WCHAR const * wcsProperty ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir if ( _psProperty.ulKind == PRSPEC_LPWSTR && 189*cdf0e10cSrcweir 0 != _psProperty.lpwstr ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir CoTaskMemFree( _psProperty.lpwstr ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir _psProperty.ulKind = PRSPEC_LPWSTR; 194*cdf0e10cSrcweir int len = (int) ( (wcslen( wcsProperty ) + 1) * sizeof( WCHAR ) ); 195*cdf0e10cSrcweir _psProperty.lpwstr = (WCHAR *)CoTaskMemAlloc( len ); 196*cdf0e10cSrcweir if ( 0 != _psProperty.lpwstr ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir memcpy( _psProperty.lpwstr, 199*cdf0e10cSrcweir wcsProperty, 200*cdf0e10cSrcweir len ); 201*cdf0e10cSrcweir return( TRUE ); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir else 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir _psProperty.lpwstr = 0; 206*cdf0e10cSrcweir return( FALSE ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir int CFullPropSpec::operator==( CFullPropSpec const & prop ) const 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir if ( memcmp( &prop._guidPropSet, 212*cdf0e10cSrcweir &_guidPropSet, 213*cdf0e10cSrcweir sizeof( _guidPropSet ) ) != 0 || 214*cdf0e10cSrcweir prop._psProperty.ulKind != _psProperty.ulKind ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir return( 0 ); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir switch( _psProperty.ulKind ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir case PRSPEC_LPWSTR: 221*cdf0e10cSrcweir return( _wcsicmp( GetPropertyName(), prop.GetPropertyName() ) == 0 ); 222*cdf0e10cSrcweir break; 223*cdf0e10cSrcweir case PRSPEC_PROPID: 224*cdf0e10cSrcweir return( GetPropertyPropid() == prop.GetPropertyPropid() ); 225*cdf0e10cSrcweir break; 226*cdf0e10cSrcweir default: 227*cdf0e10cSrcweir return( 0 ); 228*cdf0e10cSrcweir break; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir int CFullPropSpec::operator!=( CFullPropSpec const & prop ) const 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if (*this == prop) 234*cdf0e10cSrcweir return( 0 ); 235*cdf0e10cSrcweir else 236*cdf0e10cSrcweir return( 1 ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239