38 o <<
"/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */\n"
40 " * This file is part of the LibreOffice project.\n"
42 " * This Source Code Form is subject to the terms of the Mozilla Public\n"
43 " * License, v. 2.0. If a copy of the MPL was not distributed with this\n"
44 " * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n"
49 OString
const & extension,
50 std::ostream** ppOutputStream,
51 OString & targetSourceFileName,
52 OString & tmpSourceFileName)
54 bool bStandardout =
false;
58 *ppOutputStream = &std::cout;
65 OString tmpDir =
getTempDir(targetSourceFileName);
72 "cannot open " +
b2u(targetSourceFileName) +
" for writing");
74 tmpSourceFileName = file.
getName();
76 *ppOutputStream =
new std::ofstream(tmpSourceFileName.getStr(),
77 std::ios_base::binary);
84 return std::any_of(attributes.begin(), attributes.end(),
86 return rAttr.name == attrname; });
91 OUString
const & name,
93 std::set< OUString >& propinterfaces)
95 if (
name ==
"com.sun.star.beans.XPropertySet" ||
96 name ==
"com.sun.star.beans.XFastPropertySet" ||
97 name ==
"com.sun.star.beans.XPropertyAccess" )
99 propinterfaces.insert(
name);
108 for (
const auto& rBase : ent2->getDirectMandatoryBases())
112 for (
const auto& rAttr : ent2->getDirectAttributes())
115 attributes.emplace_back(
116 rAttr.name, rAttr.type,
125 std::vector< OUString >());
136 for (
const auto& rService : ent2->getDirectMandatoryBaseServices())
140 for (
const auto& rIface : ent2->getDirectMandatoryBaseInterfaces())
144 for (
const auto& rProp : ent2->getDirectProperties())
147 attributes.push_back(rProp);
154 "unexpected entity \"" +
name
155 +
"\" in call to skeletonmaker::checkAttributes");
160 OUString
const & name,
161 std::set< OUString >& interfaceTypes,
162 std::set< OUString >& serviceTypes,
171 if (
name ==
"com.sun.star.lang.XTypeProvider" ||
172 name ==
"com.sun.star.uno.XWeak" )
174 interfaceTypes.insert(
name);
177 if (serviceTypes.insert(
name).second) {
182 if (interfaceTypes.insert(ent2->getBase()).second) {
187 if (ent2->getConstructors().size() > 1 ||
188 (ent2->getConstructors().size() == 1 &&
189 !ent2->getConstructors()[0].defaultConstructor))
191 interfaceTypes.insert(OUString(
"com.sun.star.lang.XInitialization"));
197 if ( serviceTypes.insert(
name).second ) {
202 for (
const auto& rService : ent2->getDirectMandatoryBaseServices())
207 for (
const auto& rIface : ent2->getDirectMandatoryBaseInterfaces())
212 for (
const auto& rProp : ent2->getDirectProperties())
220 "unexpected entity \"" +
name
221 +
"\" in call to skeletonmaker::checkType");
226 std::set< OUString >& interfaces,
227 const std::set< OUString >& services,
228 std::u16string_view propertyhelper)
230 if ( services.empty() ) {
231 interfaces.erase(
"com.sun.star.lang.XServiceInfo");
233 interfaces.insert(
"com.sun.star.lang.XServiceInfo");
236 if ( propertyhelper ==
u"_" ) {
237 interfaces.erase(
"com.sun.star.beans.XPropertySet");
238 interfaces.erase(
"com.sun.star.beans.XFastPropertySet");
239 interfaces.erase(
"com.sun.star.beans.XPropertyAccess");
244 OUString
const & name)
254 if (!ent2->getDirectProperties().empty()) {
257 return std::any_of(ent2->getDirectMandatoryBaseServices().begin(),
258 ent2->getDirectMandatoryBaseServices().end(),
260 return checkServiceProperties(manager, rService.name); });
269 const std::set< OUString >& services,
270 const std::set< OUString >& interfaces,
272 std::set< OUString >& propinterfaces)
274 std::set< OUString >::const_iterator iter;
275 std::set< OUString >::const_iterator
end;
277 if ( !services.empty() ) {
278 iter = services.begin();
279 end = services.end();
281 iter = interfaces.begin();
282 end = interfaces.end();
285 bool oldStyleWithProperties =
false;
286 while ( iter !=
end ) {
289 if ( !services.empty() ) {
301 manager, ent2->getBase(), attributes, propinterfaces);
302 if (!(attributes.empty() || propinterfaces.empty())) {
303 return ent2->getBase();
310 if (!(attributes.empty() || propinterfaces.empty())) {
317 return oldStyleWithProperties ? OUString(
"_") : OUString();
324 if (
name ==
"com.sun.star.lang.XComponent") {
331 "unexpected entity \"" +
name
332 +
"\" in call to skeletonmaker::checkXComponentSupport");
337 return std::any_of(ent2->getDirectMandatoryBases().begin(), ent2->getDirectMandatoryBases().end(),
345 std::set< OUString >& interfaces)
347 if ( interfaces.empty() )
350 for (
const auto& rIface : interfaces ) {
351 if ( rIface ==
"com.sun.star.lang.XComponent" ) {
352 interfaces.erase(
"com.sun.star.lang.XComponent");
367 bool getterSupportsUnknown =
false;
368 for (
const auto& rException :
attribute.getExceptions)
370 if (rException ==
"com.sun.star.beans.UnknownPropertyException") {
371 getterSupportsUnknown =
true;
374 for (
const auto& rException :
attribute.setExceptions)
376 if (rException ==
"com.sun.star.beans.PropertyVetoException") {
379 }
else if (getterSupportsUnknown
380 && rException ==
"com.sun.star.beans.UnknownPropertyException")
393 std::u16string_view type,
bool & bLastAny,
394 bool & bHasXPropertySet,
bool bIsReturn)
399 type,
true,
nullptr, &rank,
nullptr,
nullptr);
405 if ( rank == 0 || rank ==2 )
422 if ( bIsReturn &&
type ==
u"com.sun.star.sheet.XVolatileResult" )
424 if ( !bIsReturn &&
type ==
u"com.sun.star.table.XCellRange" )
426 if ( !bIsReturn &&
type ==
u"com.sun.star.beans.XPropertySet" )
428 if ( bHasXPropertySet ) {
431 bHasXPropertySet =
true;
444 bool bLastAny =
false;
445 bool bHasXPropertySet =
false;
446 for (
const auto& rMethod : entity->getDirectMethods())
449 manager, rMethod.returnType, bLastAny, bHasXPropertySet,
true) )
452 OUString::Concat(
"the return type of the calc add-in function '") +
name
454 +
"' is invalid. Please check your IDL definition.");
457 bHasXPropertySet =
false;
458 for (
const auto& rParam : rMethod.parameters)
462 bLastAny, bHasXPropertySet,
false) ||
466 "the type of the " + rParam.name
467 +
" parameter of the calc add-in function '" +
name
468 +
":" + rMethod.name +
"' is invalid."
471 " The type 'sequence<any>' is allowed as last"
476 " The type 'XPropertySet' is allowed only once.")
478 +
" Please check your IDL definition.");
487 OUString
const & name,
491 if (
name ==
"com.sun.star.uno.XInterface" ||
492 name ==
"com.sun.star.lang.XLocalizable" ||
493 name ==
"com.sun.star.lang.XServiceInfo" ||
495 name ==
"com.sun.star.sheet.XAddIn" ||
496 name ==
"com.sun.star.sheet.XCompatibilityNames" ||
497 name ==
"com.sun.star.lang.XServiceName" )
506 "unexpected entity \"" +
name
507 +
"\" in call to skeletonmaker::generateFunctionParameterMap");
516 for (
const auto& rBase : ent2->getDirectMandatoryBases())
519 o, options,
manager, rBase.name, generated, bFirst);
527 for (
const auto& rMethod : ent2->getDirectMethods())
531 o <<
" ParamMap fpm;\n";
534 o <<
" java.util.Hashtable< Integer, String > fpm = "
535 "new java.util.Hashtable< Integer, String >();\n";
540 o <<
" fpm = ParamMap();\n";
543 o <<
" fpm = new java.util.Hashtable< "
544 "Integer, String >();\n";
547 std::vector< unoidl::InterfaceTypeEntity::Method::Parameter >::size_type
549 for (
const auto& rParam : rMethod.parameters)
558 o <<
" fpm.put(" <<
n <<
", \""
566 o <<
" m_functionMap[OUString(\""
567 << rMethod.name <<
"\")] = fpm;\n\n";
570 o <<
" m_functionMap.put(\"" << rMethod.name <<
"\", fpm);\n\n";
578 const std::set< OUString >& interfaces)
582 for (
const auto& rIface : interfaces ) {
void createTempFile(const ::rtl::OString &sPath)
const ::rtl::OString & getName() const
bool contains(OString const &type) const
void add(OString const &type)
rtl::Reference< ParseManager > manager
OString getTempDir(const OString &sFileName)
OString createFileNameFromType(const OString &destination, const OString &typeName, const OString &postfix)
@ SingleInterfaceBasedService
@ AccumulationBasedService
OUString checkPropertyHelper(ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, const std::set< OUString > &services, const std::set< OUString > &interfaces, AttributeInfo &attributes, std::set< OUString > &propinterfaces)
bool getOutputStream(ProgramOptions const &options, OString const &extension, std::ostream **ppOutputStream, OString &targetSourceFileName, OString &tmpSourceFileName)
create dependent on the output path, the implementation name and the extension a new output file.
::std::vector< unoidl::AccumulationBasedServiceEntity::Property > AttributeInfo
static bool checkAddinType(rtl::Reference< TypeManager > const &manager, std::u16string_view type, bool &bLastAny, bool &bHasXPropertySet, bool bIsReturn)
static bool containsAttribute(AttributeInfo &attributes, OUString const &attrname)
void checkDefaultInterfaces(std::set< OUString > &interfaces, const std::set< OUString > &services, std::u16string_view propertyhelper)
static bool checkXComponentSupport(rtl::Reference< TypeManager > const &manager, OUString const &name)
static bool checkServiceProperties(rtl::Reference< TypeManager > const &manager, OUString const &name)
static void checkAttributes(rtl::Reference< TypeManager > const &manager, OUString const &name, AttributeInfo &attributes, std::set< OUString > &propinterfaces)
static void checkAddInTypes(rtl::Reference< TypeManager > const &manager, std::u16string_view name, rtl::Reference< unoidl::InterfaceTypeEntity > const &entity)
unoidl::AccumulationBasedServiceEntity::Property::Attributes checkAdditionalPropertyFlags(unoidl::InterfaceTypeEntity::Attribute const &attribute)
void checkType(rtl::Reference< TypeManager > const &manager, OUString const &name, std::set< OUString > &interfaceTypes, std::set< OUString > &serviceTypes, AttributeInfo &properties)
void printLicenseHeader(std::ostream &o)
print the standard OpenOffice.org license header
static void generateFunctionParameterMap(std::ostream &o, ProgramOptions const &options, rtl::Reference< TypeManager > const &manager, OUString const &name, ::codemaker::GeneratedTypeSet &generated, bool &bFirst)
bool supportpropertysetmixin
OUString b2u(std::string_view s)
OString u2b(std::u16string_view s)