1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX 28*cdf0e10cSrcweir #define INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include "rtl/string.hxx" 31*cdf0e10cSrcweir #include "registry/reader.hxx" 32*cdf0e10cSrcweir #include "codemaker/typemanager.hxx" 33*cdf0e10cSrcweir #include "codemaker/unotype.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <fstream> 36*cdf0e10cSrcweir #include <hash_set> 37*cdf0e10cSrcweir #include <map> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir namespace skeletonmaker { 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir typedef ::std::map< ::rtl::OString, ::std::vector< ::rtl::OString >, 42*cdf0e10cSrcweir ::std::less< ::rtl::OString > > ProtocolCmdMap; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir typedef ::std::vector< ::std::pair< rtl::OString, 45*cdf0e10cSrcweir ::std::pair< rtl::OString, sal_Int16 > > > AttributeInfo; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir struct ProgramOptions { 49*cdf0e10cSrcweir ProgramOptions(): java5(true), all(false), dump(false), license(false), 50*cdf0e10cSrcweir shortnames(false), supportpropertysetmixin(false), 51*cdf0e10cSrcweir backwardcompatible(false), language(1), componenttype(1) {} 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir bool java5; 54*cdf0e10cSrcweir bool all; 55*cdf0e10cSrcweir bool dump; 56*cdf0e10cSrcweir bool license; 57*cdf0e10cSrcweir bool shortnames; 58*cdf0e10cSrcweir bool supportpropertysetmixin; 59*cdf0e10cSrcweir bool backwardcompatible; 60*cdf0e10cSrcweir // language specifier - is extendable 61*cdf0e10cSrcweir // 1 = Java 62*cdf0e10cSrcweir // 2 = C++ 63*cdf0e10cSrcweir short language; 64*cdf0e10cSrcweir // component type 65*cdf0e10cSrcweir // 1 = default UNO component - is extendable 66*cdf0e10cSrcweir // 2 = calc add-in 67*cdf0e10cSrcweir // 3 = add-on 68*cdf0e10cSrcweir short componenttype; 69*cdf0e10cSrcweir rtl::OString outputpath; 70*cdf0e10cSrcweir rtl::OString implname; 71*cdf0e10cSrcweir ProtocolCmdMap protocolCmdMap; 72*cdf0e10cSrcweir }; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /** 76*cdf0e10cSrcweir print the standard OpenOffice.org license header 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir @param o specifies the output stream 79*cdf0e10cSrcweir @param filename specifies the source file name 80*cdf0e10cSrcweir */ 81*cdf0e10cSrcweir void printLicenseHeader(std::ostream& o, rtl::OString const & filename); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /** 84*cdf0e10cSrcweir create dependent on the output path, the implementation name and the 85*cdf0e10cSrcweir extension a new output file. If output path is equal "stdout" the tool 86*cdf0e10cSrcweir generates the output to standard out. 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir @param options the program options including the output path and the 89*cdf0e10cSrcweir implementation name 90*cdf0e10cSrcweir @param extension specifies the file extensions (e.g. .cxx or .java) 91*cdf0e10cSrcweir @param ppOutputStream out parameter returning the output stream 92*cdf0e10cSrcweir @param targetSourceFileName out parameter returning the generated file name 93*cdf0e10cSrcweir constructed on base of the output path, the 94*cdf0e10cSrcweir implementation name and the extension 95*cdf0e10cSrcweir @param tmpSourceFileName out parameter returning the temporary file name based 96*cdf0e10cSrcweir on the output path and a generated temporary file name. 97*cdf0e10cSrcweir @return true if output is generated to standard out or else false 98*cdf0e10cSrcweir */ 99*cdf0e10cSrcweir bool getOutputStream(ProgramOptions const & options, 100*cdf0e10cSrcweir rtl::OString const & extension, 101*cdf0e10cSrcweir std::ostream** ppOutputStream, 102*cdf0e10cSrcweir rtl::OString & targetSourceFileName, 103*cdf0e10cSrcweir rtl::OString & tmpSourceFileName); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir codemaker::UnoType::Sort decomposeResolveAndCheck( 106*cdf0e10cSrcweir TypeManager const & manager, rtl::OString const & type, 107*cdf0e10cSrcweir bool resolveTypedefs, bool allowVoid, bool allowExtraEntities, 108*cdf0e10cSrcweir RTTypeClass * typeClass, rtl::OString * name, sal_Int32 * rank, 109*cdf0e10cSrcweir std::vector< rtl::OString > * arguments); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir void checkType(TypeManager const & manager, 112*cdf0e10cSrcweir rtl::OString const & type, 113*cdf0e10cSrcweir std::hash_set< rtl::OString, rtl::OStringHash >& interfaceTypes, 114*cdf0e10cSrcweir std::hash_set< rtl::OString, rtl::OStringHash >& serviceTypes, 115*cdf0e10cSrcweir AttributeInfo& properties); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir void checkDefaultInterfaces( 118*cdf0e10cSrcweir std::hash_set< rtl::OString, rtl::OStringHash >& interfaces, 119*cdf0e10cSrcweir const std::hash_set< rtl::OString, rtl::OStringHash >& services, 120*cdf0e10cSrcweir const rtl::OString & propertyhelper); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir rtl::OString checkPropertyHelper( 123*cdf0e10cSrcweir ProgramOptions const & options, TypeManager const & manager, 124*cdf0e10cSrcweir const std::hash_set< rtl::OString, rtl::OStringHash >& services, 125*cdf0e10cSrcweir const std::hash_set< rtl::OString, rtl::OStringHash >& interfaces, 126*cdf0e10cSrcweir AttributeInfo& attributes, 127*cdf0e10cSrcweir std::hash_set< rtl::OString, rtl::OStringHash >& propinterfaces); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir /** 130*cdf0e10cSrcweir checks whether the return and parameters types are valid and allowed 131*cdf0e10cSrcweir calc add-in type. The function throws a CannotDumpException with an 132*cdf0e10cSrcweir detailed error description which type is wrong 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir @param manager a type manager 135*cdf0e10cSrcweir @param reader a registry type reader of an interface defining 136*cdf0e10cSrcweir calc add-in functions 137*cdf0e10cSrcweir */ 138*cdf0e10cSrcweir void checkAddInTypes(TypeManager const & manager, 139*cdf0e10cSrcweir typereg::Reader const & reader); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /** 143*cdf0e10cSrcweir checks if XComponent have to be supported, if yes it removes it from the 144*cdf0e10cSrcweir supported interfaces list becuase it becmoes implmented by the appropriate 145*cdf0e10cSrcweir helper 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir @param manager a type manager 148*cdf0e10cSrcweir @param interfaces a list of interfaces which should be implemented 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir @return true if XComponent have to be supported 151*cdf0e10cSrcweir */ 152*cdf0e10cSrcweir bool checkXComponentSupport(TypeManager const & manager, 153*cdf0e10cSrcweir std::hash_set< rtl::OString, rtl::OStringHash >& interfaces); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir sal_uInt16 checkAdditionalPropertyFlags(typereg::Reader const & reader, 157*cdf0e10cSrcweir sal_uInt16 field, sal_uInt16 method); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir void generateFunctionParameterMap(std::ostream& o, 161*cdf0e10cSrcweir ProgramOptions const & options, 162*cdf0e10cSrcweir TypeManager const & manager, 163*cdf0e10cSrcweir const std::hash_set< ::rtl::OString, ::rtl::OStringHash >& interfaces); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir #endif // INCLUDED_UNODEVTOOLS_SOURCE_SKELETONMAKER_SKELETONCOMMON_HXX 168*cdf0e10cSrcweir 169