lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / codemaker / source / javamaker / javamaker.cxx
blob2f0a1d71f34e28a48dc5e423aba7ed4a24e34b1e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <cstdlib>
23 #include <cstring>
24 #include <iostream>
25 #include <vector>
27 #include <codemaker/generatedtypeset.hxx>
28 #include <codemaker/typemanager.hxx>
29 #include <rtl/ref.hxx>
30 #include <rtl/string.hxx>
31 #include <rtl/ustring.hxx>
32 #include <sal/main.h>
33 #include <sal/types.h>
34 #include <unoidl/unoidl.hxx>
36 #include "javaoptions.hxx"
37 #include "javatype.hxx"
39 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
40 JavaOptions options;
41 try {
42 if (!options.initOptions(argc, argv)) {
43 return EXIT_FAILURE;
46 rtl::Reference< TypeManager > typeMgr(new TypeManager);
47 for (const OString& i : options.getExtraInputFiles())
49 typeMgr->loadProvider(convertToFileUrl(i), false);
51 for (const OString& i : options.getInputFiles())
53 typeMgr->loadProvider(convertToFileUrl(i), true);
55 codemaker::GeneratedTypeSet generated;
56 if (options.isValid("-T")) {
57 OUString names(b2u(options.getOption("-T")));
58 for (sal_Int32 i = 0; i != -1;) {
59 OUString name(names.getToken(0, ';', i));
60 if (!name.isEmpty()) {
61 produce(
62 (name == "*"
63 ? ""
64 : name.endsWith(".*")
65 ? name.copy(0, name.getLength() - std::strlen(".*"))
66 : name),
67 typeMgr, generated, options);
70 } else {
71 produce("", typeMgr, generated, options);
74 catch (CannotDumpException & e) {
75 std::cerr << "ERROR: " << e.getMessage() << '\n';
76 return EXIT_FAILURE;
77 } catch (unoidl::NoSuchFileException & e) {
78 std::cerr << "ERROR: No such file <" << e.getUri() << ">\n";
79 return EXIT_FAILURE;
80 } catch (unoidl::FileFormatException & e) {
81 std::cerr
82 << "ERROR: Bad format of <" << e.getUri() << ">, \""
83 << e.getDetail() << "\"\n";
84 return EXIT_FAILURE;
85 } catch (IllegalArgument & e) {
86 std::cerr << "Illegal option " << e.m_message << '\n';
87 return EXIT_FAILURE;
88 } catch (std::exception & e) {
89 std::cerr << "Failure " << e.what() << '\n';
90 return EXIT_FAILURE;
93 return EXIT_SUCCESS;
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */