102d11301SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
302d11301SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
402d11301SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
502d11301SAndrew Rist  * distributed with this work for additional information
602d11301SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
702d11301SAndrew Rist  * to you under the Apache License, Version 2.0 (the
802d11301SAndrew Rist  * "License"); you may not use this file except in compliance
902d11301SAndrew Rist  * with the License.  You may obtain a copy of the License at
1002d11301SAndrew Rist  *
1102d11301SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1202d11301SAndrew Rist  *
1302d11301SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1402d11301SAndrew Rist  * software distributed under the License is distributed on an
1502d11301SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1602d11301SAndrew Rist  * KIND, either express or implied.  See the License for the
1702d11301SAndrew Rist  * specific language governing permissions and limitations
1802d11301SAndrew Rist  * under the License.
1902d11301SAndrew Rist  *
2002d11301SAndrew Rist  *************************************************************/
2102d11301SAndrew Rist 
2202d11301SAndrew Rist 
23cdf0e10cSrcweir #ifndef INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
24cdf0e10cSrcweir #define INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "rtl/string.hxx"
27cdf0e10cSrcweir #include "registry/reader.hxx"
28cdf0e10cSrcweir #include "codemaker/typemanager.hxx"
29cdf0e10cSrcweir #include "codemaker/unotype.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <fstream>
32cdf0e10cSrcweir #include <hash_set>
33cdf0e10cSrcweir #include <map>
34cdf0e10cSrcweir 
operator <<(std::ostream & s,const rtl::OString r)3524c56ab9SHerbert Dürr inline std::ostream& operator<<( std::ostream& s, const rtl::OString r) { return (s << r.getStr()); }
3624c56ab9SHerbert Dürr 
37cdf0e10cSrcweir namespace skeletonmaker {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir typedef ::std::map< ::rtl::OString, ::std::vector< ::rtl::OString >,
40cdf0e10cSrcweir                     ::std::less< ::rtl::OString > > ProtocolCmdMap;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir typedef ::std::vector< ::std::pair< rtl::OString,
43cdf0e10cSrcweir                      ::std::pair< rtl::OString, sal_Int16 > > > AttributeInfo;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir struct ProgramOptions {
ProgramOptionsskeletonmaker::ProgramOptions47cdf0e10cSrcweir     ProgramOptions(): java5(true), all(false), dump(false), license(false),
48cdf0e10cSrcweir                       shortnames(false), supportpropertysetmixin(false),
49cdf0e10cSrcweir                       backwardcompatible(false), language(1), componenttype(1) {}
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     bool java5;
52cdf0e10cSrcweir     bool all;
53cdf0e10cSrcweir     bool dump;
54cdf0e10cSrcweir     bool license;
55cdf0e10cSrcweir     bool shortnames;
56cdf0e10cSrcweir     bool supportpropertysetmixin;
57cdf0e10cSrcweir     bool backwardcompatible;
58cdf0e10cSrcweir     // language specifier - is extendable
59cdf0e10cSrcweir     // 1 = Java
60cdf0e10cSrcweir     // 2 = C++
61cdf0e10cSrcweir     short language;
62cdf0e10cSrcweir     // component type
63cdf0e10cSrcweir     // 1 = default UNO component - is extendable
64cdf0e10cSrcweir     // 2 = calc add-in
65cdf0e10cSrcweir     // 3 = add-on
66cdf0e10cSrcweir     short componenttype;
67cdf0e10cSrcweir     rtl::OString outputpath;
68cdf0e10cSrcweir     rtl::OString implname;
69cdf0e10cSrcweir     ProtocolCmdMap protocolCmdMap;
70cdf0e10cSrcweir };
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir /**
74cdf0e10cSrcweir    print the standard OpenOffice.org license header
75cdf0e10cSrcweir 
76cdf0e10cSrcweir    @param o specifies the output stream
77cdf0e10cSrcweir    @param filename specifies the source file name
78cdf0e10cSrcweir */
79cdf0e10cSrcweir void printLicenseHeader(std::ostream& o, rtl::OString const & filename);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /**
82cdf0e10cSrcweir    create dependent on the output path, the implementation name and the
83cdf0e10cSrcweir    extension a new output file. If output path is equal "stdout" the tool
84cdf0e10cSrcweir    generates the output to standard out.
85cdf0e10cSrcweir 
86cdf0e10cSrcweir    @param options the program options including the output path and the
87cdf0e10cSrcweir                   implementation name
88cdf0e10cSrcweir    @param extension specifies the file extensions (e.g. .cxx or .java)
89cdf0e10cSrcweir    @param ppOutputStream out parameter returning the output stream
90cdf0e10cSrcweir    @param targetSourceFileName out parameter returning the generated file name
91cdf0e10cSrcweir                                constructed on base of the output path, the
92cdf0e10cSrcweir                                implementation name and the extension
93cdf0e10cSrcweir    @param tmpSourceFileName out parameter returning the temporary file name based
94cdf0e10cSrcweir                             on the output path and a generated temporary file name.
95cdf0e10cSrcweir    @return true if output is generated to standard out or else false
96cdf0e10cSrcweir */
97cdf0e10cSrcweir bool getOutputStream(ProgramOptions const & options,
98cdf0e10cSrcweir                      rtl::OString const & extension,
99cdf0e10cSrcweir                      std::ostream** ppOutputStream,
100cdf0e10cSrcweir                      rtl::OString & targetSourceFileName,
101cdf0e10cSrcweir                      rtl::OString & tmpSourceFileName);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir codemaker::UnoType::Sort decomposeResolveAndCheck(
104cdf0e10cSrcweir     TypeManager const & manager, rtl::OString const & type,
105cdf0e10cSrcweir     bool resolveTypedefs, bool allowVoid, bool allowExtraEntities,
106cdf0e10cSrcweir     RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank,
107cdf0e10cSrcweir     std::vector< rtl::OString > * arguments);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir void checkType(TypeManager const & manager,
110cdf0e10cSrcweir                rtl::OString const & type,
111cdf0e10cSrcweir                std::hash_set< rtl::OString, rtl::OStringHash >& interfaceTypes,
112cdf0e10cSrcweir                std::hash_set< rtl::OString, rtl::OStringHash >& serviceTypes,
113cdf0e10cSrcweir                AttributeInfo& properties);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir void checkDefaultInterfaces(
116cdf0e10cSrcweir     std::hash_set< rtl::OString, rtl::OStringHash >& interfaces,
117cdf0e10cSrcweir     const std::hash_set< rtl::OString, rtl::OStringHash >& services,
118cdf0e10cSrcweir     const rtl::OString & propertyhelper);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir rtl::OString checkPropertyHelper(
121cdf0e10cSrcweir     ProgramOptions const & options, TypeManager const & manager,
122cdf0e10cSrcweir     const std::hash_set< rtl::OString, rtl::OStringHash >& services,
123cdf0e10cSrcweir     const std::hash_set< rtl::OString, rtl::OStringHash >& interfaces,
124cdf0e10cSrcweir     AttributeInfo& attributes,
125cdf0e10cSrcweir     std::hash_set< rtl::OString, rtl::OStringHash >& propinterfaces);
126cdf0e10cSrcweir 
127cdf0e10cSrcweir /**
128cdf0e10cSrcweir    checks whether the return and parameters types are valid and allowed
129cdf0e10cSrcweir    calc add-in type. The function throws a CannotDumpException with an
130cdf0e10cSrcweir    detailed error description which type is wrong
131cdf0e10cSrcweir 
132cdf0e10cSrcweir    @param manager a type manager
133cdf0e10cSrcweir    @param reader a registry type reader of an interface defining
134cdf0e10cSrcweir                  calc add-in functions
135cdf0e10cSrcweir */
136cdf0e10cSrcweir void checkAddInTypes(TypeManager const & manager,
137cdf0e10cSrcweir                      typereg::Reader const & reader);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 
140cdf0e10cSrcweir /**
141cdf0e10cSrcweir    checks if XComponent have to be supported, if yes it removes it from the
142*86e1cf34SPedro Giffuni    supported interfaces list because it becmoes implmented by the appropriate
143cdf0e10cSrcweir    helper
144cdf0e10cSrcweir 
145cdf0e10cSrcweir    @param manager a type manager
146cdf0e10cSrcweir    @param interfaces a list of interfaces which should be implemented
147cdf0e10cSrcweir 
148cdf0e10cSrcweir    @return true if XComponent have to be supported
149cdf0e10cSrcweir */
150cdf0e10cSrcweir bool checkXComponentSupport(TypeManager const & manager,
151cdf0e10cSrcweir          std::hash_set< rtl::OString, rtl::OStringHash >& interfaces);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader,
155cdf0e10cSrcweir                                         sal_uInt16 field, sal_uInt16 method);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir void generateFunctionParameterMap(std::ostream& o,
159cdf0e10cSrcweir          ProgramOptions const & options,
160cdf0e10cSrcweir          TypeManager const & manager,
161cdf0e10cSrcweir          const std::hash_set< ::rtl::OString, ::rtl::OStringHash >& interfaces);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir #endif // INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX
166cdf0e10cSrcweir 
167