1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_bridges.hxx" 30 31 #include "bridges/cpp_uno/shared/types.hxx" 32 33 #include "typelib/typeclass.h" 34 #include "typelib/typedescription.h" 35 36 namespace bridges { namespace cpp_uno { namespace shared { 37 38 namespace { 39 bool isSimpleStruct(typelib_TypeDescription const * type) { 40 switch (type->eTypeClass) { 41 case typelib_TypeClass_STRUCT: 42 { 43 typelib_CompoundTypeDescription const * p 44 = reinterpret_cast< typelib_CompoundTypeDescription const * >( 45 type); 46 for (sal_Int32 i = 0; i < p->nMembers; ++i) { 47 switch (p->ppTypeRefs[i]->eTypeClass) { 48 case typelib_TypeClass_STRUCT: 49 { 50 typelib_TypeDescription * t = 0; 51 TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); 52 bool b = isSimpleStruct(t); 53 TYPELIB_DANGER_RELEASE(t); 54 if (!b) { 55 return false; 56 } 57 } 58 break; 59 60 default: 61 if (!isSimpleType(p->ppTypeRefs[i]->eTypeClass)) 62 return false; 63 break; 64 } 65 } 66 } 67 return true; 68 69 default: 70 return false; 71 } 72 } 73 } 74 75 bool isSmallStruct(typelib_TypeDescription const * type) { 76 return (type->nSize <= 8 && isSimpleStruct(type)); 77 } 78 79 } } } 80