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