1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: idlmaker.cxx,v $
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_codemaker.hxx"
38 #include <codemaker/typemanager.hxx>
39 #include <codemaker/dependency.hxx>
41 #include "idloptions.hxx"
42 #include "idltype.hxx"
46 sal_Bool
produceAllTypes(const OString
& typeName
,
48 TypeDependency
& typeDependencies
,
51 throw( CannotDumpException
)
53 if (!produceType(typeName
, typeMgr
, typeDependencies
, pOptions
))
55 fprintf(stderr
, "%s ERROR: %s\n",
56 pOptions
->getProgramName().getStr(),
57 OString("cannot dump Type '" + typeName
+ "'").getStr());
61 RegistryKey typeKey
= typeMgr
.getTypeKey(typeName
);
62 RegistryKeyNames subKeys
;
64 if (typeKey
.getKeyNames(OUString(), subKeys
))
68 for (sal_uInt32 i
=0; i
< subKeys
.getLength(); i
++)
70 tmpName
= OUStringToOString(subKeys
.getElement(i
), RTL_TEXTENCODING_UTF8
);
72 if (pOptions
->isValid("-B"))
73 tmpName
= tmpName
.copy(tmpName
.indexOf('/', 1) + 1);
75 tmpName
= tmpName
.copy(1);
79 if (!produceAllTypes(tmpName
, typeMgr
, typeDependencies
, pOptions
, sal_True
))
83 if (!produceType(tmpName
, typeMgr
, typeDependencies
, pOptions
))
91 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
)
97 if (!options
.initOptions(argc
, argv
))
102 catch( IllegalArgument
& e
)
104 fprintf(stderr
, "Illegal option: %s\n", e
.m_message
.getStr());
108 RegistryTypeManager typeMgr
;
109 TypeDependency typeDependencies
;
111 if (!typeMgr
.init(!options
.isValid("-T"), options
.getInputFiles()))
113 fprintf(stderr
, "%s : init registries failed, check your registry files.\n", options
.getProgramName().getStr());
117 if (options
.isValid("-B"))
119 typeMgr
.setBase(options
.getOption("-B"));
124 if (options
.isValid("-T"))
126 OString
tOption(options
.getOption("-T"));
128 OString typeName
, tmpName
;
129 sal_Bool ret
= sal_False
;
130 sal_Int32 nIndex
= 0;
133 typeName
= tOption
.getToken(0, ';', nIndex
);
135 sal_Int32 nPos
= typeName
.lastIndexOf( '.' );
136 tmpName
= typeName
.copy( nPos
!= -1 ? nPos
+1 : 0 );
139 // produce this type and his scope, but the scope is not recursively generated.
140 if (typeName
.equals("*"))
145 tmpName
= typeName
.copy(0, typeName
.lastIndexOf('.')).replace('.', '/');
146 if (tmpName
.getLength() == 0)
149 tmpName
.replace('.', '/');
151 ret
= produceAllTypes(tmpName
, typeMgr
, typeDependencies
, &options
, sal_False
);
154 // produce only this type
155 ret
= produceType(typeName
.replace('.', '/'), typeMgr
, typeDependencies
, &options
);
160 fprintf(stderr
, "%s ERROR: %s\n",
161 options
.getProgramName().getStr(),
162 OString("cannot dump Type '" + typeName
+ "'").getStr());
165 } while( nIndex
!= -1 );
169 if (!produceAllTypes("/", typeMgr
, typeDependencies
, &options
, sal_True
))
171 fprintf(stderr
, "%s ERROR: %s\n",
172 options
.getProgramName().getStr(),
173 "an error occurs while dumping all types.");
178 catch( CannotDumpException
& e
)
180 fprintf(stderr
, "%s ERROR: %s\n",
181 options
.getProgramName().getStr(),
182 e
.m_message
.getStr());