Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
20 : #define INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
21 :
22 : #include "rtl/string.hxx"
23 : #include "registry/reader.hxx"
24 : #include "codemaker/typemanager.hxx"
25 : #include "codemaker/unotype.hxx"
26 :
27 : #include <fstream>
28 : #include <boost/unordered_set.hpp>
29 : #include <map>
30 :
31 : namespace skeletonmaker {
32 :
33 : typedef ::std::map< ::rtl::OString, ::std::vector< ::rtl::OString >,
34 : ::std::less< ::rtl::OString > > ProtocolCmdMap;
35 :
36 : typedef ::std::vector< ::std::pair< rtl::OString,
37 : ::std::pair< rtl::OString, sal_Int16 > > > AttributeInfo;
38 :
39 :
40 0 : struct ProgramOptions {
41 0 : ProgramOptions(): java5(true), all(false), dump(false), license(false),
42 : shortnames(false), supportpropertysetmixin(false),
43 0 : backwardcompatible(false), language(1), componenttype(1) {}
44 :
45 : bool java5;
46 : bool all;
47 : bool dump;
48 : bool license;
49 : bool shortnames;
50 : bool supportpropertysetmixin;
51 : bool backwardcompatible;
52 : // language specifier - is extendable
53 : // 1 = Java
54 : // 2 = C++
55 : short language;
56 : // component type
57 : // 1 = default UNO component - is extendable
58 : // 2 = calc add-in
59 : // 3 = add-on
60 : short componenttype;
61 : rtl::OString outputpath;
62 : rtl::OString implname;
63 : ProtocolCmdMap protocolCmdMap;
64 : };
65 :
66 :
67 : /**
68 : print the standard OpenOffice.org license header
69 :
70 : @param o specifies the output stream
71 : @param filename specifies the source file name
72 : */
73 : void printLicenseHeader(std::ostream& o, rtl::OString const & filename);
74 :
75 : /**
76 : create dependent on the output path, the implementation name and the
77 : extension a new output file. If output path is equal "stdout" the tool
78 : generates the output to standard out.
79 :
80 : @param options the program options including the output path and the
81 : implementation name
82 : @param extension specifies the file extensions (e.g. .cxx or .java)
83 : @param ppOutputStream out parameter returning the output stream
84 : @param targetSourceFileName out parameter returning the generated file name
85 : constructed on base of the output path, the
86 : implementation name and the extension
87 : @param tmpSourceFileName out parameter returning the temporary file name based
88 : on the output path and a generated temporary file name.
89 : @return true if output is generated to standard out or else false
90 : */
91 : bool getOutputStream(ProgramOptions const & options,
92 : rtl::OString const & extension,
93 : std::ostream** ppOutputStream,
94 : rtl::OString & targetSourceFileName,
95 : rtl::OString & tmpSourceFileName);
96 :
97 : codemaker::UnoType::Sort decomposeResolveAndCheck(
98 : TypeManager const & manager, rtl::OString const & type,
99 : bool resolveTypedefs, bool allowVoid, bool allowExtraEntities,
100 : RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank,
101 : std::vector< rtl::OString > * arguments);
102 :
103 : void checkType(TypeManager const & manager,
104 : rtl::OString const & type,
105 : boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaceTypes,
106 : boost::unordered_set< rtl::OString, rtl::OStringHash >& serviceTypes,
107 : AttributeInfo& properties);
108 :
109 : void checkDefaultInterfaces(
110 : boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaces,
111 : const boost::unordered_set< rtl::OString, rtl::OStringHash >& services,
112 : const rtl::OString & propertyhelper);
113 :
114 : rtl::OString checkPropertyHelper(
115 : ProgramOptions const & options, TypeManager const & manager,
116 : const boost::unordered_set< rtl::OString, rtl::OStringHash >& services,
117 : const boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaces,
118 : AttributeInfo& attributes,
119 : boost::unordered_set< rtl::OString, rtl::OStringHash >& propinterfaces);
120 :
121 : /**
122 : checks whether the return and parameters types are valid and allowed
123 : calc add-in type. The function throws a CannotDumpException with an
124 : detailed error description which type is wrong
125 :
126 : @param manager a type manager
127 : @param reader a registry type reader of an interface defining
128 : calc add-in functions
129 : */
130 : void checkAddInTypes(TypeManager const & manager,
131 : typereg::Reader const & reader);
132 :
133 :
134 : /**
135 : checks if XComponent have to be supported, if yes it removes it from the
136 : supported interfaces list becuase it becmoes implmented by the appropriate
137 : helper
138 :
139 : @param manager a type manager
140 : @param interfaces a list of interfaces which should be implemented
141 :
142 : @return true if XComponent have to be supported
143 : */
144 : bool checkXComponentSupport(TypeManager const & manager,
145 : boost::unordered_set< rtl::OString, rtl::OStringHash >& interfaces);
146 :
147 :
148 : sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader,
149 : sal_uInt16 field, sal_uInt16 method);
150 :
151 :
152 : void generateFunctionParameterMap(std::ostream& o,
153 : ProgramOptions const & options,
154 : TypeManager const & manager,
155 : const boost::unordered_set< ::rtl::OString, ::rtl::OStringHash >& interfaces);
156 :
157 : }
158 :
159 : #endif // INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
160 :
161 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|