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