1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "sal/config.h"
22 #include "codemaker/codemaker.hxx"
23 #include "codemaker/commoncpp.hxx"
24 #include "codemaker/global.hxx"
26 #include "skeletoncommon.hxx"
27 #include "skeletoncpp.hxx"
29 using namespace ::rtl
;
30 using namespace ::codemaker::cpp
;
32 namespace skeletonmaker
{ namespace cpp
{
35 std::ostream
& o
, ProgramOptions
const & options
,
36 rtl::Reference
< TypeManager
> const & manager
,
37 codemaker::UnoType::Sort sort
, OUString
const & nucleus
, sal_Int32 rank
,
38 std::vector
< OUString
> const & arguments
,
39 rtl::Reference
< unoidl::Entity
> const & entity
, short referenceType
,
42 if (defaultvalue
&& rank
== 0 && sort
<= codemaker::UnoType::SORT_CHAR
) {
44 case codemaker::UnoType::SORT_BOOLEAN
:
47 case codemaker::UnoType::SORT_CHAR
:
48 case codemaker::UnoType::SORT_BYTE
:
49 case codemaker::UnoType::SORT_SHORT
:
50 case codemaker::UnoType::SORT_UNSIGNED_SHORT
:
51 case codemaker::UnoType::SORT_LONG
:
52 case codemaker::UnoType::SORT_UNSIGNED_LONG
:
53 case codemaker::UnoType::SORT_HYPER
:
54 case codemaker::UnoType::SORT_UNSIGNED_HYPER
:
55 case codemaker::UnoType::SORT_FLOAT
:
56 case codemaker::UnoType::SORT_DOUBLE
:
64 if (defaultvalue
&& referenceType
== 16) {
65 if (sort
== codemaker::UnoType::SORT_ENUM_TYPE
) {
66 o
<< nucleus
.copy(nucleus
.lastIndexOf('.') + 1) << "_"
67 << dynamic_cast< unoidl::EnumTypeEntity
* >(entity
.get())->
72 bool bReference
= false;
73 if (((sort
> codemaker::UnoType::SORT_CHAR
||
74 rank
> 0) && referenceType
!= 8 &&
75 !(sort
== codemaker::UnoType::SORT_ENUM_TYPE
&& referenceType
== 4 && rank
== 0)) ||
76 (sort
<= codemaker::UnoType::SORT_CHAR
&& referenceType
== 2))
81 if (bReference
&& referenceType
== 4)
84 for (sal_Int32 i
= 0; i
< rank
; ++i
) {
85 o
<< ((options
.shortnames
) ? "css::uno::Sequence< " :
86 "::com::sun::star::uno::Sequence< ");
88 if (sort
== codemaker::UnoType::SORT_INTERFACE_TYPE
&& referenceType
> 0) {
89 o
<< ((options
.shortnames
) ? "css::uno::Reference< " :
90 "::com::sun::star::uno::Reference< ");
93 o
<< scopedCppName(codemaker::cpp::translateUnoToCppType(sort
, nucleus
),
94 options
.shortnames
&& referenceType
> 0);
96 if (sort
== codemaker::UnoType::SORT_INTERFACE_TYPE
&& referenceType
> 0)
99 if (!arguments
.empty()) {
101 for (std::vector
< OUString
>::const_iterator
i(arguments
.begin());
102 i
!= arguments
.end(); ++i
)
104 if (i
!= arguments
.begin())
107 printType(o
, options
, manager
, *i
, 1, false);
112 for (sal_Int32 i
= 0; i
< rank
; ++i
)
115 if (bReference
&& referenceType
> 1)
118 if (referenceType
== 8 && (sort
> codemaker::UnoType::SORT_CHAR
|| rank
> 0))
123 std::ostream
& o
, ProgramOptions
const & options
,
124 rtl::Reference
< TypeManager
> const & manager
, OUString
const & name
,
125 short referenceType
, bool defaultvalue
)
129 std::vector
< OUString
> arguments
;
130 rtl::Reference
< unoidl::Entity
> entity
;
131 codemaker::UnoType::Sort sort
= manager
->decompose(
132 name
, true, &nucleus
, &rank
, &arguments
, &entity
);
134 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
135 referenceType
, defaultvalue
);
138 bool printConstructorParameters(
139 std::ostream
& o
, ProgramOptions
const & options
,
140 rtl::Reference
< TypeManager
> const & manager
,
141 codemaker::UnoType::Sort sort
,
142 rtl::Reference
< unoidl::Entity
> const & entity
, OUString
const & name
,
143 std::vector
< OUString
> const & arguments
)
145 bool previous
= false;
147 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
149 rtl::Reference
< unoidl::PlainStructTypeEntity
> ent2(
150 dynamic_cast< unoidl::PlainStructTypeEntity
* >(entity
.get()));
152 if (!ent2
->getDirectBase().isEmpty()) {
153 rtl::Reference
< unoidl::Entity
> baseEnt
;
154 codemaker::UnoType::Sort baseSort
= manager
->getSort(
155 ent2
->getDirectBase(), &baseEnt
);
156 previous
= printConstructorParameters(
157 o
, options
, manager
, baseSort
, baseEnt
,
158 ent2
->getDirectBase(), std::vector
< OUString
>());
160 for (std::vector
< unoidl::PlainStructTypeEntity::Member
>::
161 const_iterator
i(ent2
->getDirectMembers().begin());
162 i
!= ent2
->getDirectMembers().end(); ++i
)
168 printType(o
, options
, manager
, i
->type
, 4);
170 << codemaker::cpp::translateUnoToCppIdentifier(
171 u2b(i
->name
), "param");
175 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
177 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
178 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
182 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
183 const_iterator
i(ent2
->getMembers().begin());
184 i
!= ent2
->getMembers().end(); ++i
)
190 if (i
->parameterized
) {
193 printType(o
, options
, manager
, i
->type
, 4);
196 << codemaker::cpp::translateUnoToCppIdentifier(
197 u2b(i
->name
), "param");
201 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
203 rtl::Reference
< unoidl::PolymorphicStructTypeTemplateEntity
> ent2(
204 dynamic_cast< unoidl::PolymorphicStructTypeTemplateEntity
* >(
208 unoidl::PolymorphicStructTypeTemplateEntity::Member
>::
209 const_iterator
i(ent2
->getMembers().begin());
210 i
!= ent2
->getMembers().end(); ++i
)
216 if (i
->parameterized
) {
217 for (std::vector
< OUString
>::const_iterator
j(
218 ent2
->getTypeParameters().begin());
219 j
!= ent2
->getTypeParameters().end(); ++j
)
223 j
- ent2
->getTypeParameters().begin()];
228 printType(o
, options
, manager
, i
->type
, 4);
231 << codemaker::cpp::translateUnoToCppIdentifier(
232 u2b(i
->name
), "param");
236 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
238 rtl::Reference
< unoidl::ExceptionTypeEntity
> ent2(
239 dynamic_cast< unoidl::ExceptionTypeEntity
* >(entity
.get()));
241 if (!ent2
->getDirectBase().isEmpty()) {
242 rtl::Reference
< unoidl::Entity
> baseEnt
;
243 codemaker::UnoType::Sort baseSort
= manager
->getSort(
244 ent2
->getDirectBase(), &baseEnt
);
245 previous
= printConstructorParameters(
246 o
, options
, manager
, baseSort
, baseEnt
,
247 ent2
->getDirectBase(), std::vector
< OUString
>());
249 for (std::vector
< unoidl::ExceptionTypeEntity::Member
>::
250 const_iterator
i(ent2
->getDirectMembers().begin());
251 i
!= ent2
->getDirectMembers().end(); ++i
)
257 printType(o
, options
, manager
, i
->type
, 4);
259 << codemaker::cpp::translateUnoToCppIdentifier(
260 u2b(i
->name
), "param");
265 throw CannotDumpException(
266 "unexpected entity \"" + name
267 + "\" in call to skeletonmaker::cpp::printConstructorParameters");
272 void printConstructor(
273 std::ostream
& o
, ProgramOptions
const & options
,
274 rtl::Reference
< TypeManager
> const & manager
,
275 codemaker::UnoType::Sort sort
,
276 rtl::Reference
< unoidl::Entity
> const & entity
, OUString
const & name
,
277 std::vector
< OUString
> const & arguments
)
279 o
<< "public " << name
.copy(name
.lastIndexOf('.') + 1) << '(';
280 printConstructorParameters(
281 o
, options
, manager
, sort
, entity
, name
, arguments
);
285 void printMethodParameters(
286 std::ostream
& o
, ProgramOptions
const & options
,
287 rtl::Reference
< TypeManager
> const & manager
,
288 std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
> const &
292 for (std::vector
< unoidl::InterfaceTypeEntity::Method::Parameter
>::
293 const_iterator
i(parameters
.begin());
294 i
!= parameters
.end(); ++i
)
296 if (i
!= parameters
.begin()) {
302 == unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN
)
308 printType(o
, options
, manager
, i
->type
, referenceType
);
311 o
<< codemaker::cpp::translateUnoToCppIdentifier(u2b(i
->name
), "param");
315 void printExceptionSpecification(
317 ProgramOptions
const & options
,
318 rtl::Reference
< TypeManager
> const & manager
,
319 std::vector
< OUString
> const & exceptions
)
321 o
<< ((options
.shortnames
) ? " throw (css::uno::RuntimeException" :
322 " throw (::com::sun::star::uno::RuntimeException");
323 for (std::vector
< OUString
>::const_iterator
i(exceptions
.begin());
324 i
!= exceptions
.end(); ++i
)
327 printType(o
, options
, manager
, *i
, 1);
332 void printSetPropertyMixinBody(
333 std::ostream
& o
, unoidl::InterfaceTypeEntity::Attribute
const & attribute
)
335 unoidl::AccumulationBasedServiceEntity::Property::Attributes propFlags
336 = checkAdditionalPropertyFlags(attribute
);
341 o
<< " BoundListeners l;\n";
343 if (propFlags
& unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED
) {
344 OString fieldtype
= codemaker::convertString(attribute
.type
);
346 sal_Int32 index
= fieldtype
.lastIndexOf('<');
349 bool optional
= false;
350 OStringBuffer
buffer1(64);
351 OStringBuffer
buffer2(64);
354 OString
s(fieldtype
.getToken(0, '<', nPos
));
355 OString t
= s
.copy(s
.lastIndexOf('/')+1);
357 if (t
.equals("Optional")) {
361 buffer1
.append("the_value.IsPresent");
362 buffer2
.append("the_value.Value");
364 buffer1
.insert(0, t
);
365 buffer1
.append(".IsPresent");
366 buffer2
.insert(0, t
);
367 buffer2
.append(".Value");
373 buffer1
.append("the_value.Value");
375 buffer2
.append("the_value.Value");
378 buffer1
.insert(0, t
);
379 buffer1
.append(".Value");
381 buffer2
.insert(0, t
);
382 buffer2
.append(".Value");
385 } while( nPos
<= index
);
387 o
<< " css::uno::Any v;\n";
389 o
<< " if(" << buffer1
.makeStringAndClear() << ")\n {\n"
390 << " v <<= " << buffer2
.makeStringAndClear() << ";\n }\n";
392 o
<< " v <<= " << buffer2
.makeStringAndClear() << ";\n\n";
395 o
<< " prepareSet(\n rtl::OUString(\""
396 << attribute
.name
<< "\"),\n css::uno::Any(), v, ";
398 o
<< " prepareSet(\n rtl::OUString(\""
399 << attribute
.name
<< "\"),\n css::uno::Any(), css::uno::Any(), ";
407 o
<< " {\n osl::MutexGuard g(m_aMutex);\n m_"
408 << attribute
.name
<< " = the_value;\n }\n";
411 o
<< " l.notify();\n";
416 void generateXPropertySetBodies(std::ostream
& o
,
417 const OString
& classname
,
418 const OString
& interfaceName
);
419 void generateXFastPropertySetBodies(std::ostream
& o
,
420 const OString
& classname
,
421 const OString
& interfaceName
);
422 void generateXPropertyAccessBodies(std::ostream
& o
,
423 const OString
& classname
,
424 const OString
& interfaceName
);
426 void generateXAddInBodies(std::ostream
& o
, const OString
& classname
);
428 void generateXLocalizable(std::ostream
& o
, const OString
& classname
);
430 void generateXCompatibilityNamesBodies(std::ostream
& o
, const OString
& classname
);
432 void generateXInitialization(std::ostream
& o
, const OString
& classname
);
434 void generateXDispatch(std::ostream
& o
,
435 const OString
& classname
,
436 const ProtocolCmdMap
& protocolCmdMap
);
438 void generateXDispatchProvider(std::ostream
& o
,
439 const OString
& classname
,
440 const ProtocolCmdMap
& protocolCmdMap
);
443 void printMethods(std::ostream
& o
,
444 ProgramOptions
const & options
, rtl::Reference
< TypeManager
> const & manager
,
445 OUString
const & name
, codemaker::GeneratedTypeSet
& generated
,
446 OString
const & delegate
, OString
const & classname
,
447 OString
const & indentation
, bool defaultvalue
,
448 OUString
const & propertyhelper
)
450 if (generated
.contains(u2b(name
)) || name
== "com.sun.star.uno.XInterface" ||
452 ( name
== "com.sun.star.lang.XComponent" ||
453 name
== "com.sun.star.lang.XTypeProvider" ||
454 name
== "com.sun.star.uno.XWeak" ) ) )
459 static OString
sd("_");
460 bool body
= !delegate
.isEmpty();
461 bool defaultbody
= ((delegate
.equals(sd
)) ? true : false);
463 if (body
&& propertyhelper
.getLength() > 1) {
464 if (name
== "com.sun.star.beans.XPropertySet") {
465 generated
.add(u2b(name
));
466 generateXPropertySetBodies(
467 o
, classname
, scopedCppName(u2b(propertyhelper
)));
469 } else if (name
== "com.sun.star.beans.XFastPropertySet") {
470 generated
.add(u2b(name
));
471 generateXFastPropertySetBodies(
472 o
, classname
, scopedCppName(u2b(propertyhelper
)));
474 } else if (name
== "com.sun.star.beans.XPropertyAccess") {
475 generated
.add(u2b(name
));
476 generateXPropertyAccessBodies(
477 o
, classname
, scopedCppName(u2b(propertyhelper
)));
482 if (body
&& options
.componenttype
== 2) {
483 if (name
== "com.sun.star.lang.XServiceName") {
484 o
<< "// ::com::sun::star::lang::XServiceName:\n"
485 "::rtl::OUString SAL_CALL " << classname
<< "getServiceName() "
486 "throw (css::uno::RuntimeException)\n{\n "
487 "return ::rtl::OUString("
488 "sADDIN_SERVICENAME);\n}\n";
489 generated
.add(u2b(name
));
491 } else if (name
== "com.sun.star.sheet.XAddIn") {
492 generateXAddInBodies(o
, classname
);
493 generated
.add(u2b(name
));
495 // special handling of XLocalizable -> parent of XAddIn
496 if (!generated
.contains("com.sun.star.lang.XLocalizable")) {
497 generateXLocalizable(o
, classname
);
498 generated
.add("com.sun.star.lang.XLocalizable");
501 } else if (name
== "com.sun.star.lang.XLocalizable") {
502 generateXLocalizable(o
, classname
);
503 generated
.add(u2b(name
));
505 } else if (name
== "com.sun.star.sheet.XCompatibilityNames") {
506 generateXCompatibilityNamesBodies(o
, classname
);
507 generated
.add(u2b(name
));
512 if (body
&& options
.componenttype
== 3) {
513 if (name
== "com.sun.star.lang.XInitialization") {
514 generateXInitialization(o
, classname
);
515 generated
.add(u2b(name
));
517 } else if (name
== "com.sun.star.frame.XDispatch") {
518 generateXDispatch(o
, classname
, options
.protocolCmdMap
);
519 generated
.add(u2b(name
));
521 } else if (name
== "com.sun.star.frame.XDispatchProvider") {
522 generateXDispatchProvider(o
, classname
, options
.protocolCmdMap
);
523 generated
.add(u2b(name
));
528 generated
.add(u2b(name
));
529 rtl::Reference
< unoidl::Entity
> ent
;
530 if (manager
->getSort(name
, &ent
) != codemaker::UnoType::SORT_INTERFACE_TYPE
)
532 throw CannotDumpException(
533 "unexpected entity \"" + name
534 + "\" in call to skeletonmaker::cpp::printMethods");
536 rtl::Reference
< unoidl::InterfaceTypeEntity
> ent2(
537 dynamic_cast< unoidl::InterfaceTypeEntity
* >(ent
.get()));
539 if (options
.all
|| defaultvalue
) {
540 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
541 ent2
->getDirectMandatoryBases().begin());
542 i
!= ent2
->getDirectMandatoryBases().end(); ++i
)
545 o
, options
, manager
, i
->name
, generated
, delegate
, classname
,
546 indentation
, defaultvalue
, propertyhelper
);
548 if (!(ent2
->getDirectAttributes().empty()
549 && ent2
->getDirectMethods().empty()))
551 o
<< indentation
<< "// ";
552 printType(o
, options
, manager
, name
, 0);
556 for (std::vector
< unoidl::InterfaceTypeEntity::Attribute
>::const_iterator
557 i(ent2
->getDirectAttributes().begin());
558 i
!= ent2
->getDirectAttributes().end(); ++i
)
564 printType(o
, options
, manager
, i
->type
, 1);
566 if (!classname
.isEmpty())
569 o
<< "get" << i
->name
<< "()";
570 printExceptionSpecification(o
, options
, manager
, i
->getExceptions
);
573 if (!propertyhelper
.isEmpty()) {
574 o
<< "\n{\n osl::MutexGuard g(m_aMutex);\n return m_"
575 << i
->name
<< ";\n}\n\n";
577 o
<< "\n{\n return ";
578 if (options
.componenttype
== 1) {
579 o
<< "m_" << i
->name
;
581 printType(o
, options
, manager
, i
->type
, 8, true);
586 o
<< "\n" << indentation
<< "{\n" << indentation
<< " return "
587 << delegate
.getStr() << "get" << i
->name
<< "();\n"
588 << indentation
<< "}\n\n";
599 o
<< "void SAL_CALL ";
600 if (!classname
.isEmpty())
603 o
<< "set" << i
->name
<< '(';
604 printType(o
, options
, manager
, i
->type
, 4);
606 printExceptionSpecification(o
, options
, manager
, i
->setExceptions
);
609 if (!propertyhelper
.isEmpty()) {
610 printSetPropertyMixinBody(o
, *i
);
612 if (options
.componenttype
== 1) {
613 o
<< "\n{\n m_" << i
->name
614 << " = the_value;\n}\n\n";
620 o
<< "\n" << indentation
<< "{\n" << indentation
<< " "
621 << delegate
.getStr() << "set" << i
->name
622 << "(the_value);\n" << indentation
<< "}\n\n";
629 for (std::vector
< unoidl::InterfaceTypeEntity::Method
>::const_iterator
i(
630 ent2
->getDirectMethods().begin());
631 i
!= ent2
->getDirectMethods().end(); ++i
)
637 printType(o
, options
, manager
, i
->returnType
, 1);
639 if (!classname
.isEmpty())
643 printMethodParameters(o
, options
, manager
, i
->parameters
, true);
645 printExceptionSpecification(o
, options
, manager
, i
->exceptions
);
649 if (i
->returnType
!= "void") {
650 o
<< " // TODO: Exchange the default return implementation for \""
651 << i
->name
<< "\" !!!\n";
652 o
<< " // Exchange the default return implementation.\n"
653 " // NOTE: Default initialized polymorphic structs "
654 "can cause problems because of\n // missing default "
655 "initialization of primitive types of some C++ compilers or"
656 "\n // different Any initialization in Java and C++ "
657 "polymorphic structs.\n return ";
658 printType(o
, options
, manager
, i
->returnType
, 8, true);
661 o
<< " // TODO: Insert your implementation for \""
662 << i
->name
<< "\" here.";
666 o
<< "\n" << indentation
<< "{\n" << indentation
<< " ";
667 if (i
->returnType
!= "void")
670 o
<< delegate
.getStr() << i
->name
<< '(';
671 printMethodParameters(
672 o
, options
, manager
, i
->parameters
, false);
673 o
<< ");\n" << indentation
<< "}\n\n";
684 void printConstructors(
685 std::ostream
& o
, ProgramOptions
const & options
,
686 rtl::Reference
< TypeManager
> const & manager
, OUString
const & name
)
688 rtl::Reference
< unoidl::Entity
> ent
;
689 if (manager
->getSort(name
, &ent
)
690 != codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE
)
692 throw CannotDumpException(
693 "unexpected entity \"" + name
694 + "\" in call to skeletonmaker::java::printConstructors");
696 rtl::Reference
< unoidl::SingleInterfaceBasedServiceEntity
> ent2(
697 dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(ent
.get()));
699 for (std::vector
< unoidl::SingleInterfaceBasedServiceEntity::Constructor
>::
700 const_iterator
i(ent2
->getConstructors().begin());
701 i
!= ent2
->getConstructors().end(); ++i
)
704 printType(o
, options
, manager
, ent2
->getBase(), 1);
706 if (i
->defaultConstructor
) {
709 o
<< codemaker::cpp::translateUnoToCppIdentifier(
710 u2b(i
->name
), "method");
712 o
<< ((options
.shortnames
) ? "(css::uno::Reference< css" :
713 "(::com::sun::star::uno::Reference< ::com::sun::star")
714 << "::uno::XComponentContext > const & the_context";
716 unoidl::SingleInterfaceBasedServiceEntity::Constructor::
717 Parameter
>::const_iterator
j(i
->parameters
.begin());
718 j
!= i
->parameters
.end(); ++j
)
721 printType(o
, options
, manager
, j
->type
, 4);
723 << codemaker::cpp::translateUnoToCppIdentifier(
724 u2b(j
->name
), "param");
727 printExceptionSpecification(o
, options
, manager
, i
->exceptions
);
732 void printServiceMembers(
733 std::ostream
& o
, ProgramOptions
const & options
,
734 rtl::Reference
< TypeManager
> const & manager
,
735 OUString
const & name
,
736 rtl::Reference
< unoidl::AccumulationBasedServiceEntity
> const & entity
,
737 OString
const & delegate
)
740 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
741 entity
->getDirectMandatoryBaseServices().begin());
742 i
!= entity
->getDirectMandatoryBaseServices().end(); ++i
)
744 o
<< "\n// exported service " << i
->name
<< "\n";
745 generateDocumentation(o
, options
, manager
, u2b(i
->name
), delegate
);
746 o
<< "\n// end of exported service " << i
->name
<< "\n";
748 for (std::vector
< unoidl::AnnotatedReference
>::const_iterator
i(
749 entity
->getDirectMandatoryBaseInterfaces().begin());
750 i
!= entity
->getDirectMandatoryBaseInterfaces().end(); ++i
)
752 o
<< "\n// supported interface " << i
->name
<< "\n";
753 generateDocumentation(o
, options
, manager
, u2b(i
->name
), delegate
);
755 if (delegate
.isEmpty()) {
756 o
<< "\n// properties of service \""<< name
<< "\"\n";
757 for (std::vector
< unoidl::AccumulationBasedServiceEntity::Property
>::
758 const_iterator
i(entity
->getDirectProperties().begin());
759 i
!= entity
->getDirectProperties().end(); ++i
)
762 printType(o
, options
, manager
, i
->type
, 1);
764 << codemaker::cpp::translateUnoToCppIdentifier(
765 u2b(i
->name
), "property")
771 void printMapsToCppType(
772 std::ostream
& o
, ProgramOptions
const & options
,
773 rtl::Reference
< TypeManager
> const & manager
,
774 codemaker::UnoType::Sort sort
, OUString
const & nucleus
, sal_Int32 rank
,
775 std::vector
< OUString
> const & arguments
,
776 rtl::Reference
< unoidl::Entity
> const & entity
, const char * cppTypeSort
)
779 if (cppTypeSort
!= 0)
780 o
<< cppTypeSort
<< ' ';
783 if (rank
== 0 && nucleus
== "com.sun.star.uno.XInterface") {
784 o
<< "Reference< com::sun::star::uno::XInterface >";
787 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
, 0,
793 void generateDocumentation(std::ostream
& o
,
794 ProgramOptions
const & options
, rtl::Reference
< TypeManager
> const & manager
,
795 OString
const & type
, OString
const & delegate
)
799 codemaker::UnoType::Sort sort
= manager
->decompose(
800 b2u(type
), false, &nucleus
, &rank
, 0, 0);
803 if (!delegate
.isEmpty()) {
804 if (sort
!= codemaker::UnoType::SORT_INTERFACE_TYPE
&&
805 sort
!= codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE
&&
806 sort
!= codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE
)
816 o
<< " sequence type";
817 } else if (sort
<= codemaker::UnoType::SORT_ANY
) {
821 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
822 o
<< " interface type";
825 case codemaker::UnoType::SORT_MODULE
:
829 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
830 o
<< " simple struct type";
833 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
834 o
<< " polymorphic struct type template";
837 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
838 o
<< " instantiated polymorphic struct type";
841 case codemaker::UnoType::SORT_ENUM_TYPE
:
845 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
846 o
<< " exception type";
849 case codemaker::UnoType::SORT_TYPEDEF
:
853 case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
854 o
<< " single-inheritance--based service";
857 case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE
:
858 o
<< "IDL accumulation-based service";
861 case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON
:
862 o
<< " inheritance-based singleton";
865 case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON
:
866 o
<< "IDL service-based singleton";
869 case codemaker::UnoType::SORT_CONSTANT_GROUP
:
870 o
<< "IDL constant group";
878 o
<< " \"" << type
<< "\" ";
880 std::vector
< OUString
> arguments
;
881 rtl::Reference
< unoidl::Entity
> entity
;
882 sort
= manager
->decompose(
883 b2u(type
), true, &nucleus
, &rank
, &arguments
, &entity
);
887 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
891 } else if (sort
<= codemaker::UnoType::SORT_ANY
) {
894 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
, 0);
899 case codemaker::UnoType::SORT_INTERFACE_TYPE
:
902 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
904 if (nucleus
== "com.sun.star.uno.XInterface") {
909 o
<< "; " << (options
.all
? "all" : "direct") << " methods:\n";
911 codemaker::GeneratedTypeSet generated
;
913 o
, options
, manager
, nucleus
, generated
, delegate
,
914 options
.implname
, "");
918 case codemaker::UnoType::SORT_MODULE
:
920 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
925 case codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
:
927 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
929 o
<< "; full constructor:\n";
931 o
, options
, manager
, codemaker::UnoType::SORT_PLAIN_STRUCT_TYPE
,
932 entity
, nucleus
, arguments
);
935 case codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
:
937 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
938 options
.java5
? "generic class" : "class");
939 o
<< "; full constructor:\n";
942 codemaker::UnoType::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE
,
943 entity
, nucleus
, arguments
);
946 case codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
:
948 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
949 options
.java5
? "generic class instantiation" : "class");
950 o
<< "; full constructor:\n";
953 codemaker::UnoType::SORT_INSTANTIATED_POLYMORPHIC_STRUCT_TYPE
,
954 entity
, nucleus
, arguments
);
957 case codemaker::UnoType::SORT_ENUM_TYPE
:
959 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
964 case codemaker::UnoType::SORT_CONSTANT_GROUP
:
966 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
971 case codemaker::UnoType::SORT_EXCEPTION_TYPE
:
973 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
975 o
<< "; full constructor:\n";
977 o
, options
, manager
, codemaker::UnoType::SORT_EXCEPTION_TYPE
,
978 entity
, nucleus
, arguments
);
981 case codemaker::UnoType::SORT_SINGLE_INTERFACE_BASED_SERVICE
:
984 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
986 o
<< "; construction methods:\n";
987 printConstructors(o
, options
, manager
, nucleus
);
989 generateDocumentation(
991 u2b(dynamic_cast< unoidl::SingleInterfaceBasedServiceEntity
* >(
992 entity
.get())->getBase()),
996 case codemaker::UnoType::SORT_ACCUMULATION_BASED_SERVICE
:
998 o
<< ("does not map to C++\n"
999 "// the service members are generated instead\n");
1000 printServiceMembers(
1001 o
, options
, manager
, nucleus
,
1002 dynamic_cast< unoidl::AccumulationBasedServiceEntity
* >(
1007 case codemaker::UnoType::SORT_INTERFACE_BASED_SINGLETON
:
1009 o
, options
, manager
, sort
, nucleus
, rank
, arguments
, entity
,
1011 o
<< "; get method:\nstatic ";
1013 o
, options
, manager
,
1014 dynamic_cast< unoidl::InterfaceBasedSingletonEntity
* >(
1015 entity
.get())->getBase(),
1017 o
<< " get(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);\n";
1020 case codemaker::UnoType::SORT_SERVICE_BASED_SINGLETON
:
1021 o
<< "does not map to C++\n";
1034 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */